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 // 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 CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__ | 9 #ifndef CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__ |
10 #define CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__ | 10 #define CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__ |
11 #pragma once | 11 #pragma once |
12 | 12 |
13 #include <map> | 13 #include <map> |
14 #include <string> | 14 #include <string> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "base/callback_forward.h" | 17 #include "base/callback_forward.h" |
18 #include "base/file_path.h" | 18 #include "base/file_path.h" |
19 #include "base/location.h" | 19 #include "base/location.h" |
20 #include "base/message_loop_helpers.h" | 20 #include "base/message_loop_helpers.h" |
21 #include "base/memory/ref_counted.h" | 21 #include "base/memory/ref_counted.h" |
22 #include "base/synchronization/lock.h" | 22 #include "base/synchronization/lock.h" |
23 #include "chrome/browser/search_engines/template_url_id.h" | 23 #include "chrome/browser/search_engines/template_url_id.h" |
| 24 #include "chrome/browser/profiles/refcounted_profile_keyed_service.h" |
24 #include "chrome/browser/webdata/keyword_table.h" | 25 #include "chrome/browser/webdata/keyword_table.h" |
25 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
26 #include "sql/init_status.h" | 27 #include "sql/init_status.h" |
27 | 28 |
28 class AutocompleteSyncableService; | 29 class AutocompleteSyncableService; |
29 class AutofillChange; | 30 class AutofillChange; |
30 class AutofillProfile; | 31 class AutofillProfile; |
31 class AutofillProfileSyncableService; | 32 class AutofillProfileSyncableService; |
32 class CreditCard; | 33 class CreditCard; |
33 struct DefaultWebIntentService; | 34 struct DefaultWebIntentService; |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 } | 179 } |
179 | 180 |
180 private: | 181 private: |
181 // mutable to keep GetValue() const. | 182 // mutable to keep GetValue() const. |
182 mutable T value_; | 183 mutable T value_; |
183 DISALLOW_COPY_AND_ASSIGN(WDObjectResult); | 184 DISALLOW_COPY_AND_ASSIGN(WDObjectResult); |
184 }; | 185 }; |
185 | 186 |
186 class WebDataServiceConsumer; | 187 class WebDataServiceConsumer; |
187 | 188 |
188 class WebDataService | 189 class WebDataService : public RefcountedProfileKeyedService { |
189 : public base::RefCountedThreadSafe< | |
190 WebDataService, content::BrowserThread::DeleteOnUIThread> { | |
191 public: | 190 public: |
192 // All requests return an opaque handle of the following type. | 191 // All requests return an opaque handle of the following type. |
193 typedef int Handle; | 192 typedef int Handle; |
194 | 193 |
195 ////////////////////////////////////////////////////////////////////////////// | 194 ////////////////////////////////////////////////////////////////////////////// |
196 // | 195 // |
197 // Internal requests | 196 // Internal requests |
198 // | 197 // |
199 // Every request is processed using a request object. The object contains | 198 // Every request is processed using a request object. The object contains |
200 // both the request parameters and the results. | 199 // both the request parameters and the results. |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 | 293 |
295 WebDataService(); | 294 WebDataService(); |
296 | 295 |
297 // Notifies listeners on the UI thread that multiple changes have been made to | 296 // Notifies listeners on the UI thread that multiple changes have been made to |
298 // to Autofill records of the database. | 297 // to Autofill records of the database. |
299 // NOTE: This method is intended to be called from the DB thread. It | 298 // NOTE: This method is intended to be called from the DB thread. It |
300 // it asynchronously notifies listeners on the UI thread. | 299 // it asynchronously notifies listeners on the UI thread. |
301 // |web_data_service| may be NULL for testing purposes. | 300 // |web_data_service| may be NULL for testing purposes. |
302 static void NotifyOfMultipleAutofillChanges(WebDataService* web_data_service); | 301 static void NotifyOfMultipleAutofillChanges(WebDataService* web_data_service); |
303 | 302 |
| 303 // RefcountedProfileKeyedService override: |
| 304 // Shutdown the web data service. The service can no longer be used after this |
| 305 // call. |
| 306 virtual void ShutdownOnUIThread() OVERRIDE; |
| 307 |
304 // Initializes the web data service. Returns false on failure | 308 // Initializes the web data service. Returns false on failure |
305 // Takes the path of the profile directory as its argument. | 309 // Takes the path of the profile directory as its argument. |
306 bool Init(const FilePath& profile_path); | 310 bool Init(const FilePath& profile_path); |
307 | 311 |
308 // Shutdown the web data service. The service can no longer be used after this | |
309 // call. | |
310 void Shutdown(); | |
311 | |
312 // Returns false if Shutdown() has been called. | 312 // Returns false if Shutdown() has been called. |
313 bool IsRunning() const; | 313 bool IsRunning() const; |
314 | 314 |
315 // Unloads the database without actually shutting down the service. This can | 315 // Unloads the database without actually shutting down the service. This can |
316 // be used to temporarily reduce the browser process' memory footprint. | 316 // be used to temporarily reduce the browser process' memory footprint. |
317 void UnloadDatabase(); | 317 void UnloadDatabase(); |
318 | 318 |
319 // Cancel any pending request. You need to call this method if your | 319 // Cancel any pending request. You need to call this method if your |
320 // WebDataServiceConsumer is about to be deleted. | 320 // WebDataServiceConsumer is about to be deleted. |
321 void CancelRequest(Handle h); | 321 void CancelRequest(Handle h); |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 // result can be NULL, if no result is expected or if the database could | 787 // result can be NULL, if no result is expected or if the database could |
788 // not be opened. The result object is destroyed after this call. | 788 // not be opened. The result object is destroyed after this call. |
789 virtual void OnWebDataServiceRequestDone(WebDataService::Handle h, | 789 virtual void OnWebDataServiceRequestDone(WebDataService::Handle h, |
790 const WDTypedResult* result) = 0; | 790 const WDTypedResult* result) = 0; |
791 | 791 |
792 protected: | 792 protected: |
793 virtual ~WebDataServiceConsumer() {} | 793 virtual ~WebDataServiceConsumer() {} |
794 }; | 794 }; |
795 | 795 |
796 #endif // CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__ | 796 #endif // CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__ |
OLD | NEW |