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

Side by Side Diff: chrome/browser/api/webdata/web_data_service_base.h

Issue 12494020: Remove knowledge of Chrome-specific SyncableService classes from WebDataService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unit test in debug mode. 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
« no previous file with comments | « no previous file | chrome/browser/sync/glue/autofill_data_type_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 CHROME_BROWSER_API_WEBDATA_WEB_DATA_SERVICE_BASE_H_ 5 #ifndef CHROME_BROWSER_API_WEBDATA_WEB_DATA_SERVICE_BASE_H_
6 #define CHROME_BROWSER_API_WEBDATA_WEB_DATA_SERVICE_BASE_H_ 6 #define CHROME_BROWSER_API_WEBDATA_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"
12 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
13 #include "content/public/browser/notification_source.h" 14 #include "content/public/browser/notification_source.h"
14 #include "sql/init_status.h" 15 #include "sql/init_status.h"
15 16
16 class WebDatabase; 17 class WebDatabase;
17 class WebDatabaseService; 18 class WebDatabaseService;
18 19
19 namespace base { 20 namespace base {
20 class Thread; 21 class Thread;
21 } 22 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 64
64 // Returns true if the database load has completetd successfully, and 65 // Returns true if the database load has completetd successfully, and
65 // ShutdownOnUIThread has not yet been called. 66 // ShutdownOnUIThread has not yet been called.
66 virtual bool IsDatabaseLoaded(); 67 virtual bool IsDatabaseLoaded();
67 68
68 // Returns a pointer to the DB (used by SyncableServices). May return NULL if 69 // Returns a pointer to the DB (used by SyncableServices). May return NULL if
69 // the database is not loaded or otherwise unavailable. Must be called on 70 // the database is not loaded or otherwise unavailable. Must be called on
70 // DBThread. 71 // DBThread.
71 virtual WebDatabase* GetDatabase(); 72 virtual WebDatabase* GetDatabase();
72 73
74 // Returns a SupportsUserData objects that may be used to store data
75 // owned by the DB thread on this object. Should be called only from
76 // the DB thread, and will be destroyed on the DB thread soon after
77 // |ShutdownOnUIThread()| is called.
78 base::SupportsUserData* GetDBUserData();
79
73 protected: 80 protected:
74 virtual ~WebDataServiceBase(); 81 virtual ~WebDataServiceBase();
82 virtual void ShutdownOnDBThread();
75 83
76 // Our database service. 84 // Our database service.
77 scoped_ptr<WebDatabaseService> wdbs_; 85 scoped_ptr<WebDatabaseService> wdbs_;
78 86
79 // True if we've received a notification that the WebDatabase has loaded. 87 // True if we've received a notification that the WebDatabase has loaded.
80 bool db_loaded_; 88 bool db_loaded_;
81 89
82 private: 90 private:
83 friend struct content::BrowserThread::DeleteOnThread< 91 friend struct content::BrowserThread::DeleteOnThread<
84 content::BrowserThread::UI>; 92 content::BrowserThread::UI>;
85 friend class base::DeleteHelper<WebDataServiceBase>; 93 friend class base::DeleteHelper<WebDataServiceBase>;
86 94
87 ProfileErrorCallback profile_error_callback_; 95 ProfileErrorCallback profile_error_callback_;
88 96
97 // This makes the destructor public, and thus allows us to aggregate
98 // SupportsUserData. It is private by default to prevent incorrect
99 // usage in class hierarchies where it is inherited by
100 // reference-counted objects.
101 class SupportsUserDataAggregatable : public base::SupportsUserData {
102 public:
103 SupportsUserDataAggregatable() {}
104 virtual ~SupportsUserDataAggregatable() {}
105 private:
106 DISALLOW_COPY_AND_ASSIGN(SupportsUserDataAggregatable);
107 };
108
109 // Storage for user data to be accessed only on the DB thread. May
110 // be used e.g. for SyncableService subclasses that need to be owned
111 // by this object. Is created on first call to |GetDBUserData()|.
112 scoped_ptr<SupportsUserDataAggregatable> db_thread_user_data_;
113
89 void DBInitFailed(sql::InitStatus sql_status); 114 void DBInitFailed(sql::InitStatus sql_status);
90 void NotifyDatabaseLoadedOnUIThread(); 115 void NotifyDatabaseLoadedOnUIThread();
91 void DatabaseInitOnDB(sql::InitStatus status); 116 void DatabaseInitOnDB(sql::InitStatus status);
92 }; 117 };
93 118
94 #endif // CHROME_BROWSER_API_WEBDATA_WEB_DATA_SERVICE_BASE_H_ 119 #endif // CHROME_BROWSER_API_WEBDATA_WEB_DATA_SERVICE_BASE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sync/glue/autofill_data_type_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698