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_EMBEDDED_WORKER_DEVTOOLS_AGENT_HOST_H_
6 #define CONTENT_BROWSER_DEVTOOLS_EMBEDDED_WORKER_DEVTOOLS_AGENT_HOST_H_
8 #include "content/browser/devtools/embedded_worker_devtools_manager.h"
9 #include "content/browser/devtools/ipc_devtools_agent_host.h"
10 #include "ipc/ipc_listener.h"
15 class SharedWorkerInstance
;
17 class EmbeddedWorkerDevToolsAgentHost
: public IPCDevToolsAgentHost
,
18 public IPC::Listener
{
20 typedef EmbeddedWorkerDevToolsManager::WorkerId WorkerId
;
21 typedef EmbeddedWorkerDevToolsManager::ServiceWorkerIdentifier
22 ServiceWorkerIdentifier
;
24 EmbeddedWorkerDevToolsAgentHost(WorkerId worker_id
,
25 const SharedWorkerInstance
& shared_worker
);
27 EmbeddedWorkerDevToolsAgentHost(WorkerId worker_id
,
28 const ServiceWorkerIdentifier
& service_worker
,
29 bool debug_service_worker_on_start
);
31 // DevToolsAgentHost override.
32 bool IsWorker() const override
;
33 Type
GetType() override
;
34 std::string
GetTitle() override
;
35 GURL
GetURL() override
;
36 bool Activate() override
;
37 bool Close() override
;
38 BrowserContext
* GetBrowserContext() override
;
40 // IPCDevToolsAgentHost implementation.
41 void SendMessageToAgent(IPC::Message
* message
) override
;
42 void Attach() override
;
43 void OnClientAttached() override
;
44 void OnClientDetached() override
;
46 // IPC::Listener implementation.
47 bool OnMessageReceived(const IPC::Message
& msg
) override
;
49 void WorkerReadyForInspection();
50 void WorkerRestarted(WorkerId worker_id
);
51 void WorkerDestroyed();
52 bool Matches(const SharedWorkerInstance
& other
);
53 bool Matches(const ServiceWorkerIdentifier
& other
);
57 friend class EmbeddedWorkerDevToolsManagerTest
;
59 ~EmbeddedWorkerDevToolsAgentHost() override
;
65 WORKER_PAUSED_FOR_DEBUG_ON_START
,
66 WORKER_PAUSED_FOR_REATTACH
,
69 void AttachToWorker();
70 void DetachFromWorker();
72 void OnDispatchOnInspectorFrontend(const std::string
& message
,
74 void OnSaveAgentRuntimeState(const std::string
& state
);
76 scoped_ptr
<SharedWorkerInstance
> shared_worker_
;
77 scoped_ptr
<ServiceWorkerIdentifier
> service_worker_
;
80 std::string saved_agent_state_
;
81 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerDevToolsAgentHost
);
84 } // namespace content
86 #endif // CONTENT_BROWSER_DEVTOOLS_EMBEDDED_WORKER_DEVTOOLS_AGENT_HOST_H_