| 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 "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/process/process_handle.h" | 9 #include "base/process/process_handle.h" |
| 10 #include "ipc/ipc_channel.h" | 10 #include "ipc/ipc_channel.h" |
| 11 #include "ipc/ipc_listener.h" | 11 #include "ipc/ipc_listener.h" |
| 12 |
| 13 #if defined(USE_CHROME_EDK) |
| 14 #include "mojo/edk/embedder/scoped_platform_handle.h" |
| 15 #else |
| 12 #include "third_party/mojo/src/mojo/edk/embedder/scoped_platform_handle.h" | 16 #include "third_party/mojo/src/mojo/edk/embedder/scoped_platform_handle.h" |
| 17 #endif |
| 13 | 18 |
| 14 namespace IPC { | 19 namespace IPC { |
| 15 | 20 |
| 16 class AttachmentBroker; | 21 class AttachmentBroker; |
| 17 | 22 |
| 18 // MojoBootstrap establishes a bootstrap pipe between two processes in | 23 // MojoBootstrap establishes a bootstrap pipe between two processes in |
| 19 // Chrome. It creates a native IPC::Channel first, then sends one | 24 // Chrome. It creates a native IPC::Channel first, then sends one |
| 20 // side of a newly created pipe to peer process. The pipe is intended | 25 // side of a newly created pipe to peer process. The pipe is intended |
| 21 // to be wrapped by Mojo MessagePipe. | 26 // to be wrapped by Mojo MessagePipe. |
| 22 // | 27 // |
| 23 // Clients should implement MojoBootstrapDelegate to get the pipe | 28 // Clients should implement MojoBootstrapDelegate to get the pipe |
| 24 // from MojoBootstrap object. | 29 // from MojoBootstrap object. |
| 25 // | 30 // |
| 26 // This lives on IO thread other than Create(), which can be called from | 31 // This lives on IO thread other than Create(), which can be called from |
| 27 // UI thread as Channel::Create() can be. | 32 // UI thread as Channel::Create() can be. |
| 28 class IPC_MOJO_EXPORT MojoBootstrap : public Listener { | 33 class IPC_MOJO_EXPORT MojoBootstrap : public Listener { |
| 29 public: | 34 public: |
| 30 class Delegate { | 35 class Delegate { |
| 31 public: | 36 public: |
| 32 virtual void OnPipeAvailable( | 37 virtual void OnPipeAvailable( |
| 33 mojo::embedder::ScopedPlatformHandle handle) = 0; | 38 mojo::embedder::ScopedPlatformHandle handle, |
| 39 int32 peer_pid) = 0; |
| 34 virtual void OnBootstrapError() = 0; | 40 virtual void OnBootstrapError() = 0; |
| 35 }; | 41 }; |
| 36 | 42 |
| 37 // Create the MojoBootstrap instance. | 43 // Create the MojoBootstrap instance. |
| 38 // Instead of creating IPC::Channel, passs its ChannelHandle as |handle|, | 44 // Instead of creating IPC::Channel, passs its ChannelHandle as |handle|, |
| 39 // mode as |mode|. The result is notified to passed |delegate|. | 45 // mode as |mode|. The result is notified to passed |delegate|. |
| 40 static scoped_ptr<MojoBootstrap> Create(ChannelHandle handle, | 46 static scoped_ptr<MojoBootstrap> Create(ChannelHandle handle, |
| 41 Channel::Mode mode, | 47 Channel::Mode mode, |
| 42 Delegate* delegate, | 48 Delegate* delegate, |
| 43 AttachmentBroker* broker); | 49 AttachmentBroker* broker); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 scoped_ptr<Channel> channel_; | 86 scoped_ptr<Channel> channel_; |
| 81 Delegate* delegate_; | 87 Delegate* delegate_; |
| 82 State state_; | 88 State state_; |
| 83 | 89 |
| 84 DISALLOW_COPY_AND_ASSIGN(MojoBootstrap); | 90 DISALLOW_COPY_AND_ASSIGN(MojoBootstrap); |
| 85 }; | 91 }; |
| 86 | 92 |
| 87 } // namespace IPC | 93 } // namespace IPC |
| 88 | 94 |
| 89 #endif // IPC_MOJO_IPC_MOJO_BOOTSTRAP_H_ | 95 #endif // IPC_MOJO_IPC_MOJO_BOOTSTRAP_H_ |
| OLD | NEW |