Update optimize_png_files.sh to work on msysgit bash.
[chromium-blink-merge.git] / content / child / shared_worker_devtools_agent.cc
blob853d08e359df0c7266aaceeee69829574c58af8f
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() {
58 webworker_->attachDevTools();
61 void SharedWorkerDevToolsAgent::OnReattach(const std::string& state) {
62 webworker_->reattachDevTools(WebString::fromUTF8(state));
65 void SharedWorkerDevToolsAgent::OnDetach() {
66 webworker_->detachDevTools();
69 void SharedWorkerDevToolsAgent::OnDispatchOnInspectorBackend(
70 const std::string& message) {
71 webworker_->dispatchDevToolsMessage(WebString::fromUTF8(message));
74 void SharedWorkerDevToolsAgent::OnResumeWorkerContext() {
75 webworker_->resumeWorkerContext();
78 bool SharedWorkerDevToolsAgent::Send(IPC::Message* message) {
79 return ChildThread::current()->Send(message);
82 } // namespace content