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

Side by Side Diff: chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc

Issue 10416002: Seculative resource prefetching for URLs CL. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixing enum name. Created 8 years, 6 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 (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/renderer_host/chrome_resource_dispatcher_host_delegate. h" 5 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate. h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/content_settings/host_content_settings_map.h" 12 #include "chrome/browser/content_settings/host_content_settings_map.h"
13 #include "chrome/browser/download/download_request_limiter.h" 13 #include "chrome/browser/download/download_request_limiter.h"
14 #include "chrome/browser/download/download_resource_throttle.h" 14 #include "chrome/browser/download/download_resource_throttle.h"
15 #include "chrome/browser/download/download_util.h" 15 #include "chrome/browser/download/download_util.h"
16 #include "chrome/browser/extensions/user_script_listener.h" 16 #include "chrome/browser/extensions/user_script_listener.h"
17 #include "chrome/browser/external_protocol/external_protocol_handler.h" 17 #include "chrome/browser/external_protocol/external_protocol_handler.h"
18 #include "chrome/browser/google/google_util.h" 18 #include "chrome/browser/google/google_util.h"
19 #include "chrome/browser/instant/instant_loader.h" 19 #include "chrome/browser/instant/instant_loader.h"
20 #include "chrome/browser/net/load_timing_observer.h" 20 #include "chrome/browser/net/load_timing_observer.h"
21 #include "chrome/browser/net/resource_prefetch_predictor_observer.h"
21 #include "chrome/browser/prerender/prerender_manager.h" 22 #include "chrome/browser/prerender/prerender_manager.h"
22 #include "chrome/browser/prerender/prerender_tracker.h" 23 #include "chrome/browser/prerender/prerender_tracker.h"
23 #include "chrome/browser/profiles/profile_io_data.h" 24 #include "chrome/browser/profiles/profile_io_data.h"
24 #include "chrome/browser/renderer_host/chrome_url_request_user_data.h" 25 #include "chrome/browser/renderer_host/chrome_url_request_user_data.h"
25 #include "chrome/browser/renderer_host/safe_browsing_resource_throttle.h" 26 #include "chrome/browser/renderer_host/safe_browsing_resource_throttle.h"
26 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 27 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
27 #include "chrome/browser/ui/auto_login_prompter.h" 28 #include "chrome/browser/ui/auto_login_prompter.h"
28 #include "chrome/browser/ui/login/login_prompt.h" 29 #include "chrome/browser/ui/login/login_prompt.h"
29 #include "chrome/browser/ui/sync/one_click_signin_helper.h" 30 #include "chrome/browser/ui/sync/one_click_signin_helper.h"
30 #include "chrome/common/chrome_notification_types.h" 31 #include "chrome/common/chrome_notification_types.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 #endif 143 #endif
143 144
144 AppendChromeMetricsHeaders(request, resource_context, resource_type); 145 AppendChromeMetricsHeaders(request, resource_context, resource_type);
145 146
146 AppendStandardResourceThrottles(request, 147 AppendStandardResourceThrottles(request,
147 resource_context, 148 resource_context,
148 child_id, 149 child_id,
149 route_id, 150 route_id,
150 resource_type, 151 resource_type,
151 throttles); 152 throttles);
153
154 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context);
155 if (io_data->resource_prefetch_predictor_observer())
156 io_data->resource_prefetch_predictor_observer()->OnRequestStarted(
157 request, resource_type, child_id, route_id);
152 } 158 }
153 159
154 void ChromeResourceDispatcherHostDelegate::DownloadStarting( 160 void ChromeResourceDispatcherHostDelegate::DownloadStarting(
155 net::URLRequest* request, 161 net::URLRequest* request,
156 content::ResourceContext* resource_context, 162 content::ResourceContext* resource_context,
157 int child_id, 163 int child_id,
158 int route_id, 164 int route_id,
159 int request_id, 165 int request_id,
160 bool is_content_initiated, 166 bool is_content_initiated,
161 ScopedVector<content::ResourceThrottle>* throttles) { 167 ScopedVector<content::ResourceThrottle>* throttles) {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 } 313 }
308 314
309 bool ChromeResourceDispatcherHostDelegate::ShouldForceDownloadResource( 315 bool ChromeResourceDispatcherHostDelegate::ShouldForceDownloadResource(
310 const GURL& url, const std::string& mime_type) { 316 const GURL& url, const std::string& mime_type) {
311 // Special-case user scripts to get downloaded instead of viewed. 317 // Special-case user scripts to get downloaded instead of viewed.
312 return UserScript::IsURLUserScript(url, mime_type); 318 return UserScript::IsURLUserScript(url, mime_type);
313 } 319 }
314 320
315 void ChromeResourceDispatcherHostDelegate::OnResponseStarted( 321 void ChromeResourceDispatcherHostDelegate::OnResponseStarted(
316 net::URLRequest* request, 322 net::URLRequest* request,
323 content::ResourceContext* resource_context,
317 content::ResourceResponse* response, 324 content::ResourceResponse* response,
318 IPC::Message::Sender* sender) { 325 IPC::Message::Sender* sender) {
319 LoadTimingObserver::PopulateTimingInfo(request, response); 326 LoadTimingObserver::PopulateTimingInfo(request, response);
320 327
321 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); 328 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request);
322 329
323 if (request->url().SchemeIsSecure()) { 330 if (request->url().SchemeIsSecure()) {
324 const net::URLRequestContext* context = request->context(); 331 const net::URLRequestContext* context = request->context();
325 net::TransportSecurityState* state = context->transport_security_state(); 332 net::TransportSecurityState* state = context->transport_security_state();
326 if (state) { 333 if (state) {
327 net::TransportSecurityState::DomainState domain_state; 334 net::TransportSecurityState::DomainState domain_state;
328 bool has_sni = net::SSLConfigService::IsSNIAvailable( 335 bool has_sni = net::SSLConfigService::IsSNIAvailable(
329 context->ssl_config_service()); 336 context->ssl_config_service());
330 if (state->GetDomainState( 337 if (state->GetDomainState(
331 request->url().host(), has_sni, &domain_state)) { 338 request->url().host(), has_sni, &domain_state)) {
332 sender->Send(new ChromeViewMsg_AddStrictSecurityHost( 339 sender->Send(new ChromeViewMsg_AddStrictSecurityHost(
333 info->GetRouteID(), request->url().host())); 340 info->GetRouteID(), request->url().host()));
334 } 341 }
335 } 342 }
336 } 343 }
337 344
338 // See if the response contains the X-Auto-Login header. If so, this was 345 // See if the response contains the X-Auto-Login header. If so, this was
339 // a request for a login page, and the server is allowing the browser to 346 // a request for a login page, and the server is allowing the browser to
340 // suggest auto-login, if available. 347 // suggest auto-login, if available.
341 AutoLoginPrompter::ShowInfoBarIfPossible(request, info->GetChildID(), 348 AutoLoginPrompter::ShowInfoBarIfPossible(request, info->GetChildID(),
342 info->GetRouteID()); 349 info->GetRouteID());
350
351 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context);
352 if (io_data->resource_prefetch_predictor_observer())
353 io_data->resource_prefetch_predictor_observer()->OnResponseStarted(request);
343 } 354 }
344 355
345 void ChromeResourceDispatcherHostDelegate::OnRequestRedirected( 356 void ChromeResourceDispatcherHostDelegate::OnRequestRedirected(
346 net::URLRequest* request, 357 net::URLRequest* request,
358 content::ResourceContext* resource_context,
347 content::ResourceResponse* response) { 359 content::ResourceResponse* response) {
348 LoadTimingObserver::PopulateTimingInfo(request, response); 360 LoadTimingObserver::PopulateTimingInfo(request, response);
349 361
350 #if defined(ENABLE_ONE_CLICK_SIGNIN) 362 #if defined(ENABLE_ONE_CLICK_SIGNIN)
351 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); 363 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request);
352 364
353 // See if the response contains the Google-Accounts-SignIn header. If so, 365 // See if the response contains the Google-Accounts-SignIn header. If so,
354 // then the user has just finished signing in, and the server is allowing the 366 // then the user has just finished signing in, and the server is allowing the
355 // browser to suggest connecting the user's profile to the account. 367 // browser to suggest connecting the user's profile to the account.
356 OneClickSigninHelper::ShowInfoBarIfPossible(request, info->GetChildID(), 368 OneClickSigninHelper::ShowInfoBarIfPossible(request, info->GetChildID(),
357 info->GetRouteID()); 369 info->GetRouteID());
358 #endif 370 #endif
371
372 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context);
373 if (io_data->resource_prefetch_predictor_observer())
374 io_data->resource_prefetch_predictor_observer()->OnRequestRedirected(
375 request);
359 } 376 }
360 377
361 void ChromeResourceDispatcherHostDelegate::OnFieldTrialGroupFinalized( 378 void ChromeResourceDispatcherHostDelegate::OnFieldTrialGroupFinalized(
362 const std::string& trial_name, 379 const std::string& trial_name,
363 const std::string& group_name) { 380 const std::string& group_name) {
364 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 381 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
365 chrome_variations::ID new_id = 382 chrome_variations::ID new_id =
366 experiments_helper::GetGoogleVariationID(trial_name, group_name); 383 experiments_helper::GetGoogleVariationID(trial_name, group_name);
367 if (new_id == chrome_variations::kEmptyID) 384 if (new_id == chrome_variations::kEmptyID)
368 return; 385 return;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 if (base::Base64Encode(serialized, &hashed)) { 427 if (base::Base64Encode(serialized, &hashed)) {
411 // If successful, swap the header value with the new one. 428 // If successful, swap the header value with the new one.
412 // Note that the list of IDs and the header could be temporarily out of sync 429 // Note that the list of IDs and the header could be temporarily out of sync
413 // if IDs are added as we are recreating the header, but we're OK with those 430 // if IDs are added as we are recreating the header, but we're OK with those
414 // descrepancies. 431 // descrepancies.
415 variation_ids_header_ = hashed; 432 variation_ids_header_ = hashed;
416 } else { 433 } else {
417 DVLOG(1) << "Failed to base64 encode Variation IDs value: " << serialized; 434 DVLOG(1) << "Failed to base64 encode Variation IDs value: " << serialized;
418 } 435 }
419 } 436 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698