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

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

Issue 13898011: Move SupportsUserData code into AutofillWebData (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase and test fix Created 7 years, 7 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 "base/supports_user_data.h"
13 #include "components/webdata/common/web_database_observer.h" 12 #include "components/webdata/common/web_database_observer.h"
14 #include "components/webdata/common/webdata_export.h" 13 #include "components/webdata/common/webdata_export.h"
15 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
16 #include "content/public/browser/notification_source.h" 15 #include "content/public/browser/notification_source.h"
17 #include "sql/init_status.h" 16 #include "sql/init_status.h"
18 17
19 class WebDatabase; 18 class WebDatabase;
20 class WebDatabaseService; 19 class WebDatabaseService;
21 class WebDatabaseTable; 20 class WebDatabaseTable;
22 21
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 81
83 // Returns true if the database load has completetd successfully, and 82 // Returns true if the database load has completetd successfully, and
84 // ShutdownOnUIThread has not yet been called. 83 // ShutdownOnUIThread has not yet been called.
85 virtual bool IsDatabaseLoaded(); 84 virtual bool IsDatabaseLoaded();
86 85
87 // Returns a pointer to the DB (used by SyncableServices). May return NULL if 86 // Returns a pointer to the DB (used by SyncableServices). May return NULL if
88 // the database is not loaded or otherwise unavailable. Must be called on 87 // the database is not loaded or otherwise unavailable. Must be called on
89 // DBThread. 88 // DBThread.
90 virtual WebDatabase* GetDatabase(); 89 virtual WebDatabase* GetDatabase();
91 90
92 // Returns a SupportsUserData objects that may be used to store data
93 // owned by the DB thread on this object. Should be called only from
94 // the DB thread, and will be destroyed on the DB thread soon after
95 // |ShutdownOnUIThread()| is called.
96 base::SupportsUserData* GetDBUserData();
97
98 protected: 91 protected:
99 virtual ~WebDataServiceBase(); 92 virtual ~WebDataServiceBase();
100 virtual void ShutdownOnDBThread();
101 93
102 // Our database service. 94 // Our database service.
103 scoped_refptr<WebDatabaseService> wdbs_; 95 scoped_refptr<WebDatabaseService> wdbs_;
104 96
105 // True if we've received a notification that the WebDatabase has loaded. 97 // True if we've received a notification that the WebDatabase has loaded.
106 bool db_loaded_; 98 bool db_loaded_;
107 99
108 private: 100 private:
109 friend struct content::BrowserThread::DeleteOnThread< 101 friend struct content::BrowserThread::DeleteOnThread<
110 content::BrowserThread::UI>; 102 content::BrowserThread::UI>;
111 friend class base::DeleteHelper<WebDataServiceBase>; 103 friend class base::DeleteHelper<WebDataServiceBase>;
112 // We have to friend RCTS<> so WIN shared-lib build is happy (crbug/112250). 104 // We have to friend RCTS<> so WIN shared-lib build is happy (crbug/112250).
113 friend class base::RefCountedThreadSafe<WebDataServiceBase, 105 friend class base::RefCountedThreadSafe<WebDataServiceBase,
114 content::BrowserThread::DeleteOnUIThread>; 106 content::BrowserThread::DeleteOnUIThread>;
115 107
116 ProfileErrorCallback profile_error_callback_; 108 ProfileErrorCallback profile_error_callback_;
117
118 // This makes the destructor public, and thus allows us to aggregate
119 // SupportsUserData. It is private by default to prevent incorrect
120 // usage in class hierarchies where it is inherited by
121 // reference-counted objects.
122 class SupportsUserDataAggregatable : public base::SupportsUserData {
123 public:
124 SupportsUserDataAggregatable() {}
125 virtual ~SupportsUserDataAggregatable() {}
126 private:
127 DISALLOW_COPY_AND_ASSIGN(SupportsUserDataAggregatable);
128 };
129
130 // Storage for user data to be accessed only on the DB thread. May
131 // be used e.g. for SyncableService subclasses that need to be owned
132 // by this object. Is created on first call to |GetDBUserData()|.
133 scoped_ptr<SupportsUserDataAggregatable> db_thread_user_data_;
134 }; 109 };
135 110
136 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BASE_H_ 111 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BASE_H_
OLDNEW
« no previous file with comments | « components/autofill/browser/webdata/autofill_webdata_service.cc ('k') | components/webdata/common/web_data_service_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698