| OLD | NEW |
| (Empty) | |
| 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/worker/worker_devtools_agent.h" |
| 6 |
| 7 #include "content/common/devtools_messages.h" |
| 8 #include "content/worker/worker_thread.h" |
| 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCString.h" |
| 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" |
| 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWorker.h" |
| 12 |
| 13 using WebKit::WebString; |
| 14 using WebKit::WebWorker; |
| 15 |
| 16 WorkerDevToolsAgent::WorkerDevToolsAgent(int route_id, WebWorker* webworker) |
| 17 : route_id_(route_id), |
| 18 webworker_(webworker) { |
| 19 } |
| 20 |
| 21 WorkerDevToolsAgent::~WorkerDevToolsAgent() { |
| 22 } |
| 23 |
| 24 // Called on the Worker thread. |
| 25 bool WorkerDevToolsAgent::OnMessageReceived(const IPC::Message& message) { |
| 26 bool handled = true; |
| 27 IPC_BEGIN_MESSAGE_MAP(WorkerDevToolsAgent, message) |
| 28 IPC_MESSAGE_HANDLER(WorkerDevToolsAgentMsg_Attach, OnAttach) |
| 29 IPC_MESSAGE_HANDLER(WorkerDevToolsAgentMsg_Detach, OnDetach) |
| 30 IPC_MESSAGE_HANDLER(WorkerDevToolsAgentMsg_DispatchOnInspectorBackend, |
| 31 OnDispatchOnInspectorBackend) |
| 32 IPC_MESSAGE_UNHANDLED(handled = false) |
| 33 IPC_END_MESSAGE_MAP() |
| 34 return handled; |
| 35 } |
| 36 |
| 37 void WorkerDevToolsAgent::OnAttach() { |
| 38 webworker_->attachDevTools(); |
| 39 } |
| 40 |
| 41 void WorkerDevToolsAgent::OnDetach() { |
| 42 webworker_->detachDevTools(); |
| 43 } |
| 44 |
| 45 void WorkerDevToolsAgent::OnDispatchOnInspectorBackend( |
| 46 const std::string& message) { |
| 47 webworker_->dispatchDevToolsMessage(WebString::fromUTF8(message)); |
| 48 } |
| 49 |
| 50 bool WorkerDevToolsAgent::Send(IPC::Message* message) { |
| 51 return WorkerThread::current()->Send(message); |
| 52 } |
| 53 |
| 54 void WorkerDevToolsAgent::SendDevToolsMessage(const WebString& message) { |
| 55 Send(new DevToolsAgentMsg_DispatchMessageFromWorker(route_id_, |
| 56 message.utf8())); |
| 57 } |
| OLD | NEW |