| 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_ |
| 11 | 11 |
| 12 #include <memory> | 12 #include <memory> |
| 13 | 13 |
| 14 #include "base/callback_forward.h" | 14 #include "base/callback_forward.h" |
| 15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
| 17 #include "base/macros.h" | 17 #include "base/macros.h" |
| 18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
| 19 #include "base/memory/ref_counted_delete_on_message_loop.h" | 19 #include "base/memory/ref_counted_delete_on_sequence.h" |
| 20 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
| 21 #include "base/observer_list.h" | 21 #include "base/observer_list.h" |
| 22 #include "base/single_thread_task_runner.h" | 22 #include "base/single_thread_task_runner.h" |
| 23 #include "components/webdata/common/web_data_service_base.h" | 23 #include "components/webdata/common/web_data_service_base.h" |
| 24 #include "components/webdata/common/web_database.h" | 24 #include "components/webdata/common/web_database.h" |
| 25 #include "components/webdata/common/webdata_export.h" | 25 #include "components/webdata/common/webdata_export.h" |
| 26 | 26 |
| 27 class WebDatabaseBackend; | 27 class WebDatabaseBackend; |
| 28 | 28 |
| 29 namespace tracked_objects { | 29 namespace tracked_objects { |
| 30 class Location; | 30 class Location; |
| 31 } | 31 } |
| 32 | 32 |
| 33 class WDTypedResult; | 33 class WDTypedResult; |
| 34 class WebDataServiceConsumer; | 34 class WebDataServiceConsumer; |
| 35 | 35 |
| 36 | 36 |
| 37 //////////////////////////////////////////////////////////////////////////////// | 37 //////////////////////////////////////////////////////////////////////////////// |
| 38 // | 38 // |
| 39 // WebDatabaseService defines the interface to a generic data repository | 39 // WebDatabaseService defines the interface to a generic data repository |
| 40 // responsible for controlling access to the web database (metadata associated | 40 // responsible for controlling access to the web database (metadata associated |
| 41 // with web pages). | 41 // with web pages). |
| 42 // | 42 // |
| 43 //////////////////////////////////////////////////////////////////////////////// | 43 //////////////////////////////////////////////////////////////////////////////// |
| 44 | 44 |
| 45 class WEBDATA_EXPORT WebDatabaseService | 45 class WEBDATA_EXPORT WebDatabaseService |
| 46 : public base::RefCountedDeleteOnMessageLoop<WebDatabaseService> { | 46 : public base::RefCountedDeleteOnSequence<WebDatabaseService> { |
| 47 public: | 47 public: |
| 48 using ReadTask = base::Callback<std::unique_ptr<WDTypedResult>(WebDatabase*)>; | 48 using ReadTask = base::Callback<std::unique_ptr<WDTypedResult>(WebDatabase*)>; |
| 49 using WriteTask = base::Callback<WebDatabase::State(WebDatabase*)>; | 49 using WriteTask = base::Callback<WebDatabase::State(WebDatabase*)>; |
| 50 | 50 |
| 51 // Types for managing DB loading callbacks. | 51 // Types for managing DB loading callbacks. |
| 52 using DBLoadedCallback = base::Closure; | 52 using DBLoadedCallback = base::Closure; |
| 53 using DBLoadErrorCallback = | 53 using DBLoadErrorCallback = |
| 54 base::Callback<void(sql::InitStatus, const std::string&)>; | 54 base::Callback<void(sql::InitStatus, const std::string&)>; |
| 55 | 55 |
| 56 // Takes the path to the WebDatabase file. | 56 // Takes the path to the WebDatabase file. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 // (following a database load failure), then cleared. | 105 // (following a database load failure), then cleared. |
| 106 // Note: if the database load is already complete, then the callback will NOT | 106 // Note: if the database load is already complete, then the callback will NOT |
| 107 // be stored or called. | 107 // be stored or called. |
| 108 void RegisterDBErrorCallback(const DBLoadErrorCallback& callback); | 108 void RegisterDBErrorCallback(const DBLoadErrorCallback& callback); |
| 109 | 109 |
| 110 bool db_loaded() const { return db_loaded_; }; | 110 bool db_loaded() const { return db_loaded_; }; |
| 111 | 111 |
| 112 private: | 112 private: |
| 113 class BackendDelegate; | 113 class BackendDelegate; |
| 114 friend class BackendDelegate; | 114 friend class BackendDelegate; |
| 115 friend class base::RefCountedDeleteOnMessageLoop<WebDatabaseService>; | 115 friend class base::RefCountedDeleteOnSequence<WebDatabaseService>; |
| 116 friend class base::DeleteHelper<WebDatabaseService>; | 116 friend class base::DeleteHelper<WebDatabaseService>; |
| 117 | 117 |
| 118 using LoadedCallbacks = std::vector<DBLoadedCallback>; | 118 using LoadedCallbacks = std::vector<DBLoadedCallback>; |
| 119 using ErrorCallbacks = std::vector<DBLoadErrorCallback>; | 119 using ErrorCallbacks = std::vector<DBLoadErrorCallback>; |
| 120 | 120 |
| 121 virtual ~WebDatabaseService(); | 121 virtual ~WebDatabaseService(); |
| 122 | 122 |
| 123 void OnDatabaseLoadDone(sql::InitStatus status, | 123 void OnDatabaseLoadDone(sql::InitStatus status, |
| 124 const std::string& diagnostics); | 124 const std::string& diagnostics); |
| 125 | 125 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 140 | 140 |
| 141 scoped_refptr<base::SingleThreadTaskRunner> db_thread_; | 141 scoped_refptr<base::SingleThreadTaskRunner> db_thread_; |
| 142 | 142 |
| 143 // All vended weak pointers are invalidated in ShutdownDatabase(). | 143 // All vended weak pointers are invalidated in ShutdownDatabase(). |
| 144 base::WeakPtrFactory<WebDatabaseService> weak_ptr_factory_; | 144 base::WeakPtrFactory<WebDatabaseService> weak_ptr_factory_; |
| 145 | 145 |
| 146 DISALLOW_COPY_AND_ASSIGN(WebDatabaseService); | 146 DISALLOW_COPY_AND_ASSIGN(WebDatabaseService); |
| 147 }; | 147 }; |
| 148 | 148 |
| 149 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_SERVICE_H_ | 149 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_SERVICE_H_ |
| OLD | NEW |