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

Unified Diff: components/webdata/common/web_database_service.h

Issue 17760007: components/webdata: Cleanup callback usage in WebDatabaseService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: disallow 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 side-by-side diff with in-line comments
Download patch
Index: components/webdata/common/web_database_service.h
diff --git a/components/webdata/common/web_database_service.h b/components/webdata/common/web_database_service.h
index 78b5befe72f960c79f9f4020c2a08b50874224bc..95ef5e2c7a1828883de95fe8e442720ce522670e 100644
--- a/components/webdata/common/web_database_service.h
+++ b/components/webdata/common/web_database_service.h
@@ -52,6 +52,10 @@ class WEBDATA_EXPORT WebDatabaseService
typedef base::Callback<scoped_ptr<WDTypedResult>(WebDatabase*)> ReadTask;
typedef base::Callback<WebDatabase::State(WebDatabase*)> WriteTask;
+ // Types for managing DB loading callbacks.
+ typedef base::Closure DBLoadedCallback;
+ typedef base::Callback<void(sql::InitStatus)> DBLoadErrorCallback;
+
// Takes the path to the WebDatabase file.
// WebDatabaseService lives on |ui_thread| and posts tasks to |db_thread|.
WebDatabaseService(const base::FilePath& path,
@@ -101,17 +105,16 @@ class WEBDATA_EXPORT WebDatabaseService
// (following a successful database load), then cleared.
// Note: if the database load is already complete, then the callback will NOT
// be stored or called.
- void RegisterDBLoadedCallback(const base::Callback<void(void)>& callback);
+ void RegisterDBLoadedCallback(const DBLoadedCallback& callback);
// Register a callback to be notified that the database has failed to load.
// Multiple callbacks may be registered, and each will be called at most once
// (following a database load failure), then cleared.
// Note: if the database load is already complete, then the callback will NOT
// be stored or called.
- void RegisterDBErrorCallback(
- const base::Callback<void(sql::InitStatus)>& callback);
+ void RegisterDBErrorCallback(const DBLoadErrorCallback& callback);
- bool db_loaded() { return db_loaded_; };
+ bool db_loaded() const { return db_loaded_; };
private:
class BackendDelegate;
@@ -119,6 +122,9 @@ class WEBDATA_EXPORT WebDatabaseService
friend class base::RefCountedDeleteOnMessageLoop<WebDatabaseService>;
friend class base::DeleteHelper<WebDatabaseService>;
+ typedef std::vector<DBLoadedCallback> LoadedCallbacks;
+ typedef std::vector<DBLoadErrorCallback> ErrorCallbacks;
+
virtual ~WebDatabaseService();
void OnDatabaseLoadDone(sql::InitStatus status);
@@ -132,13 +138,6 @@ class WEBDATA_EXPORT WebDatabaseService
// All vended weak pointers are invalidated in ShutdownDatabase().
base::WeakPtrFactory<WebDatabaseService> weak_ptr_factory_;
- // Types for managing DB loading callbacks.
- typedef base::Callback<void(void)> DBLoadedCallback;
- typedef std::vector<DBLoadedCallback> LoadedCallbacks;
-
- typedef base::Callback<void(sql::InitStatus)> DBLoadErrorCallback;
- typedef std::vector<DBLoadErrorCallback> ErrorCallbacks;
-
// Callbacks to be called once the DB has loaded.
LoadedCallbacks loaded_callbacks_;
@@ -149,6 +148,8 @@ class WEBDATA_EXPORT WebDatabaseService
bool db_loaded_;
scoped_refptr<base::MessageLoopProxy> db_thread_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebDatabaseService);
};
#endif // COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_SERVICE_H_
« no previous file with comments | « components/webdata/common/web_data_service_base.cc ('k') | components/webdata/common/web_database_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698