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

Side by Side Diff: content/browser/devtools/protocol/target_auto_attacher.cc

Issue 2944523002: Improving flat containers interface. (Closed)
Patch Set: Minimizing target_auto_attacher diff Created 3 years, 5 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/protocol/target_auto_attacher.h" 5 #include "content/browser/devtools/protocol/target_auto_attacher.h"
6 6
7 #include "content/browser/devtools/render_frame_devtools_agent_host.h" 7 #include "content/browser/devtools/render_frame_devtools_agent_host.h"
8 #include "content/browser/devtools/service_worker_devtools_agent_host.h" 8 #include "content/browser/devtools/service_worker_devtools_agent_host.h"
9 #include "content/browser/frame_host/frame_tree.h" 9 #include "content/browser/frame_host/frame_tree.h"
10 #include "content/browser/frame_host/frame_tree_node.h" 10 #include "content/browser/frame_host/frame_tree_node.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 queue.push(node->child_at(i)); 127 queue.push(node->child_at(i));
128 } 128 }
129 } 129 }
130 } 130 }
131 131
132 // TODO(dgozman): support wait_for_debugger_on_start_. 132 // TODO(dgozman): support wait_for_debugger_on_start_.
133 ReattachTargetsOfType(new_hosts, DevToolsAgentHost::kTypeFrame, false); 133 ReattachTargetsOfType(new_hosts, DevToolsAgentHost::kTypeFrame, false);
134 } 134 }
135 135
136 void TargetAutoAttacher::AgentHostClosed(DevToolsAgentHost* host) { 136 void TargetAutoAttacher::AgentHostClosed(DevToolsAgentHost* host) {
137 auto_attached_hosts_.erase(host); 137 auto_attached_hosts_.erase(make_scoped_refptr(host));
138 } 138 }
139 139
140 void TargetAutoAttacher::ReattachServiceWorkers(bool waiting_for_debugger) { 140 void TargetAutoAttacher::ReattachServiceWorkers(bool waiting_for_debugger) {
141 if (!auto_attach_) 141 if (!auto_attach_)
142 return; 142 return;
143 143
144 frame_urls_.clear(); 144 frame_urls_.clear();
145 BrowserContext* browser_context = nullptr; 145 BrowserContext* browser_context = nullptr;
146 if (render_frame_host_) { 146 if (render_frame_host_) {
147 // TODO(dgozman): do not traverse inside cross-process subframes. 147 // TODO(dgozman): do not traverse inside cross-process subframes.
(...skipping 11 matching lines...) Expand all
159 new_hosts.insert(pair.second); 159 new_hosts.insert(pair.second);
160 } 160 }
161 ReattachTargetsOfType(new_hosts, DevToolsAgentHost::kTypeServiceWorker, 161 ReattachTargetsOfType(new_hosts, DevToolsAgentHost::kTypeServiceWorker,
162 waiting_for_debugger); 162 waiting_for_debugger);
163 } 163 }
164 164
165 void TargetAutoAttacher::ReattachTargetsOfType(const Hosts& new_hosts, 165 void TargetAutoAttacher::ReattachTargetsOfType(const Hosts& new_hosts,
166 const std::string& type, 166 const std::string& type,
167 bool waiting_for_debugger) { 167 bool waiting_for_debugger) {
168 Hosts old_hosts = auto_attached_hosts_; 168 Hosts old_hosts = auto_attached_hosts_;
169 for (auto& it : old_hosts) { 169 for (auto& host : old_hosts) {
170 DevToolsAgentHost* host = it.get();
171 if (host->GetType() == type && new_hosts.find(host) == new_hosts.end()) { 170 if (host->GetType() == type && new_hosts.find(host) == new_hosts.end()) {
172 auto_attached_hosts_.erase(host); 171 auto_attached_hosts_.erase(host);
173 detach_callback_.Run(host); 172 detach_callback_.Run(host.get());
174 } 173 }
175 } 174 }
176 for (auto& it : new_hosts) { 175 for (auto& host : new_hosts) {
177 DevToolsAgentHost* host = it.get();
178 if (old_hosts.find(host) == old_hosts.end()) { 176 if (old_hosts.find(host) == old_hosts.end()) {
179 if (attach_callback_.Run(host, waiting_for_debugger)) 177 if (attach_callback_.Run(host.get(), waiting_for_debugger))
180 auto_attached_hosts_.insert(host); 178 auto_attached_hosts_.insert(host.get());
danakj 2017/07/20 16:12:20 unclear to me why you get the raw pointer to inser
dyaroshev 2017/07/20 16:33:02 Sorry.
181 } 179 }
182 } 180 }
183 } 181 }
184 182
185 void TargetAutoAttacher::SetAutoAttach(bool auto_attach, 183 void TargetAutoAttacher::SetAutoAttach(bool auto_attach,
186 bool wait_for_debugger_on_start) { 184 bool wait_for_debugger_on_start) {
187 wait_for_debugger_on_start_ = wait_for_debugger_on_start; 185 wait_for_debugger_on_start_ = wait_for_debugger_on_start;
188 if (auto_attach_ == auto_attach) 186 if (auto_attach_ == auto_attach)
189 return; 187 return;
190 auto_attach_ = auto_attach; 188 auto_attach_ = auto_attach;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 ServiceWorkerDevToolsAgentHost* host) { 245 ServiceWorkerDevToolsAgentHost* host) {
248 ReattachServiceWorkers(false); 246 ReattachServiceWorkers(false);
249 } 247 }
250 248
251 void TargetAutoAttacher::WorkerDestroyed(ServiceWorkerDevToolsAgentHost* host) { 249 void TargetAutoAttacher::WorkerDestroyed(ServiceWorkerDevToolsAgentHost* host) {
252 ReattachServiceWorkers(false); 250 ReattachServiceWorkers(false);
253 } 251 }
254 252
255 } // namespace protocol 253 } // namespace protocol
256 } // namespace content 254 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698