Removing uses of X11 native key events.
[chromium-blink-merge.git] / content / child / shared_worker_devtools_agent.cc
blobcec6e56c0e9a8e801c8b4e03cf7c44b7684b4fa5
1 // Copyright 2014 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.
5 #include "content/child/shared_worker_devtools_agent.h"
7 #include "content/child/child_thread.h"
8 #include "content/common/devtools_messages.h"
9 #include "third_party/WebKit/public/platform/WebCString.h"
10 #include "third_party/WebKit/public/platform/WebString.h"
11 #include "third_party/WebKit/public/web/WebSharedWorker.h"
13 using blink::WebSharedWorker;
14 using blink::WebString;
16 namespace content {
18 SharedWorkerDevToolsAgent::SharedWorkerDevToolsAgent(
19 int route_id,
20 WebSharedWorker* webworker)
21 : route_id_(route_id),
22 webworker_(webworker) {
25 SharedWorkerDevToolsAgent::~SharedWorkerDevToolsAgent() {
28 // Called on the Worker thread.
29 bool SharedWorkerDevToolsAgent::OnMessageReceived(const IPC::Message& message) {
30 bool handled = true;
31 IPC_BEGIN_MESSAGE_MAP(SharedWorkerDevToolsAgent, message)
32 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Attach, OnAttach)
33 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Reattach, OnReattach)
34 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Detach, OnDetach)
35 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DispatchOnInspectorBackend,
36 OnDispatchOnInspectorBackend)
37 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_ResumeWorkerContext,
38 OnResumeWorkerContext)
39 IPC_MESSAGE_UNHANDLED(handled = false)
40 IPC_END_MESSAGE_MAP()
41 return handled;
44 void SharedWorkerDevToolsAgent::SendDevToolsMessage(
45 const blink::WebString& message) {
46 Send(new DevToolsClientMsg_DispatchOnInspectorFrontend(
47 route_id_,
48 message.utf8()));
51 void SharedWorkerDevToolsAgent::SaveDevToolsAgentState(
52 const blink::WebString& state) {
53 Send(new DevToolsHostMsg_SaveAgentRuntimeState(route_id_,
54 state.utf8()));
57 void SharedWorkerDevToolsAgent::OnAttach(const std::string& host_id) {
58 webworker_->attachDevTools(WebString::fromUTF8(host_id));
61 void SharedWorkerDevToolsAgent::OnReattach(const std::string& host_id,
62 const std::string& state) {
63 webworker_->reattachDevTools(WebString::fromUTF8(host_id),
64 WebString::fromUTF8(state));
67 void SharedWorkerDevToolsAgent::OnDetach() {
68 webworker_->detachDevTools();
71 void SharedWorkerDevToolsAgent::OnDispatchOnInspectorBackend(
72 const std::string& message) {
73 webworker_->dispatchDevToolsMessage(WebString::fromUTF8(message));
76 void SharedWorkerDevToolsAgent::OnResumeWorkerContext() {
77 webworker_->resumeWorkerContext();
80 bool SharedWorkerDevToolsAgent::Send(IPC::Message* message) {
81 return ChildThread::current()->Send(message);
84 } // namespace content