OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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. |
| 4 |
| 5 #ifndef HEADLESS_LIB_BROWSER_HEADLESS_DEVTOOLS_CLIENT_IMPL_H_ |
| 6 #define HEADLESS_LIB_BROWSER_HEADLESS_DEVTOOLS_CLIENT_IMPL_H_ |
| 7 |
| 8 #include <unordered_map> |
| 9 |
| 10 #include "content/public/browser/devtools_agent_host_client.h" |
| 11 #include "headless/public/domains/accessibility.h" |
| 12 #include "headless/public/domains/animation.h" |
| 13 #include "headless/public/domains/application_cache.h" |
| 14 #include "headless/public/domains/cache_storage.h" |
| 15 #include "headless/public/domains/console.h" |
| 16 #include "headless/public/domains/css.h" |
| 17 #include "headless/public/domains/database.h" |
| 18 #include "headless/public/domains/debugger.h" |
| 19 #include "headless/public/domains/device_orientation.h" |
| 20 #include "headless/public/domains/dom.h" |
| 21 #include "headless/public/domains/dom_debugger.h" |
| 22 #include "headless/public/domains/dom_storage.h" |
| 23 #include "headless/public/domains/emulation.h" |
| 24 #include "headless/public/domains/heap_profiler.h" |
| 25 #include "headless/public/domains/indexeddb.h" |
| 26 #include "headless/public/domains/input.h" |
| 27 #include "headless/public/domains/inspector.h" |
| 28 #include "headless/public/domains/io.h" |
| 29 #include "headless/public/domains/layer_tree.h" |
| 30 #include "headless/public/domains/memory.h" |
| 31 #include "headless/public/domains/network.h" |
| 32 #include "headless/public/domains/page.h" |
| 33 #include "headless/public/domains/profiler.h" |
| 34 #include "headless/public/domains/rendering.h" |
| 35 #include "headless/public/domains/runtime.h" |
| 36 #include "headless/public/domains/security.h" |
| 37 #include "headless/public/domains/service_worker.h" |
| 38 #include "headless/public/domains/tracing.h" |
| 39 #include "headless/public/domains/worker.h" |
| 40 #include "headless/public/headless_devtools_client.h" |
| 41 #include "headless/public/internal/message_dispatcher.h" |
| 42 |
| 43 namespace base { |
| 44 class DictionaryValue; |
| 45 } |
| 46 |
| 47 namespace content { |
| 48 class DevToolsAgentHost; |
| 49 } |
| 50 |
| 51 namespace headless { |
| 52 |
| 53 class HeadlessDevToolsClientImpl : public HeadlessDevToolsClient, |
| 54 public content::DevToolsAgentHostClient, |
| 55 public internal::MessageDispatcher { |
| 56 public: |
| 57 HeadlessDevToolsClientImpl(); |
| 58 ~HeadlessDevToolsClientImpl() override; |
| 59 |
| 60 static HeadlessDevToolsClientImpl* From(HeadlessDevToolsClient* client); |
| 61 |
| 62 // HeadlessDevToolsClient implementation: |
| 63 accessibility::Domain* GetAccessibility() override; |
| 64 animation::Domain* GetAnimation() override; |
| 65 application_cache::Domain* GetApplicationCache() override; |
| 66 cache_storage::Domain* GetCacheStorage() override; |
| 67 console::Domain* GetConsole() override; |
| 68 css::Domain* GetCSS() override; |
| 69 database::Domain* GetDatabase() override; |
| 70 debugger::Domain* GetDebugger() override; |
| 71 device_orientation::Domain* GetDeviceOrientation() override; |
| 72 dom::Domain* GetDOM() override; |
| 73 dom_debugger::Domain* GetDOMDebugger() override; |
| 74 dom_storage::Domain* GetDOMStorage() override; |
| 75 emulation::Domain* GetEmulation() override; |
| 76 heap_profiler::Domain* GetHeapProfiler() override; |
| 77 indexeddb::Domain* GetIndexedDB() override; |
| 78 input::Domain* GetInput() override; |
| 79 inspector::Domain* GetInspector() override; |
| 80 io::Domain* GetIO() override; |
| 81 layer_tree::Domain* GetLayerTree() override; |
| 82 memory::Domain* GetMemory() override; |
| 83 network::Domain* GetNetwork() override; |
| 84 page::Domain* GetPage() override; |
| 85 profiler::Domain* GetProfiler() override; |
| 86 rendering::Domain* GetRendering() override; |
| 87 runtime::Domain* GetRuntime() override; |
| 88 security::Domain* GetSecurity() override; |
| 89 service_worker::Domain* GetServiceWorker() override; |
| 90 tracing::Domain* GetTracing() override; |
| 91 worker::Domain* GetWorker() override; |
| 92 |
| 93 // content::DevToolstAgentHostClient implementation: |
| 94 void DispatchProtocolMessage(content::DevToolsAgentHost* agent_host, |
| 95 const std::string& json_message) override; |
| 96 void AgentHostClosed(content::DevToolsAgentHost* agent_host, |
| 97 bool replaced_with_another_client) override; |
| 98 |
| 99 // internal::MessageDispatcher implementation: |
| 100 void SendMessage(const char* method, |
| 101 std::unique_ptr<base::Value> params, |
| 102 base::Callback<void(const base::Value&)> callback) override; |
| 103 void SendMessage(const char* method, |
| 104 std::unique_ptr<base::Value> params, |
| 105 base::Callback<void()> callback) override; |
| 106 void SendMessage(const char* method, |
| 107 base::Callback<void(const base::Value&)> callback) override; |
| 108 void SendMessage(const char* method, |
| 109 base::Callback<void()> callback) override; |
| 110 |
| 111 void AttachToHost(content::DevToolsAgentHost* agent_host); |
| 112 void DetachFromHost(content::DevToolsAgentHost* agent_host); |
| 113 |
| 114 // Returns the message id. |
| 115 int FinalizeAndSendMessage(base::DictionaryValue* message); |
| 116 |
| 117 private: |
| 118 // Represents a message for which we are still waiting for a reply. Contains |
| 119 // a callback with or without a result parameter depending on the message that |
| 120 // is pending. |
| 121 struct PendingMessage { |
| 122 PendingMessage(); |
| 123 explicit PendingMessage(base::Callback<void()> callback); |
| 124 explicit PendingMessage(base::Callback<void(const base::Value&)> callback); |
| 125 ~PendingMessage(); |
| 126 |
| 127 // TODO(skyostil): Use a class union once allowed. |
| 128 base::Callback<void()> callback; |
| 129 base::Callback<void(const base::Value&)> callback_with_result; |
| 130 }; |
| 131 |
| 132 content::DevToolsAgentHost* agent_host_; // Not owned. |
| 133 int next_message_id_; |
| 134 std::unordered_map<int, PendingMessage> pending_messages_; |
| 135 |
| 136 accessibility::Domain accessibility_domain_; |
| 137 animation::Domain animation_domain_; |
| 138 application_cache::Domain application_cache_domain_; |
| 139 cache_storage::Domain cache_storage_domain_; |
| 140 console::Domain console_domain_; |
| 141 css::Domain css_domain_; |
| 142 database::Domain database_domain_; |
| 143 debugger::Domain debugger_domain_; |
| 144 device_orientation::Domain device_orientation_domain_; |
| 145 dom_debugger::Domain dom_debugger_domain_; |
| 146 dom::Domain dom_domain_; |
| 147 dom_storage::Domain dom_storage_domain_; |
| 148 emulation::Domain emulation_domain_; |
| 149 heap_profiler::Domain heap_profiler_domain_; |
| 150 indexeddb::Domain indexeddb_domain_; |
| 151 input::Domain input_domain_; |
| 152 inspector::Domain inspector_domain_; |
| 153 io::Domain io_domain_; |
| 154 layer_tree::Domain layer_tree_domain_; |
| 155 memory::Domain memory_domain_; |
| 156 network::Domain network_domain_; |
| 157 page::Domain page_domain_; |
| 158 profiler::Domain profiler_domain_; |
| 159 rendering::Domain rendering_domain_; |
| 160 runtime::Domain runtime_domain_; |
| 161 security::Domain security_domain_; |
| 162 service_worker::Domain service_worker_domain_; |
| 163 tracing::Domain tracing_domain_; |
| 164 worker::Domain worker_domain_; |
| 165 |
| 166 DISALLOW_COPY_AND_ASSIGN(HeadlessDevToolsClientImpl); |
| 167 }; |
| 168 |
| 169 } // namespace headless |
| 170 |
| 171 #endif // HEADLESS_LIB_BROWSER_HEADLESS_DEVTOOLS_CLIENT_IMPL_H_ |
OLD | NEW |