Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / ipc / ipc_sync_channel.h
index 46ac910..3593485 100644 (file)
@@ -23,6 +23,7 @@ class WaitableEvent;
 namespace IPC {
 
 class SyncMessage;
+class ChannelFactory;
 
 // This is similar to ChannelProxy, with the added feature of supporting sending
 // synchronous messages.
@@ -30,7 +31,7 @@ class SyncMessage;
 // Overview of how the sync channel works
 // --------------------------------------
 // When the sending thread sends a synchronous message, we create a bunch
-// of tracking info (created in SendWithTimeout, stored in the PendingSyncMsg
+// of tracking info (created in Send, stored in the PendingSyncMsg
 // structure) associated with the message that we identify by the unique
 // "MessageId" on the SyncMessage. Among the things we save is the
 // "Deserializer" which is provided by the sync message. This object is in
@@ -66,29 +67,33 @@ class IPC_EXPORT SyncChannel : public ChannelProxy {
 
   // Creates and initializes a sync channel. If create_pipe_now is specified,
   // the channel will be initialized synchronously.
-  SyncChannel(const IPC::ChannelHandle& channel_handle,
-              Channel::Mode mode,
-              Listener* listener,
-              base::SingleThreadTaskRunner* ipc_task_runner,
-              bool create_pipe_now,
-              base::WaitableEvent* shutdown_event);
+  // The naming pattern follows IPC::Channel.
+  static scoped_ptr<SyncChannel> Create(
+      const IPC::ChannelHandle& channel_handle,
+      IPC::Channel::Mode mode,
+      Listener* listener,
+      const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner,
+      bool create_pipe_now,
+      base::WaitableEvent* shutdown_event);
+
+  static scoped_ptr<SyncChannel> Create(
+      scoped_ptr<ChannelFactory> factory,
+      Listener* listener,
+      const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner,
+      bool create_pipe_now,
+      base::WaitableEvent* shutdown_event);
 
   // Creates an uninitialized sync channel. Call ChannelProxy::Init to
   // initialize the channel. This two-step setup allows message filters to be
   // added before any messages are sent or received.
-  SyncChannel(Listener* listener,
-              base::SingleThreadTaskRunner* ipc_task_runner,
-              base::WaitableEvent* shutdown_event);
+  static scoped_ptr<SyncChannel> Create(
+      Listener* listener,
+      const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner,
+      base::WaitableEvent* shutdown_event);
 
-  virtual ~SyncChannel();
+  ~SyncChannel() override;
 
-  virtual bool Send(Message* message) OVERRIDE;
-  virtual bool SendWithTimeout(Message* message, int timeout_ms);
-
-  // Whether we allow sending messages with no time-out.
-  void set_sync_messages_with_no_timeout_allowed(bool value) {
-    sync_messages_with_no_timeout_allowed_ = value;
-  }
+  bool Send(Message* message) override;
 
   // Sets the dispatch group for this channel, to only allow re-entrant dispatch
   // of messages to other channels in the same group.
@@ -116,9 +121,10 @@ class IPC_EXPORT SyncChannel : public ChannelProxy {
   // ChannelProxy::Context for more information.
   class SyncContext : public Context {
    public:
-    SyncContext(Listener* listener,
-                base::SingleThreadTaskRunner* ipc_task_runner,
-                base::WaitableEvent* shutdown_event);
+    SyncContext(
+        Listener* listener,
+        const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner,
+        base::WaitableEvent* shutdown_event);
 
     // Adds information about an outgoing sync message to the context so that
     // we know how to deserialize the reply.
@@ -164,17 +170,17 @@ class IPC_EXPORT SyncChannel : public ChannelProxy {
     base::WaitableEventWatcher::EventCallback MakeWaitableEventCallback();
 
    private:
-    virtual ~SyncContext();
+    ~SyncContext() override;
     // ChannelProxy methods that we override.
 
     // Called on the listener thread.
-    virtual void Clear() OVERRIDE;
+    void Clear() override;
 
     // Called on the IPC thread.
-    virtual bool OnMessageReceived(const Message& msg) OVERRIDE;
-    virtual void OnChannelError() OVERRIDE;
-    virtual void OnChannelOpened() OVERRIDE;
-    virtual void OnChannelClosed() OVERRIDE;
+    bool OnMessageReceived(const Message& msg) override;
+    void OnChannelError() override;
+    void OnChannelOpened() override;
+    void OnChannelClosed() override;
 
     // Cancels all pending Send calls.
     void CancelPendingSends();
@@ -194,6 +200,11 @@ class IPC_EXPORT SyncChannel : public ChannelProxy {
   };
 
  private:
+  SyncChannel(
+      Listener* listener,
+      const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner,
+      base::WaitableEvent* shutdown_event);
+
   void OnWaitableEventSignaled(base::WaitableEvent* arg);
 
   SyncContext* sync_context() {
@@ -212,8 +223,6 @@ class IPC_EXPORT SyncChannel : public ChannelProxy {
   // Starts the dispatch watcher.
   void StartWatching();
 
-  bool sync_messages_with_no_timeout_allowed_;
-
   // Used to signal events between the IPC and listener threads.
   base::WaitableEventWatcher dispatch_watcher_;
   base::WaitableEventWatcher::EventCallback dispatch_watcher_callback_;