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 COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BASE_H_ | 5 #ifndef COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BASE_H_ |
6 #define COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BASE_H_ | 6 #define COMPONENTS_WEBDATA_COMMON_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" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/supports_user_data.h" | 12 #include "base/supports_user_data.h" |
| 13 #include "components/webdata/common/webdata_export.h" |
13 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
14 #include "content/public/browser/notification_source.h" | 15 #include "content/public/browser/notification_source.h" |
15 #include "sql/init_status.h" | 16 #include "sql/init_status.h" |
16 | 17 |
17 class WebDatabase; | 18 class WebDatabase; |
18 class WebDatabaseService; | 19 class WebDatabaseService; |
19 class WebDatabaseTable; | 20 class WebDatabaseTable; |
20 | 21 |
21 namespace base { | 22 namespace base { |
22 class Thread; | 23 class Thread; |
23 } | 24 } |
24 | 25 |
25 // Base for WebDataService class hierarchy. | 26 // Base for WebDataService class hierarchy. |
26 class WebDataServiceBase | 27 class WEBDATA_EXPORT WebDataServiceBase |
27 : public base::RefCountedThreadSafe<WebDataServiceBase, | 28 : public base::RefCountedThreadSafe<WebDataServiceBase, |
28 content::BrowserThread::DeleteOnUIThread> { | 29 content::BrowserThread::DeleteOnUIThread> { |
29 public: | 30 public: |
30 // All requests return an opaque handle of the following type. | 31 // All requests return an opaque handle of the following type. |
31 typedef int Handle; | 32 typedef int Handle; |
32 | 33 |
33 // Users of this class may provide a callback to handle errors | 34 // 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 | 35 // (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 | 36 // takes a single parameter, the sql::InitStatus value from trying |
36 // to open the database. | 37 // to open the database. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 // Our database service. | 93 // Our database service. |
93 scoped_refptr<WebDatabaseService> wdbs_; | 94 scoped_refptr<WebDatabaseService> wdbs_; |
94 | 95 |
95 // True if we've received a notification that the WebDatabase has loaded. | 96 // True if we've received a notification that the WebDatabase has loaded. |
96 bool db_loaded_; | 97 bool db_loaded_; |
97 | 98 |
98 private: | 99 private: |
99 friend struct content::BrowserThread::DeleteOnThread< | 100 friend struct content::BrowserThread::DeleteOnThread< |
100 content::BrowserThread::UI>; | 101 content::BrowserThread::UI>; |
101 friend class base::DeleteHelper<WebDataServiceBase>; | 102 friend class base::DeleteHelper<WebDataServiceBase>; |
| 103 // We have to friend RCTS<> so WIN shared-lib build is happy (crbug/112250). |
| 104 friend class base::RefCountedThreadSafe<WebDataServiceBase, |
| 105 content::BrowserThread::DeleteOnUIThread>; |
102 | 106 |
103 ProfileErrorCallback profile_error_callback_; | 107 ProfileErrorCallback profile_error_callback_; |
104 | 108 |
105 // This makes the destructor public, and thus allows us to aggregate | 109 // This makes the destructor public, and thus allows us to aggregate |
106 // SupportsUserData. It is private by default to prevent incorrect | 110 // SupportsUserData. It is private by default to prevent incorrect |
107 // usage in class hierarchies where it is inherited by | 111 // usage in class hierarchies where it is inherited by |
108 // reference-counted objects. | 112 // reference-counted objects. |
109 class SupportsUserDataAggregatable : public base::SupportsUserData { | 113 class SupportsUserDataAggregatable : public base::SupportsUserData { |
110 public: | 114 public: |
111 SupportsUserDataAggregatable() {} | 115 SupportsUserDataAggregatable() {} |
(...skipping 10 matching lines...) Expand all Loading... |
122 // Called after database is successfully loaded. By default this function does | 126 // Called after database is successfully loaded. By default this function does |
123 // nothing. Subclasses can override to support notification. | 127 // nothing. Subclasses can override to support notification. |
124 virtual void NotifyDatabaseLoadedOnUIThread(); | 128 virtual void NotifyDatabaseLoadedOnUIThread(); |
125 | 129 |
126 void DBInitFailed(sql::InitStatus sql_status); | 130 void DBInitFailed(sql::InitStatus sql_status); |
127 void DBInitSucceeded(); | 131 void DBInitSucceeded(); |
128 void DatabaseInitOnDB(sql::InitStatus status); | 132 void DatabaseInitOnDB(sql::InitStatus status); |
129 }; | 133 }; |
130 | 134 |
131 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BASE_H_ | 135 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BASE_H_ |
OLD | NEW |