Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / content / child / child_thread.h
index b272db3..9b63fb8 100644 (file)
 #include "base/memory/weak_ptr.h"
 #include "base/power_monitor/power_monitor.h"
 #include "base/tracked_objects.h"
+#include "content/child/mojo/mojo_application.h"
 #include "content/common/content_export.h"
 #include "content/common/message_router.h"
 #include "ipc/ipc_message.h"  // For IPC_MESSAGE_LOG_ENABLED.
-#include "mojo/public/interfaces/service_provider/service_provider.mojom.h"
 
 namespace base {
 class MessageLoop;
@@ -35,17 +35,11 @@ namespace blink {
 class WebFrame;
 }  // namespace blink
 
-namespace webkit_glue {
-class ResourceLoaderBridge;
-}  // namespace webkit_glue
-
 namespace content {
 class ChildHistogramMessageFilter;
 class ChildResourceMessageFilter;
 class ChildSharedBitmapManager;
 class FileSystemDispatcher;
-class MojoApplication;
-class ServiceWorkerDispatcher;
 class ServiceWorkerMessageFilter;
 class QuotaDispatcher;
 class QuotaMessageFilter;
@@ -56,15 +50,22 @@ class WebSocketDispatcher;
 struct RequestInfo;
 
 // The main thread of a child process derives from this class.
-class CONTENT_EXPORT ChildThread
-    : public IPC::Listener,
-      public IPC::Sender,
-      public NON_EXPORTED_BASE(mojo::ServiceProvider) {
+class CONTENT_EXPORT ChildThread : public IPC::Listener, public IPC::Sender {
  public:
+  struct CONTENT_EXPORT Options {
+    Options();
+    explicit Options(bool mojo);
+    Options(std::string name, bool mojo)
+        : channel_name(name), use_mojo_channel(mojo) {}
+
+    std::string channel_name;
+    bool use_mojo_channel;
+  };
+
   // Creates the thread.
   ChildThread();
   // Used for single-process mode and for in process gpu mode.
-  explicit ChildThread(const std::string& channel_name);
+  explicit ChildThread(const Options& options);
   // ChildProcess::main_thread() is reset after Shutdown(), and before the
   // destructor, so any subsystem that relies on ChildProcess::main_thread()
   // must be terminated before Shutdown returns. In particular, if a subsystem
@@ -111,10 +112,6 @@ class CONTENT_EXPORT ChildThread
     return file_system_dispatcher_.get();
   }
 
-  ServiceWorkerDispatcher* service_worker_dispatcher() const {
-    return service_worker_dispatcher_.get();
-  }
-
   QuotaDispatcher* quota_dispatcher() const {
     return quota_dispatcher_.get();
   }
@@ -153,6 +150,10 @@ class CONTENT_EXPORT ChildThread
   static void ShutdownThread();
 #endif
 
+  ServiceRegistry* service_registry() const {
+    return mojo_application_->service_registry();
+  }
+
  protected:
   friend class ChildProcess;
 
@@ -170,13 +171,6 @@ class CONTENT_EXPORT ChildThread
   virtual void OnChannelConnected(int32 peer_pid) OVERRIDE;
   virtual void OnChannelError() OVERRIDE;
 
-  // mojo::ServiceProvider implementation:
-  virtual void ConnectToService(
-      const mojo::String& service_url,
-      const mojo::String& service_name,
-      mojo::ScopedMessagePipeHandle message_pipe,
-      const mojo::String& requestor_url) OVERRIDE;
-
  private:
   class ChildThreadMessageRouter : public MessageRouter {
    public:
@@ -188,7 +182,8 @@ class CONTENT_EXPORT ChildThread
     IPC::Sender* const sender_;
   };
 
-  void Init();
+  void Init(const Options& options);
+  scoped_ptr<IPC::SyncChannel> CreateChannel(bool use_mojo_channel);
 
   // IPC message handlers.
   void OnShutdown();
@@ -234,8 +229,6 @@ class CONTENT_EXPORT ChildThread
 
   scoped_ptr<FileSystemDispatcher> file_system_dispatcher_;
 
-  scoped_ptr<ServiceWorkerDispatcher> service_worker_dispatcher_;
-
   scoped_ptr<QuotaDispatcher> quota_dispatcher_;
 
   scoped_refptr<ChildHistogramMessageFilter> histogram_message_filter_;