Rename Animate as Begin(Main)Frame
[chromium-blink-merge.git] / content / browser / devtools / embedded_worker_devtools_agent_host.h
blob0b186c9b504ec996af4a985b2ade0c91daeae539
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 virtual bool IsWorker() const OVERRIDE;
33 // IPCDevToolsAgentHost implementation.
34 virtual void SendMessageToAgent(IPC::Message* message) OVERRIDE;
35 virtual void Attach() OVERRIDE;
36 virtual void OnClientAttached() OVERRIDE {}
37 virtual void OnClientDetached() OVERRIDE;
39 // IPC::Listener implementation.
40 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
42 void WorkerContextStarted();
43 void WorkerRestarted(WorkerId worker_id);
44 void WorkerDestroyed();
45 bool Matches(const SharedWorkerInstance& other);
46 bool Matches(const ServiceWorkerIdentifier& other);
48 private:
49 friend class EmbeddedWorkerDevToolsManagerTest;
51 virtual ~EmbeddedWorkerDevToolsAgentHost();
53 enum WorkerState {
54 WORKER_UNINSPECTED,
55 WORKER_INSPECTED,
56 WORKER_TERMINATED,
57 WORKER_PAUSED_FOR_DEBUG_ON_START,
58 WORKER_PAUSED_FOR_REATTACH,
61 void AttachToWorker();
62 void DetachFromWorker();
63 void WorkerCreated();
64 void OnDispatchOnInspectorFrontend(const std::string& message);
65 void OnSaveAgentRuntimeState(const std::string& state);
67 scoped_ptr<SharedWorkerInstance> shared_worker_;
68 scoped_ptr<ServiceWorkerIdentifier> service_worker_;
69 WorkerState state_;
70 WorkerId worker_id_;
71 std::string saved_agent_state_;
72 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerDevToolsAgentHost);
75 } // namespace content
77 #endif // CONTENT_BROWSER_DEVTOOLS_EMBEDDED_WORKER_DEVTOOLS_AGENT_HOST_H_