| 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_message_loop.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 WebDatabaseBackend; |
| 27 class WebDataRequestManager; | 27 class WebDataRequestManager; |
| 28 | 28 |
| 29 namespace content { | 29 namespace content { |
| 30 class BrowserContext; | 30 class BrowserContext; |
| 31 } | 31 } |
| 32 | 32 |
| 33 namespace tracked_objects { | 33 namespace tracked_objects { |
| 34 class Location; | 34 class Location; |
| 35 } | 35 } |
| 36 | 36 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 // Initializes the web database service. | 70 // Initializes the web database service. |
| 71 virtual void LoadDatabase(); | 71 virtual void LoadDatabase(); |
| 72 | 72 |
| 73 // Unloads the database and shuts down the service. | 73 // Unloads the database and shuts down the service. |
| 74 virtual void ShutdownDatabase(); | 74 virtual void ShutdownDatabase(); |
| 75 | 75 |
| 76 // Gets a pointer to the WebDatabase (owned by WebDatabaseService). | 76 // Gets a pointer to the WebDatabase (owned by WebDatabaseService). |
| 77 // TODO(caitkp): remove this method once SyncServices no longer depend on it. | 77 // TODO(caitkp): remove this method once SyncServices no longer depend on it. |
| 78 virtual WebDatabase* GetDatabaseOnDB() const; | 78 virtual WebDatabase* GetDatabaseOnDB() const; |
| 79 | 79 |
| 80 // Returns a pointer to the WebDataServiceBackend. | 80 // Returns a pointer to the WebDatabaseBackend. |
| 81 scoped_refptr<WebDataServiceBackend> GetBackend() const; | 81 scoped_refptr<WebDatabaseBackend> GetBackend() const; |
| 82 | 82 |
| 83 // Schedule an update/write task on the DB thread. | 83 // Schedule an update/write task on the DB thread. |
| 84 virtual void ScheduleDBTask( | 84 virtual void ScheduleDBTask( |
| 85 const tracked_objects::Location& from_here, | 85 const tracked_objects::Location& from_here, |
| 86 const WriteTask& task); | 86 const WriteTask& task); |
| 87 | 87 |
| 88 // Schedule a read task on the DB thread. | 88 // Schedule a read task on the DB thread. |
| 89 virtual WebDataServiceBase::Handle ScheduleDBTaskWithResult( | 89 virtual WebDataServiceBase::Handle ScheduleDBTaskWithResult( |
| 90 const tracked_objects::Location& from_here, | 90 const tracked_objects::Location& from_here, |
| 91 const ReadTask& task, | 91 const ReadTask& task, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 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_; |
| 129 | 129 |
| 130 // The primary owner is |WebDatabaseService| but is refcounted because | 130 // The primary owner is |WebDatabaseService| but is refcounted because |
| 131 // PostTask on DB thread may outlive us. | 131 // PostTask on DB thread may outlive us. |
| 132 scoped_refptr<WebDataServiceBackend> wds_backend_; | 132 scoped_refptr<WebDatabaseBackend> web_db_backend_; |
| 133 | 133 |
| 134 // Callbacks to be called once the DB has loaded. | 134 // Callbacks to be called once the DB has loaded. |
| 135 LoadedCallbacks loaded_callbacks_; | 135 LoadedCallbacks loaded_callbacks_; |
| 136 | 136 |
| 137 // Callbacks to be called if the DB has failed to load. | 137 // Callbacks to be called if the DB has failed to load. |
| 138 ErrorCallbacks error_callbacks_; | 138 ErrorCallbacks error_callbacks_; |
| 139 | 139 |
| 140 // True if the WebDatabase has loaded. | 140 // True if the WebDatabase has loaded. |
| 141 bool db_loaded_; | 141 bool db_loaded_; |
| 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 |