Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Side by Side Diff: content/child/child_thread_impl.cc

Issue 2000113002: Delegate WebSocket message handlers to the loading task runner (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address on reviews Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_impl.h" 5 #include "content/child/child_thread_impl.h"
6 6
7 #include <signal.h> 7 #include <signal.h>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "content/child/mojo/mojo_application.h" 44 #include "content/child/mojo/mojo_application.h"
45 #include "content/child/notifications/notification_dispatcher.h" 45 #include "content/child/notifications/notification_dispatcher.h"
46 #include "content/child/power_monitor_broadcast_source.h" 46 #include "content/child/power_monitor_broadcast_source.h"
47 #include "content/child/push_messaging/push_dispatcher.h" 47 #include "content/child/push_messaging/push_dispatcher.h"
48 #include "content/child/quota_dispatcher.h" 48 #include "content/child/quota_dispatcher.h"
49 #include "content/child/quota_message_filter.h" 49 #include "content/child/quota_message_filter.h"
50 #include "content/child/resource_dispatcher.h" 50 #include "content/child/resource_dispatcher.h"
51 #include "content/child/service_worker/service_worker_message_filter.h" 51 #include "content/child/service_worker/service_worker_message_filter.h"
52 #include "content/child/thread_safe_sender.h" 52 #include "content/child/thread_safe_sender.h"
53 #include "content/child/websocket_dispatcher.h" 53 #include "content/child/websocket_dispatcher.h"
54 #include "content/child/websocket_message_filter.h"
54 #include "content/common/child_process_messages.h" 55 #include "content/common/child_process_messages.h"
55 #include "content/common/in_process_child_thread_params.h" 56 #include "content/common/in_process_child_thread_params.h"
56 #include "content/common/mojo/mojo_shell_connection_impl.h" 57 #include "content/common/mojo/mojo_shell_connection_impl.h"
57 #include "content/public/common/content_switches.h" 58 #include "content/public/common/content_switches.h"
58 #include "content/public/common/mojo_channel_switches.h" 59 #include "content/public/common/mojo_channel_switches.h"
59 #include "ipc/attachment_broker.h" 60 #include "ipc/attachment_broker.h"
60 #include "ipc/attachment_broker_unprivileged.h" 61 #include "ipc/attachment_broker_unprivileged.h"
61 #include "ipc/ipc_logging.h" 62 #include "ipc/ipc_logging.h"
62 #include "ipc/ipc_platform_file.h" 63 #include "ipc/ipc_platform_file.h"
63 #include "ipc/ipc_switches.h" 64 #include "ipc/ipc_switches.h"
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 new ServiceWorkerMessageFilter(thread_safe_sender_.get()); 425 new ServiceWorkerMessageFilter(thread_safe_sender_.get());
425 426
426 quota_message_filter_ = 427 quota_message_filter_ =
427 new QuotaMessageFilter(thread_safe_sender_.get()); 428 new QuotaMessageFilter(thread_safe_sender_.get());
428 quota_dispatcher_.reset(new QuotaDispatcher(thread_safe_sender_.get(), 429 quota_dispatcher_.reset(new QuotaDispatcher(thread_safe_sender_.get(),
429 quota_message_filter_.get())); 430 quota_message_filter_.get()));
430 notification_dispatcher_ = 431 notification_dispatcher_ =
431 new NotificationDispatcher(thread_safe_sender_.get()); 432 new NotificationDispatcher(thread_safe_sender_.get());
432 push_dispatcher_ = new PushDispatcher(thread_safe_sender_.get()); 433 push_dispatcher_ = new PushDispatcher(thread_safe_sender_.get());
433 434
435 websocket_message_filter_ =
436 new WebSocketMessageFilter(websocket_dispatcher_.get());
437
434 channel_->AddFilter(histogram_message_filter_.get()); 438 channel_->AddFilter(histogram_message_filter_.get());
435 channel_->AddFilter(resource_message_filter_.get()); 439 channel_->AddFilter(resource_message_filter_.get());
436 channel_->AddFilter(quota_message_filter_->GetFilter()); 440 channel_->AddFilter(quota_message_filter_->GetFilter());
437 channel_->AddFilter(notification_dispatcher_->GetFilter()); 441 channel_->AddFilter(notification_dispatcher_->GetFilter());
438 channel_->AddFilter(push_dispatcher_->GetFilter()); 442 channel_->AddFilter(push_dispatcher_->GetFilter());
439 channel_->AddFilter(service_worker_message_filter_->GetFilter()); 443 channel_->AddFilter(service_worker_message_filter_->GetFilter());
444 channel_->AddFilter(websocket_message_filter_.get());
440 445
441 if (!IsInBrowserProcess()) { 446 if (!IsInBrowserProcess()) {
442 // In single process mode, browser-side tracing and memory will cover the 447 // In single process mode, browser-side tracing and memory will cover the
443 // whole process including renderers. 448 // whole process including renderers.
444 channel_->AddFilter(new tracing::ChildTraceMessageFilter( 449 channel_->AddFilter(new tracing::ChildTraceMessageFilter(
445 ChildProcess::current()->io_task_runner())); 450 ChildProcess::current()->io_task_runner()));
446 channel_->AddFilter(new ChildMemoryMessageFilter()); 451 channel_->AddFilter(new ChildMemoryMessageFilter());
447 } 452 }
448 453
449 // In single process mode we may already have a power monitor 454 // In single process mode we may already have a power monitor
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 // Send is allowed to fail during shutdown. Return null in this case. 611 // Send is allowed to fail during shutdown. Return null in this case.
607 return nullptr; 612 return nullptr;
608 } 613 }
609 return shared_buf; 614 return shared_buf;
610 } 615 }
611 616
612 bool ChildThreadImpl::OnMessageReceived(const IPC::Message& msg) { 617 bool ChildThreadImpl::OnMessageReceived(const IPC::Message& msg) {
613 // Resource responses are sent to the resource dispatcher. 618 // Resource responses are sent to the resource dispatcher.
614 if (resource_dispatcher_->OnMessageReceived(msg)) 619 if (resource_dispatcher_->OnMessageReceived(msg))
615 return true; 620 return true;
616 if (websocket_dispatcher_->OnMessageReceived(msg))
617 return true;
618 if (file_system_dispatcher_->OnMessageReceived(msg)) 621 if (file_system_dispatcher_->OnMessageReceived(msg))
619 return true; 622 return true;
620 623
621 bool handled = true; 624 bool handled = true;
622 IPC_BEGIN_MESSAGE_MAP(ChildThreadImpl, msg) 625 IPC_BEGIN_MESSAGE_MAP(ChildThreadImpl, msg)
623 IPC_MESSAGE_HANDLER(ChildProcessMsg_Shutdown, OnShutdown) 626 IPC_MESSAGE_HANDLER(ChildProcessMsg_Shutdown, OnShutdown)
624 #if defined(IPC_MESSAGE_LOG_ENABLED) 627 #if defined(IPC_MESSAGE_LOG_ENABLED)
625 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetIPCLoggingEnabled, 628 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetIPCLoggingEnabled,
626 OnSetIPCLoggingEnabled) 629 OnSetIPCLoggingEnabled)
627 #endif 630 #endif
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 void ChildThreadImpl::EnsureConnected() { 725 void ChildThreadImpl::EnsureConnected() {
723 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; 726 VLOG(0) << "ChildThreadImpl::EnsureConnected()";
724 base::Process::Current().Terminate(0, false); 727 base::Process::Current().Terminate(0, false);
725 } 728 }
726 729
727 bool ChildThreadImpl::IsInBrowserProcess() const { 730 bool ChildThreadImpl::IsInBrowserProcess() const {
728 return static_cast<bool>(browser_process_io_runner_); 731 return static_cast<bool>(browser_process_io_runner_);
729 } 732 }
730 733
731 } // namespace content 734 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698