Chromium Code Reviews| Index: content/worker/worker_devtools_agent.cc |
| diff --git a/content/worker/worker_devtools_agent.cc b/content/worker/worker_devtools_agent.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ffcdb7e2c9ea1a7f0f348990dced5d0fab191cc2 |
| --- /dev/null |
| +++ b/content/worker/worker_devtools_agent.cc |
| @@ -0,0 +1,61 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "content/worker/worker_devtools_agent.h" |
| + |
| +#include "content/common/devtools_messages.h" |
| +#include "content/worker/worker_thread.h" |
| +#include "ipc/ipc_message.h" |
| +#include "ipc/ipc_message_macros.h" |
|
jam
2011/05/25 17:50:12
no need to include these two ipc headers. they're
yurys
2011/05/26 09:11:49
Done.
|
| +#include "third_party/WebKit/Source/WebKit/chromium/public/WebCString.h" |
| +#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" |
|
jam
2011/05/25 17:50:12
no need?
yurys
2011/05/26 09:11:49
It's used in WorkerDevToolsAgent::SendDevToolsMess
|
| +#include "third_party/WebKit/Source/WebKit/chromium/public/WebWorker.h" |
| + |
| +using WebKit::WebString; |
| +using WebKit::WebCString; |
| +using WebKit::WebWorker; |
| + |
| +WorkerDevToolsAgent::WorkerDevToolsAgent(int route_id, WebWorker* webworker) |
| + : route_id_(route_id) |
| + , webworker_(webworker) { |
|
jam
2011/05/25 17:50:12
comma on previous line
please check the chrome st
yurys
2011/05/26 09:11:49
Yeah, sorry about all these style errors, I defini
|
| +} |
| + |
| +WorkerDevToolsAgent::~WorkerDevToolsAgent() { |
| +} |
| + |
| +// Called on the Worker thread. |
| +bool WorkerDevToolsAgent::OnMessageReceived(const IPC::Message& message) { |
| + bool handled = true; |
| + IPC_BEGIN_MESSAGE_MAP(WorkerDevToolsAgent, message) |
| + IPC_MESSAGE_HANDLER(WorkerDevToolsAgentMsg_Attach, OnAttach) |
| + IPC_MESSAGE_HANDLER(WorkerDevToolsAgentMsg_Detach, OnDetach) |
| + IPC_MESSAGE_HANDLER(WorkerDevToolsAgentMsg_DispatchOnInspectorBackend, |
| + OnDispatchOnInspectorBackend) |
| + IPC_MESSAGE_UNHANDLED(handled = false) |
| + IPC_END_MESSAGE_MAP() |
| + return handled; |
| +} |
| + |
| +void WorkerDevToolsAgent::OnAttach() { |
| + webworker_->attachDevTools(); |
| +} |
| + |
| +void WorkerDevToolsAgent::OnDetach() { |
| + webworker_->detachDevTools(); |
| +} |
| + |
| +void WorkerDevToolsAgent::OnDispatchOnInspectorBackend( |
| + const std::string& message) { |
| + webworker_->dispatchDevToolsMessage(WebString::fromUTF8(message)); |
| +} |
| + |
| +bool WorkerDevToolsAgent::Send(IPC::Message* message) { |
| + return WorkerThread::current()->Send(message); |
| +} |
| + |
| +void WorkerDevToolsAgent::SendDevToolsMessage(const WebString& message) |
| +{ |
|
jam
2011/05/25 17:50:12
nit: brace bracket on previous line
yurys
2011/05/26 09:11:49
Done.
|
| + Send(new DevToolsAgentMsg_DispatchMessageFromWorker(route_id_, |
| + message.utf8())); |
| +} |