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

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

Issue 9949024: Moved WebDataService to ProfileKeyedService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: re-base Created 8 years, 8 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 #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.h" 23 #include "chrome/browser/search_engines/template_url.h"
24 #include "chrome/browser/search_engines/template_url_id.h" 24 #include "chrome/browser/search_engines/template_url_id.h"
25 #include "chrome/browser/profiles/refcounted_profile_keyed_service.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;
33 class CreditCard; 34 class CreditCard;
34 struct DefaultWebIntentService; 35 struct DefaultWebIntentService;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 } 180 }
180 181
181 private: 182 private:
182 // mutable to keep GetValue() const. 183 // mutable to keep GetValue() const.
183 mutable T value_; 184 mutable T value_;
184 DISALLOW_COPY_AND_ASSIGN(WDObjectResult); 185 DISALLOW_COPY_AND_ASSIGN(WDObjectResult);
185 }; 186 };
186 187
187 class WebDataServiceConsumer; 188 class WebDataServiceConsumer;
188 189
189 class WebDataService 190 class WebDataService : public RefcountedProfileKeyedService {
190 : public base::RefCountedThreadSafe<
191 WebDataService, content::BrowserThread::DeleteOnUIThread> {
192 public: 191 public:
193 // All requests return an opaque handle of the following type. 192 // All requests return an opaque handle of the following type.
194 typedef int Handle; 193 typedef int Handle;
195 194
196 ////////////////////////////////////////////////////////////////////////////// 195 //////////////////////////////////////////////////////////////////////////////
197 // 196 //
198 // Internal requests 197 // Internal requests
199 // 198 //
200 // Every request is processed using a request object. The object contains 199 // Every request is processed using a request object. The object contains
201 // both the request parameters and the results. 200 // both the request parameters and the results.
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 294
296 WebDataService(); 295 WebDataService();
297 296
298 // Notifies listeners on the UI thread that multiple changes have been made to 297 // Notifies listeners on the UI thread that multiple changes have been made to
299 // to Autofill records of the database. 298 // to Autofill records of the database.
300 // NOTE: This method is intended to be called from the DB thread. It 299 // NOTE: This method is intended to be called from the DB thread. It
301 // it asynchronously notifies listeners on the UI thread. 300 // it asynchronously notifies listeners on the UI thread.
302 // |web_data_service| may be NULL for testing purposes. 301 // |web_data_service| may be NULL for testing purposes.
303 static void NotifyOfMultipleAutofillChanges(WebDataService* web_data_service); 302 static void NotifyOfMultipleAutofillChanges(WebDataService* web_data_service);
304 303
304 // RefcountedProfileKeyedService override:
305 // Shutdown the web data service. The service can no longer be used after this
306 // call.
307 virtual void ShutdownOnUIThread() OVERRIDE;
308
305 // Initializes the web data service. Returns false on failure 309 // Initializes the web data service. Returns false on failure
306 // Takes the path of the profile directory as its argument. 310 // Takes the path of the profile directory as its argument.
307 bool Init(const FilePath& profile_path); 311 bool Init(const FilePath& profile_path);
308 312
309 // Shutdown the web data service. The service can no longer be used after this
310 // call.
311 void Shutdown();
312
313 // Returns false if Shutdown() has been called. 313 // Returns false if Shutdown() has been called.
314 bool IsRunning() const; 314 bool IsRunning() const;
315 315
316 // Unloads the database without actually shutting down the service. This can 316 // Unloads the database without actually shutting down the service. This can
317 // be used to temporarily reduce the browser process' memory footprint. 317 // be used to temporarily reduce the browser process' memory footprint.
318 void UnloadDatabase(); 318 void UnloadDatabase();
319 319
320 // Cancel any pending request. You need to call this method if your 320 // Cancel any pending request. You need to call this method if your
321 // WebDataServiceConsumer is about to be deleted. 321 // WebDataServiceConsumer is about to be deleted.
322 void CancelRequest(Handle h); 322 void CancelRequest(Handle h);
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
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__
OLDNEW
« no previous file with comments | « chrome/browser/webdata/autocomplete_syncable_service.cc ('k') | chrome/browser/webdata/web_data_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698