cc: Make picture pile base thread safe.
[chromium-blink-merge.git] / content / browser / devtools / embedded_worker_devtools_agent_host.h
blobcb0e45f3369af53272c38d4d5e8b25c033df3274
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"
12 namespace content {
14 class SharedWorkerInstance;
16 class EmbeddedWorkerDevToolsAgentHost : public IPCDevToolsAgentHost,
17 public IPC::Listener {
18 public:
19 typedef EmbeddedWorkerDevToolsManager::WorkerId WorkerId;
20 typedef EmbeddedWorkerDevToolsManager::ServiceWorkerIdentifier
21 ServiceWorkerIdentifier;
23 EmbeddedWorkerDevToolsAgentHost(WorkerId worker_id,
24 const SharedWorkerInstance& shared_worker);
26 EmbeddedWorkerDevToolsAgentHost(WorkerId worker_id,
27 const ServiceWorkerIdentifier& service_worker,
28 bool debug_service_worker_on_start);
30 // DevToolsAgentHost override.
31 bool IsWorker() const override;
32 Type GetType() override;
33 std::string GetTitle() override;
34 GURL GetURL() override;
35 bool Activate() override;
36 bool Close() override;
38 // IPCDevToolsAgentHost implementation.
39 void SendMessageToAgent(IPC::Message* message) override;
40 void Attach() override;
41 void OnClientAttached() override {}
42 void OnClientDetached() override;
44 // IPC::Listener implementation.
45 bool OnMessageReceived(const IPC::Message& msg) override;
47 void WorkerReadyForInspection();
48 void WorkerRestarted(WorkerId worker_id);
49 void WorkerDestroyed();
50 bool Matches(const SharedWorkerInstance& other);
51 bool Matches(const ServiceWorkerIdentifier& other);
52 bool IsTerminated();
54 private:
55 friend class EmbeddedWorkerDevToolsManagerTest;
57 ~EmbeddedWorkerDevToolsAgentHost() override;
59 enum WorkerState {
60 WORKER_UNINSPECTED,
61 WORKER_INSPECTED,
62 WORKER_TERMINATED,
63 WORKER_PAUSED_FOR_DEBUG_ON_START,
64 WORKER_PAUSED_FOR_REATTACH,
67 void AttachToWorker();
68 void DetachFromWorker();
69 void WorkerCreated();
70 void OnDispatchOnInspectorFrontend(const std::string& message,
71 uint32 total_size);
72 void OnSaveAgentRuntimeState(const std::string& state);
74 scoped_ptr<SharedWorkerInstance> shared_worker_;
75 scoped_ptr<ServiceWorkerIdentifier> service_worker_;
76 WorkerState state_;
77 WorkerId worker_id_;
78 std::string saved_agent_state_;
79 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerDevToolsAgentHost);
82 } // namespace content
84 #endif // CONTENT_BROWSER_DEVTOOLS_EMBEDDED_WORKER_DEVTOOLS_AGENT_HOST_H_