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_ |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
86 virtual WebDataServiceBase::Handle ScheduleDBTaskWithResult( | 86 virtual WebDataServiceBase::Handle ScheduleDBTaskWithResult( |
87 const tracked_objects::Location& from_here, | 87 const tracked_objects::Location& from_here, |
88 const ReadTask& task, | 88 const ReadTask& task, |
89 WebDataServiceConsumer* consumer); | 89 WebDataServiceConsumer* consumer); |
90 | 90 |
91 // Cancel an existing request for a task on the DB thread. | 91 // Cancel an existing request for a task on the DB thread. |
92 // TODO(caitkp): Think about moving the definition of the Handle type to | 92 // TODO(caitkp): Think about moving the definition of the Handle type to |
93 // somewhere else. | 93 // somewhere else. |
94 virtual void CancelRequest(WebDataServiceBase::Handle h); | 94 virtual void CancelRequest(WebDataServiceBase::Handle h); |
95 | 95 |
96 void AddObserver(WebDatabaseObserver* observer); | 96 // Register a callback to be notified that the database has loaded. Multiple |
97 void RemoveObserver(WebDatabaseObserver* observer); | 97 // callbacks may be registered, and each will be called at most once |
98 // (following a successful database load), then cleared. | |
99 // Note: if the database load is already complete, then the callback will NOT | |
100 // be stored or called. | |
101 void RegisterDBLoadedCallback(const base::Callback<void(void)>& callback); | |
tfarina
2013/06/26 03:53:51
base::Callback<void(void)> is base::Closure.
| |
102 | |
103 // Register a callback to be notified that the database has failed to load. | |
104 // Multiple callbacks may be registered, and each will be called at most once | |
105 // (following a database load failure), then cleared. | |
106 // Note: if the database load is already complete, then the callback will NOT | |
107 // be stored or called. | |
108 void RegisterDBErrorCallback( | |
109 const base::Callback<void(sql::InitStatus)>& callback); | |
110 | |
111 bool db_loaded() { return db_loaded_; }; | |
tfarina
2013/06/26 03:53:51
minorminornit: const
| |
98 | 112 |
99 private: | 113 private: |
100 class BackendDelegate; | 114 class BackendDelegate; |
101 friend struct content::BrowserThread::DeleteOnThread< | 115 friend struct content::BrowserThread::DeleteOnThread< |
102 content::BrowserThread::UI>; | 116 content::BrowserThread::UI>; |
103 friend class base::DeleteHelper<WebDatabaseService>; | 117 friend class base::DeleteHelper<WebDatabaseService>; |
104 // We have to friend RCTS<> so WIN shared-lib build is happy (crbug/112250). | 118 // We have to friend RCTS<> so WIN shared-lib build is happy (crbug/112250). |
105 friend class base::RefCountedThreadSafe<WebDatabaseService, | 119 friend class base::RefCountedThreadSafe<WebDatabaseService, |
106 content::BrowserThread::DeleteOnUIThread>; | 120 content::BrowserThread::DeleteOnUIThread>; |
107 friend class BackendDelegate; | 121 friend class BackendDelegate; |
108 | 122 |
109 virtual ~WebDatabaseService(); | 123 virtual ~WebDatabaseService(); |
110 | 124 |
111 void OnDatabaseLoadDone(sql::InitStatus status); | 125 void OnDatabaseLoadDone(sql::InitStatus status); |
112 | 126 |
113 base::FilePath path_; | 127 base::FilePath path_; |
114 | 128 |
115 // The primary owner is |WebDatabaseService| but is refcounted because | 129 // The primary owner is |WebDatabaseService| but is refcounted because |
116 // PostTask on DB thread may outlive us. | 130 // PostTask on DB thread may outlive us. |
117 scoped_refptr<WebDataServiceBackend> wds_backend_; | 131 scoped_refptr<WebDataServiceBackend> wds_backend_; |
118 | 132 |
119 ObserverList<WebDatabaseObserver> observer_list_; | |
120 | |
121 // All vended weak pointers are invalidated in ShutdownDatabase(). | 133 // All vended weak pointers are invalidated in ShutdownDatabase(). |
122 base::WeakPtrFactory<WebDatabaseService> weak_ptr_factory_; | 134 base::WeakPtrFactory<WebDatabaseService> weak_ptr_factory_; |
135 | |
136 // Types for managing DB loading callbacks. | |
137 typedef base::Callback<void(void)> DBLoadedCallback; | |
tfarina
2013/06/26 03:53:51
if we move the callback typedefs to the public sec
| |
138 typedef std::vector<DBLoadedCallback> LoadedCallbacks; | |
139 | |
140 typedef base::Callback<void(sql::InitStatus)> DBLoadErrorCallback; | |
141 typedef std::vector<DBLoadErrorCallback> ErrorCallbacks; | |
142 | |
143 // Callbacks to be called once the DB has loaded. | |
144 LoadedCallbacks loaded_callbacks_; | |
145 | |
146 // Callbacks to be called if the DB has failed to load. | |
147 ErrorCallbacks error_callbacks_; | |
148 | |
149 // True if the WebDatabase has loaded. | |
150 bool db_loaded_; | |
123 }; | 151 }; |
tfarina
2013/06/26 03:53:51
minornit: DISALLOW_COPY_AND_ASSING
| |
124 | 152 |
125 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_SERVICE_H_ | 153 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_SERVICE_H_ |
OLD | NEW |