| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" |
| 10 #include "base/process/process_handle.h" | 11 #include "base/process/process_handle.h" |
| 12 #include "build/build_config.h" |
| 11 #include "ipc/ipc_message_utils.h" | 13 #include "ipc/ipc_message_utils.h" |
| 12 #include "ipc/ipc_platform_file.h" | 14 #include "ipc/ipc_platform_file.h" |
| 13 #include "third_party/mojo/src/mojo/edk/embedder/platform_channel_pair.h" | 15 #include "third_party/mojo/src/mojo/edk/embedder/platform_channel_pair.h" |
| 14 | 16 |
| 15 namespace IPC { | 17 namespace IPC { |
| 16 | 18 |
| 17 namespace { | 19 namespace { |
| 18 | 20 |
| 19 // MojoBootstrap for the server process. You should create the instance | 21 // MojoBootstrap for the server process. You should create the instance |
| 20 // using MojoBootstrap::Create(). | 22 // using MojoBootstrap::Create(). |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 // using MojoBootstrap::Create(). | 104 // using MojoBootstrap::Create(). |
| 103 class MojoClientBootstrap : public MojoBootstrap { | 105 class MojoClientBootstrap : public MojoBootstrap { |
| 104 public: | 106 public: |
| 105 MojoClientBootstrap(); | 107 MojoClientBootstrap(); |
| 106 | 108 |
| 107 private: | 109 private: |
| 108 // Listener implementations | 110 // Listener implementations |
| 109 bool OnMessageReceived(const Message& message) override; | 111 bool OnMessageReceived(const Message& message) override; |
| 110 void OnChannelConnected(int32_t peer_pid) override; | 112 void OnChannelConnected(int32_t peer_pid) override; |
| 111 | 113 |
| 112 int32 peer_pid_; | 114 int32_t peer_pid_; |
| 113 | 115 |
| 114 DISALLOW_COPY_AND_ASSIGN(MojoClientBootstrap); | 116 DISALLOW_COPY_AND_ASSIGN(MojoClientBootstrap); |
| 115 }; | 117 }; |
| 116 | 118 |
| 117 MojoClientBootstrap::MojoClientBootstrap() : peer_pid_(0) { | 119 MojoClientBootstrap::MojoClientBootstrap() : peer_pid_(0) { |
| 118 } | 120 } |
| 119 | 121 |
| 120 bool MojoClientBootstrap::OnMessageReceived(const Message& message) { | 122 bool MojoClientBootstrap::OnMessageReceived(const Message& message) { |
| 121 if (state() != STATE_INITIALIZED) { | 123 if (state() != STATE_INITIALIZED) { |
| 122 set_state(STATE_ERROR); | 124 set_state(STATE_ERROR); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 int MojoBootstrap::GetClientFileDescriptor() const { | 215 int MojoBootstrap::GetClientFileDescriptor() const { |
| 214 return channel_->GetClientFileDescriptor(); | 216 return channel_->GetClientFileDescriptor(); |
| 215 } | 217 } |
| 216 | 218 |
| 217 base::ScopedFD MojoBootstrap::TakeClientFileDescriptor() { | 219 base::ScopedFD MojoBootstrap::TakeClientFileDescriptor() { |
| 218 return channel_->TakeClientFileDescriptor(); | 220 return channel_->TakeClientFileDescriptor(); |
| 219 } | 221 } |
| 220 #endif // defined(OS_POSIX) && !defined(OS_NACL) | 222 #endif // defined(OS_POSIX) && !defined(OS_NACL) |
| 221 | 223 |
| 222 } // namespace IPC | 224 } // namespace IPC |
| OLD | NEW |