OLD | NEW |
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/predictor_database.h" | 5 #include "chrome/browser/predictors/predictor_database.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
13 #include "chrome/browser/predictors/autocomplete_action_predictor_table.h" | 13 #include "chrome/browser/predictors/autocomplete_action_predictor_table.h" |
14 #include "chrome/browser/predictors/resource_prefetch_predictor.h" | 14 #include "chrome/browser/predictors/resource_prefetch_predictor.h" |
15 #include "chrome/browser/predictors/resource_prefetch_predictor_tables.h" | 15 #include "chrome/browser/predictors/resource_prefetch_predictor_tables.h" |
| 16 #include "chrome/browser/prerender/prerender_field_trial.h" |
16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
17 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
18 #include "sql/connection.h" | 19 #include "sql/connection.h" |
19 #include "sql/statement.h" | 20 #include "sql/statement.h" |
20 | 21 |
21 namespace { | 22 namespace { |
22 | 23 |
23 // TODO(shishir): This should move to a more generic name. | 24 // TODO(shishir): This should move to a more generic name. |
24 const FilePath::CharType kPredictorDatabaseName[] = | 25 const FilePath::CharType kPredictorDatabaseName[] = |
25 FILE_PATH_LITERAL("Network Action Predictor"); | 26 FILE_PATH_LITERAL("Network Action Predictor"); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 60 |
60 DISALLOW_COPY_AND_ASSIGN(PredictorDatabaseInternal); | 61 DISALLOW_COPY_AND_ASSIGN(PredictorDatabaseInternal); |
61 }; | 62 }; |
62 | 63 |
63 | 64 |
64 PredictorDatabaseInternal::PredictorDatabaseInternal(Profile* profile) | 65 PredictorDatabaseInternal::PredictorDatabaseInternal(Profile* profile) |
65 : db_path_(profile->GetPath().Append(kPredictorDatabaseName)), | 66 : db_path_(profile->GetPath().Append(kPredictorDatabaseName)), |
66 autocomplete_table_(new AutocompleteActionPredictorTable()), | 67 autocomplete_table_(new AutocompleteActionPredictorTable()), |
67 resource_prefetch_tables_(new ResourcePrefetchPredictorTables()) { | 68 resource_prefetch_tables_(new ResourcePrefetchPredictorTables()) { |
68 is_resource_prefetch_predictor_enabled_ = | 69 is_resource_prefetch_predictor_enabled_ = |
69 ResourcePrefetchPredictor::IsEnabled(profile); | 70 prerender::IsSpeculativeResourcePrefetchingLearningEnabled(profile) || |
| 71 prerender::IsSpeculativeResourcePrefetchingEnabled(profile); |
70 } | 72 } |
71 | 73 |
72 PredictorDatabaseInternal::~PredictorDatabaseInternal() { | 74 PredictorDatabaseInternal::~PredictorDatabaseInternal() { |
73 } | 75 } |
74 | 76 |
75 void PredictorDatabaseInternal::Initialize() { | 77 void PredictorDatabaseInternal::Initialize() { |
76 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::DB)); | 78 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::DB)); |
77 db_.set_exclusive_locking(); | 79 db_.set_exclusive_locking(); |
78 bool success = db_.Open(db_path_); | 80 bool success = db_.Open(db_path_); |
79 | 81 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 scoped_refptr<ResourcePrefetchPredictorTables> | 130 scoped_refptr<ResourcePrefetchPredictorTables> |
129 PredictorDatabase::resource_prefetch_tables() { | 131 PredictorDatabase::resource_prefetch_tables() { |
130 return db_->resource_prefetch_tables_; | 132 return db_->resource_prefetch_tables_; |
131 } | 133 } |
132 | 134 |
133 sql::Connection* PredictorDatabase::GetDatabase() { | 135 sql::Connection* PredictorDatabase::GetDatabase() { |
134 return &db_->db_; | 136 return &db_->db_; |
135 } | 137 } |
136 | 138 |
137 } // namespace predictors | 139 } // namespace predictors |
OLD | NEW |