diff options
author | mattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-04 23:35:44 +0000 |
---|---|---|
committer | mattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-04 23:35:44 +0000 |
commit | 3f2f5f05a2a9afe503e0c4e13a8dad87ab214b14 (patch) | |
tree | 1177d24b6ca5f81de4a0d0ae0b748cd596d5beaf | |
parent | d2981f38a23525812f2030cf68a5ef6259e30fb7 (diff) | |
download | chromium_src-3f2f5f05a2a9afe503e0c4e13a8dad87ab214b14.zip chromium_src-3f2f5f05a2a9afe503e0c4e13a8dad87ab214b14.tar.gz chromium_src-3f2f5f05a2a9afe503e0c4e13a8dad87ab214b14.tar.bz2 |
Use WeakPtrFactory in CookieTreeModel instead of explicit cancellation on destruction.
BUG=121863
TEST=trybots
Review URL: https://chromiumcodereview.appspot.com/9968112
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@130767 0039d316-1c4b-4281-b951-d872f2087c98
31 files changed, 52 insertions, 223 deletions
diff --git a/chrome/browser/browsing_data_appcache_helper.cc b/chrome/browser/browsing_data_appcache_helper.cc index 7417a19..a16ff02 100644 --- a/chrome/browser/browsing_data_appcache_helper.cc +++ b/chrome/browser/browsing_data_appcache_helper.cc @@ -45,18 +45,6 @@ void BrowsingDataAppCacheHelper::StartFetching(const base::Closure& callback) { GetAllAppCacheInfo(info_collection_, appcache_info_callback_.callback()); } -void BrowsingDataAppCacheHelper::CancelNotification() { - if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { - completion_callback_.Reset(); - BrowserThread::PostTask( - BrowserThread::IO, FROM_HERE, - base::Bind(&BrowsingDataAppCacheHelper::CancelNotification, this)); - return; - } - - appcache_info_callback_.Cancel(); -} - void BrowsingDataAppCacheHelper::DeleteAppCacheGroup( const GURL& manifest_url) { if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { @@ -96,10 +84,8 @@ void BrowsingDataAppCacheHelper::OnFetchComplete(int rv) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(is_fetching_); is_fetching_ = false; - if (!completion_callback_.is_null()) { - completion_callback_.Run(); - completion_callback_.Reset(); - } + completion_callback_.Run(); + completion_callback_.Reset(); } CannedBrowsingDataAppCacheHelper::CannedBrowsingDataAppCacheHelper( diff --git a/chrome/browser/browsing_data_appcache_helper.h b/chrome/browser/browsing_data_appcache_helper.h index 07c00c4..668cadd 100644 --- a/chrome/browser/browsing_data_appcache_helper.h +++ b/chrome/browser/browsing_data_appcache_helper.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -26,7 +26,6 @@ class BrowsingDataAppCacheHelper explicit BrowsingDataAppCacheHelper(Profile* profile); virtual void StartFetching(const base::Closure& completion_callback); - virtual void CancelNotification(); virtual void DeleteAppCacheGroup(const GURL& manifest_url); appcache::AppCacheInfoCollection* info_collection() const { @@ -75,7 +74,6 @@ class CannedBrowsingDataAppCacheHelper : public BrowsingDataAppCacheHelper { // BrowsingDataAppCacheHelper methods. virtual void StartFetching(const base::Closure& completion_callback) OVERRIDE; - virtual void CancelNotification() OVERRIDE {} private: virtual ~CannedBrowsingDataAppCacheHelper(); diff --git a/chrome/browser/browsing_data_cookie_helper.cc b/chrome/browser/browsing_data_cookie_helper.cc index c048de1..18054a3 100644 --- a/chrome/browser/browsing_data_cookie_helper.cc +++ b/chrome/browser/browsing_data_cookie_helper.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -38,11 +38,6 @@ void BrowsingDataCookieHelper::StartFetching( base::Bind(&BrowsingDataCookieHelper::FetchCookiesOnIOThread, this)); } -void BrowsingDataCookieHelper::CancelNotification() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - completion_callback_.Reset(); -} - void BrowsingDataCookieHelper::DeleteCookie( const net::CookieMonster::CanonicalCookie& cookie) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -77,10 +72,8 @@ void BrowsingDataCookieHelper::NotifyInUIThread( DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(is_fetching_); is_fetching_ = false; - if (!completion_callback_.is_null()) { - completion_callback_.Run(cookies); - completion_callback_.Reset(); - } + completion_callback_.Run(cookies); + completion_callback_.Reset(); } void BrowsingDataCookieHelper::DeleteCookieOnIOThread( @@ -158,12 +151,9 @@ bool CannedBrowsingDataCookieHelper::empty() const { void CannedBrowsingDataCookieHelper::StartFetching( const net::CookieMonster::GetCookieListCallback& callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (!callback.is_null()) - callback.Run(cookie_list_); + callback.Run(cookie_list_); } -void CannedBrowsingDataCookieHelper::CancelNotification() {} - bool CannedBrowsingDataCookieHelper::DeleteMetchingCookie( const net::CookieMonster::CanonicalCookie& add_cookie) { typedef net::CookieList::iterator cookie_iterator; diff --git a/chrome/browser/browsing_data_cookie_helper.h b/chrome/browser/browsing_data_cookie_helper.h index 51c230a..2ef0512 100644 --- a/chrome/browser/browsing_data_cookie_helper.h +++ b/chrome/browser/browsing_data_cookie_helper.h @@ -25,8 +25,6 @@ class URLRequestContextGetter; // A client of this class need to call StartFetching from the UI thread to // initiate the flow, and it'll be notified by the callback in its UI // thread at some later point. -// The client must call CancelNotification() if it's destroyed before the -// callback is notified. class BrowsingDataCookieHelper : public base::RefCountedThreadSafe<BrowsingDataCookieHelper> { public: @@ -38,11 +36,6 @@ class BrowsingDataCookieHelper virtual void StartFetching( const base::Callback<void(const net::CookieList& cookies)>& callback); - // Cancels the notification callback (i.e., the window that created it no - // longer exists). - // This must be called only in the UI thread. - virtual void CancelNotification(); - // Requests a single cookie to be deleted in the IO thread. This must be // called in the UI thread. virtual void DeleteCookie(const net::CookieMonster::CanonicalCookie& cookie); @@ -113,7 +106,6 @@ class CannedBrowsingDataCookieHelper : public BrowsingDataCookieHelper { // BrowsingDataCookieHelper methods. virtual void StartFetching( const net::CookieMonster::GetCookieListCallback& callback) OVERRIDE; - virtual void CancelNotification() OVERRIDE; private: // Check if the cookie list contains a cookie with the same name, diff --git a/chrome/browser/browsing_data_database_helper.cc b/chrome/browser/browsing_data_database_helper.cc index ccd89e1..b64c024 100644 --- a/chrome/browser/browsing_data_database_helper.cc +++ b/chrome/browser/browsing_data_database_helper.cc @@ -68,11 +68,6 @@ void BrowsingDataDatabaseHelper::StartFetching( this)); } -void BrowsingDataDatabaseHelper::CancelNotification() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - completion_callback_.Reset(); -} - void BrowsingDataDatabaseHelper::DeleteDatabase(const std::string& origin, const std::string& name) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -124,12 +119,8 @@ void BrowsingDataDatabaseHelper::FetchDatabaseInfoOnFileThread() { void BrowsingDataDatabaseHelper::NotifyInUIThread() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(is_fetching_); - // Note: completion_callback_ mutates only in the UI thread, so it's safe to - // test it here. - if (!completion_callback_.is_null()) { - completion_callback_.Run(database_info_); - completion_callback_.Reset(); - } + completion_callback_.Run(database_info_); + completion_callback_.Reset(); is_fetching_ = false; database_info_.clear(); } diff --git a/chrome/browser/browsing_data_database_helper.h b/chrome/browser/browsing_data_database_helper.h index e348b06..a8b5937 100644 --- a/chrome/browser/browsing_data_database_helper.h +++ b/chrome/browser/browsing_data_database_helper.h @@ -24,8 +24,6 @@ class Profile; // A client of this class need to call StartFetching from the UI thread to // initiate the flow, and it'll be notified by the callback in its UI // thread at some later point. -// The client must call CancelNotification() if it's destroyed before the -// callback is notified. class BrowsingDataDatabaseHelper : public base::RefCountedThreadSafe<BrowsingDataDatabaseHelper> { public: @@ -58,11 +56,6 @@ class BrowsingDataDatabaseHelper virtual void StartFetching( const base::Callback<void(const std::list<DatabaseInfo>&)>& callback); - // Cancels the notification callback (i.e., the window that created it no - // longer exists). - // This must be called only in the UI thread. - virtual void CancelNotification(); - // Requests a single database to be deleted in the FILE thread. This must be // called in the UI thread. virtual void DeleteDatabase(const std::string& origin, diff --git a/chrome/browser/browsing_data_file_system_helper.cc b/chrome/browser/browsing_data_file_system_helper.cc index 417ce0ca..90f9f75 100644 --- a/chrome/browser/browsing_data_file_system_helper.cc +++ b/chrome/browser/browsing_data_file_system_helper.cc @@ -33,7 +33,6 @@ class BrowsingDataFileSystemHelperImpl : public BrowsingDataFileSystemHelper { explicit BrowsingDataFileSystemHelperImpl(Profile* profile); virtual void StartFetching(const base::Callback< void(const std::list<FileSystemInfo>&)>& callback) OVERRIDE; - virtual void CancelNotification() OVERRIDE; virtual void DeleteFileSystemOrigin(const GURL& origin) OVERRIDE; private: @@ -97,11 +96,6 @@ void BrowsingDataFileSystemHelperImpl::StartFetching( this)); } -void BrowsingDataFileSystemHelperImpl::CancelNotification() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - completion_callback_.Reset(); -} - void BrowsingDataFileSystemHelperImpl::DeleteFileSystemOrigin( const GURL& origin) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -155,12 +149,8 @@ void BrowsingDataFileSystemHelperImpl::FetchFileSystemInfoInFileThread() { void BrowsingDataFileSystemHelperImpl::NotifyOnUIThread() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(is_fetching_); - // completion_callback_ mutates only in the UI thread, so we're safe to test - // it here. - if (!completion_callback_.is_null()) { - completion_callback_.Run(file_system_info_); - completion_callback_.Reset(); - } + completion_callback_.Run(file_system_info_); + completion_callback_.Reset(); is_fetching_ = false; } @@ -278,14 +268,7 @@ void CannedBrowsingDataFileSystemHelper::StartFetching( void CannedBrowsingDataFileSystemHelper::NotifyOnUIThread() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(is_fetching_); - if (!completion_callback_.is_null()) { - completion_callback_.Run(file_system_info_); - completion_callback_.Reset(); - } - is_fetching_ = false; -} - -void CannedBrowsingDataFileSystemHelper::CancelNotification() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + completion_callback_.Run(file_system_info_); completion_callback_.Reset(); + is_fetching_ = false; } diff --git a/chrome/browser/browsing_data_file_system_helper.h b/chrome/browser/browsing_data_file_system_helper.h index e00db12..9e3e544 100644 --- a/chrome/browser/browsing_data_file_system_helper.h +++ b/chrome/browser/browsing_data_file_system_helper.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -29,9 +29,7 @@ class Profile; // system data when a client calls StartFetching from the UI thread, and will // notify the client via a supplied callback when the data is available. // Only one StartFetching task can run at a time: executing StartFetching while -// another StartFetching task is running will DCHECK. If the client must abort -// the process before completion (it's destroyed, for example) then it must call -// CancelNotification. +// another StartFetching task is running will DCHECK. // // The client's callback is passed a list of FileSystemInfo objects containing // usage information for each origin's temporary and persistent file systems. @@ -86,11 +84,6 @@ class BrowsingDataFileSystemHelper virtual void StartFetching(const base::Callback< void(const std::list<FileSystemInfo>&)>& callback) = 0; - // Cancels the notification callback associated with StartFetching. Clients - // that are destroyed before the callback is triggered must call this, and - // it must be called only on the UI thread. - virtual void CancelNotification() = 0; - // Deletes any temporary or persistent file systems associated with |origin| // from the disk. Deletion will occur asynchronously on the FILE thread, but // this function must be called only on the UI thread. @@ -140,7 +133,6 @@ class CannedBrowsingDataFileSystemHelper // BrowsingDataFileSystemHelper implementation. virtual void StartFetching(const base::Callback< void(const std::list<FileSystemInfo>&)>& callback) OVERRIDE; - virtual void CancelNotification() OVERRIDE; // Note that this doesn't actually have an implementation for this canned // class. It hasn't been necessary for anything that uses the canned diff --git a/chrome/browser/browsing_data_indexed_db_helper.cc b/chrome/browser/browsing_data_indexed_db_helper.cc index 5794a62..c18db05 100644 --- a/chrome/browser/browsing_data_indexed_db_helper.cc +++ b/chrome/browser/browsing_data_indexed_db_helper.cc @@ -33,7 +33,6 @@ class BrowsingDataIndexedDBHelperImpl : public BrowsingDataIndexedDBHelper { virtual void StartFetching( const base::Callback<void(const std::list<IndexedDBInfo>&)>& callback) OVERRIDE; - virtual void CancelNotification() OVERRIDE; virtual void DeleteIndexedDB(const GURL& origin) OVERRIDE; private: @@ -88,11 +87,6 @@ void BrowsingDataIndexedDBHelperImpl::StartFetching( this)); } -void BrowsingDataIndexedDBHelperImpl::CancelNotification() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - completion_callback_.Reset(); -} - void BrowsingDataIndexedDBHelperImpl::DeleteIndexedDB( const GURL& origin) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -126,12 +120,8 @@ void BrowsingDataIndexedDBHelperImpl::FetchIndexedDBInfoInWebKitThread() { void BrowsingDataIndexedDBHelperImpl::NotifyInUIThread() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(is_fetching_); - // Note: completion_callback_ mutates only in the UI thread, so it's safe to - // test it here. - if (!completion_callback_.is_null()) { - completion_callback_.Run(indexed_db_info_); - completion_callback_.Reset(); - } + completion_callback_.Run(indexed_db_info_); + completion_callback_.Reset(); is_fetching_ = false; } @@ -260,16 +250,7 @@ void CannedBrowsingDataIndexedDBHelper::NotifyInUIThread() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(is_fetching_); - // Completion_callback_ mutates only in the UI thread, so it's safe to test it - // here. - if (!completion_callback_.is_null()) { - completion_callback_.Run(indexed_db_info_); - completion_callback_.Reset(); - } - is_fetching_ = false; -} - -void CannedBrowsingDataIndexedDBHelper::CancelNotification() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + completion_callback_.Run(indexed_db_info_); completion_callback_.Reset(); + is_fetching_ = false; } diff --git a/chrome/browser/browsing_data_indexed_db_helper.h b/chrome/browser/browsing_data_indexed_db_helper.h index 5916b40..3c73d9f 100644 --- a/chrome/browser/browsing_data_indexed_db_helper.h +++ b/chrome/browser/browsing_data_indexed_db_helper.h @@ -25,8 +25,7 @@ class Profile; // aggregating and deleting browsing data stored in indexed databases. A // client of this class need to call StartFetching from the UI thread to // initiate the flow, and it'll be notified by the callback in its UI thread at -// some later point. The client must call CancelNotification() if it's -// destroyed before the callback is notified. +// some later point. class BrowsingDataIndexedDBHelper : public base::RefCountedThreadSafe<BrowsingDataIndexedDBHelper> { public: @@ -53,10 +52,6 @@ class BrowsingDataIndexedDBHelper virtual void StartFetching( const base::Callback<void(const std::list<IndexedDBInfo>&)>& callback) = 0; - // Cancels the notification callback (i.e., the window that created it no - // longer exists). - // This must be called only in the UI thread. - virtual void CancelNotification() = 0; // Requests a single indexed database to be deleted in the WEBKIT thread. virtual void DeleteIndexedDB(const GURL& origin) = 0; @@ -93,7 +88,6 @@ class CannedBrowsingDataIndexedDBHelper virtual void StartFetching( const base::Callback<void(const std::list<IndexedDBInfo>&)>& callback) OVERRIDE; - virtual void CancelNotification() OVERRIDE; virtual void DeleteIndexedDB(const GURL& origin) OVERRIDE {} private: diff --git a/chrome/browser/browsing_data_local_storage_helper.cc b/chrome/browser/browsing_data_local_storage_helper.cc index 43bc237..13b5ea8 100644 --- a/chrome/browser/browsing_data_local_storage_helper.cc +++ b/chrome/browser/browsing_data_local_storage_helper.cc @@ -72,11 +72,6 @@ void BrowsingDataLocalStorageHelper::StartFetching( &BrowsingDataLocalStorageHelper::GetAllStorageFilesCallback, this)); } -void BrowsingDataLocalStorageHelper::CancelNotification() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - completion_callback_.Reset(); -} - void BrowsingDataLocalStorageHelper::DeleteLocalStorageFile( const FilePath& file_path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -130,10 +125,8 @@ void BrowsingDataLocalStorageHelper::NotifyInUIThread() { DCHECK(is_fetching_); // Note: completion_callback_ mutates only in the UI thread, so it's safe to // test it here. - if (!completion_callback_.is_null()) { - completion_callback_.Run(local_storage_info_); - completion_callback_.Reset(); - } + completion_callback_.Run(local_storage_info_); + completion_callback_.Reset(); is_fetching_ = false; } diff --git a/chrome/browser/browsing_data_local_storage_helper.h b/chrome/browser/browsing_data_local_storage_helper.h index 4b4ea3c..3924a47 100644 --- a/chrome/browser/browsing_data_local_storage_helper.h +++ b/chrome/browser/browsing_data_local_storage_helper.h @@ -30,8 +30,6 @@ class DOMStorageContext; // A client of this class need to call StartFetching from the UI thread to // initiate the flow, and it'll be notified by the callback in its UI // thread at some later point. -// The client must call CancelNotification() if it's destroyed before the -// callback is notified. class BrowsingDataLocalStorageHelper : public base::RefCountedThreadSafe<BrowsingDataLocalStorageHelper> { public: @@ -66,10 +64,6 @@ class BrowsingDataLocalStorageHelper // This must be called only in the UI thread. virtual void StartFetching( const base::Callback<void(const std::list<LocalStorageInfo>&)>& callback); - // Cancels the notification callback (i.e., the window that created it no - // longer exists). - // This must be called only in the UI thread. - virtual void CancelNotification(); // Requests a single local storage file to be deleted in the WEBKIT thread. virtual void DeleteLocalStorageFile(const FilePath& file_path); diff --git a/chrome/browser/browsing_data_quota_helper.h b/chrome/browser/browsing_data_quota_helper.h index b330bee..9d4d9fc 100644 --- a/chrome/browser/browsing_data_quota_helper.h +++ b/chrome/browser/browsing_data_quota_helper.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -29,8 +29,7 @@ struct BrowsingDataQuotaHelperDeleter { // through the instance. // // Call Create to create an instance for a profile and call StartFetching with -// a callback to fetch information asynchronously. If result is no longer needed -// after StartFetching, call CancelNotification to prevent callback. +// a callback to fetch information asynchronously. // // Parallel fetching is not allowed, a fetching task should start after end of // previous task. All method of this class should called from UI thread. @@ -65,7 +64,6 @@ class BrowsingDataQuotaHelper static BrowsingDataQuotaHelper* Create(Profile* profile); virtual void StartFetching(const FetchResultCallback& callback) = 0; - virtual void CancelNotification() = 0; virtual void RevokeHostQuota(const std::string& host) = 0; diff --git a/chrome/browser/browsing_data_quota_helper_impl.cc b/chrome/browser/browsing_data_quota_helper_impl.cc index ed8bb71..12d88f0 100644 --- a/chrome/browser/browsing_data_quota_helper_impl.cc +++ b/chrome/browser/browsing_data_quota_helper_impl.cc @@ -36,10 +36,6 @@ void BrowsingDataQuotaHelperImpl::StartFetching( FetchQuotaInfo(); } -void BrowsingDataQuotaHelperImpl::CancelNotification() { - callback_.Reset(); -} - void BrowsingDataQuotaHelperImpl::RevokeHostQuota(const std::string& host) { if (!io_thread_->BelongsToCurrentThread()) { io_thread_->PostTask( @@ -146,10 +142,6 @@ void BrowsingDataQuotaHelperImpl::GotHostUsage(const std::string& host, } void BrowsingDataQuotaHelperImpl::OnComplete() { - // Check if CancelNotification was called - if (callback_.is_null()) - return; - if (!ui_thread_->BelongsToCurrentThread()) { ui_thread_->PostTask( FROM_HERE, diff --git a/chrome/browser/browsing_data_quota_helper_impl.h b/chrome/browser/browsing_data_quota_helper_impl.h index 26071b9..5e857a7 100644 --- a/chrome/browser/browsing_data_quota_helper_impl.h +++ b/chrome/browser/browsing_data_quota_helper_impl.h @@ -30,7 +30,6 @@ class QuotaManager; class BrowsingDataQuotaHelperImpl : public BrowsingDataQuotaHelper { public: virtual void StartFetching(const FetchResultCallback& callback) OVERRIDE; - virtual void CancelNotification() OVERRIDE; virtual void RevokeHostQuota(const std::string& host) OVERRIDE; private: diff --git a/chrome/browser/cookies_tree_model.cc b/chrome/browser/cookies_tree_model.cc index ccb75bf..211f110 100644 --- a/chrome/browser/cookies_tree_model.cc +++ b/chrome/browser/cookies_tree_model.cc @@ -9,7 +9,6 @@ #include <vector> #include "base/bind.h" -#include "base/bind_helpers.h" #include "base/memory/linked_ptr.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" @@ -626,23 +625,24 @@ CookiesTreeModel::CookiesTreeModel( file_system_helper_(file_system_helper), quota_helper_(quota_helper), batch_update_(0), - use_cookie_source_(use_cookie_source) { + use_cookie_source_(use_cookie_source), + ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { DCHECK(cookie_helper_); cookie_helper_->StartFetching( base::Bind(&CookiesTreeModel::OnCookiesModelInfoLoaded, - base::Unretained(this))); + weak_ptr_factory_.GetWeakPtr())); DCHECK(database_helper_); database_helper_->StartFetching( base::Bind(&CookiesTreeModel::OnDatabaseModelInfoLoaded, - base::Unretained(this))); + weak_ptr_factory_.GetWeakPtr())); DCHECK(local_storage_helper_); local_storage_helper_->StartFetching( base::Bind(&CookiesTreeModel::OnLocalStorageModelInfoLoaded, - base::Unretained(this))); + weak_ptr_factory_.GetWeakPtr())); if (session_storage_helper_) { session_storage_helper_->StartFetching( base::Bind(&CookiesTreeModel::OnSessionStorageModelInfoLoaded, - base::Unretained(this))); + weak_ptr_factory_.GetWeakPtr())); } // TODO(michaeln): When all of the UI implementations have been updated, make @@ -650,43 +650,29 @@ CookiesTreeModel::CookiesTreeModel( if (appcache_helper_) { appcache_helper_->StartFetching( base::Bind(&CookiesTreeModel::OnAppCacheModelInfoLoaded, - base::Unretained(this))); + weak_ptr_factory_.GetWeakPtr())); } if (indexed_db_helper_) { indexed_db_helper_->StartFetching( base::Bind(&CookiesTreeModel::OnIndexedDBModelInfoLoaded, - base::Unretained(this))); + weak_ptr_factory_.GetWeakPtr())); } if (file_system_helper_) { file_system_helper_->StartFetching( base::Bind(&CookiesTreeModel::OnFileSystemModelInfoLoaded, - base::Unretained(this))); + weak_ptr_factory_.GetWeakPtr())); } if (quota_helper_) { quota_helper_->StartFetching( base::Bind(&CookiesTreeModel::OnQuotaModelInfoLoaded, - base::Unretained(this))); + weak_ptr_factory_.GetWeakPtr())); } } -CookiesTreeModel::~CookiesTreeModel() { - cookie_helper_->CancelNotification(); - database_helper_->CancelNotification(); - local_storage_helper_->CancelNotification(); - if (session_storage_helper_) - session_storage_helper_->CancelNotification(); - if (appcache_helper_) - appcache_helper_->CancelNotification(); - if (indexed_db_helper_) - indexed_db_helper_->CancelNotification(); - if (file_system_helper_) - file_system_helper_->CancelNotification(); - if (quota_helper_) - quota_helper_->CancelNotification(); -} +CookiesTreeModel::~CookiesTreeModel() {} /////////////////////////////////////////////////////////////////////////////// // CookiesTreeModel, TreeModel methods (public): diff --git a/chrome/browser/cookies_tree_model.h b/chrome/browser/cookies_tree_model.h index 2d71374..4ed0462 100644 --- a/chrome/browser/cookies_tree_model.h +++ b/chrome/browser/cookies_tree_model.h @@ -14,6 +14,7 @@ #include <vector> #include "base/memory/ref_counted.h" +#include "base/memory/weak_ptr.h" #include "base/observer_list.h" #include "base/string16.h" #include "base/utf_string_conversions.h" @@ -669,6 +670,8 @@ class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> { // Otherwise, use the CanonicalCookie::Domain attribute. bool use_cookie_source_; + base::WeakPtrFactory<CookiesTreeModel> weak_ptr_factory_; + friend class CookieTreeAppCacheNode; friend class CookieTreeCookieNode; friend class CookieTreeDatabaseNode; diff --git a/chrome/browser/mock_browsing_data_appcache_helper.cc b/chrome/browser/mock_browsing_data_appcache_helper.cc index 6d1b6db..2c124b1 100644 --- a/chrome/browser/mock_browsing_data_appcache_helper.cc +++ b/chrome/browser/mock_browsing_data_appcache_helper.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -19,10 +19,6 @@ void MockBrowsingDataAppCacheHelper::StartFetching( completion_callback_ = completion_callback; } -void MockBrowsingDataAppCacheHelper::CancelNotification() { - completion_callback_.Reset(); -} - void MockBrowsingDataAppCacheHelper::DeleteAppCacheGroup( const GURL& manifest_url) { } diff --git a/chrome/browser/mock_browsing_data_appcache_helper.h b/chrome/browser/mock_browsing_data_appcache_helper.h index 15b0b4d..daf834b 100644 --- a/chrome/browser/mock_browsing_data_appcache_helper.h +++ b/chrome/browser/mock_browsing_data_appcache_helper.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -15,7 +15,6 @@ class MockBrowsingDataAppCacheHelper explicit MockBrowsingDataAppCacheHelper(Profile* profile); virtual void StartFetching(const base::Closure& completion_callback) OVERRIDE; - virtual void CancelNotification() OVERRIDE; virtual void DeleteAppCacheGroup(const GURL& manifest_url) OVERRIDE; private: diff --git a/chrome/browser/mock_browsing_data_cookie_helper.cc b/chrome/browser/mock_browsing_data_cookie_helper.cc index be897b5..0d526c9 100644 --- a/chrome/browser/mock_browsing_data_cookie_helper.cc +++ b/chrome/browser/mock_browsing_data_cookie_helper.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -19,10 +19,6 @@ void MockBrowsingDataCookieHelper::StartFetching( callback_ = callback; } -void MockBrowsingDataCookieHelper::CancelNotification() { - callback_.Reset(); -} - void MockBrowsingDataCookieHelper::DeleteCookie( const net::CookieMonster::CanonicalCookie& cookie) { std::string key = cookie.Name() + "=" + cookie.Value(); diff --git a/chrome/browser/mock_browsing_data_cookie_helper.h b/chrome/browser/mock_browsing_data_cookie_helper.h index 2eb05e7..d88de69 100644 --- a/chrome/browser/mock_browsing_data_cookie_helper.h +++ b/chrome/browser/mock_browsing_data_cookie_helper.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -19,7 +19,6 @@ class MockBrowsingDataCookieHelper : public BrowsingDataCookieHelper { // BrowsingDataCookieHelper methods. virtual void StartFetching( const net::CookieMonster::GetCookieListCallback &callback) OVERRIDE; - virtual void CancelNotification() OVERRIDE; virtual void DeleteCookie( const net::CookieMonster::CanonicalCookie& cookie) OVERRIDE; diff --git a/chrome/browser/mock_browsing_data_database_helper.cc b/chrome/browser/mock_browsing_data_database_helper.cc index 3f8a82a..4e8024e4 100644 --- a/chrome/browser/mock_browsing_data_database_helper.cc +++ b/chrome/browser/mock_browsing_data_database_helper.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -20,10 +20,6 @@ void MockBrowsingDataDatabaseHelper::StartFetching( callback_ = callback; } -void MockBrowsingDataDatabaseHelper::CancelNotification() { - callback_.Reset(); -} - void MockBrowsingDataDatabaseHelper::DeleteDatabase( const std::string& origin, const std::string& name) { diff --git a/chrome/browser/mock_browsing_data_database_helper.h b/chrome/browser/mock_browsing_data_database_helper.h index 72f33e0..655bf00 100644 --- a/chrome/browser/mock_browsing_data_database_helper.h +++ b/chrome/browser/mock_browsing_data_database_helper.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -23,8 +23,6 @@ class MockBrowsingDataDatabaseHelper : public BrowsingDataDatabaseHelper { const base::Callback<void(const std::list<DatabaseInfo>&)>& callback) OVERRIDE; - virtual void CancelNotification() OVERRIDE; - virtual void DeleteDatabase(const std::string& origin, const std::string& name) OVERRIDE; diff --git a/chrome/browser/mock_browsing_data_file_system_helper.cc b/chrome/browser/mock_browsing_data_file_system_helper.cc index 3ecc344..a73d5bc 100644 --- a/chrome/browser/mock_browsing_data_file_system_helper.cc +++ b/chrome/browser/mock_browsing_data_file_system_helper.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -19,10 +19,6 @@ void MockBrowsingDataFileSystemHelper::StartFetching( callback_ = callback; } -void MockBrowsingDataFileSystemHelper::CancelNotification() { - callback_.Reset(); -} - void MockBrowsingDataFileSystemHelper::DeleteFileSystemOrigin( const GURL& origin) { std::string key = origin.spec(); diff --git a/chrome/browser/mock_browsing_data_file_system_helper.h b/chrome/browser/mock_browsing_data_file_system_helper.h index 15dac27..1741d13 100644 --- a/chrome/browser/mock_browsing_data_file_system_helper.h +++ b/chrome/browser/mock_browsing_data_file_system_helper.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -24,7 +24,6 @@ class MockBrowsingDataFileSystemHelper : public BrowsingDataFileSystemHelper { // BrowsingDataFileSystemHelper implementation. virtual void StartFetching(const base::Callback< void(const std::list<FileSystemInfo>&)>& callback) OVERRIDE; - virtual void CancelNotification() OVERRIDE; virtual void DeleteFileSystemOrigin(const GURL& origin) OVERRIDE; // Adds a specific filesystem. diff --git a/chrome/browser/mock_browsing_data_indexed_db_helper.cc b/chrome/browser/mock_browsing_data_indexed_db_helper.cc index 91894f2..3cc77c9 100644 --- a/chrome/browser/mock_browsing_data_indexed_db_helper.cc +++ b/chrome/browser/mock_browsing_data_indexed_db_helper.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -18,10 +18,6 @@ void MockBrowsingDataIndexedDBHelper::StartFetching( callback_ = callback; } -void MockBrowsingDataIndexedDBHelper::CancelNotification() { - callback_.Reset(); -} - void MockBrowsingDataIndexedDBHelper::DeleteIndexedDB( const GURL& origin) { CHECK(origins_.find(origin) != origins_.end()); diff --git a/chrome/browser/mock_browsing_data_indexed_db_helper.h b/chrome/browser/mock_browsing_data_indexed_db_helper.h index f4b9dea..29bb275 100644 --- a/chrome/browser/mock_browsing_data_indexed_db_helper.h +++ b/chrome/browser/mock_browsing_data_indexed_db_helper.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -39,7 +39,6 @@ class MockBrowsingDataIndexedDBHelper virtual void StartFetching( const base::Callback<void(const std::list<IndexedDBInfo>&)>& callback) OVERRIDE; - virtual void CancelNotification() OVERRIDE; virtual void DeleteIndexedDB(const GURL& origin) OVERRIDE; private: diff --git a/chrome/browser/mock_browsing_data_local_storage_helper.cc b/chrome/browser/mock_browsing_data_local_storage_helper.cc index 7f22368..c52259a 100644 --- a/chrome/browser/mock_browsing_data_local_storage_helper.cc +++ b/chrome/browser/mock_browsing_data_local_storage_helper.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -21,10 +21,6 @@ void MockBrowsingDataLocalStorageHelper::StartFetching( callback_ = callback; } -void MockBrowsingDataLocalStorageHelper::CancelNotification() { - callback_.Reset(); -} - void MockBrowsingDataLocalStorageHelper::DeleteLocalStorageFile( const FilePath& file_path) { CHECK(files_.find(file_path.value()) != files_.end()); diff --git a/chrome/browser/mock_browsing_data_local_storage_helper.h b/chrome/browser/mock_browsing_data_local_storage_helper.h index dbc6a4a..f2ba04d 100644 --- a/chrome/browser/mock_browsing_data_local_storage_helper.h +++ b/chrome/browser/mock_browsing_data_local_storage_helper.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -25,7 +25,6 @@ class MockBrowsingDataLocalStorageHelper virtual void StartFetching( const base::Callback<void(const std::list<LocalStorageInfo>&)>& callback) OVERRIDE; - virtual void CancelNotification() OVERRIDE; virtual void DeleteLocalStorageFile(const FilePath& file_path) OVERRIDE; // Adds some LocalStorageInfo samples. diff --git a/chrome/browser/mock_browsing_data_quota_helper.cc b/chrome/browser/mock_browsing_data_quota_helper.cc index 82d879c..5dd50b1 100644 --- a/chrome/browser/mock_browsing_data_quota_helper.cc +++ b/chrome/browser/mock_browsing_data_quota_helper.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -17,10 +17,6 @@ void MockBrowsingDataQuotaHelper::StartFetching( callback_ = callback; } -void MockBrowsingDataQuotaHelper::CancelNotification() { - callback_.Reset(); -} - void MockBrowsingDataQuotaHelper::RevokeHostQuota(const std::string& host) { } diff --git a/chrome/browser/mock_browsing_data_quota_helper.h b/chrome/browser/mock_browsing_data_quota_helper.h index 10dd05e..1981474 100644 --- a/chrome/browser/mock_browsing_data_quota_helper.h +++ b/chrome/browser/mock_browsing_data_quota_helper.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -17,7 +17,6 @@ class MockBrowsingDataQuotaHelper : public BrowsingDataQuotaHelper { explicit MockBrowsingDataQuotaHelper(Profile* profile); virtual void StartFetching(const FetchResultCallback& callback) OVERRIDE; - virtual void CancelNotification() OVERRIDE; virtual void RevokeHostQuota(const std::string& host) OVERRIDE; void AddHost(const std::string& host, |