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/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 9 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 11 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
| 12 #include "content/public/browser/notification_source.h" | 13 #include "content/public/browser/notification_source.h" |
| 13 #include "sql/init_status.h" | 14 #include "sql/init_status.h" |
| 14 | 15 |
| 15 class WebDatabase; | 16 class WebDatabase; |
| 16 class WebDatabaseService; | 17 class WebDatabaseService; |
| 17 | 18 |
| 18 namespace base { | 19 namespace base { |
| 19 class Thread; | 20 class Thread; |
| 20 } | 21 } |
| 21 | 22 |
| 22 // Base for WebDataService class hierarchy. | 23 // Base for WebDataService class hierarchy. |
| 23 class WebDataServiceBase | 24 class WebDataServiceBase |
| 24 : public base::RefCountedThreadSafe<WebDataServiceBase, | 25 : public base::RefCountedThreadSafe<WebDataServiceBase, |
| 25 content::BrowserThread::DeleteOnUIThread> { | 26 content::BrowserThread::DeleteOnUIThread> { |
| 26 public: | 27 public: |
| 27 // All requests return an opaque handle of the following type. | 28 // All requests return an opaque handle of the following type. |
| 28 typedef int Handle; | 29 typedef int Handle; |
| 29 | 30 |
| 30 WebDataServiceBase(); | 31 // Users of this class may provide a callback to handle errors |
| 32 // (e.g. by showing a UI). The callback is called only on error, and | |
| 33 // takes a single parameter, the sql::InitStatus value from trying | |
| 34 // to open the database. | |
| 35 typedef base::Callback<void(sql::InitStatus)> ProfileErrorCallback; | |
|
Cait (Slow)
2013/03/18 16:16:37
ATM we have a WebDataServiceBase::ProfileErrorCall
Jói
2013/03/18 23:21:23
Yes, I think we should wait for all the pieces to
| |
| 36 | |
| 37 // |callback| will only be invoked on error, and only if | |
| 38 // ||callback.is_null()| evaluates to true. | |
|
Cait (Slow)
2013/03/18 16:16:37
nit: |callback.is_null() --> !callback.is_null()
Jói
2013/03/18 23:21:23
Thanks for the catch. Switched "evaluates to true"
| |
| 39 WebDataServiceBase(const ProfileErrorCallback& callback); | |
| 31 | 40 |
| 32 // Cancel any pending request. You need to call this method if your | 41 // Cancel any pending request. You need to call this method if your |
| 33 // WebDataServiceConsumer is about to be deleted. | 42 // WebDataServiceConsumer is about to be deleted. |
| 34 virtual void CancelRequest(Handle h); | 43 virtual void CancelRequest(Handle h); |
| 35 | 44 |
| 36 // Returns the notification source for this service. This may use a | 45 // Returns the notification source for this service. This may use a |
| 37 // pointer other than this object's |this| pointer. | 46 // pointer other than this object's |this| pointer. |
| 38 virtual content::NotificationSource GetNotificationSource(); | 47 virtual content::NotificationSource GetNotificationSource(); |
| 39 | 48 |
| 40 // Shutdown the web data service. The service can no longer be used after this | 49 // Shutdown the web data service. The service can no longer be used after this |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 67 scoped_ptr<WebDatabaseService> wdbs_; | 76 scoped_ptr<WebDatabaseService> wdbs_; |
| 68 | 77 |
| 69 // True if we've received a notification that the WebDatabase has loaded. | 78 // True if we've received a notification that the WebDatabase has loaded. |
| 70 bool db_loaded_; | 79 bool db_loaded_; |
| 71 | 80 |
| 72 private: | 81 private: |
| 73 friend struct content::BrowserThread::DeleteOnThread< | 82 friend struct content::BrowserThread::DeleteOnThread< |
| 74 content::BrowserThread::UI>; | 83 content::BrowserThread::UI>; |
| 75 friend class base::DeleteHelper<WebDataServiceBase>; | 84 friend class base::DeleteHelper<WebDataServiceBase>; |
| 76 | 85 |
| 86 ProfileErrorCallback profile_error_callback_; | |
| 87 | |
| 77 void DBInitFailed(sql::InitStatus sql_status); | 88 void DBInitFailed(sql::InitStatus sql_status); |
| 78 void NotifyDatabaseLoadedOnUIThread(); | 89 void NotifyDatabaseLoadedOnUIThread(); |
| 79 void DatabaseInitOnDB(sql::InitStatus status); | 90 void DatabaseInitOnDB(sql::InitStatus status); |
| 80 }; | 91 }; |
| 81 | 92 |
| 82 #endif // CHROME_BROWSER_API_WEBDATA_WEB_DATA_SERVICE_BASE_H_ | 93 #endif // CHROME_BROWSER_API_WEBDATA_WEB_DATA_SERVICE_BASE_H_ |
| OLD | NEW |