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 #ifndef CONTENT_BROWSER_DEVTOOLS_WORKER_DEVTOOLS_AGENT_HOST_H_
6 #define CONTENT_BROWSER_DEVTOOLS_WORKER_DEVTOOLS_AGENT_HOST_H_
8 #include "content/browser/devtools/devtools_agent_host_impl.h"
9 #include "ipc/ipc_listener.h"
14 class DevToolsProtocolHandler
;
15 class SharedWorkerInstance
;
17 class WorkerDevToolsAgentHost
: public DevToolsAgentHostImpl
,
18 public IPC::Listener
{
20 typedef std::pair
<int, int> WorkerId
;
22 // DevToolsAgentHost override.
23 BrowserContext
* GetBrowserContext() override
;
24 bool DispatchProtocolMessage(const std::string
& message
) override
;
26 // DevToolsAgentHostImpl overrides.
27 void Attach() override
;
28 void Detach() override
;
30 // IPC::Listener implementation.
31 bool OnMessageReceived(const IPC::Message
& msg
) override
;
33 void PauseForDebugOnStart();
34 bool IsPausedForDebugOnStart();
36 void WorkerReadyForInspection();
37 void WorkerRestarted(WorkerId worker_id
);
38 void WorkerDestroyed();
42 explicit WorkerDevToolsAgentHost(WorkerId worker_id
);
43 ~WorkerDevToolsAgentHost() override
;
49 WORKER_PAUSED_FOR_DEBUG_ON_START
,
50 WORKER_PAUSED_FOR_REATTACH
,
53 virtual void OnAttachedStateChanged(bool attached
);
54 const WorkerId
& worker_id() const { return worker_id_
; }
57 friend class SharedWorkerDevToolsManagerTest
;
59 void AttachToWorker();
60 void DetachFromWorker();
62 void OnDispatchOnInspectorFrontend(const DevToolsMessageChunk
& message
);
64 scoped_ptr
<DevToolsProtocolHandler
> protocol_handler_
;
65 DevToolsMessageChunkProcessor chunk_processor_
;
68 DISALLOW_COPY_AND_ASSIGN(WorkerDevToolsAgentHost
);
71 } // namespace content
73 #endif // CONTENT_BROWSER_DEVTOOLS_WORKER_DEVTOOLS_AGENT_HOST_H_