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

Side by Side Diff: chrome/browser/predictors/resource_prefetch_predictor.cc

Issue 2228003002: predictors: Fix duplicate content type detection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comment. Created 4 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/predictors/resource_prefetch_predictor.h" 5 #include "chrome/browser/predictors/resource_prefetch_predictor.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 resource_url(other.resource_url), 366 resource_url(other.resource_url),
367 resource_type(other.resource_type), 367 resource_type(other.resource_type),
368 priority(other.priority), 368 priority(other.priority),
369 mime_type(other.mime_type), 369 mime_type(other.mime_type),
370 was_cached(other.was_cached), 370 was_cached(other.was_cached),
371 redirect_url(other.redirect_url) {} 371 redirect_url(other.redirect_url) {}
372 372
373 ResourcePrefetchPredictor::URLRequestSummary::~URLRequestSummary() { 373 ResourcePrefetchPredictor::URLRequestSummary::~URLRequestSummary() {
374 } 374 }
375 375
376 // static
377 bool ResourcePrefetchPredictor::URLRequestSummary::SummarizeResponse(
378 const net::URLRequest& request,
379 URLRequestSummary* summary) {
380 const content::ResourceRequestInfo* info =
381 content::ResourceRequestInfo::ForRequest(&request);
382 if (!info)
383 return false;
384
385 int render_process_id, render_frame_id;
386 if (!info->GetAssociatedRenderFrame(&render_process_id, &render_frame_id))
387 return false;
388
389 summary->navigation_id = NavigationID(render_process_id, render_frame_id,
390 request.first_party_for_cookies());
391 summary->navigation_id.creation_time = request.creation_time();
392 summary->resource_url = request.original_url();
393 summary->resource_type = info->GetResourceType();
394 summary->priority = request.priority();
395 request.GetMimeType(&summary->mime_type);
396 summary->was_cached = request.was_cached();
397 return true;
398 }
399
376 ResourcePrefetchPredictor::Result::Result( 400 ResourcePrefetchPredictor::Result::Result(
377 PrefetchKeyType i_key_type, 401 PrefetchKeyType i_key_type,
378 ResourcePrefetcher::RequestVector* i_requests) 402 ResourcePrefetcher::RequestVector* i_requests)
379 : key_type(i_key_type), 403 : key_type(i_key_type),
380 requests(i_requests) { 404 requests(i_requests) {
381 } 405 }
382 406
383 ResourcePrefetchPredictor::Result::~Result() { 407 ResourcePrefetchPredictor::Result::~Result() {
384 } 408 }
385 409
(...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after
1385 // HistoryService is already loaded. Continue with Initialization. 1409 // HistoryService is already loaded. Continue with Initialization.
1386 OnHistoryAndCacheLoaded(); 1410 OnHistoryAndCacheLoaded();
1387 return; 1411 return;
1388 } 1412 }
1389 DCHECK(!history_service_observer_.IsObserving(history_service)); 1413 DCHECK(!history_service_observer_.IsObserving(history_service));
1390 history_service_observer_.Add(history_service); 1414 history_service_observer_.Add(history_service);
1391 return; 1415 return;
1392 } 1416 }
1393 1417
1394 } // namespace predictors 1418 } // namespace predictors
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698