OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef CHROME_BROWSER_PREDICTORS_PREDICTOR_TABLE_BASE_H_ |
| 6 #define CHROME_BROWSER_PREDICTORS_PREDICTOR_TABLE_BASE_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/synchronization/cancellation_flag.h" |
| 11 |
| 12 namespace sql { |
| 13 class Connection; |
| 14 } |
| 15 |
| 16 namespace predictors { |
| 17 |
| 18 // Base class for all tables in the PredictorDatabase. |
| 19 // |
| 20 // Refcounted as it is created and destroyed in the UI thread but all database |
| 21 // related functions need to happen in the database thread. |
| 22 class PredictorTableBase |
| 23 : public base::RefCountedThreadSafe<PredictorTableBase> { |
| 24 protected: |
| 25 PredictorTableBase(); |
| 26 virtual ~PredictorTableBase(); |
| 27 |
| 28 // DB thread functions. |
| 29 virtual void CreateTableIfNonExistent() = 0; |
| 30 virtual void LogDatabaseStats() = 0; |
| 31 void Initialize(sql::Connection* db); |
| 32 sql::Connection* DB(); |
| 33 |
| 34 base::CancellationFlag cancelled_; |
| 35 |
| 36 private: |
| 37 friend class base::RefCountedThreadSafe<PredictorTableBase>; |
| 38 |
| 39 sql::Connection* db_; |
| 40 |
| 41 DISALLOW_COPY_AND_ASSIGN(PredictorTableBase); |
| 42 }; |
| 43 |
| 44 } // namespace predictors |
| 45 |
| 46 #endif // CHROME_BROWSER_PREDICTORS_PREDICTOR_TABLE_BASE_H_ |
OLD | NEW |