OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_API_WEBDATA_WEB_DATA_SERVICE_BASE_H_ | 5 #ifndef CHROME_BROWSER_API_WEBDATA_WEB_DATA_SERVICE_BASE_H_ |
6 #define CHROME_BROWSER_API_WEBDATA_WEB_DATA_SERVICE_BASE_H_ | 6 #define CHROME_BROWSER_API_WEBDATA_WEB_DATA_SERVICE_BASE_H_ |
7 | 7 |
8 #include "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 | 32 |
33 // Users of this class may provide a callback to handle errors | 33 // Users of this class may provide a callback to handle errors |
34 // (e.g. by showing a UI). The callback is called only on error, and | 34 // (e.g. by showing a UI). The callback is called only on error, and |
35 // takes a single parameter, the sql::InitStatus value from trying | 35 // takes a single parameter, the sql::InitStatus value from trying |
36 // to open the database. | 36 // to open the database. |
37 // TODO(joi): Should we combine this with WebDatabaseService::InitCallback? | 37 // TODO(joi): Should we combine this with WebDatabaseService::InitCallback? |
38 typedef base::Callback<void(sql::InitStatus)> ProfileErrorCallback; | 38 typedef base::Callback<void(sql::InitStatus)> ProfileErrorCallback; |
39 | 39 |
40 // |callback| will only be invoked on error, and only if | 40 // |callback| will only be invoked on error, and only if |
41 // |callback.is_null()| evaluates to false. | 41 // |callback.is_null()| evaluates to false. |
42 explicit WebDataServiceBase(const ProfileErrorCallback& callback); | 42 WebDataServiceBase(scoped_refptr<WebDatabaseService> wdbs, |
| 43 const ProfileErrorCallback& callback); |
43 | 44 |
44 // Cancel any pending request. You need to call this method if your | 45 // Cancel any pending request. You need to call this method if your |
45 // WebDataServiceConsumer is about to be deleted. | 46 // WebDataServiceConsumer is about to be deleted. |
46 virtual void CancelRequest(Handle h); | 47 virtual void CancelRequest(Handle h); |
47 | 48 |
48 // Returns the notification source for this service. This may use a | 49 // Returns the notification source for this service. This may use a |
49 // pointer other than this object's |this| pointer. | 50 // pointer other than this object's |this| pointer. |
50 virtual content::NotificationSource GetNotificationSource(); | 51 virtual content::NotificationSource GetNotificationSource(); |
51 | 52 |
52 // Shutdown the web data service. The service can no longer be used after this | 53 // Shutdown the web data service. The service can no longer be used after this |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 // owned by the DB thread on this object. Should be called only from | 86 // owned by the DB thread on this object. Should be called only from |
86 // the DB thread, and will be destroyed on the DB thread soon after | 87 // the DB thread, and will be destroyed on the DB thread soon after |
87 // |ShutdownOnUIThread()| is called. | 88 // |ShutdownOnUIThread()| is called. |
88 base::SupportsUserData* GetDBUserData(); | 89 base::SupportsUserData* GetDBUserData(); |
89 | 90 |
90 protected: | 91 protected: |
91 virtual ~WebDataServiceBase(); | 92 virtual ~WebDataServiceBase(); |
92 virtual void ShutdownOnDBThread(); | 93 virtual void ShutdownOnDBThread(); |
93 | 94 |
94 // Our database service. | 95 // Our database service. |
95 scoped_ptr<WebDatabaseService> wdbs_; | 96 scoped_refptr<WebDatabaseService> wdbs_; |
96 | 97 |
97 // True if we've received a notification that the WebDatabase has loaded. | 98 // True if we've received a notification that the WebDatabase has loaded. |
98 bool db_loaded_; | 99 bool db_loaded_; |
99 | 100 |
100 private: | 101 private: |
101 friend struct content::BrowserThread::DeleteOnThread< | 102 friend struct content::BrowserThread::DeleteOnThread< |
102 content::BrowserThread::UI>; | 103 content::BrowserThread::UI>; |
103 friend class base::DeleteHelper<WebDataServiceBase>; | 104 friend class base::DeleteHelper<WebDataServiceBase>; |
104 | 105 |
105 ProfileErrorCallback profile_error_callback_; | 106 ProfileErrorCallback profile_error_callback_; |
(...skipping 14 matching lines...) Expand all Loading... |
120 // be used e.g. for SyncableService subclasses that need to be owned | 121 // be used e.g. for SyncableService subclasses that need to be owned |
121 // by this object. Is created on first call to |GetDBUserData()|. | 122 // by this object. Is created on first call to |GetDBUserData()|. |
122 scoped_ptr<SupportsUserDataAggregatable> db_thread_user_data_; | 123 scoped_ptr<SupportsUserDataAggregatable> db_thread_user_data_; |
123 | 124 |
124 void DBInitFailed(sql::InitStatus sql_status); | 125 void DBInitFailed(sql::InitStatus sql_status); |
125 void NotifyDatabaseLoadedOnUIThread(); | 126 void NotifyDatabaseLoadedOnUIThread(); |
126 void DatabaseInitOnDB(sql::InitStatus status); | 127 void DatabaseInitOnDB(sql::InitStatus status); |
127 }; | 128 }; |
128 | 129 |
129 #endif // CHROME_BROWSER_API_WEBDATA_WEB_DATA_SERVICE_BASE_H_ | 130 #endif // CHROME_BROWSER_API_WEBDATA_WEB_DATA_SERVICE_BASE_H_ |
OLD | NEW |