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 #include "ipc/mojo/ipc_mojo_bootstrap.h" | 5 #include "ipc/mojo/ipc_mojo_bootstrap.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/process/process_handle.h" | 8 #include "base/process/process_handle.h" |
9 #include "ipc/ipc_message_utils.h" | 9 #include "ipc/ipc_message_utils.h" |
10 #include "ipc/ipc_platform_file.h" | 10 #include "ipc/ipc_platform_file.h" |
11 #include "mojo/edk/embedder/platform_channel_pair.h" | 11 #include "mojo/edk/embedder/platform_channel_pair.h" |
12 | 12 |
13 namespace IPC { | 13 namespace IPC { |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 // MojoBootstrap for the server process. You should create the instance | 17 // MojoBootstrap for the server process. You should create the instance |
18 // using MojoBootstrap::Create(). | 18 // using MojoBootstrap::Create(). |
19 class MojoServerBootstrap : public MojoBootstrap { | 19 class MojoServerBootstrap : public MojoBootstrap { |
20 public: | 20 public: |
21 MojoServerBootstrap(); | 21 MojoServerBootstrap(); |
22 | 22 |
23 virtual void OnClientLaunched(base::ProcessHandle process) override; | 23 void OnClientLaunched(base::ProcessHandle process) override; |
24 | 24 |
25 private: | 25 private: |
26 void SendClientPipe(); | 26 void SendClientPipe(); |
27 void SendClientPipeIfReady(); | 27 void SendClientPipeIfReady(); |
28 | 28 |
29 // Listener implementations | 29 // Listener implementations |
30 virtual bool OnMessageReceived(const Message& message) override; | 30 bool OnMessageReceived(const Message& message) override; |
31 virtual void OnChannelConnected(int32 peer_pid) override; | 31 void OnChannelConnected(int32 peer_pid) override; |
32 | 32 |
33 mojo::embedder::ScopedPlatformHandle server_pipe_; | 33 mojo::embedder::ScopedPlatformHandle server_pipe_; |
34 base::ProcessHandle client_process_; | 34 base::ProcessHandle client_process_; |
35 bool connected_; | 35 bool connected_; |
36 | 36 |
37 DISALLOW_COPY_AND_ASSIGN(MojoServerBootstrap); | 37 DISALLOW_COPY_AND_ASSIGN(MojoServerBootstrap); |
38 }; | 38 }; |
39 | 39 |
40 MojoServerBootstrap::MojoServerBootstrap() | 40 MojoServerBootstrap::MojoServerBootstrap() |
41 : client_process_(base::kNullProcessHandle), connected_(false) { | 41 : client_process_(base::kNullProcessHandle), connected_(false) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 105 |
106 return true; | 106 return true; |
107 } | 107 } |
108 | 108 |
109 // MojoBootstrap for client processes. You should create the instance | 109 // MojoBootstrap for client processes. You should create the instance |
110 // using MojoBootstrap::Create(). | 110 // using MojoBootstrap::Create(). |
111 class MojoClientBootstrap : public MojoBootstrap { | 111 class MojoClientBootstrap : public MojoBootstrap { |
112 public: | 112 public: |
113 MojoClientBootstrap(); | 113 MojoClientBootstrap(); |
114 | 114 |
115 virtual void OnClientLaunched(base::ProcessHandle process) override; | 115 void OnClientLaunched(base::ProcessHandle process) override; |
116 | 116 |
117 private: | 117 private: |
118 // Listener implementations | 118 // Listener implementations |
119 virtual bool OnMessageReceived(const Message& message) override; | 119 bool OnMessageReceived(const Message& message) override; |
120 virtual void OnChannelConnected(int32 peer_pid) override; | 120 void OnChannelConnected(int32 peer_pid) override; |
121 | 121 |
122 DISALLOW_COPY_AND_ASSIGN(MojoClientBootstrap); | 122 DISALLOW_COPY_AND_ASSIGN(MojoClientBootstrap); |
123 }; | 123 }; |
124 | 124 |
125 MojoClientBootstrap::MojoClientBootstrap() { | 125 MojoClientBootstrap::MojoClientBootstrap() { |
126 } | 126 } |
127 | 127 |
128 bool MojoClientBootstrap::OnMessageReceived(const Message& message) { | 128 bool MojoClientBootstrap::OnMessageReceived(const Message& message) { |
129 PlatformFileForTransit pipe; | 129 PlatformFileForTransit pipe; |
130 PickleIterator iter(message); | 130 PickleIterator iter(message); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 int MojoBootstrap::GetClientFileDescriptor() const { | 210 int MojoBootstrap::GetClientFileDescriptor() const { |
211 return channel_->GetClientFileDescriptor(); | 211 return channel_->GetClientFileDescriptor(); |
212 } | 212 } |
213 | 213 |
214 base::ScopedFD MojoBootstrap::TakeClientFileDescriptor() { | 214 base::ScopedFD MojoBootstrap::TakeClientFileDescriptor() { |
215 return channel_->TakeClientFileDescriptor(); | 215 return channel_->TakeClientFileDescriptor(); |
216 } | 216 } |
217 #endif // defined(OS_POSIX) && !defined(OS_NACL) | 217 #endif // defined(OS_POSIX) && !defined(OS_NACL) |
218 | 218 |
219 } // namespace IPC | 219 } // namespace IPC |
OLD | NEW |