Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/child/child_thread.h" | 5 #include "content/child/child_thread.h" |
| 6 | 6 |
| 7 #include <signal.h> | 7 #include <signal.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 191 | 191 |
| 192 ChildThread::ChildThreadMessageRouter::ChildThreadMessageRouter( | 192 ChildThread::ChildThreadMessageRouter::ChildThreadMessageRouter( |
| 193 IPC::Sender* sender) | 193 IPC::Sender* sender) |
| 194 : sender_(sender) {} | 194 : sender_(sender) {} |
| 195 | 195 |
| 196 bool ChildThread::ChildThreadMessageRouter::Send(IPC::Message* msg) { | 196 bool ChildThread::ChildThreadMessageRouter::Send(IPC::Message* msg) { |
| 197 return sender_->Send(msg); | 197 return sender_->Send(msg); |
| 198 } | 198 } |
| 199 | 199 |
| 200 ChildThread::ChildThread() | 200 ChildThread::ChildThread() |
| 201 : router_(this), | 201 : mojo_application_(this), |
| 202 router_(this), | |
| 202 channel_connected_factory_(this), | 203 channel_connected_factory_(this), |
| 203 in_browser_process_(false) { | 204 in_browser_process_(false) { |
| 204 channel_name_ = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 205 channel_name_ = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 205 switches::kProcessChannelID); | 206 switches::kProcessChannelID); |
| 206 Init(); | 207 Init(); |
| 207 } | 208 } |
| 208 | 209 |
| 209 ChildThread::ChildThread(const std::string& channel_name) | 210 ChildThread::ChildThread(const std::string& channel_name) |
| 210 : channel_name_(channel_name), | 211 : mojo_application_(this), |
| 212 channel_name_(channel_name), | |
| 211 router_(this), | 213 router_(this), |
| 212 channel_connected_factory_(this), | 214 channel_connected_factory_(this), |
| 213 in_browser_process_(true) { | 215 in_browser_process_(true) { |
| 214 Init(); | 216 Init(); |
| 215 } | 217 } |
| 216 | 218 |
| 217 void ChildThread::Init() { | 219 void ChildThread::Init() { |
| 218 g_lazy_tls.Pointer()->Set(this); | 220 g_lazy_tls.Pointer()->Set(this); |
| 219 on_channel_error_called_ = false; | 221 on_channel_error_called_ = false; |
| 220 message_loop_ = base::MessageLoop::current(); | 222 message_loop_ = base::MessageLoop::current(); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 342 | 344 |
| 343 void ChildThread::OnChannelConnected(int32 peer_pid) { | 345 void ChildThread::OnChannelConnected(int32 peer_pid) { |
| 344 channel_connected_factory_.InvalidateWeakPtrs(); | 346 channel_connected_factory_.InvalidateWeakPtrs(); |
| 345 } | 347 } |
| 346 | 348 |
| 347 void ChildThread::OnChannelError() { | 349 void ChildThread::OnChannelError() { |
| 348 set_on_channel_error_called(true); | 350 set_on_channel_error_called(true); |
| 349 base::MessageLoop::current()->Quit(); | 351 base::MessageLoop::current()->Quit(); |
| 350 } | 352 } |
| 351 | 353 |
| 354 void ChildThread::AcceptConnection( | |
| 355 const mojo::String& service_name, | |
| 356 mojo::ScopedMessagePipeHandle message_pipe) { | |
| 357 // By default, we handle no services. | |
|
sky
2014/04/22 15:52:20
If we get here does it mean someone is sending the
| |
| 358 } | |
| 359 | |
| 352 bool ChildThread::Send(IPC::Message* msg) { | 360 bool ChildThread::Send(IPC::Message* msg) { |
| 353 DCHECK(base::MessageLoop::current() == message_loop()); | 361 DCHECK(base::MessageLoop::current() == message_loop()); |
| 354 if (!channel_) { | 362 if (!channel_) { |
| 355 delete msg; | 363 delete msg; |
| 356 return false; | 364 return false; |
| 357 } | 365 } |
| 358 | 366 |
| 359 return channel_->Send(msg); | 367 return channel_->Send(msg); |
| 360 } | 368 } |
| 361 | 369 |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 533 // inflight that would addref it. | 541 // inflight that would addref it. |
| 534 Send(new ChildProcessHostMsg_ShutdownRequest); | 542 Send(new ChildProcessHostMsg_ShutdownRequest); |
| 535 } | 543 } |
| 536 | 544 |
| 537 void ChildThread::EnsureConnected() { | 545 void ChildThread::EnsureConnected() { |
| 538 VLOG(0) << "ChildThread::EnsureConnected()"; | 546 VLOG(0) << "ChildThread::EnsureConnected()"; |
| 539 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); | 547 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); |
| 540 } | 548 } |
| 541 | 549 |
| 542 } // namespace content | 550 } // namespace content |
| OLD | NEW |