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

Side by Side Diff: chrome/browser/prerender/prerender_manager.cc

Issue 8515027: Define the public version of the browser side RenderProcessHost interface. This interface is not ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/prerender/prerender_manager.h" 5 #include "chrome/browser/prerender/prerender_manager.h"
6 6
7 #include <string> 7 #include <string>
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 19 matching lines...) Expand all
30 #include "chrome/browser/prerender/prerender_util.h" 30 #include "chrome/browser/prerender/prerender_util.h"
31 #include "chrome/browser/profiles/profile.h" 31 #include "chrome/browser/profiles/profile.h"
32 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 32 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
33 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper_delegate.h" 33 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper_delegate.h"
34 #include "chrome/common/chrome_notification_types.h" 34 #include "chrome/common/chrome_notification_types.h"
35 #include "chrome/common/chrome_switches.h" 35 #include "chrome/common/chrome_switches.h"
36 #include "chrome/common/render_messages.h" 36 #include "chrome/common/render_messages.h"
37 #include "content/browser/cancelable_request.h" 37 #include "content/browser/cancelable_request.h"
38 #include "content/browser/debugger/render_view_devtools_agent_host.h" 38 #include "content/browser/debugger/render_view_devtools_agent_host.h"
39 #include "content/browser/in_process_webkit/session_storage_namespace.h" 39 #include "content/browser/in_process_webkit/session_storage_namespace.h"
40 #include "content/browser/renderer_host/render_process_host.h"
41 #include "content/browser/renderer_host/render_view_host.h" 40 #include "content/browser/renderer_host/render_view_host.h"
42 #include "content/browser/renderer_host/resource_dispatcher_host.h" 41 #include "content/browser/renderer_host/resource_dispatcher_host.h"
43 #include "content/browser/tab_contents/render_view_host_manager.h" 42 #include "content/browser/tab_contents/render_view_host_manager.h"
44 #include "content/browser/tab_contents/tab_contents.h" 43 #include "content/browser/tab_contents/tab_contents.h"
45 #include "content/browser/tab_contents/tab_contents_delegate.h" 44 #include "content/browser/tab_contents/tab_contents_delegate.h"
46 #include "content/public/browser/browser_thread.h" 45 #include "content/public/browser/browser_thread.h"
47 #include "content/public/browser/notification_observer.h" 46 #include "content/public/browser/notification_observer.h"
48 #include "content/public/browser/notification_registrar.h" 47 #include "content/public/browser/notification_registrar.h"
49 #include "content/public/browser/notification_source.h" 48 #include "content/public/browser/notification_source.h"
49 #include "content/public/browser/render_process_host.h"
50 50
51 using content::BrowserThread; 51 using content::BrowserThread;
52 52
53 namespace prerender { 53 namespace prerender {
54 54
55 namespace { 55 namespace {
56 56
57 // Time window for which we will record windowed PLT's from the last 57 // Time window for which we will record windowed PLT's from the last
58 // observed link rel=prefetch tag. 58 // observed link rel=prefetch tag.
59 const int kWindowDurationSeconds = 30; 59 const int kWindowDurationSeconds = 30;
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 uint8 experiment = GetQueryStringBasedExperiment(url_arg); 394 uint8 experiment = GetQueryStringBasedExperiment(url_arg);
395 395
396 // Do not prerender if there are too many render processes, and we would 396 // Do not prerender if there are too many render processes, and we would
397 // have to use an existing one. We do not want prerendering to happen in 397 // have to use an existing one. We do not want prerendering to happen in
398 // a shared process, so that we can always reliably lower the CPU 398 // a shared process, so that we can always reliably lower the CPU
399 // priority for prerendering. 399 // priority for prerendering.
400 // In single-process mode, ShouldTryToUseExistingProcessHost() always returns 400 // In single-process mode, ShouldTryToUseExistingProcessHost() always returns
401 // true, so that case needs to be explicitly checked for. 401 // true, so that case needs to be explicitly checked for.
402 // TODO(tburkard): Figure out how to cancel prerendering in the opposite 402 // TODO(tburkard): Figure out how to cancel prerendering in the opposite
403 // case, when a new tab is added to a process used for prerendering. 403 // case, when a new tab is added to a process used for prerendering.
404 if (RenderProcessHost::ShouldTryToUseExistingProcessHost() && 404 if (content::RenderProcessHost::ShouldTryToUseExistingProcessHost() &&
405 !RenderProcessHost::run_renderer_in_process()) { 405 !content::RenderProcessHost::run_renderer_in_process()) {
406 RecordFinalStatus(origin, experiment, FINAL_STATUS_TOO_MANY_PROCESSES); 406 RecordFinalStatus(origin, experiment, FINAL_STATUS_TOO_MANY_PROCESSES);
407 return false; 407 return false;
408 } 408 }
409 409
410 // Check if enough time has passed since the last prerender. 410 // Check if enough time has passed since the last prerender.
411 if (!DoesRateLimitAllowPrerender()) { 411 if (!DoesRateLimitAllowPrerender()) {
412 // Cancel the prerender. We could add it to the pending prerender list but 412 // Cancel the prerender. We could add it to the pending prerender list but
413 // this doesn't make sense as the next prerender request will be triggered 413 // this doesn't make sense as the next prerender request will be triggered
414 // by a navigation and is unlikely to be the same site. 414 // by a navigation and is unlikely to be the same site.
415 RecordFinalStatus(origin, experiment, FINAL_STATUS_RATE_LIMIT_EXCEEDED); 415 RecordFinalStatus(origin, experiment, FINAL_STATUS_RATE_LIMIT_EXCEEDED);
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 1128
1129 void PrerenderManager::RecordFinalStatus(Origin origin, 1129 void PrerenderManager::RecordFinalStatus(Origin origin,
1130 uint8 experiment_id, 1130 uint8 experiment_id,
1131 FinalStatus final_status) const { 1131 FinalStatus final_status) const {
1132 histograms_->RecordFinalStatus(origin, experiment_id, final_status); 1132 histograms_->RecordFinalStatus(origin, experiment_id, final_status);
1133 } 1133 }
1134 1134
1135 PrerenderManager* FindPrerenderManagerUsingRenderProcessId( 1135 PrerenderManager* FindPrerenderManagerUsingRenderProcessId(
1136 int render_process_id) { 1136 int render_process_id) {
1137 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1137 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1138 RenderProcessHost* render_process_host = 1138 content::RenderProcessHost* render_process_host =
1139 RenderProcessHost::FromID(render_process_id); 1139 content::RenderProcessHost::FromID(render_process_id);
1140 // Each render process is guaranteed to only hold RenderViews owned by the 1140 // Each render process is guaranteed to only hold RenderViews owned by the
1141 // same BrowserContext. This is enforced by 1141 // same BrowserContext. This is enforced by
1142 // RenderProcessHost::GetExistingProcessHost. 1142 // RenderProcessHost::GetExistingProcessHost.
1143 if (!render_process_host || !render_process_host->browser_context()) 1143 if (!render_process_host || !render_process_host->GetBrowserContext())
1144 return NULL; 1144 return NULL;
1145 Profile* profile = Profile::FromBrowserContext( 1145 Profile* profile = Profile::FromBrowserContext(
1146 render_process_host->browser_context()); 1146 render_process_host->GetBrowserContext());
1147 if (!profile) 1147 if (!profile)
1148 return NULL; 1148 return NULL;
1149 return PrerenderManagerFactory::GetInstance()->GetForProfile(profile); 1149 return PrerenderManagerFactory::GetInstance()->GetForProfile(profile);
1150 } 1150 }
1151 1151
1152 } // namespace prerender 1152 } // namespace prerender
OLDNEW
« no previous file with comments | « chrome/browser/prerender/prerender_contents.cc ('k') | chrome/browser/printing/background_printing_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698