diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-01 07:19:08 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-01 07:19:08 +0000 |
commit | 0439c190fe62b22fc1407c780193eea762d97ce0 (patch) | |
tree | dcc3d6167809b15fa514b73f3fd2739161d0cd3b /components | |
parent | 01fd53c5f7cb9fc2e82bab45aacbae3b16c0a413 (diff) | |
download | chromium_src-0439c190fe62b22fc1407c780193eea762d97ce0.zip chromium_src-0439c190fe62b22fc1407c780193eea762d97ce0.tar.gz chromium_src-0439c190fe62b22fc1407c780193eea762d97ce0.tar.bz2 |
components/webdata: Cleanup callback usage in WebDatabaseService.
And also in WebDataServiceBase.
BUG=181277
R=joi@chromium.org
Review URL: https://chromiumcodereview.appspot.com/17760007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209378 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components')
4 files changed, 20 insertions, 16 deletions
diff --git a/components/webdata/common/web_data_service_base.cc b/components/webdata/common/web_data_service_base.cc index 496f723d..169cb63 100644 --- a/components/webdata/common/web_data_service_base.cc +++ b/components/webdata/common/web_data_service_base.cc @@ -62,7 +62,7 @@ bool WebDataServiceBase::IsDatabaseLoaded() { } void WebDataServiceBase::RegisterDBLoadedCallback( - const base::Callback<void(void)>& callback) { + const DBLoadedCallback& callback) { if (!wdbs_.get()) return; wdbs_->RegisterDBLoadedCallback(callback); diff --git a/components/webdata/common/web_data_service_base.h b/components/webdata/common/web_data_service_base.h index 7a2d6bf..3a39622 100644 --- a/components/webdata/common/web_data_service_base.h +++ b/components/webdata/common/web_data_service_base.h @@ -36,6 +36,8 @@ class WEBDATA_EXPORT WebDataServiceBase // TODO(joi): Should we combine this with WebDatabaseService::InitCallback? typedef base::Callback<void(sql::InitStatus)> ProfileErrorCallback; + typedef base::Closure DBLoadedCallback; + // |callback| will only be invoked on error, and only if // |callback.is_null()| evaluates to false. // @@ -72,8 +74,7 @@ class WEBDATA_EXPORT WebDataServiceBase // (following a successful database load), then cleared. // Note: if the database load is already complete, then the callback will NOT // be stored or called. - virtual void RegisterDBLoadedCallback( - const base::Callback<void(void)>& callback); + virtual void RegisterDBLoadedCallback(const DBLoadedCallback& callback); // Returns true if the database load has completetd successfully, and // ShutdownOnUIThread has not yet been called. @@ -95,6 +96,8 @@ class WEBDATA_EXPORT WebDataServiceBase private: ProfileErrorCallback profile_error_callback_; + + DISALLOW_COPY_AND_ASSIGN(WebDataServiceBase); }; #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BASE_H_ diff --git a/components/webdata/common/web_database_service.cc b/components/webdata/common/web_database_service.cc index cd20427..11eb30b 100644 --- a/components/webdata/common/web_database_service.cc +++ b/components/webdata/common/web_database_service.cc @@ -150,12 +150,12 @@ void WebDatabaseService::CancelRequest(WebDataServiceBase::Handle h) { } void WebDatabaseService::RegisterDBLoadedCallback( - const base::Callback<void(void)>& callback) { + const DBLoadedCallback& callback) { loaded_callbacks_.push_back(callback); } void WebDatabaseService::RegisterDBErrorCallback( - const base::Callback<void(sql::InitStatus)>& callback) { + const DBLoadErrorCallback& callback) { error_callbacks_.push_back(callback); } diff --git a/components/webdata/common/web_database_service.h b/components/webdata/common/web_database_service.h index 78b5bef..95ef5e2 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_ |