| 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 <stdint.h> | 7 #include <cstdint> |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "chrome/browser/predictors/autocomplete_action_predictor_table.h" | 15 #include "chrome/browser/predictors/autocomplete_action_predictor_table.h" |
| 16 #include "chrome/browser/predictors/loading_predictor_config.h" |
| 16 #include "chrome/browser/predictors/resource_prefetch_predictor.h" | 17 #include "chrome/browser/predictors/resource_prefetch_predictor.h" |
| 17 #include "chrome/browser/predictors/resource_prefetch_predictor_tables.h" | 18 #include "chrome/browser/predictors/resource_prefetch_predictor_tables.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 19 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 20 #include "sql/connection.h" | 21 #include "sql/connection.h" |
| 21 | 22 |
| 22 using content::BrowserThread; | 23 using content::BrowserThread; |
| 23 | 24 |
| 24 namespace { | 25 namespace { |
| 25 | 26 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 PredictorDatabaseInternal::PredictorDatabaseInternal(Profile* profile) | 68 PredictorDatabaseInternal::PredictorDatabaseInternal(Profile* profile) |
| 68 : db_path_(profile->GetPath().Append(kPredictorDatabaseName)), | 69 : db_path_(profile->GetPath().Append(kPredictorDatabaseName)), |
| 69 db_(new sql::Connection()), | 70 db_(new sql::Connection()), |
| 70 autocomplete_table_(new AutocompleteActionPredictorTable()), | 71 autocomplete_table_(new AutocompleteActionPredictorTable()), |
| 71 resource_prefetch_tables_(new ResourcePrefetchPredictorTables()) { | 72 resource_prefetch_tables_(new ResourcePrefetchPredictorTables()) { |
| 72 db_->set_histogram_tag("Predictor"); | 73 db_->set_histogram_tag("Predictor"); |
| 73 | 74 |
| 74 // This db does not use [meta] table, store mmap status data elsewhere. | 75 // This db does not use [meta] table, store mmap status data elsewhere. |
| 75 db_->set_mmap_alt_status(); | 76 db_->set_mmap_alt_status(); |
| 76 | 77 |
| 77 ResourcePrefetchPredictorConfig config; | |
| 78 is_resource_prefetch_predictor_enabled_ = | 78 is_resource_prefetch_predictor_enabled_ = |
| 79 IsSpeculativeResourcePrefetchingEnabled(profile, &config); | 79 IsSpeculativeResourcePrefetchingEnabled(profile, nullptr); |
| 80 } | 80 } |
| 81 | 81 |
| 82 PredictorDatabaseInternal::~PredictorDatabaseInternal() { | 82 PredictorDatabaseInternal::~PredictorDatabaseInternal() { |
| 83 // The connection pointer needs to be deleted on the DB thread since there | 83 // The connection pointer needs to be deleted on the DB thread since there |
| 84 // might be a task in progress on the DB thread which uses this connection. | 84 // might be a task in progress on the DB thread which uses this connection. |
| 85 if (BrowserThread::IsMessageLoopValid(BrowserThread::DB)) | 85 if (BrowserThread::IsMessageLoopValid(BrowserThread::DB)) |
| 86 BrowserThread::DeleteSoon(BrowserThread::DB, FROM_HERE, db_.release()); | 86 BrowserThread::DeleteSoon(BrowserThread::DB, FROM_HERE, db_.release()); |
| 87 } | 87 } |
| 88 | 88 |
| 89 void PredictorDatabaseInternal::Initialize() { | 89 void PredictorDatabaseInternal::Initialize() { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 scoped_refptr<ResourcePrefetchPredictorTables> | 145 scoped_refptr<ResourcePrefetchPredictorTables> |
| 146 PredictorDatabase::resource_prefetch_tables() { | 146 PredictorDatabase::resource_prefetch_tables() { |
| 147 return db_->resource_prefetch_tables_; | 147 return db_->resource_prefetch_tables_; |
| 148 } | 148 } |
| 149 | 149 |
| 150 sql::Connection* PredictorDatabase::GetDatabase() { | 150 sql::Connection* PredictorDatabase::GetDatabase() { |
| 151 return db_->db_.get(); | 151 return db_->db_.get(); |
| 152 } | 152 } |
| 153 | 153 |
| 154 } // namespace predictors | 154 } // namespace predictors |
| OLD | NEW |