Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: content/browser/devtools/devtools_agent_host_impl.cc

Issue 2867693004: Snapshot of all changes to get jumbo in blink and content.
Patch Set: Exclude certain files from jumbo because of a Windows problem Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/devtools/devtools_agent_host_impl.h" 5 #include "content/browser/devtools/devtools_agent_host_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 12 matching lines...) Expand all
23 #include "content/browser/devtools/shared_worker_devtools_manager.h" 23 #include "content/browser/devtools/shared_worker_devtools_manager.h"
24 #include "content/browser/frame_host/frame_tree_node.h" 24 #include "content/browser/frame_host/frame_tree_node.h"
25 #include "content/browser/renderer_host/render_view_host_impl.h" 25 #include "content/browser/renderer_host/render_view_host_impl.h"
26 #include "content/public/browser/browser_thread.h" 26 #include "content/public/browser/browser_thread.h"
27 #include "content/public/browser/content_browser_client.h" 27 #include "content/public/browser/content_browser_client.h"
28 28
29 namespace content { 29 namespace content {
30 30
31 namespace { 31 namespace {
32 typedef std::map<std::string, DevToolsAgentHostImpl*> Instances; 32 typedef std::map<std::string, DevToolsAgentHostImpl*> Instances;
33 base::LazyInstance<Instances>::Leaky g_instances = LAZY_INSTANCE_INITIALIZER; 33 base::LazyInstance<Instances>::Leaky g_devtools_instances =
34 LAZY_INSTANCE_INITIALIZER;
34 35
35 base::LazyInstance<base::ObserverList<DevToolsAgentHostObserver>>::Leaky 36 base::LazyInstance<base::ObserverList<DevToolsAgentHostObserver>>::Leaky
36 g_observers = LAZY_INSTANCE_INITIALIZER; 37 g_devtools_observers = LAZY_INSTANCE_INITIALIZER;
37 } // namespace 38 } // namespace
38 39
39 const char DevToolsAgentHost::kTypePage[] = "page"; 40 const char DevToolsAgentHost::kTypePage[] = "page";
40 const char DevToolsAgentHost::kTypeFrame[] = "iframe"; 41 const char DevToolsAgentHost::kTypeFrame[] = "iframe";
41 const char DevToolsAgentHost::kTypeSharedWorker[] = "shared_worker"; 42 const char DevToolsAgentHost::kTypeSharedWorker[] = "shared_worker";
42 const char DevToolsAgentHost::kTypeServiceWorker[] = "service_worker"; 43 const char DevToolsAgentHost::kTypeServiceWorker[] = "service_worker";
43 const char DevToolsAgentHost::kTypeBrowser[] = "browser"; 44 const char DevToolsAgentHost::kTypeBrowser[] = "browser";
44 const char DevToolsAgentHost::kTypeGuest[] = "webview"; 45 const char DevToolsAgentHost::kTypeGuest[] = "webview";
45 const char DevToolsAgentHost::kTypeOther[] = "other"; 46 const char DevToolsAgentHost::kTypeOther[] = "other";
46 int DevToolsAgentHostImpl::s_force_creation_count_ = 0; 47 int DevToolsAgentHostImpl::s_force_creation_count_ = 0;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 ServiceWorkerDevToolsAgentHost::List service_list; 87 ServiceWorkerDevToolsAgentHost::List service_list;
87 ServiceWorkerDevToolsManager::GetInstance()->AddAllAgentHosts(&service_list); 88 ServiceWorkerDevToolsManager::GetInstance()->AddAllAgentHosts(&service_list);
88 for (const auto& host : service_list) 89 for (const auto& host : service_list)
89 result.push_back(host); 90 result.push_back(host);
90 91
91 RenderFrameDevToolsAgentHost::AddAllAgentHosts(&result); 92 RenderFrameDevToolsAgentHost::AddAllAgentHosts(&result);
92 93
93 #if DCHECK_IS_ON() 94 #if DCHECK_IS_ON()
94 for (auto it : result) { 95 for (auto it : result) {
95 DevToolsAgentHostImpl* host = static_cast<DevToolsAgentHostImpl*>(it.get()); 96 DevToolsAgentHostImpl* host = static_cast<DevToolsAgentHostImpl*>(it.get());
96 DCHECK(g_instances.Get().find(host->id_) != g_instances.Get().end()); 97 DCHECK(g_devtools_instances.Get().find(host->id_) !=
98 g_devtools_instances.Get().end());
97 } 99 }
98 #endif 100 #endif
99 101
100 return result; 102 return result;
101 } 103 }
102 104
103 // Called on the UI thread. 105 // Called on the UI thread.
104 // static 106 // static
105 scoped_refptr<DevToolsAgentHost> DevToolsAgentHost::GetForWorker( 107 scoped_refptr<DevToolsAgentHost> DevToolsAgentHost::GetForWorker(
106 int worker_process_id, 108 int worker_process_id,
(...skipping 14 matching lines...) Expand all
121 } 123 }
122 124
123 DevToolsAgentHostImpl::~DevToolsAgentHostImpl() { 125 DevToolsAgentHostImpl::~DevToolsAgentHostImpl() {
124 DCHECK_CURRENTLY_ON(BrowserThread::UI); 126 DCHECK_CURRENTLY_ON(BrowserThread::UI);
125 NotifyDestroyed(); 127 NotifyDestroyed();
126 } 128 }
127 129
128 // static 130 // static
129 scoped_refptr<DevToolsAgentHost> DevToolsAgentHost::GetForId( 131 scoped_refptr<DevToolsAgentHost> DevToolsAgentHost::GetForId(
130 const std::string& id) { 132 const std::string& id) {
131 if (g_instances == NULL) 133 if (g_devtools_instances == NULL)
132 return NULL; 134 return NULL;
133 Instances::iterator it = g_instances.Get().find(id); 135 Instances::iterator it = g_devtools_instances.Get().find(id);
134 if (it == g_instances.Get().end()) 136 if (it == g_devtools_instances.Get().end())
135 return NULL; 137 return NULL;
136 return it->second; 138 return it->second;
137 } 139 }
138 140
139 // static 141 // static
140 scoped_refptr<DevToolsAgentHost> DevToolsAgentHost::Forward( 142 scoped_refptr<DevToolsAgentHost> DevToolsAgentHost::Forward(
141 const std::string& id, 143 const std::string& id,
142 std::unique_ptr<DevToolsExternalAgentProxyDelegate> delegate) { 144 std::unique_ptr<DevToolsExternalAgentProxyDelegate> delegate) {
143 scoped_refptr<DevToolsAgentHost> result = DevToolsAgentHost::GetForId(id); 145 scoped_refptr<DevToolsAgentHost> result = DevToolsAgentHost::GetForId(id);
144 if (result) 146 if (result)
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 } 284 }
283 285
284 void DevToolsAgentHostImpl::InspectElement( 286 void DevToolsAgentHostImpl::InspectElement(
285 DevToolsSession* session, 287 DevToolsSession* session,
286 int x, 288 int x,
287 int y) { 289 int y) {
288 } 290 }
289 291
290 // static 292 // static
291 void DevToolsAgentHost::DetachAllClients() { 293 void DevToolsAgentHost::DetachAllClients() {
292 if (g_instances == NULL) 294 if (g_devtools_instances == NULL)
293 return; 295 return;
294 296
295 // Make a copy, since detaching may lead to agent destruction, which 297 // Make a copy, since detaching may lead to agent destruction, which
296 // removes it from the instances. 298 // removes it from the instances.
297 Instances copy = g_instances.Get(); 299 Instances copy = g_devtools_instances.Get();
298 for (Instances::iterator it(copy.begin()); it != copy.end(); ++it) { 300 for (Instances::iterator it(copy.begin()); it != copy.end(); ++it) {
299 DevToolsAgentHostImpl* agent_host = it->second; 301 DevToolsAgentHostImpl* agent_host = it->second;
300 agent_host->ForceDetachAllClients(true); 302 agent_host->ForceDetachAllClients(true);
301 } 303 }
302 } 304 }
303 305
304 // static 306 // static
305 void DevToolsAgentHost::AddObserver(DevToolsAgentHostObserver* observer) { 307 void DevToolsAgentHost::AddObserver(DevToolsAgentHostObserver* observer) {
306 if (observer->ShouldForceDevToolsAgentHostCreation()) { 308 if (observer->ShouldForceDevToolsAgentHostCreation()) {
307 if (!DevToolsAgentHostImpl::s_force_creation_count_) { 309 if (!DevToolsAgentHostImpl::s_force_creation_count_) {
308 // Force all agent hosts when first observer is added. 310 // Force all agent hosts when first observer is added.
309 DevToolsAgentHost::GetOrCreateAll(); 311 DevToolsAgentHost::GetOrCreateAll();
310 } 312 }
311 DevToolsAgentHostImpl::s_force_creation_count_++; 313 DevToolsAgentHostImpl::s_force_creation_count_++;
312 } 314 }
313 315
314 g_observers.Get().AddObserver(observer); 316 g_devtools_observers.Get().AddObserver(observer);
315 for (const auto& id_host : g_instances.Get()) 317 for (const auto& id_host : g_devtools_instances.Get())
316 observer->DevToolsAgentHostCreated(id_host.second); 318 observer->DevToolsAgentHostCreated(id_host.second);
317 } 319 }
318 320
319 // static 321 // static
320 void DevToolsAgentHost::RemoveObserver(DevToolsAgentHostObserver* observer) { 322 void DevToolsAgentHost::RemoveObserver(DevToolsAgentHostObserver* observer) {
321 if (observer->ShouldForceDevToolsAgentHostCreation()) 323 if (observer->ShouldForceDevToolsAgentHostCreation())
322 DevToolsAgentHostImpl::s_force_creation_count_--; 324 DevToolsAgentHostImpl::s_force_creation_count_--;
323 g_observers.Get().RemoveObserver(observer); 325 g_devtools_observers.Get().RemoveObserver(observer);
324 } 326 }
325 327
326 // static 328 // static
327 bool DevToolsAgentHostImpl::ShouldForceCreation() { 329 bool DevToolsAgentHostImpl::ShouldForceCreation() {
328 return !!s_force_creation_count_; 330 return !!s_force_creation_count_;
329 } 331 }
330 332
331 void DevToolsAgentHostImpl::NotifyCreated() { 333 void DevToolsAgentHostImpl::NotifyCreated() {
332 DCHECK(g_instances.Get().find(id_) == g_instances.Get().end()); 334 DCHECK(g_devtools_instances.Get().find(id_) == g_devtools_instances.Get().end( ));
333 g_instances.Get()[id_] = this; 335 g_devtools_instances.Get()[id_] = this;
334 for (auto& observer : g_observers.Get()) 336 for (auto& observer : g_devtools_observers.Get())
335 observer.DevToolsAgentHostCreated(this); 337 observer.DevToolsAgentHostCreated(this);
336 } 338 }
337 339
338 void DevToolsAgentHostImpl::NotifyAttached() { 340 void DevToolsAgentHostImpl::NotifyAttached() {
339 for (auto& observer : g_observers.Get()) 341 for (auto& observer : g_devtools_observers.Get())
340 observer.DevToolsAgentHostAttached(this); 342 observer.DevToolsAgentHostAttached(this);
341 } 343 }
342 344
343 void DevToolsAgentHostImpl::NotifyDetached() { 345 void DevToolsAgentHostImpl::NotifyDetached() {
344 for (auto& observer : g_observers.Get()) 346 for (auto& observer : g_devtools_observers.Get())
345 observer.DevToolsAgentHostDetached(this); 347 observer.DevToolsAgentHostDetached(this);
346 } 348 }
347 349
348 void DevToolsAgentHostImpl::NotifyDestroyed() { 350 void DevToolsAgentHostImpl::NotifyDestroyed() {
349 DCHECK(g_instances.Get().find(id_) != g_instances.Get().end()); 351 DCHECK(g_devtools_instances.Get().find(id_) != g_devtools_instances.Get().end( ));
350 for (auto& observer : g_observers.Get()) 352 for (auto& observer : g_devtools_observers.Get())
351 observer.DevToolsAgentHostDestroyed(this); 353 observer.DevToolsAgentHostDestroyed(this);
352 g_instances.Get().erase(id_); 354 g_devtools_instances.Get().erase(id_);
353 } 355 }
354 356
355 // DevToolsMessageChunkProcessor ----------------------------------------------- 357 // DevToolsMessageChunkProcessor -----------------------------------------------
356 358
357 DevToolsMessageChunkProcessor::DevToolsMessageChunkProcessor( 359 DevToolsMessageChunkProcessor::DevToolsMessageChunkProcessor(
358 const SendMessageCallback& callback) 360 const SendMessageCallback& callback)
359 : callback_(callback), 361 : callback_(callback),
360 message_buffer_size_(0), 362 message_buffer_size_(0),
361 last_call_id_(0) { 363 last_call_id_(0) {
362 } 364 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 } 401 }
400 402
401 void DevToolsMessageChunkProcessor::Reset() { 403 void DevToolsMessageChunkProcessor::Reset() {
402 message_buffer_ = std::string(); 404 message_buffer_ = std::string();
403 message_buffer_size_ = 0; 405 message_buffer_size_ = 0;
404 state_cookie_ = std::string(); 406 state_cookie_ = std::string();
405 last_call_id_ = 0; 407 last_call_id_ = 0;
406 } 408 }
407 409
408 } // namespace content 410 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/compositor/software_output_device_x11.cc ('k') | content/browser/devtools/devtools_io_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698