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

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

Issue 12386019: Instant: Use only one hidden WebContents per profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . 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 | Annotate | Revision Log
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 10 matching lines...) Expand all
21 #include "chrome/app/chrome_command_ids.h" 21 #include "chrome/app/chrome_command_ids.h"
22 #include "chrome/browser/background/background_contents_service.h" 22 #include "chrome/browser/background/background_contents_service.h"
23 #include "chrome/browser/background/background_contents_service_factory.h" 23 #include "chrome/browser/background/background_contents_service_factory.h"
24 #include "chrome/browser/browser_process.h" 24 #include "chrome/browser/browser_process.h"
25 #include "chrome/browser/devtools/devtools_window.h" 25 #include "chrome/browser/devtools/devtools_window.h"
26 #include "chrome/browser/extensions/extension_host.h" 26 #include "chrome/browser/extensions/extension_host.h"
27 #include "chrome/browser/extensions/extension_process_manager.h" 27 #include "chrome/browser/extensions/extension_process_manager.h"
28 #include "chrome/browser/extensions/extension_service.h" 28 #include "chrome/browser/extensions/extension_service.h"
29 #include "chrome/browser/extensions/extension_system.h" 29 #include "chrome/browser/extensions/extension_system.h"
30 #include "chrome/browser/favicon/favicon_tab_helper.h" 30 #include "chrome/browser/favicon/favicon_tab_helper.h"
31 #include "chrome/browser/instant/instant_controller.h"
32 #include "chrome/browser/instant/instant_preloader.h"
33 #include "chrome/browser/instant/instant_service.h"
34 #include "chrome/browser/instant/instant_service_factory.h"
31 #include "chrome/browser/prerender/prerender_manager.h" 35 #include "chrome/browser/prerender/prerender_manager.h"
32 #include "chrome/browser/prerender/prerender_manager_factory.h" 36 #include "chrome/browser/prerender/prerender_manager_factory.h"
33 #include "chrome/browser/printing/background_printing_manager.h" 37 #include "chrome/browser/printing/background_printing_manager.h"
34 #include "chrome/browser/profiles/profile.h" 38 #include "chrome/browser/profiles/profile.h"
35 #include "chrome/browser/profiles/profile_info_cache.h" 39 #include "chrome/browser/profiles/profile_info_cache.h"
36 #include "chrome/browser/profiles/profile_manager.h" 40 #include "chrome/browser/profiles/profile_manager.h"
37 #include "chrome/browser/tab_contents/background_contents.h" 41 #include "chrome/browser/tab_contents/background_contents.h"
38 #include "chrome/browser/tab_contents/tab_util.h" 42 #include "chrome/browser/tab_contents/tab_util.h"
39 #include "chrome/browser/ui/browser.h" 43 #include "chrome/browser/ui/browser.h"
40 #include "chrome/browser/ui/browser_finder.h" 44 #include "chrome/browser/ui/browser_finder.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 bool IsContentsPrerendering(WebContents* web_contents) { 156 bool IsContentsPrerendering(WebContents* web_contents) {
153 Profile* profile = 157 Profile* profile =
154 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 158 Profile::FromBrowserContext(web_contents->GetBrowserContext());
155 prerender::PrerenderManager* prerender_manager = 159 prerender::PrerenderManager* prerender_manager =
156 prerender::PrerenderManagerFactory::GetForProfile(profile); 160 prerender::PrerenderManagerFactory::GetForProfile(profile);
157 return prerender_manager && 161 return prerender_manager &&
158 prerender_manager->IsWebContentsPrerendering(web_contents, NULL); 162 prerender_manager->IsWebContentsPrerendering(web_contents, NULL);
159 } 163 }
160 164
161 bool IsContentsInstant(WebContents* web_contents) { 165 bool IsContentsInstant(WebContents* web_contents) {
166 Profile* profile =
167 Profile::FromBrowserContext(web_contents->GetBrowserContext());
168 InstantService* instant_service =
169 InstantServiceFactory::GetForProfile(profile);
170 if (instant_service &&
171 instant_service->preloader()->contents() == web_contents)
172 return true;
173
162 for (chrome::BrowserIterator it; !it.done(); it.Next()) { 174 for (chrome::BrowserIterator it; !it.done(); it.Next()) {
163 if (it->instant_controller() && 175 if (it->instant_controller() &&
164 it->instant_controller()->instant()-> 176 it->instant_controller()->instant()->GetOverlayContents() ==
165 GetOverlayContents() == web_contents) { 177 web_contents)
166 return true; 178 return true;
167 }
168 } 179 }
169 180
170 return false; 181 return false;
171 } 182 }
172 183
173 bool IsContentsBackgroundPrinted(WebContents* web_contents) { 184 bool IsContentsBackgroundPrinted(WebContents* web_contents) {
174 printing::BackgroundPrintingManager* printing_manager = 185 printing::BackgroundPrintingManager* printing_manager =
175 g_browser_process->background_printing_manager(); 186 g_browser_process->background_printing_manager();
176 return printing_manager->HasPrintPreviewDialog(web_contents); 187 return printing_manager->HasPrintPreviewDialog(web_contents);
177 } 188 }
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 // are tab contents (WebContents serving as a tab in a Browser), Instant 442 // are tab contents (WebContents serving as a tab in a Browser), Instant
432 // pages, prerender pages, and background printed pages. 443 // pages, prerender pages, and background printed pages.
433 444
434 // Add all the existing WebContentses. 445 // Add all the existing WebContentses.
435 for (TabContentsIterator iterator; !iterator.done(); iterator.Next()) 446 for (TabContentsIterator iterator; !iterator.done(); iterator.Next())
436 Add(*iterator); 447 Add(*iterator);
437 448
438 // Add all the Instant pages. 449 // Add all the Instant pages.
439 for (chrome::BrowserIterator it; !it.done(); it.Next()) { 450 for (chrome::BrowserIterator it; !it.done(); it.Next()) {
440 if (it->instant_controller() && 451 if (it->instant_controller() &&
441 it->instant_controller()->instant()->GetOverlayContents()) { 452 it->instant_controller()->instant()->GetOverlayContents())
442 Add(it->instant_controller()->instant()->GetOverlayContents()); 453 Add(it->instant_controller()->instant()->GetOverlayContents());
443 }
444 } 454 }
445 455
446 // Add all the prerender pages.
447 std::vector<Profile*> profiles( 456 std::vector<Profile*> profiles(
448 g_browser_process->profile_manager()->GetLoadedProfiles()); 457 g_browser_process->profile_manager()->GetLoadedProfiles());
449 for (size_t i = 0; i < profiles.size(); ++i) { 458 for (size_t i = 0; i < profiles.size(); ++i) {
459 // Add all the prerender pages.
450 prerender::PrerenderManager* prerender_manager = 460 prerender::PrerenderManager* prerender_manager =
451 prerender::PrerenderManagerFactory::GetForProfile(profiles[i]); 461 prerender::PrerenderManagerFactory::GetForProfile(profiles[i]);
452 if (prerender_manager) { 462 if (prerender_manager) {
453 const std::vector<content::WebContents*> contentses = 463 const std::vector<content::WebContents*> contentses =
454 prerender_manager->GetAllPrerenderingContents(); 464 prerender_manager->GetAllPrerenderingContents();
455 for (size_t j = 0; j < contentses.size(); ++j) 465 for (size_t j = 0; j < contentses.size(); ++j)
456 Add(contentses[j]); 466 Add(contentses[j]);
457 } 467 }
468
469 // Add the Instant per-profile preloaded page.
470 InstantService* instant_service =
471 InstantServiceFactory::GetForProfile(profiles[i]);
472 if (instant_service && instant_service->preloader()->contents())
473 Add(instant_service->preloader()->contents());
458 } 474 }
459 475
460 // Add all the pages being background printed. 476 // Add all the pages being background printed.
461 printing::BackgroundPrintingManager* printing_manager = 477 printing::BackgroundPrintingManager* printing_manager =
462 g_browser_process->background_printing_manager(); 478 g_browser_process->background_printing_manager();
463 for (printing::BackgroundPrintingManager::WebContentsSet::iterator i = 479 for (printing::BackgroundPrintingManager::WebContentsSet::iterator i =
464 printing_manager->begin(); 480 printing_manager->begin();
465 i != printing_manager->end(); ++i) { 481 i != printing_manager->end(); ++i) {
466 Add(*i); 482 Add(*i);
467 } 483 }
(...skipping 1435 matching lines...) Expand 10 before | Expand all | Expand 10 after
1903 case content::NOTIFICATION_WEB_CONTENTS_CONNECTED: 1919 case content::NOTIFICATION_WEB_CONTENTS_CONNECTED:
1904 Add(web_contents->GetRenderViewHost()); 1920 Add(web_contents->GetRenderViewHost());
1905 break; 1921 break;
1906 case content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED: 1922 case content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED:
1907 Remove(web_contents->GetRenderViewHost()); 1923 Remove(web_contents->GetRenderViewHost());
1908 break; 1924 break;
1909 default: 1925 default:
1910 NOTREACHED() << "Unexpected notification."; 1926 NOTREACHED() << "Unexpected notification.";
1911 } 1927 }
1912 } 1928 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698