1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "content/browser/devtools/worker_devtools_message_filter.h" 6 7 #include "content/browser/devtools/worker_devtools_manager.h" 8 #include "content/common/devtools_messages.h" 9 #include "content/common/worker_messages.h" 10 11 namespace content { 12 13 WorkerDevToolsMessageFilter::WorkerDevToolsMessageFilter( 14 int worker_process_host_id) 15 : worker_process_host_id_(worker_process_host_id), 16 current_routing_id_(0) { 17 } 18 19 WorkerDevToolsMessageFilter::~WorkerDevToolsMessageFilter() { 20 } 21 22 bool WorkerDevToolsMessageFilter::OnMessageReceived( 23 const IPC::Message& message, 24 bool* message_was_ok) { 25 bool handled = true; 26 current_routing_id_ = message.routing_id(); 27 IPC_BEGIN_MESSAGE_MAP_EX(WorkerDevToolsMessageFilter, message, 28 *message_was_ok) 29 IPC_MESSAGE_HANDLER(DevToolsClientMsg_DispatchOnInspectorFrontend, 30 OnDispatchOnInspectorFrontend) 31 IPC_MESSAGE_HANDLER(DevToolsHostMsg_SaveAgentRuntimeState, 32 OnSaveAgentRumtimeState) 33 IPC_MESSAGE_UNHANDLED(handled = false) 34 IPC_END_MESSAGE_MAP_EX() 35 return handled; 36 } 37 38 void WorkerDevToolsMessageFilter::OnDispatchOnInspectorFrontend( 39 const std::string& message) { 40 WorkerDevToolsManager::GetInstance()->ForwardToDevToolsClient( 41 worker_process_host_id_, current_routing_id_, message); 42 } 43 44 void WorkerDevToolsMessageFilter::OnSaveAgentRumtimeState( 45 const std::string& state) { 46 WorkerDevToolsManager::GetInstance()->SaveAgentRuntimeState( 47 worker_process_host_id_, current_routing_id_, state); 48 } 49 50 } // namespace content 51