| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef IPC_MOJO_IPC_MOJO_BOOTSTRAP_H_ | 5 #ifndef IPC_MOJO_IPC_MOJO_BOOTSTRAP_H_ |
| 6 #define IPC_MOJO_IPC_MOJO_BOOTSTRAP_H_ | 6 #define IPC_MOJO_IPC_MOJO_BOOTSTRAP_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/process/process_handle.h" | 12 #include "base/process/process_handle.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "ipc/ipc_channel.h" | 14 #include "ipc/ipc_channel.h" |
| 15 #include "ipc/ipc_listener.h" | 15 #include "ipc/ipc_listener.h" |
| 16 #include "third_party/mojo/src/mojo/edk/embedder/scoped_platform_handle.h" | 16 #include "mojo/edk/embedder/scoped_platform_handle.h" |
| 17 | 17 |
| 18 namespace IPC { | 18 namespace IPC { |
| 19 | 19 |
| 20 // MojoBootstrap establishes a bootstrap pipe between two processes in | 20 // MojoBootstrap establishes a bootstrap pipe between two processes in |
| 21 // Chrome. It creates a native IPC::Channel first, then sends one | 21 // Chrome. It creates a native IPC::Channel first, then sends one |
| 22 // side of a newly created pipe to peer process. The pipe is intended | 22 // side of a newly created pipe to peer process. The pipe is intended |
| 23 // to be wrapped by Mojo MessagePipe. | 23 // to be wrapped by Mojo MessagePipe. |
| 24 // | 24 // |
| 25 // Clients should implement MojoBootstrapDelegate to get the pipe | 25 // Clients should implement MojoBootstrapDelegate to get the pipe |
| 26 // from MojoBootstrap object. | 26 // from MojoBootstrap object. |
| 27 // | 27 // |
| 28 // This lives on IO thread other than Create(), which can be called from | 28 // This lives on IO thread other than Create(), which can be called from |
| 29 // UI thread as Channel::Create() can be. | 29 // UI thread as Channel::Create() can be. |
| 30 class IPC_MOJO_EXPORT MojoBootstrap : public Listener { | 30 class IPC_MOJO_EXPORT MojoBootstrap : public Listener { |
| 31 public: | 31 public: |
| 32 class Delegate { | 32 class Delegate { |
| 33 public: | 33 public: |
| 34 virtual void OnPipeAvailable(mojo::embedder::ScopedPlatformHandle handle, | 34 virtual void OnPipeAvailable(mojo::edk::ScopedPlatformHandle handle, |
| 35 int32_t peer_pid) = 0; | 35 int32_t peer_pid) = 0; |
| 36 virtual void OnBootstrapError() = 0; | 36 virtual void OnBootstrapError() = 0; |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 // Create the MojoBootstrap instance. | 39 // Create the MojoBootstrap instance. |
| 40 // Instead of creating IPC::Channel, passs its ChannelHandle as |handle|, | 40 // Instead of creating IPC::Channel, passs its ChannelHandle as |handle|, |
| 41 // mode as |mode|. The result is notified to passed |delegate|. | 41 // mode as |mode|. The result is notified to passed |delegate|. |
| 42 static scoped_ptr<MojoBootstrap> Create(ChannelHandle handle, | 42 static scoped_ptr<MojoBootstrap> Create(ChannelHandle handle, |
| 43 Channel::Mode mode, | 43 Channel::Mode mode, |
| 44 Delegate* delegate); | 44 Delegate* delegate); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 scoped_ptr<Channel> channel_; | 81 scoped_ptr<Channel> channel_; |
| 82 Delegate* delegate_; | 82 Delegate* delegate_; |
| 83 State state_; | 83 State state_; |
| 84 | 84 |
| 85 DISALLOW_COPY_AND_ASSIGN(MojoBootstrap); | 85 DISALLOW_COPY_AND_ASSIGN(MojoBootstrap); |
| 86 }; | 86 }; |
| 87 | 87 |
| 88 } // namespace IPC | 88 } // namespace IPC |
| 89 | 89 |
| 90 #endif // IPC_MOJO_IPC_MOJO_BOOTSTRAP_H_ | 90 #endif // IPC_MOJO_IPC_MOJO_BOOTSTRAP_H_ |
| OLD | NEW |