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

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

Issue 10704169: Revert 146170 - Adding a field trial to enable speculative resource prefetching learning. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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 | Annotate | Revision Log
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/predictors/resource_prefetch_predictor.h" 5 #include "chrome/browser/predictors/resource_prefetch_predictor.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/stl_util.h" 13 #include "base/stl_util.h"
14 #include "base/time.h" 14 #include "base/time.h"
15 #include "chrome/browser/history/history.h" 15 #include "chrome/browser/history/history.h"
16 #include "chrome/browser/history/history_notifications.h" 16 #include "chrome/browser/history/history_notifications.h"
17 #include "chrome/browser/history/in_memory_database.h" 17 #include "chrome/browser/history/in_memory_database.h"
18 #include "chrome/browser/history/url_database.h" 18 #include "chrome/browser/history/url_database.h"
19 #include "chrome/browser/predictors/predictor_database.h" 19 #include "chrome/browser/predictors/predictor_database.h"
20 #include "chrome/browser/predictors/predictor_database_factory.h" 20 #include "chrome/browser/predictors/predictor_database_factory.h"
21 #include "chrome/browser/prerender/prerender_field_trial.h"
22 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
23 #include "chrome/common/chrome_notification_types.h" 22 #include "chrome/common/chrome_notification_types.h"
24 #include "chrome/common/chrome_switches.h" 23 #include "chrome/common/chrome_switches.h"
25 #include "chrome/common/url_constants.h" 24 #include "chrome/common/url_constants.h"
26 #include "content/public/browser/browser_thread.h" 25 #include "content/public/browser/browser_thread.h"
27 #include "content/public/browser/load_from_memory_cache_details.h" 26 #include "content/public/browser/load_from_memory_cache_details.h"
28 #include "content/public/browser/navigation_controller.h" 27 #include "content/public/browser/navigation_controller.h"
29 #include "content/public/browser/notification_service.h" 28 #include "content/public/browser/notification_service.h"
30 #include "content/public/browser/notification_source.h" 29 #include "content/public/browser/notification_source.h"
31 #include "content/public/browser/notification_types.h" 30 #include "content/public/browser/notification_types.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 initialization_state_(NOT_INITIALIZED), 107 initialization_state_(NOT_INITIALIZED),
109 tables_(PredictorDatabaseFactory::GetForProfile( 108 tables_(PredictorDatabaseFactory::GetForProfile(
110 profile)->resource_prefetch_tables()) { 109 profile)->resource_prefetch_tables()) {
111 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 110 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
112 } 111 }
113 112
114 ResourcePrefetchPredictor::~ResourcePrefetchPredictor() { 113 ResourcePrefetchPredictor::~ResourcePrefetchPredictor() {
115 } 114 }
116 115
117 // static 116 // static
118 bool ResourcePrefetchPredictor::IsEnabled(Profile* profile) { 117 bool ResourcePrefetchPredictor::IsEnabled() {
119 return prerender::IsSpeculativeResourcePrefetchingLearningEnabled(profile); 118 CommandLine* command_line = CommandLine::ForCurrentProcess();
119 return command_line->HasSwitch(
120 switches::kEnableSpeculativeResourcePrefetching);
120 } 121 }
121 122
122 void ResourcePrefetchPredictor::LazilyInitialize() { 123 void ResourcePrefetchPredictor::LazilyInitialize() {
123 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 124 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
124 125
125 DCHECK_EQ(initialization_state_, NOT_INITIALIZED); 126 DCHECK_EQ(initialization_state_, NOT_INITIALIZED);
126 initialization_state_ = INITIALIZING; 127 initialization_state_ = INITIALIZING;
127 128
128 // Request the in-memory database from the history to force it to load so it's 129 // Request the in-memory database from the history to force it to load so it's
129 // available as soon as possible. 130 // available as soon as possible.
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 tables_, 763 tables_,
763 urls_to_delete)); 764 urls_to_delete));
764 } 765 }
765 766
766 void ResourcePrefetchPredictor::SetTablesForTesting( 767 void ResourcePrefetchPredictor::SetTablesForTesting(
767 scoped_refptr<ResourcePrefetchPredictorTables> tables) { 768 scoped_refptr<ResourcePrefetchPredictorTables> tables) {
768 tables_ = tables; 769 tables_ = tables;
769 } 770 }
770 771
771 } // namespace predictors 772 } // namespace predictors
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698