| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_BACKEND_H_ | 5 #ifndef COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_BACKEND_H_ |
| 6 #define COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_BACKEND_H_ | 6 #define COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_BACKEND_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 Delegate* delegate, | 51 Delegate* delegate, |
| 52 const scoped_refptr<base::SingleThreadTaskRunner>& db_thread); | 52 const scoped_refptr<base::SingleThreadTaskRunner>& db_thread); |
| 53 | 53 |
| 54 // Must call only before InitDatabaseWithCallback. | 54 // Must call only before InitDatabaseWithCallback. |
| 55 void AddTable(std::unique_ptr<WebDatabaseTable> table); | 55 void AddTable(std::unique_ptr<WebDatabaseTable> table); |
| 56 | 56 |
| 57 // Initializes the database and notifies caller via callback when complete. | 57 // Initializes the database and notifies caller via callback when complete. |
| 58 // Callback is called synchronously. | 58 // Callback is called synchronously. |
| 59 void InitDatabase(); | 59 void InitDatabase(); |
| 60 | 60 |
| 61 // Opens the database file from the profile path if an init has not yet been | |
| 62 // attempted. Separated from the constructor to ease construction/destruction | |
| 63 // of this object on one thread but database access on the DB thread. Returns | |
| 64 // the status of the database. | |
| 65 sql::InitStatus LoadDatabaseIfNecessary(); | |
| 66 | |
| 67 // Shuts down the database. | 61 // Shuts down the database. |
| 68 void ShutdownDatabase(); | 62 void ShutdownDatabase(); |
| 69 | 63 |
| 70 // Task wrappers to update requests and and notify |request_manager_|. These | 64 // Task wrappers to update requests and and notify |request_manager_|. These |
| 71 // are used in cases where the request is being made from the UI thread and an | 65 // are used in cases where the request is being made from the UI thread and an |
| 72 // asyncronous callback is required to notify the client of |request|'s | 66 // asyncronous callback is required to notify the client of |request|'s |
| 73 // completion. | 67 // completion. |
| 74 void DBWriteTaskWrapper(const WebDatabaseService::WriteTask& task, | 68 void DBWriteTaskWrapper(const WebDatabaseService::WriteTask& task, |
| 75 std::unique_ptr<WebDataRequest> request); | 69 std::unique_ptr<WebDataRequest> request); |
| 76 void DBReadTaskWrapper(const WebDatabaseService::ReadTask& task, | 70 void DBReadTaskWrapper(const WebDatabaseService::ReadTask& task, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 87 | 81 |
| 88 WebDatabase* database() { return db_.get(); } | 82 WebDatabase* database() { return db_.get(); } |
| 89 | 83 |
| 90 protected: | 84 protected: |
| 91 friend class base::RefCountedDeleteOnMessageLoop<WebDatabaseBackend>; | 85 friend class base::RefCountedDeleteOnMessageLoop<WebDatabaseBackend>; |
| 92 friend class base::DeleteHelper<WebDatabaseBackend>; | 86 friend class base::DeleteHelper<WebDatabaseBackend>; |
| 93 | 87 |
| 94 virtual ~WebDatabaseBackend(); | 88 virtual ~WebDatabaseBackend(); |
| 95 | 89 |
| 96 private: | 90 private: |
| 91 // Opens the database file from the profile path if an init has not yet been |
| 92 // attempted. Separated from the constructor to ease construction/destruction |
| 93 // of this object on one thread but database access on the DB thread. |
| 94 void LoadDatabaseIfNecessary(); |
| 95 |
| 97 // Invoked on a db error. | 96 // Invoked on a db error. |
| 98 void DatabaseErrorCallback(int error, sql::Statement* statement); | 97 void DatabaseErrorCallback(int error, sql::Statement* statement); |
| 99 | 98 |
| 100 // Commit the current transaction. | 99 // Commit the current transaction. |
| 101 void Commit(); | 100 void Commit(); |
| 102 | 101 |
| 103 // Path to database file. | 102 // Path to database file. |
| 104 base::FilePath db_path_; | 103 base::FilePath db_path_; |
| 105 | 104 |
| 106 // The tables that participate in managing the database. These are | 105 // The tables that participate in managing the database. These are |
| (...skipping 27 matching lines...) Expand all Loading... |
| 134 // diagnostic information. | 133 // diagnostic information. |
| 135 std::string diagnostics_; | 134 std::string diagnostics_; |
| 136 | 135 |
| 137 // Delegate. See the class definition above for more information. | 136 // Delegate. See the class definition above for more information. |
| 138 std::unique_ptr<Delegate> delegate_; | 137 std::unique_ptr<Delegate> delegate_; |
| 139 | 138 |
| 140 DISALLOW_COPY_AND_ASSIGN(WebDatabaseBackend); | 139 DISALLOW_COPY_AND_ASSIGN(WebDatabaseBackend); |
| 141 }; | 140 }; |
| 142 | 141 |
| 143 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_BACKEND_H_ | 142 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_BACKEND_H_ |
| OLD | NEW |