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 #include "third_party/mojo/src/mojo/edk/embedder/scoped_platform_handle.h" | 12 #include "third_party/mojo/src/mojo/edk/embedder/scoped_platform_handle.h" |
13 | 13 |
14 namespace IPC { | 14 namespace IPC { |
15 | 15 |
| 16 class AttachmentBroker; |
| 17 |
16 // MojoBootstrap establishes a bootstrap pipe between two processes in | 18 // MojoBootstrap establishes a bootstrap pipe between two processes in |
17 // Chrome. It creates a native IPC::Channel first, then sends one | 19 // 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 | 20 // side of a newly created pipe to peer process. The pipe is intended |
19 // to be wrapped by Mojo MessagePipe. | 21 // to be wrapped by Mojo MessagePipe. |
20 // | 22 // |
21 // Clients should implement MojoBootstrapDelegate to get the pipe | 23 // Clients should implement MojoBootstrapDelegate to get the pipe |
22 // from MojoBootstrap object. It should also tell the client process handle | 24 // from MojoBootstrap object. It should also tell the client process handle |
23 // using OnClientLaunched(). | 25 // using OnClientLaunched(). |
24 // | 26 // |
25 // This lives on IO thread other than Create(), which can be called from | 27 // This lives on IO thread other than Create(), which can be called from |
26 // UI thread as Channel::Create() can be. | 28 // UI thread as Channel::Create() can be. |
27 class IPC_MOJO_EXPORT MojoBootstrap : public Listener { | 29 class IPC_MOJO_EXPORT MojoBootstrap : public Listener { |
28 public: | 30 public: |
29 class Delegate { | 31 class Delegate { |
30 public: | 32 public: |
31 virtual void OnPipeAvailable( | 33 virtual void OnPipeAvailable( |
32 mojo::embedder::ScopedPlatformHandle handle) = 0; | 34 mojo::embedder::ScopedPlatformHandle handle) = 0; |
33 virtual void OnBootstrapError() = 0; | 35 virtual void OnBootstrapError() = 0; |
34 }; | 36 }; |
35 | 37 |
36 // Create the MojoBootstrap instance. | 38 // Create the MojoBootstrap instance. |
37 // Instead of creating IPC::Channel, passs its ChannelHandle as |handle|, | 39 // Instead of creating IPC::Channel, passs its ChannelHandle as |handle|, |
38 // mode as |mode|. The result is notified to passed |delegate|. | 40 // mode as |mode|. The result is notified to passed |delegate|. |
39 static scoped_ptr<MojoBootstrap> Create(ChannelHandle handle, | 41 static scoped_ptr<MojoBootstrap> Create(ChannelHandle handle, |
40 Channel::Mode mode, | 42 Channel::Mode mode, |
41 Delegate* delegate); | 43 Delegate* delegate, |
| 44 AttachmentBroker* broker); |
42 | 45 |
43 MojoBootstrap(); | 46 MojoBootstrap(); |
44 ~MojoBootstrap() override; | 47 ~MojoBootstrap() override; |
45 | 48 |
46 // Start the handshake over the underlying platform channel. | 49 // Start the handshake over the underlying platform channel. |
47 bool Connect(); | 50 bool Connect(); |
48 | 51 |
49 // GetSelfPID returns the PID associated with |channel_|. | 52 // GetSelfPID returns the PID associated with |channel_|. |
50 base::ProcessId GetSelfPID() const; | 53 base::ProcessId GetSelfPID() const; |
51 | 54 |
(...skipping 29 matching lines...) Expand all Loading... |
81 scoped_ptr<Channel> channel_; | 84 scoped_ptr<Channel> channel_; |
82 Delegate* delegate_; | 85 Delegate* delegate_; |
83 State state_; | 86 State state_; |
84 | 87 |
85 DISALLOW_COPY_AND_ASSIGN(MojoBootstrap); | 88 DISALLOW_COPY_AND_ASSIGN(MojoBootstrap); |
86 }; | 89 }; |
87 | 90 |
88 } // namespace IPC | 91 } // namespace IPC |
89 | 92 |
90 #endif // IPC_MOJO_IPC_MOJO_BOOTSTRAP_H_ | 93 #endif // IPC_MOJO_IPC_MOJO_BOOTSTRAP_H_ |
OLD | NEW |