| 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 #include <utility> |
| 8 | 9 |
| 9 #include "base/logging.h" | 10 #include "base/logging.h" |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 11 #include "base/process/process_handle.h" | 12 #include "base/process/process_handle.h" |
| 12 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 13 #include "ipc/ipc_message_utils.h" | 14 #include "ipc/ipc_message_utils.h" |
| 14 #include "ipc/ipc_platform_file.h" | 15 #include "ipc/ipc_platform_file.h" |
| 15 #include "third_party/mojo/src/mojo/edk/embedder/platform_channel_pair.h" | 16 #include "third_party/mojo/src/mojo/edk/embedder/platform_channel_pair.h" |
| 16 | 17 |
| 17 namespace IPC { | 18 namespace IPC { |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 Channel::Mode mode, | 158 Channel::Mode mode, |
| 158 Delegate* delegate) { | 159 Delegate* delegate) { |
| 159 CHECK(mode == Channel::MODE_CLIENT || mode == Channel::MODE_SERVER); | 160 CHECK(mode == Channel::MODE_CLIENT || mode == Channel::MODE_SERVER); |
| 160 scoped_ptr<MojoBootstrap> self = | 161 scoped_ptr<MojoBootstrap> self = |
| 161 mode == Channel::MODE_CLIENT | 162 mode == Channel::MODE_CLIENT |
| 162 ? scoped_ptr<MojoBootstrap>(new MojoClientBootstrap()) | 163 ? scoped_ptr<MojoBootstrap>(new MojoClientBootstrap()) |
| 163 : scoped_ptr<MojoBootstrap>(new MojoServerBootstrap()); | 164 : scoped_ptr<MojoBootstrap>(new MojoServerBootstrap()); |
| 164 | 165 |
| 165 scoped_ptr<Channel> bootstrap_channel = | 166 scoped_ptr<Channel> bootstrap_channel = |
| 166 Channel::Create(handle, mode, self.get()); | 167 Channel::Create(handle, mode, self.get()); |
| 167 self->Init(bootstrap_channel.Pass(), delegate); | 168 self->Init(std::move(bootstrap_channel), delegate); |
| 168 return self.Pass(); | 169 return self; |
| 169 } | 170 } |
| 170 | 171 |
| 171 MojoBootstrap::MojoBootstrap() : delegate_(NULL), state_(STATE_INITIALIZED) { | 172 MojoBootstrap::MojoBootstrap() : delegate_(NULL), state_(STATE_INITIALIZED) { |
| 172 } | 173 } |
| 173 | 174 |
| 174 MojoBootstrap::~MojoBootstrap() { | 175 MojoBootstrap::~MojoBootstrap() { |
| 175 } | 176 } |
| 176 | 177 |
| 177 void MojoBootstrap::Init(scoped_ptr<Channel> channel, Delegate* delegate) { | 178 void MojoBootstrap::Init(scoped_ptr<Channel> channel, Delegate* delegate) { |
| 178 channel_ = channel.Pass(); | 179 channel_ = std::move(channel); |
| 179 delegate_ = delegate; | 180 delegate_ = delegate; |
| 180 } | 181 } |
| 181 | 182 |
| 182 bool MojoBootstrap::Connect() { | 183 bool MojoBootstrap::Connect() { |
| 183 return channel_->Connect(); | 184 return channel_->Connect(); |
| 184 } | 185 } |
| 185 | 186 |
| 186 base::ProcessId MojoBootstrap::GetSelfPID() const { | 187 base::ProcessId MojoBootstrap::GetSelfPID() const { |
| 187 return channel_->GetSelfPID(); | 188 return channel_->GetSelfPID(); |
| 188 } | 189 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 215 int MojoBootstrap::GetClientFileDescriptor() const { | 216 int MojoBootstrap::GetClientFileDescriptor() const { |
| 216 return channel_->GetClientFileDescriptor(); | 217 return channel_->GetClientFileDescriptor(); |
| 217 } | 218 } |
| 218 | 219 |
| 219 base::ScopedFD MojoBootstrap::TakeClientFileDescriptor() { | 220 base::ScopedFD MojoBootstrap::TakeClientFileDescriptor() { |
| 220 return channel_->TakeClientFileDescriptor(); | 221 return channel_->TakeClientFileDescriptor(); |
| 221 } | 222 } |
| 222 #endif // defined(OS_POSIX) && !defined(OS_NACL) | 223 #endif // defined(OS_POSIX) && !defined(OS_NACL) |
| 223 | 224 |
| 224 } // namespace IPC | 225 } // namespace IPC |
| OLD | NEW |