Chromium Code Reviews| 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 20 matching lines...) Expand all Loading... | |
| 31 typedef int Handle; | 31 typedef int Handle; |
| 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. |
|
dhollowa
2013/03/21 16:44:07
nit: Comment on |wdbs| and the nature of the share
Cait (Slow)
2013/03/21 23:23:27
Done.
| |
| 42 WebDataServiceBase(const base::FilePath& path, | 42 WebDataServiceBase( |
| 43 const ProfileErrorCallback& callback); | 43 scoped_refptr<WebDatabaseService> wdbs, |
| 44 const ProfileErrorCallback& callback); | |
| 44 | 45 |
| 45 // Cancel any pending request. You need to call this method if your | 46 // Cancel any pending request. You need to call this method if your |
| 46 // WebDataServiceConsumer is about to be deleted. | 47 // WebDataServiceConsumer is about to be deleted. |
| 47 virtual void CancelRequest(Handle h); | 48 virtual void CancelRequest(Handle h); |
| 48 | 49 |
| 49 // Returns the notification source for this service. This may use a | 50 // Returns the notification source for this service. This may use a |
| 50 // pointer other than this object's |this| pointer. | 51 // pointer other than this object's |this| pointer. |
| 51 virtual content::NotificationSource GetNotificationSource(); | 52 virtual content::NotificationSource GetNotificationSource(); |
| 52 | 53 |
| 53 // Shutdown the web data service. The service can no longer be used after this | 54 // 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... | |
| 86 // owned by the DB thread on this object. Should be called only from | 87 // owned by the DB thread on this object. Should be called only from |
| 87 // the DB thread, and will be destroyed on the DB thread soon after | 88 // the DB thread, and will be destroyed on the DB thread soon after |
| 88 // |ShutdownOnUIThread()| is called. | 89 // |ShutdownOnUIThread()| is called. |
| 89 base::SupportsUserData* GetDBUserData(); | 90 base::SupportsUserData* GetDBUserData(); |
| 90 | 91 |
| 91 protected: | 92 protected: |
| 92 virtual ~WebDataServiceBase(); | 93 virtual ~WebDataServiceBase(); |
| 93 virtual void ShutdownOnDBThread(); | 94 virtual void ShutdownOnDBThread(); |
| 94 | 95 |
| 95 // Our database service. | 96 // Our database service. |
| 96 scoped_ptr<WebDatabaseService> wdbs_; | 97 scoped_refptr<WebDatabaseService> wdbs_; |
| 97 | 98 |
| 98 // True if we've received a notification that the WebDatabase has loaded. | 99 // True if we've received a notification that the WebDatabase has loaded. |
| 99 bool db_loaded_; | 100 bool db_loaded_; |
| 100 | 101 |
| 101 private: | 102 private: |
| 102 friend struct content::BrowserThread::DeleteOnThread< | 103 friend struct content::BrowserThread::DeleteOnThread< |
| 103 content::BrowserThread::UI>; | 104 content::BrowserThread::UI>; |
| 104 friend class base::DeleteHelper<WebDataServiceBase>; | 105 friend class base::DeleteHelper<WebDataServiceBase>; |
| 105 | 106 |
| 106 // TODO(caitkp): Get rid of this once we fully split | |
| 107 // AutofillWebDataService and WebDatabaseService away from | |
| 108 // WebDataService. | |
| 109 base::FilePath path_; | |
| 110 | |
| 111 ProfileErrorCallback profile_error_callback_; | 107 ProfileErrorCallback profile_error_callback_; |
| 112 | 108 |
| 113 // This makes the destructor public, and thus allows us to aggregate | 109 // This makes the destructor public, and thus allows us to aggregate |
| 114 // SupportsUserData. It is private by default to prevent incorrect | 110 // SupportsUserData. It is private by default to prevent incorrect |
| 115 // usage in class hierarchies where it is inherited by | 111 // usage in class hierarchies where it is inherited by |
| 116 // reference-counted objects. | 112 // reference-counted objects. |
| 117 class SupportsUserDataAggregatable : public base::SupportsUserData { | 113 class SupportsUserDataAggregatable : public base::SupportsUserData { |
| 118 public: | 114 public: |
| 119 SupportsUserDataAggregatable() {} | 115 SupportsUserDataAggregatable() {} |
| 120 virtual ~SupportsUserDataAggregatable() {} | 116 virtual ~SupportsUserDataAggregatable() {} |
| 121 private: | 117 private: |
| 122 DISALLOW_COPY_AND_ASSIGN(SupportsUserDataAggregatable); | 118 DISALLOW_COPY_AND_ASSIGN(SupportsUserDataAggregatable); |
| 123 }; | 119 }; |
| 124 | 120 |
| 125 // Storage for user data to be accessed only on the DB thread. May | 121 // Storage for user data to be accessed only on the DB thread. May |
| 126 // be used e.g. for SyncableService subclasses that need to be owned | 122 // be used e.g. for SyncableService subclasses that need to be owned |
| 127 // by this object. Is created on first call to |GetDBUserData()|. | 123 // by this object. Is created on first call to |GetDBUserData()|. |
| 128 scoped_ptr<SupportsUserDataAggregatable> db_thread_user_data_; | 124 scoped_ptr<SupportsUserDataAggregatable> db_thread_user_data_; |
| 129 | 125 |
| 130 void DBInitFailed(sql::InitStatus sql_status); | 126 void DBInitFailed(sql::InitStatus sql_status); |
| 131 void NotifyDatabaseLoadedOnUIThread(); | 127 void NotifyDatabaseLoadedOnUIThread(); |
| 132 void DatabaseInitOnDB(sql::InitStatus status); | 128 void DatabaseInitOnDB(sql::InitStatus status); |
| 133 }; | 129 }; |
| 134 | 130 |
| 135 #endif // CHROME_BROWSER_API_WEBDATA_WEB_DATA_SERVICE_BASE_H_ | 131 #endif // CHROME_BROWSER_API_WEBDATA_WEB_DATA_SERVICE_BASE_H_ |
| OLD | NEW |