Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(314)

Side by Side Diff: chrome/browser/webdata/web_data_service.h

Issue 12805007: wd5-syncableServices for try only (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: wd5-syncableServices with debug test fix Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 11
12 #include <map> 12 #include <map>
13 #include <string> 13 #include <string>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/callback_forward.h" 16 #include "base/callback_forward.h"
17 #include "base/files/file_path.h" 17 #include "base/files/file_path.h"
18 #include "base/location.h" 18 #include "base/location.h"
19 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
20 #include "base/sequenced_task_runner_helpers.h" 20 #include "base/sequenced_task_runner_helpers.h"
21 #include "base/synchronization/lock.h" 21 #include "base/synchronization/lock.h"
22 #include "chrome/browser/api/webdata/autofill_web_data_service.h" 22 #include "chrome/browser/api/webdata/autofill_web_data_service.h"
23 #include "chrome/browser/api/webdata/web_data_results.h" 23 #include "chrome/browser/api/webdata/web_data_results.h"
24 #include "chrome/browser/api/webdata/web_data_service_base.h" 24 #include "chrome/browser/api/webdata/web_data_service_base.h"
25 #include "chrome/browser/api/webdata/web_data_service_consumer.h" 25 #include "chrome/browser/api/webdata/web_data_service_consumer.h"
26 #include "chrome/browser/profiles/refcounted_profile_keyed_service.h"
27 #include "chrome/browser/search_engines/template_url.h" 26 #include "chrome/browser/search_engines/template_url.h"
28 #include "chrome/browser/search_engines/template_url_id.h" 27 #include "chrome/browser/search_engines/template_url_id.h"
29 #include "chrome/browser/webdata/keyword_table.h" 28 #include "chrome/browser/webdata/keyword_table.h"
30 #include "chrome/browser/webdata/web_data_request_manager.h"
31 #include "chrome/browser/webdata/web_database.h" 29 #include "chrome/browser/webdata/web_database.h"
32 #include "content/public/browser/browser_thread.h"
33 #include "sql/init_status.h"
34 30
35 class AutocompleteSyncableService; 31 class AutocompleteSyncableService;
36 class AutofillChange; 32 class AutofillChange;
37 class AutofillProfileSyncableService; 33 class AutofillProfileSyncableService;
38 struct DefaultWebIntentService; 34 struct DefaultWebIntentService;
39 class GURL; 35 class GURL;
40 #if defined(OS_WIN) 36 #if defined(OS_WIN)
41 struct IE7PasswordInfo; 37 struct IE7PasswordInfo;
42 #endif 38 #endif
43 class MessageLoop; 39 class MessageLoop;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 // 0 indicates there is no default search provider. 94 // 0 indicates there is no default search provider.
99 int64 default_search_provider_id; 95 int64 default_search_provider_id;
100 // Version of the built-in keywords. A value of 0 indicates a first run. 96 // Version of the built-in keywords. A value of 0 indicates a first run.
101 int builtin_keyword_version; 97 int builtin_keyword_version;
102 }; 98 };
103 99
104 class WebDataServiceConsumer; 100 class WebDataServiceConsumer;
105 101
106 class WebDataService 102 class WebDataService
107 : public WebDataServiceBase, 103 : public WebDataServiceBase,
108 public AutofillWebData, 104 public AutofillWebData {
109 public RefcountedProfileKeyedService {
110 public: 105 public:
111 // Retrieve a WebDataService for the given context. 106 // Retrieve a WebDataService for the given context.
112 static scoped_refptr<WebDataService> FromBrowserContext( 107 static scoped_refptr<WebDataService> FromBrowserContext(
113 content::BrowserContext* context); 108 content::BrowserContext* context);
114 109
115 WebDataService(); 110 explicit WebDataService(const ProfileErrorCallback& callback);
116
117 // WebDataServiceBase implementation.
118 virtual void CancelRequest(Handle h) OVERRIDE;
119 virtual content::NotificationSource GetNotificationSource() OVERRIDE;
120 111
121 // Notifies listeners on the UI thread that multiple changes have been made to 112 // Notifies listeners on the UI thread that multiple changes have been made to
122 // to Autofill records of the database. 113 // to Autofill records of the database.
123 // NOTE: This method is intended to be called from the DB thread. It 114 // NOTE: This method is intended to be called from the DB thread. It
124 // it asynchronously notifies listeners on the UI thread. 115 // it asynchronously notifies listeners on the UI thread.
125 // |web_data_service| may be NULL for testing purposes. 116 // |web_data_service| may be NULL for testing purposes.
126 static void NotifyOfMultipleAutofillChanges(WebDataService* web_data_service); 117 static void NotifyOfMultipleAutofillChanges(WebDataService* web_data_service);
127 118
128 // RefcountedProfileKeyedService override:
129 // Shutdown the web data service. The service can no longer be used after this
130 // call.
131 virtual void ShutdownOnUIThread() OVERRIDE;
132 119
133 // Initializes the web data service.
134 void Init(const base::FilePath& path);
135
136 // Unloads the database without actually shutting down the service. This can
137 // be used to temporarily reduce the browser process' memory footprint.
138 void UnloadDatabase();
139
140 // Unloads the database permanently and shuts down service.
141 void ShutdownDatabase();
142
143 // Returns true if the database load has completetd successfully, and
144 // ShutdownOnUIThread has not yet been called.
145 virtual bool IsDatabaseLoaded();
146
147 // Returns a pointer to the DB (used by SyncableServices). May return NULL if
148 // the database is not loaded or otherwise unavailable. Must be called on
149 // DBThread.
150 virtual WebDatabase* GetDatabase();
151 120
152 ////////////////////////////////////////////////////////////////////////////// 121 //////////////////////////////////////////////////////////////////////////////
153 // 122 //
154 // Keywords 123 // Keywords
155 // 124 //
156 ////////////////////////////////////////////////////////////////////////////// 125 //////////////////////////////////////////////////////////////////////////////
157 126
158 // As the database processes requests at a later date, all deletion is 127 // As the database processes requests at a later date, all deletion is
159 // done on the background thread. 128 // done on the background thread.
160 // 129 //
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 278
310 // Removes Autofill records from the database. 279 // Removes Autofill records from the database.
311 void RemoveAutofillProfilesAndCreditCardsModifiedBetween( 280 void RemoveAutofillProfilesAndCreditCardsModifiedBetween(
312 const base::Time& delete_begin, 281 const base::Time& delete_begin,
313 const base::Time& delete_end); 282 const base::Time& delete_end);
314 283
315 // Removes form elements recorded for Autocomplete from the database. 284 // Removes form elements recorded for Autocomplete from the database.
316 void RemoveFormElementsAddedBetween(const base::Time& delete_begin, 285 void RemoveFormElementsAddedBetween(const base::Time& delete_begin,
317 const base::Time& delete_end); 286 const base::Time& delete_end);
318 287
319 // Returns the syncable service for Autofill addresses and credit cards stored
320 // in this table. The returned service is owned by |this| object.
321 virtual AutofillProfileSyncableService*
322 GetAutofillProfileSyncableService() const;
323
324 // Returns the syncable service for field autocomplete stored in this table.
325 // The returned service is owned by |this| object.
326 virtual AutocompleteSyncableService*
327 GetAutocompleteSyncableService() const;
328
329 protected: 288 protected:
289 // TODO(caitkp): We probably don't need these anymore.
330 friend class TemplateURLServiceTest; 290 friend class TemplateURLServiceTest;
331 friend class TemplateURLServiceTestingProfile; 291 friend class TemplateURLServiceTestingProfile;
332 friend class WebDataServiceTest; 292 friend class WebDataServiceTest;
333 friend class WebDataRequest; 293 friend class WebDataRequest;
334 294
295 // For unit tests, passes a null callback.
296 WebDataService();
297
335 virtual ~WebDataService(); 298 virtual ~WebDataService();
336 299
300 private:
337 ////////////////////////////////////////////////////////////////////////////// 301 //////////////////////////////////////////////////////////////////////////////
338 // 302 //
339 // The following methods are only invoked in the web data service thread. 303 // The following methods are only invoked in the web data service thread.
340 // 304 //
341 ////////////////////////////////////////////////////////////////////////////// 305 //////////////////////////////////////////////////////////////////////////////
342 private:
343 friend struct content::BrowserThread::DeleteOnThread<
344 content::BrowserThread::UI>;
345 friend class base::DeleteHelper<WebDataService>;
346
347 // Initialize any syncable services.
348 void InitializeSyncableServices();
349
350 // Deletes the syncable services.
351 void ShutdownSyncableServices();
352
353 void DBInitFailed(sql::InitStatus sql_status);
354 void NotifyDatabaseLoadedOnUIThread();
355 void DatabaseInitOnDB(sql::InitStatus status);
356 306
357 ////////////////////////////////////////////////////////////////////////////// 307 //////////////////////////////////////////////////////////////////////////////
358 // 308 //
359 // Keywords. 309 // Keywords.
360 // 310 //
361 ////////////////////////////////////////////////////////////////////////////// 311 //////////////////////////////////////////////////////////////////////////////
362 WebDatabase::State AddKeywordImpl( 312 WebDatabase::State AddKeywordImpl(
363 const TemplateURLData& data, WebDatabase* db); 313 const TemplateURLData& data, WebDatabase* db);
364 WebDatabase::State RemoveKeywordImpl( 314 WebDatabase::State RemoveKeywordImpl(
365 TemplateURLID id, WebDatabase* db); 315 TemplateURLID id, WebDatabase* db);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 scoped_ptr<WDTypedResult> GetCreditCardsImpl(WebDatabase* db); 415 scoped_ptr<WDTypedResult> GetCreditCardsImpl(WebDatabase* db);
466 WebDatabase::State RemoveAutofillProfilesAndCreditCardsModifiedBetweenImpl( 416 WebDatabase::State RemoveAutofillProfilesAndCreditCardsModifiedBetweenImpl(
467 const base::Time& delete_begin, const base::Time& delete_end, 417 const base::Time& delete_begin, const base::Time& delete_end,
468 WebDatabase* db); 418 WebDatabase* db);
469 419
470 // Callbacks to ensure that sensitive info is destroyed if request is 420 // Callbacks to ensure that sensitive info is destroyed if request is
471 // cancelled. 421 // cancelled.
472 void DestroyAutofillProfileResult(const WDTypedResult* result); 422 void DestroyAutofillProfileResult(const WDTypedResult* result);
473 void DestroyAutofillCreditCardResult(const WDTypedResult* result); 423 void DestroyAutofillCreditCardResult(const WDTypedResult* result);
474 424
475 // Our database service.
476 scoped_ptr<WebDatabaseService> wdbs_;
477
478 // True if we've received a notification that the WebDatabase has loaded.
479 bool db_loaded_;
480
481 // Syncable services for the database data. We own the services, but don't
482 // use |scoped_ptr|s because the lifetimes must be managed on the database
483 // thread.
484 // Currently only Autocomplete and Autofill profiles use the new Sync API, but
485 // all the database data should migrate to this API over time.
486 AutocompleteSyncableService* autocomplete_syncable_service_;
487 AutofillProfileSyncableService* autofill_profile_syncable_service_;
488
489 DISALLOW_COPY_AND_ASSIGN(WebDataService); 425 DISALLOW_COPY_AND_ASSIGN(WebDataService);
490 }; 426 };
491 427
492 #endif // CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__ 428 #endif // CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__
OLDNEW
« no previous file with comments | « chrome/browser/webdata/web_apps_table_unittest.cc ('k') | chrome/browser/webdata/web_data_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698