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