Popular sites on the NTP: re-download popular suggestions once per Chrome run
[chromium-blink-merge.git] / chrome / browser / predictors / predictor_table_base.cc
blob8175e71d36f0e39e1b4215e30f80c60a693f6f32
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
3 // found in the LICENSE file.
5 #include "chrome/browser/predictors/predictor_table_base.h"
7 #include "base/logging.h"
8 #include "content/public/browser/browser_thread.h"
9 #include "sql/connection.h"
11 using content::BrowserThread;
13 namespace predictors {
15 PredictorTableBase::PredictorTableBase() : db_(NULL) {
18 PredictorTableBase::~PredictorTableBase() {
21 void PredictorTableBase::Initialize(sql::Connection* db) {
22 CHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
23 db_ = db;
24 CreateTableIfNonExistent();
27 void PredictorTableBase::SetCancelled() {
28 cancelled_.Set();
31 sql::Connection* PredictorTableBase::DB() {
32 CHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
33 return db_;
36 void PredictorTableBase::ResetDB() {
37 CHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
38 db_ = NULL;
41 bool PredictorTableBase::CantAccessDatabase() {
42 CHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
43 return cancelled_.IsSet() || !db_;
46 } // namespace predictors