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