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

Side by Side Diff: chrome/browser/ui/webui/inspect_ui.cc

Issue 12589003: Remove duplicated code from chrome://inspect implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@targets
Patch Set: Rebase Created 7 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/ui/webui/inspect_ui.h" 5 #include "chrome/browser/ui/webui/inspect_ui.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 14 matching lines...) Expand all
25 #include "content/public/browser/devtools_agent_host.h" 25 #include "content/public/browser/devtools_agent_host.h"
26 #include "content/public/browser/devtools_client_host.h" 26 #include "content/public/browser/devtools_client_host.h"
27 #include "content/public/browser/devtools_manager.h" 27 #include "content/public/browser/devtools_manager.h"
28 #include "content/public/browser/favicon_status.h" 28 #include "content/public/browser/favicon_status.h"
29 #include "content/public/browser/navigation_entry.h" 29 #include "content/public/browser/navigation_entry.h"
30 #include "content/public/browser/notification_service.h" 30 #include "content/public/browser/notification_service.h"
31 #include "content/public/browser/notification_source.h" 31 #include "content/public/browser/notification_source.h"
32 #include "content/public/browser/notification_types.h" 32 #include "content/public/browser/notification_types.h"
33 #include "content/public/browser/render_process_host.h" 33 #include "content/public/browser/render_process_host.h"
34 #include "content/public/browser/render_view_host.h" 34 #include "content/public/browser/render_view_host.h"
35 #include "content/public/browser/render_widget_host.h"
36 #include "content/public/browser/web_contents.h" 35 #include "content/public/browser/web_contents.h"
37 #include "content/public/browser/web_ui.h" 36 #include "content/public/browser/web_ui.h"
38 #include "content/public/browser/web_ui_data_source.h" 37 #include "content/public/browser/web_ui_data_source.h"
39 #include "content/public/browser/web_ui_message_handler.h" 38 #include "content/public/browser/web_ui_message_handler.h"
40 #include "content/public/browser/worker_service.h" 39 #include "content/public/browser/worker_service.h"
41 #include "content/public/browser/worker_service_observer.h" 40 #include "content/public/browser/worker_service_observer.h"
42 #include "content/public/common/process_type.h" 41 #include "content/public/common/process_type.h"
43 #include "grit/browser_resources.h" 42 #include "grit/browser_resources.h"
44 #include "grit/generated_resources.h" 43 #include "grit/generated_resources.h"
45 #include "net/base/escape.h" 44 #include "net/base/escape.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 173
175 bool HandleDataRequestCallback( 174 bool HandleDataRequestCallback(
176 const std::string& path, 175 const std::string& path,
177 const content::WebUIDataSource::GotDataCallback& callback) { 176 const content::WebUIDataSource::GotDataCallback& callback) {
178 std::set<RenderViewHost*> tab_rvhs; 177 std::set<RenderViewHost*> tab_rvhs;
179 for (TabContentsIterator it; !it.done(); it.Next()) 178 for (TabContentsIterator it; !it.done(); it.Next())
180 tab_rvhs.insert(it->GetRenderViewHost()); 179 tab_rvhs.insert(it->GetRenderViewHost());
181 180
182 scoped_ptr<ListValue> rvh_list(new ListValue()); 181 scoped_ptr<ListValue> rvh_list(new ListValue());
183 182
184 for (RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator()); 183 std::vector<RenderViewHost*> rvh_vector =
185 !it.IsAtEnd(); it.Advance()) { 184 DevToolsAgentHost::GetValidRenderViewHosts();
186 RenderProcessHost* render_process_host = it.GetCurrentValue();
187 DCHECK(render_process_host);
188 185
189 // Ignore processes that don't have a connection, such as crashed tabs. 186 for (std::vector<RenderViewHost*>::iterator it(rvh_vector.begin());
190 if (!render_process_host->HasConnection()) 187 it != rvh_vector.end(); it++) {
191 continue; 188 bool is_tab = tab_rvhs.find(*it) != tab_rvhs.end();
192 189 rvh_list->Append(BuildTargetDescriptor(*it, is_tab));
193 RenderProcessHost::RenderWidgetHostsIterator rwit(
194 render_process_host->GetRenderWidgetHostsIterator());
195 for (; !rwit.IsAtEnd(); rwit.Advance()) {
196 const RenderWidgetHost* widget = rwit.GetCurrentValue();
197 DCHECK(widget);
198 if (!widget || !widget->IsRenderView())
199 continue;
200
201 RenderViewHost* rvh =
202 RenderViewHost::From(const_cast<RenderWidgetHost*>(widget));
203
204 bool is_tab = tab_rvhs.find(rvh) != tab_rvhs.end();
205 rvh_list->Append(BuildTargetDescriptor(rvh, is_tab));
206 }
207 } 190 }
208 191
209 BrowserThread::PostTask( 192 BrowserThread::PostTask(
210 BrowserThread::IO, 193 BrowserThread::IO,
211 FROM_HERE, 194 FROM_HERE,
212 base::Bind(&SendDescriptors, base::Owned(rvh_list.release()), callback)); 195 base::Bind(&SendDescriptors, base::Owned(rvh_list.release()), callback));
213 return true; 196 return true;
214 } 197 }
215 198
216 class InspectMessageHandler : public WebUIMessageHandler { 199 class InspectMessageHandler : public WebUIMessageHandler {
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 const content::WebUIDataSource::GotDataCallback& callback, 436 const content::WebUIDataSource::GotDataCallback& callback,
454 const std::string& error, 437 const std::string& error,
455 const std::string& data) { 438 const std::string& data) {
456 ListValue result; 439 ListValue result;
457 result.AppendString(error); 440 result.AppendString(error);
458 result.AppendString(data); 441 result.AppendString(data);
459 std::string json_string; 442 std::string json_string;
460 base::JSONWriter::Write(&result, &json_string); 443 base::JSONWriter::Write(&result, &json_string);
461 callback.Run(base::RefCountedString::TakeString(&json_string)); 444 callback.Run(base::RefCountedString::TakeString(&json_string));
462 } 445 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698