[Ozone-Gbm] Explicitly crash if trying software rendering on GBM
[chromium-blink-merge.git] / content / browser / devtools / shared_worker_devtools_manager.cc
blobcd4d19607869c274dde622833f6790cf0112d9a6
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 #include "content/browser/devtools/shared_worker_devtools_manager.h"
7 #include "content/browser/devtools/devtools_manager.h"
8 #include "content/browser/devtools/shared_worker_devtools_agent_host.h"
9 #include "content/browser/shared_worker/shared_worker_instance.h"
10 #include "content/public/browser/browser_thread.h"
12 namespace content {
14 // static
15 SharedWorkerDevToolsManager* SharedWorkerDevToolsManager::GetInstance() {
16 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
17 return Singleton<SharedWorkerDevToolsManager>::get();
20 bool SharedWorkerDevToolsManager::WorkerCreated(
21 int worker_process_id,
22 int worker_route_id,
23 const SharedWorkerInstance& instance) {
24 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
25 const WorkerId id(worker_process_id, worker_route_id);
26 AgentHostMap::iterator it = FindExistingWorkerAgentHost(instance);
27 if (it == workers().end()) {
28 workers()[id] = new SharedWorkerDevToolsAgentHost(id, instance);
29 DevToolsManager::GetInstance()->AgentHostChanged(workers()[id]);
30 return false;
32 WorkerRestarted(id, it);
33 return true;
36 SharedWorkerDevToolsManager::AgentHostMap::iterator
37 SharedWorkerDevToolsManager::FindExistingWorkerAgentHost(
38 const SharedWorkerInstance& instance) {
39 AgentHostMap::iterator it = workers().begin();
40 for (; it != workers().end(); ++it) {
41 if (static_cast<SharedWorkerDevToolsAgentHost*>(
42 it->second)->Matches(instance))
43 break;
45 return it;
48 SharedWorkerDevToolsManager::SharedWorkerDevToolsManager() {
51 SharedWorkerDevToolsManager::~SharedWorkerDevToolsManager() {
54 void SharedWorkerDevToolsManager::ResetForTesting() {
55 workers().clear();
58 } // namespace content