Index: ipc/ipc_mojo_bootstrap.h |
diff --git a/ipc/ipc_mojo_bootstrap.h b/ipc/ipc_mojo_bootstrap.h |
index f18857a77d27b68c2e55fc8b2a7a0d0dc25b4dfe..b9df4083e6816e20e14ea7531b450f4619b9ed63 100644 |
--- a/ipc/ipc_mojo_bootstrap.h |
+++ b/ipc/ipc_mojo_bootstrap.h |
@@ -11,6 +11,7 @@ |
#include "base/macros.h" |
#include "base/memory/ref_counted.h" |
+#include "base/process/process_handle.h" |
#include "base/single_thread_task_runner.h" |
#include "build/build_config.h" |
#include "ipc/ipc.mojom.h" |
@@ -33,26 +34,57 @@ |
public: |
class Delegate { |
public: |
- virtual ~Delegate() {} |
- |
- virtual void OnPipesAvailable(mojom::ChannelAssociatedPtr sender, |
- mojom::ChannelAssociatedRequest receiver) = 0; |
+ virtual void OnPipesAvailable( |
+ mojom::ChannelAssociatedPtrInfo send_channel, |
+ mojom::ChannelAssociatedRequest receive_channel, |
+ int32_t peer_pid) = 0; |
+ virtual void OnBootstrapError() = 0; |
}; |
- |
- virtual ~MojoBootstrap() {} |
// Create the MojoBootstrap instance, using |handle| as the message pipe, in |
// mode as specified by |mode|. The result is passed to |delegate|. |
static std::unique_ptr<MojoBootstrap> Create( |
mojo::ScopedMessagePipeHandle handle, |
Channel::Mode mode, |
- Delegate* delegate, |
- const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner); |
+ Delegate* delegate); |
+ |
+ MojoBootstrap(); |
+ virtual ~MojoBootstrap(); |
// Start the handshake over the underlying message pipe. |
virtual void Connect() = 0; |
virtual mojo::AssociatedGroup* GetAssociatedGroup() = 0; |
+ |
+ virtual void SetProxyTaskRunner( |
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner) = 0; |
+ |
+ // GetSelfPID returns our PID. |
+ base::ProcessId GetSelfPID() const; |
+ |
+ protected: |
+ // On MojoServerBootstrap: INITIALIZED -> WAITING_ACK -> READY |
+ // On MojoClientBootstrap: INITIALIZED -> READY |
+ // STATE_ERROR is a catch-all state that captures any observed error. |
+ enum State { STATE_INITIALIZED, STATE_WAITING_ACK, STATE_READY, STATE_ERROR }; |
+ |
+ Delegate* delegate() const { return delegate_; } |
+ void Fail(); |
+ bool HasFailed() const; |
+ |
+ State state() const { return state_; } |
+ void set_state(State state) { state_ = state; } |
+ |
+ mojo::ScopedMessagePipeHandle TakeHandle(); |
+ |
+ private: |
+ void Init(mojo::ScopedMessagePipeHandle, Delegate* delegate); |
+ |
+ mojo::ScopedMessagePipeHandle handle_; |
+ Delegate* delegate_; |
+ State state_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(MojoBootstrap); |
}; |
} // namespace IPC |