| 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 "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
| 14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 17 #include "base/memory/ref_counted_delete_on_message_loop.h" | 17 #include "base/memory/ref_counted_delete_on_task_runner.h" |
| 18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
| 19 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
| 20 #include "base/message_loop/message_loop_proxy.h" | 20 #include "base/message_loop/message_loop_proxy.h" |
| 21 #include "base/observer_list.h" | 21 #include "base/observer_list.h" |
| 22 #include "components/webdata/common/web_data_service_base.h" | 22 #include "components/webdata/common/web_data_service_base.h" |
| 23 #include "components/webdata/common/web_database.h" | 23 #include "components/webdata/common/web_database.h" |
| 24 #include "components/webdata/common/webdata_export.h" | 24 #include "components/webdata/common/webdata_export.h" |
| 25 | 25 |
| 26 class WebDataServiceBackend; | 26 class WebDataServiceBackend; |
| 27 class WebDataRequestManager; | 27 class WebDataRequestManager; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 //////////////////////////////////////////////////////////////////////////////// | 41 //////////////////////////////////////////////////////////////////////////////// |
| 42 // | 42 // |
| 43 // WebDatabaseService defines the interface to a generic data repository | 43 // WebDatabaseService defines the interface to a generic data repository |
| 44 // responsible for controlling access to the web database (metadata associated | 44 // responsible for controlling access to the web database (metadata associated |
| 45 // with web pages). | 45 // with web pages). |
| 46 // | 46 // |
| 47 //////////////////////////////////////////////////////////////////////////////// | 47 //////////////////////////////////////////////////////////////////////////////// |
| 48 | 48 |
| 49 class WEBDATA_EXPORT WebDatabaseService | 49 class WEBDATA_EXPORT WebDatabaseService |
| 50 : public base::RefCountedDeleteOnMessageLoop<WebDatabaseService> { | 50 : public base::RefCountedDeleteOnTaskRunner<WebDatabaseService> { |
| 51 public: | 51 public: |
| 52 typedef base::Callback<scoped_ptr<WDTypedResult>(WebDatabase*)> ReadTask; | 52 typedef base::Callback<scoped_ptr<WDTypedResult>(WebDatabase*)> ReadTask; |
| 53 typedef base::Callback<WebDatabase::State(WebDatabase*)> WriteTask; | 53 typedef base::Callback<WebDatabase::State(WebDatabase*)> WriteTask; |
| 54 | 54 |
| 55 // Types for managing DB loading callbacks. | 55 // Types for managing DB loading callbacks. |
| 56 typedef base::Closure DBLoadedCallback; | 56 typedef base::Closure DBLoadedCallback; |
| 57 typedef base::Callback<void(sql::InitStatus)> DBLoadErrorCallback; | 57 typedef base::Callback<void(sql::InitStatus)> DBLoadErrorCallback; |
| 58 | 58 |
| 59 // Takes the path to the WebDatabase file. | 59 // Takes the path to the WebDatabase file. |
| 60 // WebDatabaseService lives on |ui_thread| and posts tasks to |db_thread|. | 60 // WebDatabaseService lives on |ui_thread| and posts tasks to |db_thread|. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 // (following a database load failure), then cleared. | 108 // (following a database load failure), then cleared. |
| 109 // Note: if the database load is already complete, then the callback will NOT | 109 // Note: if the database load is already complete, then the callback will NOT |
| 110 // be stored or called. | 110 // be stored or called. |
| 111 void RegisterDBErrorCallback(const DBLoadErrorCallback& callback); | 111 void RegisterDBErrorCallback(const DBLoadErrorCallback& callback); |
| 112 | 112 |
| 113 bool db_loaded() const { return db_loaded_; }; | 113 bool db_loaded() const { return db_loaded_; }; |
| 114 | 114 |
| 115 private: | 115 private: |
| 116 class BackendDelegate; | 116 class BackendDelegate; |
| 117 friend class BackendDelegate; | 117 friend class BackendDelegate; |
| 118 friend class base::RefCountedDeleteOnMessageLoop<WebDatabaseService>; | 118 friend class base::RefCountedDeleteOnTaskRunner<WebDatabaseService>; |
| 119 friend class base::DeleteHelper<WebDatabaseService>; | 119 friend class base::DeleteHelper<WebDatabaseService>; |
| 120 | 120 |
| 121 typedef std::vector<DBLoadedCallback> LoadedCallbacks; | 121 typedef std::vector<DBLoadedCallback> LoadedCallbacks; |
| 122 typedef std::vector<DBLoadErrorCallback> ErrorCallbacks; | 122 typedef std::vector<DBLoadErrorCallback> ErrorCallbacks; |
| 123 | 123 |
| 124 virtual ~WebDatabaseService(); | 124 virtual ~WebDatabaseService(); |
| 125 | 125 |
| 126 void OnDatabaseLoadDone(sql::InitStatus status); | 126 void OnDatabaseLoadDone(sql::InitStatus status); |
| 127 | 127 |
| 128 base::FilePath path_; | 128 base::FilePath path_; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 142 | 142 |
| 143 scoped_refptr<base::MessageLoopProxy> db_thread_; | 143 scoped_refptr<base::MessageLoopProxy> db_thread_; |
| 144 | 144 |
| 145 // All vended weak pointers are invalidated in ShutdownDatabase(). | 145 // All vended weak pointers are invalidated in ShutdownDatabase(). |
| 146 base::WeakPtrFactory<WebDatabaseService> weak_ptr_factory_; | 146 base::WeakPtrFactory<WebDatabaseService> weak_ptr_factory_; |
| 147 | 147 |
| 148 DISALLOW_COPY_AND_ASSIGN(WebDatabaseService); | 148 DISALLOW_COPY_AND_ASSIGN(WebDatabaseService); |
| 149 }; | 149 }; |
| 150 | 150 |
| 151 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_SERVICE_H_ | 151 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_SERVICE_H_ |
| OLD | NEW |