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 11 matching lines...) Expand all Loading... |
22 #include "base/synchronization/condition_variable.h" | 22 #include "base/synchronization/condition_variable.h" |
23 #include "base/synchronization/lock.h" | 23 #include "base/synchronization/lock.h" |
24 #include "base/threading/thread_local.h" | 24 #include "base/threading/thread_local.h" |
25 #include "base/tracked_objects.h" | 25 #include "base/tracked_objects.h" |
26 #include "components/tracing/child_trace_message_filter.h" | 26 #include "components/tracing/child_trace_message_filter.h" |
27 #include "content/child/child_histogram_message_filter.h" | 27 #include "content/child/child_histogram_message_filter.h" |
28 #include "content/child/child_process.h" | 28 #include "content/child/child_process.h" |
29 #include "content/child/child_resource_message_filter.h" | 29 #include "content/child/child_resource_message_filter.h" |
30 #include "content/child/child_shared_bitmap_manager.h" | 30 #include "content/child/child_shared_bitmap_manager.h" |
31 #include "content/child/fileapi/file_system_dispatcher.h" | 31 #include "content/child/fileapi/file_system_dispatcher.h" |
| 32 #include "content/child/mojo/mojo_application.h" |
32 #include "content/child/power_monitor_broadcast_source.h" | 33 #include "content/child/power_monitor_broadcast_source.h" |
33 #include "content/child/quota_dispatcher.h" | 34 #include "content/child/quota_dispatcher.h" |
34 #include "content/child/quota_message_filter.h" | 35 #include "content/child/quota_message_filter.h" |
35 #include "content/child/resource_dispatcher.h" | 36 #include "content/child/resource_dispatcher.h" |
36 #include "content/child/service_worker/service_worker_dispatcher.h" | 37 #include "content/child/service_worker/service_worker_dispatcher.h" |
37 #include "content/child/service_worker/service_worker_message_filter.h" | 38 #include "content/child/service_worker/service_worker_message_filter.h" |
38 #include "content/child/socket_stream_dispatcher.h" | 39 #include "content/child/socket_stream_dispatcher.h" |
39 #include "content/child/thread_safe_sender.h" | 40 #include "content/child/thread_safe_sender.h" |
40 #include "content/child/websocket_dispatcher.h" | 41 #include "content/child/websocket_dispatcher.h" |
41 #include "content/common/child_process_messages.h" | 42 #include "content/common/child_process_messages.h" |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 IPC::Channel::MODE_CLIENT, | 230 IPC::Channel::MODE_CLIENT, |
230 this, | 231 this, |
231 ChildProcess::current()->io_message_loop_proxy(), | 232 ChildProcess::current()->io_message_loop_proxy(), |
232 true, | 233 true, |
233 ChildProcess::current()->GetShutDownEvent())); | 234 ChildProcess::current()->GetShutDownEvent())); |
234 #ifdef IPC_MESSAGE_LOG_ENABLED | 235 #ifdef IPC_MESSAGE_LOG_ENABLED |
235 if (!in_browser_process_) | 236 if (!in_browser_process_) |
236 IPC::Logging::GetInstance()->SetIPCSender(this); | 237 IPC::Logging::GetInstance()->SetIPCSender(this); |
237 #endif | 238 #endif |
238 | 239 |
| 240 mojo_application_.reset(new MojoApplication(this)); |
| 241 |
239 sync_message_filter_ = | 242 sync_message_filter_ = |
240 new IPC::SyncMessageFilter(ChildProcess::current()->GetShutDownEvent()); | 243 new IPC::SyncMessageFilter(ChildProcess::current()->GetShutDownEvent()); |
241 thread_safe_sender_ = new ThreadSafeSender( | 244 thread_safe_sender_ = new ThreadSafeSender( |
242 base::MessageLoopProxy::current().get(), sync_message_filter_.get()); | 245 base::MessageLoopProxy::current().get(), sync_message_filter_.get()); |
243 | 246 |
244 resource_dispatcher_.reset(new ResourceDispatcher(this)); | 247 resource_dispatcher_.reset(new ResourceDispatcher(this)); |
245 socket_stream_dispatcher_.reset(new SocketStreamDispatcher()); | 248 socket_stream_dispatcher_.reset(new SocketStreamDispatcher()); |
246 websocket_dispatcher_.reset(new WebSocketDispatcher); | 249 websocket_dispatcher_.reset(new WebSocketDispatcher); |
247 file_system_dispatcher_.reset(new FileSystemDispatcher()); | 250 file_system_dispatcher_.reset(new FileSystemDispatcher()); |
248 | 251 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 | 345 |
343 void ChildThread::OnChannelConnected(int32 peer_pid) { | 346 void ChildThread::OnChannelConnected(int32 peer_pid) { |
344 channel_connected_factory_.InvalidateWeakPtrs(); | 347 channel_connected_factory_.InvalidateWeakPtrs(); |
345 } | 348 } |
346 | 349 |
347 void ChildThread::OnChannelError() { | 350 void ChildThread::OnChannelError() { |
348 set_on_channel_error_called(true); | 351 set_on_channel_error_called(true); |
349 base::MessageLoop::current()->Quit(); | 352 base::MessageLoop::current()->Quit(); |
350 } | 353 } |
351 | 354 |
| 355 void ChildThread::AcceptConnection( |
| 356 const mojo::String& service_name, |
| 357 mojo::ScopedMessagePipeHandle message_pipe) { |
| 358 // By default, we don't expect incoming connections. |
| 359 NOTREACHED(); |
| 360 } |
| 361 |
352 bool ChildThread::Send(IPC::Message* msg) { | 362 bool ChildThread::Send(IPC::Message* msg) { |
353 DCHECK(base::MessageLoop::current() == message_loop()); | 363 DCHECK(base::MessageLoop::current() == message_loop()); |
354 if (!channel_) { | 364 if (!channel_) { |
355 delete msg; | 365 delete msg; |
356 return false; | 366 return false; |
357 } | 367 } |
358 | 368 |
359 return channel_->Send(msg); | 369 return channel_->Send(msg); |
360 } | 370 } |
361 | 371 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 } | 412 } |
403 } else { | 413 } else { |
404 NOTREACHED() << "Browser allocation request message failed"; | 414 NOTREACHED() << "Browser allocation request message failed"; |
405 return NULL; | 415 return NULL; |
406 } | 416 } |
407 #endif | 417 #endif |
408 return shared_buf.release(); | 418 return shared_buf.release(); |
409 } | 419 } |
410 | 420 |
411 bool ChildThread::OnMessageReceived(const IPC::Message& msg) { | 421 bool ChildThread::OnMessageReceived(const IPC::Message& msg) { |
| 422 if (mojo_application_->OnMessageReceived(msg)) |
| 423 return true; |
| 424 |
412 // Resource responses are sent to the resource dispatcher. | 425 // Resource responses are sent to the resource dispatcher. |
413 if (resource_dispatcher_->OnMessageReceived(msg)) | 426 if (resource_dispatcher_->OnMessageReceived(msg)) |
414 return true; | 427 return true; |
415 if (socket_stream_dispatcher_->OnMessageReceived(msg)) | 428 if (socket_stream_dispatcher_->OnMessageReceived(msg)) |
416 return true; | 429 return true; |
417 if (websocket_dispatcher_->OnMessageReceived(msg)) | 430 if (websocket_dispatcher_->OnMessageReceived(msg)) |
418 return true; | 431 return true; |
419 if (file_system_dispatcher_->OnMessageReceived(msg)) | 432 if (file_system_dispatcher_->OnMessageReceived(msg)) |
420 return true; | 433 return true; |
421 | 434 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 // inflight that would addref it. | 546 // inflight that would addref it. |
534 Send(new ChildProcessHostMsg_ShutdownRequest); | 547 Send(new ChildProcessHostMsg_ShutdownRequest); |
535 } | 548 } |
536 | 549 |
537 void ChildThread::EnsureConnected() { | 550 void ChildThread::EnsureConnected() { |
538 VLOG(0) << "ChildThread::EnsureConnected()"; | 551 VLOG(0) << "ChildThread::EnsureConnected()"; |
539 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); | 552 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); |
540 } | 553 } |
541 | 554 |
542 } // namespace content | 555 } // namespace content |
OLD | NEW |