Chromium Code Reviews| 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 // Chromium settings and storage represent user-selected preferences and | 5 // Chromium settings and storage represent user-selected preferences and |
| 6 // information and MUST not be extracted, overwritten or modified except | 6 // information and MUST not be extracted, overwritten or modified except |
| 7 // through Chromium defined APIs. | 7 // through Chromium defined APIs. |
| 8 | 8 |
| 9 #ifndef COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_SERVICE_H_ | 9 #ifndef COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_SERVICE_H_ |
| 10 #define COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_SERVICE_H_ | 10 #define COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_SERVICE_H_ |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 48 //////////////////////////////////////////////////////////////////////////////// | 48 //////////////////////////////////////////////////////////////////////////////// |
| 49 | 49 |
| 50 class WEBDATA_EXPORT WebDatabaseService | 50 class WEBDATA_EXPORT WebDatabaseService |
| 51 : public base::RefCountedDeleteOnMessageLoop<WebDatabaseService> { | 51 : public base::RefCountedDeleteOnMessageLoop<WebDatabaseService> { |
| 52 public: | 52 public: |
| 53 typedef base::Callback<std::unique_ptr<WDTypedResult>(WebDatabase*)> ReadTask; | 53 typedef base::Callback<std::unique_ptr<WDTypedResult>(WebDatabase*)> ReadTask; |
| 54 typedef base::Callback<WebDatabase::State(WebDatabase*)> WriteTask; | 54 typedef base::Callback<WebDatabase::State(WebDatabase*)> WriteTask; |
| 55 | 55 |
| 56 // Types for managing DB loading callbacks. | 56 // Types for managing DB loading callbacks. |
| 57 typedef base::Closure DBLoadedCallback; | 57 typedef base::Closure DBLoadedCallback; |
| 58 typedef base::Callback<void(sql::InitStatus)> DBLoadErrorCallback; | 58 typedef base::Callback<void(sql::InitStatus, |
|
Lei Zhang
2016/07/09 01:04:47
typedef foo bar -> using bar = foo;
afakhry
2016/07/11 16:47:45
Done.
| |
| 59 const sql::DatabaseDiagnosticMap&)> | |
| 60 DBLoadErrorCallback; | |
| 59 | 61 |
| 60 // Takes the path to the WebDatabase file. | 62 // Takes the path to the WebDatabase file. |
| 61 // WebDatabaseService lives on |ui_thread| and posts tasks to |db_thread|. | 63 // WebDatabaseService lives on |ui_thread| and posts tasks to |db_thread|. |
| 62 WebDatabaseService(const base::FilePath& path, | 64 WebDatabaseService(const base::FilePath& path, |
| 63 scoped_refptr<base::SingleThreadTaskRunner> ui_thread, | 65 scoped_refptr<base::SingleThreadTaskRunner> ui_thread, |
| 64 scoped_refptr<base::SingleThreadTaskRunner> db_thread); | 66 scoped_refptr<base::SingleThreadTaskRunner> db_thread); |
| 65 | 67 |
| 66 // Adds |table| as a WebDatabaseTable that will participate in | 68 // Adds |table| as a WebDatabaseTable that will participate in |
| 67 // managing the database, transferring ownership. All calls to this | 69 // managing the database, transferring ownership. All calls to this |
| 68 // method must be made before |LoadDatabase| is called. | 70 // method must be made before |LoadDatabase| is called. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 class BackendDelegate; | 119 class BackendDelegate; |
| 118 friend class BackendDelegate; | 120 friend class BackendDelegate; |
| 119 friend class base::RefCountedDeleteOnMessageLoop<WebDatabaseService>; | 121 friend class base::RefCountedDeleteOnMessageLoop<WebDatabaseService>; |
| 120 friend class base::DeleteHelper<WebDatabaseService>; | 122 friend class base::DeleteHelper<WebDatabaseService>; |
| 121 | 123 |
| 122 typedef std::vector<DBLoadedCallback> LoadedCallbacks; | 124 typedef std::vector<DBLoadedCallback> LoadedCallbacks; |
| 123 typedef std::vector<DBLoadErrorCallback> ErrorCallbacks; | 125 typedef std::vector<DBLoadErrorCallback> ErrorCallbacks; |
| 124 | 126 |
| 125 virtual ~WebDatabaseService(); | 127 virtual ~WebDatabaseService(); |
| 126 | 128 |
| 127 void OnDatabaseLoadDone(sql::InitStatus status); | 129 void OnDatabaseLoadDone(sql::InitStatus status, |
| 130 const sql::DatabaseDiagnosticMap& diagnostics); | |
| 128 | 131 |
| 129 base::FilePath path_; | 132 base::FilePath path_; |
| 130 | 133 |
| 131 // The primary owner is |WebDatabaseService| but is refcounted because | 134 // The primary owner is |WebDatabaseService| but is refcounted because |
| 132 // PostTask on DB thread may outlive us. | 135 // PostTask on DB thread may outlive us. |
| 133 scoped_refptr<WebDatabaseBackend> web_db_backend_; | 136 scoped_refptr<WebDatabaseBackend> web_db_backend_; |
| 134 | 137 |
| 135 // Callbacks to be called once the DB has loaded. | 138 // Callbacks to be called once the DB has loaded. |
| 136 LoadedCallbacks loaded_callbacks_; | 139 LoadedCallbacks loaded_callbacks_; |
| 137 | 140 |
| 138 // Callbacks to be called if the DB has failed to load. | 141 // Callbacks to be called if the DB has failed to load. |
| 139 ErrorCallbacks error_callbacks_; | 142 ErrorCallbacks error_callbacks_; |
| 140 | 143 |
| 141 // True if the WebDatabase has loaded. | 144 // True if the WebDatabase has loaded. |
| 142 bool db_loaded_; | 145 bool db_loaded_; |
| 143 | 146 |
| 144 scoped_refptr<base::SingleThreadTaskRunner> db_thread_; | 147 scoped_refptr<base::SingleThreadTaskRunner> db_thread_; |
| 145 | 148 |
| 146 // All vended weak pointers are invalidated in ShutdownDatabase(). | 149 // All vended weak pointers are invalidated in ShutdownDatabase(). |
| 147 base::WeakPtrFactory<WebDatabaseService> weak_ptr_factory_; | 150 base::WeakPtrFactory<WebDatabaseService> weak_ptr_factory_; |
| 148 | 151 |
| 149 DISALLOW_COPY_AND_ASSIGN(WebDatabaseService); | 152 DISALLOW_COPY_AND_ASSIGN(WebDatabaseService); |
| 150 }; | 153 }; |
| 151 | 154 |
| 152 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_SERVICE_H_ | 155 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_SERVICE_H_ |
| OLD | NEW |