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

Side by Side Diff: chrome/browser/task_manager/task_manager_resource_providers.cc

Issue 12114034: Swap BrowserList::const_iterator for the multi-desktop aware BrowserIterator in many scenarios. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/sessions/session_service.cc ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/task_manager/task_manager_resource_providers.h" 5 #include "chrome/browser/task_manager/task_manager_resource_providers.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 22 matching lines...) Expand all
33 #include "chrome/browser/prerender/prerender_manager_factory.h" 33 #include "chrome/browser/prerender/prerender_manager_factory.h"
34 #include "chrome/browser/printing/background_printing_manager.h" 34 #include "chrome/browser/printing/background_printing_manager.h"
35 #include "chrome/browser/profiles/profile.h" 35 #include "chrome/browser/profiles/profile.h"
36 #include "chrome/browser/profiles/profile_info_cache.h" 36 #include "chrome/browser/profiles/profile_info_cache.h"
37 #include "chrome/browser/profiles/profile_manager.h" 37 #include "chrome/browser/profiles/profile_manager.h"
38 #include "chrome/browser/tab_contents/background_contents.h" 38 #include "chrome/browser/tab_contents/background_contents.h"
39 #include "chrome/browser/tab_contents/tab_util.h" 39 #include "chrome/browser/tab_contents/tab_util.h"
40 #include "chrome/browser/ui/browser.h" 40 #include "chrome/browser/ui/browser.h"
41 #include "chrome/browser/ui/browser_finder.h" 41 #include "chrome/browser/ui/browser_finder.h"
42 #include "chrome/browser/ui/browser_instant_controller.h" 42 #include "chrome/browser/ui/browser_instant_controller.h"
43 #include "chrome/browser/ui/browser_list.h" 43 #include "chrome/browser/ui/browser_iterator.h"
44 #include "chrome/browser/ui/panels/panel.h" 44 #include "chrome/browser/ui/panels/panel.h"
45 #include "chrome/browser/ui/panels/panel_manager.h" 45 #include "chrome/browser/ui/panels/panel_manager.h"
46 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" 46 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h"
47 #include "chrome/browser/view_type_utils.h" 47 #include "chrome/browser/view_type_utils.h"
48 #include "chrome/common/chrome_notification_types.h" 48 #include "chrome/common/chrome_notification_types.h"
49 #include "chrome/common/chrome_switches.h" 49 #include "chrome/common/chrome_switches.h"
50 #include "chrome/common/extensions/extension.h" 50 #include "chrome/common/extensions/extension.h"
51 #include "chrome/common/render_messages.h" 51 #include "chrome/common/render_messages.h"
52 #include "chrome/common/url_constants.h" 52 #include "chrome/common/url_constants.h"
53 #include "content/public/browser/browser_child_process_host_iterator.h" 53 #include "content/public/browser/browser_child_process_host_iterator.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 bool IsContentsPrerendering(WebContents* web_contents) { 152 bool IsContentsPrerendering(WebContents* web_contents) {
153 Profile* profile = 153 Profile* profile =
154 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 154 Profile::FromBrowserContext(web_contents->GetBrowserContext());
155 prerender::PrerenderManager* prerender_manager = 155 prerender::PrerenderManager* prerender_manager =
156 prerender::PrerenderManagerFactory::GetForProfile(profile); 156 prerender::PrerenderManagerFactory::GetForProfile(profile);
157 return prerender_manager && 157 return prerender_manager &&
158 prerender_manager->IsWebContentsPrerendering(web_contents, NULL); 158 prerender_manager->IsWebContentsPrerendering(web_contents, NULL);
159 } 159 }
160 160
161 bool IsContentsInstant(WebContents* web_contents) { 161 bool IsContentsInstant(WebContents* web_contents) {
162 for (BrowserList::const_iterator i = BrowserList::begin(); 162 for (chrome::BrowserIterator it; !it.done(); it.Next()) {
163 i != BrowserList::end(); ++i) { 163 if (it->instant_controller() &&
164 if ((*i)->instant_controller() && 164 it->instant_controller()->instant()->
165 (*i)->instant_controller()->instant()->
166 GetPreviewContents() == web_contents) { 165 GetPreviewContents() == web_contents) {
167 return true; 166 return true;
168 } 167 }
169 } 168 }
170 169
171 return false; 170 return false;
172 } 171 }
173 172
174 bool IsContentsBackgroundPrinted(WebContents* web_contents) { 173 bool IsContentsBackgroundPrinted(WebContents* web_contents) {
175 printing::BackgroundPrintingManager* printing_manager = 174 printing::BackgroundPrintingManager* printing_manager =
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 439
441 // The contents that are tracked by this resource provider are those that 440 // The contents that are tracked by this resource provider are those that
442 // are tab contents (WebContents serving as a tab in a Browser), instant 441 // are tab contents (WebContents serving as a tab in a Browser), instant
443 // pages, prerender pages, and background printed pages. 442 // pages, prerender pages, and background printed pages.
444 443
445 // Add all the existing WebContentses. 444 // Add all the existing WebContentses.
446 for (TabContentsIterator iterator; !iterator.done(); iterator.Next()) 445 for (TabContentsIterator iterator; !iterator.done(); iterator.Next())
447 Add(*iterator); 446 Add(*iterator);
448 447
449 // Add all the instant pages. 448 // Add all the instant pages.
450 for (BrowserList::const_iterator i = BrowserList::begin(); 449 for (chrome::BrowserIterator it; !it.done(); it.Next()) {
451 i != BrowserList::end(); ++i) { 450 if (it->instant_controller() &&
452 if ((*i)->instant_controller() && 451 it->instant_controller()->instant()->GetPreviewContents()) {
453 (*i)->instant_controller()->instant()->GetPreviewContents()) { 452 Add(it->instant_controller()->instant()->GetPreviewContents());
454 Add((*i)->instant_controller()->instant()->GetPreviewContents());
455 } 453 }
456 } 454 }
457 455
458 // Add all the prerender pages. 456 // Add all the prerender pages.
459 std::vector<Profile*> profiles( 457 std::vector<Profile*> profiles(
460 g_browser_process->profile_manager()->GetLoadedProfiles()); 458 g_browser_process->profile_manager()->GetLoadedProfiles());
461 for (size_t i = 0; i < profiles.size(); ++i) { 459 for (size_t i = 0; i < profiles.size(); ++i) {
462 prerender::PrerenderManager* prerender_manager = 460 prerender::PrerenderManager* prerender_manager =
463 prerender::PrerenderManagerFactory::GetForProfile(profiles[i]); 461 prerender::PrerenderManagerFactory::GetForProfile(profiles[i]);
464 if (prerender_manager) { 462 if (prerender_manager) {
(...skipping 1480 matching lines...) Expand 10 before | Expand all | Expand 10 after
1945 case content::NOTIFICATION_WEB_CONTENTS_CONNECTED: 1943 case content::NOTIFICATION_WEB_CONTENTS_CONNECTED:
1946 Add(web_contents->GetRenderViewHost()); 1944 Add(web_contents->GetRenderViewHost());
1947 break; 1945 break;
1948 case content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED: 1946 case content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED:
1949 Remove(web_contents->GetRenderViewHost()); 1947 Remove(web_contents->GetRenderViewHost());
1950 break; 1948 break;
1951 default: 1949 default:
1952 NOTREACHED() << "Unexpected notification."; 1950 NOTREACHED() << "Unexpected notification.";
1953 } 1951 }
1954 } 1952 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/session_service.cc ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698