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