Chromium Code Reviews| 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_channel_mojo.h" | 5 #include "ipc/mojo/ipc_channel_mojo.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "ipc/ipc_listener.h" | 10 #include "ipc/ipc_listener.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 const ChannelHandle& channel_handle) { | 76 const ChannelHandle& channel_handle) { |
| 77 return make_scoped_ptr( | 77 return make_scoped_ptr( |
| 78 new MojoChannelFactory(NULL, channel_handle, Channel::MODE_CLIENT)) | 78 new MojoChannelFactory(NULL, channel_handle, Channel::MODE_CLIENT)) |
| 79 .PassAs<ChannelFactory>(); | 79 .PassAs<ChannelFactory>(); |
| 80 } | 80 } |
| 81 | 81 |
| 82 ChannelMojo::ChannelMojo(ChannelMojoHost* host, | 82 ChannelMojo::ChannelMojo(ChannelMojoHost* host, |
| 83 const ChannelHandle& handle, | 83 const ChannelHandle& handle, |
| 84 Mode mode, | 84 Mode mode, |
| 85 Listener* listener) | 85 Listener* listener) |
| 86 : host_(host), | 86 : host_(host ? host->ToWeakPtr() : base::WeakPtr<ChannelMojoHost>()), |
|
viettrungluu
2014/09/25 19:38:34
Maybe it's better to just do in the body:
if (hos
Hajime Morrita
2014/09/25 22:00:03
Done.
| |
| 87 mode_(mode), | 87 mode_(mode), |
| 88 listener_(listener), | 88 listener_(listener), |
| 89 peer_pid_(base::kNullProcessId), | 89 peer_pid_(base::kNullProcessId), |
| 90 weak_factory_(this) { | 90 weak_factory_(this) { |
| 91 // Create MojoBootstrap after all members are set as it touches | 91 // Create MojoBootstrap after all members are set as it touches |
| 92 // ChannelMojo from a different thread. | 92 // ChannelMojo from a different thread. |
| 93 bootstrap_ = MojoBootstrap::Create(handle, mode, this); | 93 bootstrap_ = MojoBootstrap::Create(handle, mode, this); |
| 94 if (host_) | 94 if (host_) |
| 95 host_->OnChannelCreated(this); | 95 host_->OnChannelCreated(weak_factory_.GetWeakPtr()); |
| 96 } | 96 } |
| 97 | 97 |
| 98 ChannelMojo::~ChannelMojo() { | 98 ChannelMojo::~ChannelMojo() { |
| 99 Close(); | 99 Close(); |
| 100 | |
| 101 if (host_) | |
| 102 host_->OnChannelDestroyed(); | |
| 103 } | 100 } |
| 104 | 101 |
| 105 void ChannelMojo::InitControlReader( | 102 void ChannelMojo::InitControlReader( |
| 106 mojo::embedder::ScopedPlatformHandle handle) { | 103 mojo::embedder::ScopedPlatformHandle handle) { |
| 107 DCHECK(base::MessageLoopForIO::IsCurrent()); | 104 DCHECK(base::MessageLoopForIO::IsCurrent()); |
| 108 mojo::embedder::ChannelInfo* channel_info; | 105 mojo::embedder::ChannelInfo* channel_info; |
| 109 mojo::ScopedMessagePipeHandle control_pipe = | 106 mojo::ScopedMessagePipeHandle control_pipe = |
| 110 mojo::embedder::CreateChannelOnIOThread(handle.Pass(), &channel_info); | 107 mojo::embedder::CreateChannelOnIOThread(handle.Pass(), &channel_info); |
| 111 channel_info_.reset(channel_info); | 108 channel_info_.reset(channel_info); |
| 112 | 109 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 266 handles->push_back(wrapped_handle); | 263 handles->push_back(wrapped_handle); |
| 267 } | 264 } |
| 268 } | 265 } |
| 269 | 266 |
| 270 return MOJO_RESULT_OK; | 267 return MOJO_RESULT_OK; |
| 271 } | 268 } |
| 272 | 269 |
| 273 #endif // defined(OS_POSIX) && !defined(OS_NACL) | 270 #endif // defined(OS_POSIX) && !defined(OS_NACL) |
| 274 | 271 |
| 275 } // namespace IPC | 272 } // namespace IPC |
| OLD | NEW |