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

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

Issue 10829195: Speculative resource prefetching - Not modify resource_type for MAIN_FRAME requests. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixing spacing. 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 22 matching lines...) Expand all
33 33
34 summary->navigation_id.render_process_id = render_process_id; 34 summary->navigation_id.render_process_id = render_process_id;
35 summary->navigation_id.render_view_id = render_view_id; 35 summary->navigation_id.render_view_id = render_view_id;
36 summary->navigation_id.main_frame_url = request->first_party_for_cookies(); 36 summary->navigation_id.main_frame_url = request->first_party_for_cookies();
37 summary->navigation_id.creation_time = request->creation_time(); 37 summary->navigation_id.creation_time = request->creation_time();
38 summary->resource_url = request->original_url(); 38 summary->resource_url = request->original_url();
39 summary->resource_type = info->GetResourceType(); 39 summary->resource_type = info->GetResourceType();
40 request->GetMimeType(&summary->mime_type); 40 request->GetMimeType(&summary->mime_type);
41 summary->was_cached = request->was_cached(); 41 summary->was_cached = request->was_cached();
42 42
43 // We want to rely on the mime_type to determine the resource type since we 43 // Use the mime_type to determine the resource type for subresources since
44 // dont want types such as PREFETCH, SUB_RESOURCE, etc. 44 // types such as PREFETCH, SUB_RESOURCE, etc are not useful.
45 summary->resource_type = 45 if (summary->resource_type != ResourceType::MAIN_FRAME) {
46 ResourcePrefetchPredictor::GetResourceTypeFromMimeType( 46 summary->resource_type =
47 summary->mime_type, 47 ResourcePrefetchPredictor::GetResourceTypeFromMimeType(
48 summary->resource_type); 48 summary->mime_type,
49 summary->resource_type);
50 }
49 return true; 51 return true;
50 } 52 }
51 53
52 } // namespace 54 } // namespace
53 55
54 namespace chrome_browser_net { 56 namespace chrome_browser_net {
55 57
56 ResourcePrefetchPredictorObserver::ResourcePrefetchPredictorObserver( 58 ResourcePrefetchPredictorObserver::ResourcePrefetchPredictorObserver(
57 ResourcePrefetchPredictor* predictor) 59 ResourcePrefetchPredictor* predictor)
58 : predictor_(predictor->AsWeakPtr()) { 60 : predictor_(predictor->AsWeakPtr()) {
59 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 61 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
60 } 62 }
61 63
62 ResourcePrefetchPredictorObserver::~ResourcePrefetchPredictorObserver() { 64 ResourcePrefetchPredictorObserver::~ResourcePrefetchPredictorObserver() {
63 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || 65 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) ||
64 BrowserThread::CurrentlyOn(BrowserThread::IO)); 66 BrowserThread::CurrentlyOn(BrowserThread::IO));
65 } 67 }
66 68
67 void ResourcePrefetchPredictorObserver::OnRequestStarted( 69 void ResourcePrefetchPredictorObserver::OnRequestStarted(
68 net::URLRequest* request, 70 net::URLRequest* request,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 125
124 BrowserThread::PostTask( 126 BrowserThread::PostTask(
125 BrowserThread::UI, 127 BrowserThread::UI,
126 FROM_HERE, 128 FROM_HERE,
127 base::Bind(&ResourcePrefetchPredictor::RecordUrlResponse, 129 base::Bind(&ResourcePrefetchPredictor::RecordUrlResponse,
128 predictor_, 130 predictor_,
129 summary)); 131 summary));
130 } 132 }
131 133
132 } // namespace chrome_browser_net 134 } // namespace chrome_browser_net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698