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

Side by Side Diff: chrome/browser/net/resource_prefetch_predictor_observer.cc

Issue 10827103: Speculative resource prefetching - fixing missing navigations due to server side redirects. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixing comment. Created 8 years, 4 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/net/resource_prefetch_predictor_observer.h" 5 #include "chrome/browser/net/resource_prefetch_predictor_observer.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
10 #include "content/public/browser/resource_request_info.h" 10 #include "content/public/browser/resource_request_info.h"
11 #include "net/http/http_response_headers.h"
11 #include "net/url_request/url_request.h" 12 #include "net/url_request/url_request.h"
12 13
13 using content::BrowserThread; 14 using content::BrowserThread;
14 using predictors::ResourcePrefetchPredictor; 15 using predictors::ResourcePrefetchPredictor;
15 16
16 namespace { 17 namespace {
17 18
18 bool SummarizeResponse(net::URLRequest* request, 19 bool SummarizeResponse(net::URLRequest* request,
19 ResourcePrefetchPredictor::URLRequestSummary* summary) { 20 ResourcePrefetchPredictor::URLRequestSummary* summary) {
20 const content::ResourceRequestInfo* info = 21 const content::ResourceRequestInfo* info =
(...skipping 11 matching lines...) Expand all
32 33
33 summary->navigation_id.render_process_id = render_process_id; 34 summary->navigation_id.render_process_id = render_process_id;
34 summary->navigation_id.render_view_id = render_view_id; 35 summary->navigation_id.render_view_id = render_view_id;
35 summary->navigation_id.main_frame_url = request->first_party_for_cookies(); 36 summary->navigation_id.main_frame_url = request->first_party_for_cookies();
36 summary->navigation_id.creation_time = request->creation_time(); 37 summary->navigation_id.creation_time = request->creation_time();
37 summary->resource_url = request->original_url(); 38 summary->resource_url = request->original_url();
38 summary->resource_type = info->GetResourceType(); 39 summary->resource_type = info->GetResourceType();
39 request->GetMimeType(&summary->mime_type); 40 request->GetMimeType(&summary->mime_type);
40 summary->was_cached = request->was_cached(); 41 summary->was_cached = request->was_cached();
41 42
43 // Try to determine if this is a redirect response.
44 net::HttpResponseHeaders* headers = request->response_headers();
45 if (headers) {
mmenke 2012/08/01 15:39:53 Rather than muck with the full set of headers, can
mmenke 2012/08/01 15:59:00 Err... That's not quite right. I'd suggest modif
Shishir 2012/08/01 18:07:49 Done.
Shishir 2012/08/01 18:07:49 Passing on the redirect url.
46 std::string value;
47 if (headers->IsRedirect(&value)) {
48 summary->redirect_url = request->url().Resolve(value);
49 if (!summary->redirect_url.is_valid())
50 summary->redirect_url = GURL();
51 }
52 }
53
42 // We want to rely on the mime_type to determine the resource type since we 54 // We want to rely on the mime_type to determine the resource type since we
43 // dont want types such as PREFETCH, SUB_RESOURCE, etc. 55 // dont want types such as PREFETCH, SUB_RESOURCE, etc.
44 summary->resource_type = 56 summary->resource_type =
45 ResourcePrefetchPredictor::GetResourceTypeFromMimeType( 57 ResourcePrefetchPredictor::GetResourceTypeFromMimeType(
46 summary->mime_type, 58 summary->mime_type,
47 summary->resource_type); 59 summary->resource_type);
48 return true; 60 return true;
49 } 61 }
50 62
51 } // namespace 63 } // namespace
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 130
119 BrowserThread::PostTask( 131 BrowserThread::PostTask(
120 BrowserThread::UI, 132 BrowserThread::UI,
121 FROM_HERE, 133 FROM_HERE,
122 base::Bind(&ResourcePrefetchPredictor::RecordUrlResponse, 134 base::Bind(&ResourcePrefetchPredictor::RecordUrlResponse,
123 predictor_, 135 predictor_,
124 summary)); 136 summary));
125 } 137 }
126 138
127 } // namespace chrome_browser_net 139 } // namespace chrome_browser_net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698