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

Side by Side Diff: components/webdata/common/web_data_service_base.h

Issue 16154031: Un-refcount AutofillWebData and TokenWebData (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase on ToT Created 7 years, 6 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 #ifndef COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BASE_H_ 5 #ifndef COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BASE_H_
6 #define COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BASE_H_ 6 #define COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BASE_H_
7 7
8 #include "base/callback_forward.h" 8 #include "base/callback_forward.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "components/webdata/common/webdata_export.h" 12 #include "components/webdata/common/webdata_export.h"
13 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
14 #include "sql/init_status.h" 14 #include "sql/init_status.h"
15 15
16 class WebDatabase; 16 class WebDatabase;
17 class WebDatabaseService; 17 class WebDatabaseService;
18 class WebDatabaseTable; 18 class WebDatabaseTable;
19 19
20 namespace base { 20 namespace base {
21 class Thread; 21 class Thread;
22 } 22 }
23 23
24 // Base for WebDataService class hierarchy. 24 // Base for WebDataService class hierarchy.
25 class WEBDATA_EXPORT WebDataServiceBase 25 class WEBDATA_EXPORT WebDataServiceBase {
26 : public base::RefCountedThreadSafe<WebDataServiceBase,
27 content::BrowserThread::DeleteOnUIThread> {
28 public: 26 public:
29 // All requests return an opaque handle of the following type. 27 // All requests return an opaque handle of the following type.
30 typedef int Handle; 28 typedef int Handle;
31 29
32 // Users of this class may provide a callback to handle errors 30 // Users of this class may provide a callback to handle errors
33 // (e.g. by showing a UI). The callback is called only on error, and 31 // (e.g. by showing a UI). The callback is called only on error, and
34 // takes a single parameter, the sql::InitStatus value from trying 32 // takes a single parameter, the sql::InitStatus value from trying
35 // to open the database. 33 // to open the database.
36 // TODO(joi): Should we combine this with WebDatabaseService::InitCallback? 34 // TODO(joi): Should we combine this with WebDatabaseService::InitCallback?
37 typedef base::Callback<void(sql::InitStatus)> ProfileErrorCallback; 35 typedef base::Callback<void(sql::InitStatus)> ProfileErrorCallback;
38 36
39 // |callback| will only be invoked on error, and only if 37 // |callback| will only be invoked on error, and only if
40 // |callback.is_null()| evaluates to false. 38 // |callback.is_null()| evaluates to false.
41 // 39 //
42 // The ownership of |wdbs| is shared, with the primary owner being the 40 // The ownership of |wdbs| is shared, with the primary owner being the
43 // WebDataServiceWrapper, and secondary owners being subclasses of 41 // WebDataServiceWrapper, and secondary owners being subclasses of
44 // WebDataServiceBase, which receive |wdbs| upon construction. The 42 // WebDataServiceBase, which receive |wdbs| upon construction. The
45 // WebDataServiceWrapper handles the initializing and shutting down and of 43 // WebDataServiceWrapper handles the initializing and shutting down and of
46 // the |wdbs| object. 44 // the |wdbs| object.
47 WebDataServiceBase(scoped_refptr<WebDatabaseService> wdbs, 45 WebDataServiceBase(scoped_refptr<WebDatabaseService> wdbs,
48 const ProfileErrorCallback& callback); 46 const ProfileErrorCallback& callback);
49 47
48 virtual ~WebDataServiceBase();
49
50 // Cancel any pending request. You need to call this method if your 50 // Cancel any pending request. You need to call this method if your
51 // WebDataServiceConsumer is about to be deleted. 51 // WebDataServiceConsumer is about to be deleted.
52 virtual void CancelRequest(Handle h); 52 virtual void CancelRequest(Handle h);
53 53
54 // Shutdown the web data service. The service can no longer be used after this 54 // Shutdown the web data service. The service can no longer be used after this
55 // call. 55 // call.
56 virtual void ShutdownOnUIThread(); 56 virtual void ShutdownOnUIThread();
57 57
58 // Initializes the web data service. 58 // Initializes the web data service.
59 virtual void Init(); 59 virtual void Init();
(...skipping 16 matching lines...) Expand all
76 // Returns true if the database load has completetd successfully, and 76 // Returns true if the database load has completetd successfully, and
77 // ShutdownOnUIThread has not yet been called. 77 // ShutdownOnUIThread has not yet been called.
78 virtual bool IsDatabaseLoaded(); 78 virtual bool IsDatabaseLoaded();
79 79
80 // Returns a pointer to the DB (used by SyncableServices). May return NULL if 80 // Returns a pointer to the DB (used by SyncableServices). May return NULL if
81 // the database is not loaded or otherwise unavailable. Must be called on 81 // the database is not loaded or otherwise unavailable. Must be called on
82 // DBThread. 82 // DBThread.
83 virtual WebDatabase* GetDatabase(); 83 virtual WebDatabase* GetDatabase();
84 84
85 protected: 85 protected:
86 virtual ~WebDataServiceBase();
87
88 // Our database service. 86 // Our database service.
89 scoped_refptr<WebDatabaseService> wdbs_; 87 scoped_refptr<WebDatabaseService> wdbs_;
90 88
91 private: 89 private:
92 friend struct content::BrowserThread::DeleteOnThread< 90 ProfileErrorCallback profile_error_callback_;
93 content::BrowserThread::UI>;
94 friend class base::DeleteHelper<WebDataServiceBase>;
95 // We have to friend RCTS<> so WIN shared-lib build is happy (crbug/112250).
96 friend class base::RefCountedThreadSafe<WebDataServiceBase,
97 content::BrowserThread::DeleteOnUIThread>;
98 91
99 ProfileErrorCallback profile_error_callback_; 92 DISALLOW_COPY_AND_ASSIGN(WebDataServiceBase);
100 }; 93 };
101 94
102 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BASE_H_ 95 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698