diff options
author | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-18 00:12:30 +0000 |
---|---|---|
committer | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-18 00:12:30 +0000 |
commit | 713be8bc9bc902ced8489f1436ac729ddab3b5a6 (patch) | |
tree | 68965ae2a26c4ce39971eef2c8333d06a90aee6d /chrome | |
parent | 96d1526ce642e52f7e889ec673c0bbfbf2e04ed7 (diff) | |
download | chromium_src-713be8bc9bc902ced8489f1436ac729ddab3b5a6.zip chromium_src-713be8bc9bc902ced8489f1436ac729ddab3b5a6.tar.gz chromium_src-713be8bc9bc902ced8489f1436ac729ddab3b5a6.tar.bz2 |
When deleting storage through the cookies tree model, also update its cache
BUG=43249
TEST=CookiesTreeModelTest.RemoveAll
Review URL: http://codereview.chromium.org/7676002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97245 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
28 files changed, 316 insertions, 249 deletions
diff --git a/chrome/browser/browsing_data_database_helper.cc b/chrome/browser/browsing_data_database_helper.cc index 437f5e9..b836a44 100644 --- a/chrome/browser/browsing_data_database_helper.cc +++ b/chrome/browser/browsing_data_database_helper.cc @@ -56,7 +56,7 @@ BrowsingDataDatabaseHelper::~BrowsingDataDatabaseHelper() { } void BrowsingDataDatabaseHelper::StartFetching( - Callback1<const std::vector<DatabaseInfo>& >::Type* callback) { + Callback1<const std::list<DatabaseInfo>& >::Type* callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!is_fetching_); DCHECK(callback); @@ -193,7 +193,7 @@ bool CannedBrowsingDataDatabaseHelper::empty() const { } void CannedBrowsingDataDatabaseHelper::StartFetching( - Callback1<const std::vector<DatabaseInfo>& >::Type* callback) { + Callback1<const std::list<DatabaseInfo>& >::Type* callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!is_fetching_); DCHECK(callback); @@ -207,7 +207,7 @@ CannedBrowsingDataDatabaseHelper::~CannedBrowsingDataDatabaseHelper() {} void CannedBrowsingDataDatabaseHelper::ConvertInfoInWebKitThread() { base::AutoLock auto_lock(lock_); - for (std::vector<PendingDatabaseInfo>::const_iterator + for (std::list<PendingDatabaseInfo>::const_iterator info = pending_database_info_.begin(); info != pending_database_info_.end(); ++info) { WebSecurityOrigin web_security_origin = @@ -217,7 +217,7 @@ void CannedBrowsingDataDatabaseHelper::ConvertInfoInWebKitThread() { web_security_origin.databaseIdentifier().utf8(); bool duplicate = false; - for (std::vector<DatabaseInfo>::iterator database = database_info_.begin(); + for (std::list<DatabaseInfo>::iterator database = database_info_.begin(); database != database_info_.end(); ++database) { if (database->origin_identifier == origin_identifier && database->database_name == info->name) { diff --git a/chrome/browser/browsing_data_database_helper.h b/chrome/browser/browsing_data_database_helper.h index 6bf57eb..62cc2d9 100644 --- a/chrome/browser/browsing_data_database_helper.h +++ b/chrome/browser/browsing_data_database_helper.h @@ -6,8 +6,8 @@ #define CHROME_BROWSER_BROWSING_DATA_DATABASE_HELPER_H_ #pragma once +#include <list> #include <string> -#include <vector> #include "base/callback.h" #include "base/memory/scoped_ptr.h" @@ -57,7 +57,7 @@ class BrowsingDataDatabaseHelper // callback. // This must be called only in the UI thread. virtual void StartFetching( - Callback1<const std::vector<DatabaseInfo>& >::Type* callback); + Callback1<const std::list<DatabaseInfo>& >::Type* callback); // Cancels the notification callback (i.e., the window that created it no // longer exists). @@ -77,10 +77,10 @@ class BrowsingDataDatabaseHelper void NotifyInUIThread(); // This only mutates in the FILE thread. - std::vector<DatabaseInfo> database_info_; + std::list<DatabaseInfo> database_info_; // This only mutates on the UI thread. - scoped_ptr<Callback1<const std::vector<DatabaseInfo>& >::Type > + scoped_ptr<Callback1<const std::list<DatabaseInfo>& >::Type > completion_callback_; // Indicates whether or not we're currently fetching information: @@ -128,7 +128,7 @@ class CannedBrowsingDataDatabaseHelper : public BrowsingDataDatabaseHelper { // BrowsingDataDatabaseHelper methods. virtual void StartFetching( - Callback1<const std::vector<DatabaseInfo>& >::Type* callback); + Callback1<const std::list<DatabaseInfo>& >::Type* callback); virtual void CancelNotification() {} private: @@ -153,7 +153,7 @@ class CannedBrowsingDataDatabaseHelper : public BrowsingDataDatabaseHelper { mutable base::Lock lock_; // This may mutate on WEBKIT and UI threads. - std::vector<PendingDatabaseInfo> pending_database_info_; + std::list<PendingDatabaseInfo> pending_database_info_; Profile* profile_; diff --git a/chrome/browser/browsing_data_database_helper_browsertest.cc b/chrome/browser/browsing_data_database_helper_browsertest.cc index 1f33088..36b3205 100644 --- a/chrome/browser/browsing_data_database_helper_browsertest.cc +++ b/chrome/browser/browsing_data_database_helper_browsertest.cc @@ -59,12 +59,12 @@ class StopTestOnCallback { DCHECK(database_helper_); } - void Callback(const std::vector<BrowsingDataDatabaseHelper::DatabaseInfo>& + void Callback(const std::list<BrowsingDataDatabaseHelper::DatabaseInfo>& database_info_list) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); ASSERT_EQ(1UL, database_info_list.size()); EXPECT_EQ(std::string(kTestIdentifier1), - database_info_list.at(0).origin_identifier); + database_info_list.begin()->origin_identifier); MessageLoop::current()->Quit(); } @@ -103,16 +103,20 @@ IN_PROC_BROWSER_TEST_F(BrowsingDataDatabaseHelperTest, CannedAddDatabase) { helper->StartFetching( NewCallback(&callback, &TestCompletionCallback::callback)); - std::vector<BrowsingDataDatabaseHelper::DatabaseInfo> result = + std::list<BrowsingDataDatabaseHelper::DatabaseInfo> result = callback.result(); ASSERT_EQ(3u, result.size()); - EXPECT_STREQ(origin_str1, result[0].origin_identifier.c_str()); - EXPECT_STREQ(db1, result[0].database_name.c_str()); - EXPECT_STREQ(origin_str1, result[1].origin_identifier.c_str()); - EXPECT_STREQ(db2, result[1].database_name.c_str()); - EXPECT_STREQ(origin_str2, result[2].origin_identifier.c_str()); - EXPECT_STREQ(db3, result[2].database_name.c_str()); + std::list<BrowsingDataDatabaseHelper::DatabaseInfo>::iterator info = + result.begin(); + EXPECT_STREQ(origin_str1, info->origin_identifier.c_str()); + EXPECT_STREQ(db1, info->database_name.c_str()); + info++; + EXPECT_STREQ(origin_str1, info->origin_identifier.c_str()); + EXPECT_STREQ(db2, info->database_name.c_str()); + info++; + EXPECT_STREQ(origin_str2, info->origin_identifier.c_str()); + EXPECT_STREQ(db3, info->database_name.c_str()); } IN_PROC_BROWSER_TEST_F(BrowsingDataDatabaseHelperTest, CannedUnique) { @@ -129,11 +133,11 @@ IN_PROC_BROWSER_TEST_F(BrowsingDataDatabaseHelperTest, CannedUnique) { helper->StartFetching( NewCallback(&callback, &TestCompletionCallback::callback)); - std::vector<BrowsingDataDatabaseHelper::DatabaseInfo> result = + std::list<BrowsingDataDatabaseHelper::DatabaseInfo> result = callback.result(); ASSERT_EQ(1u, result.size()); - EXPECT_STREQ(origin_str, result[0].origin_identifier.c_str()); - EXPECT_STREQ(db, result[0].database_name.c_str()); + EXPECT_STREQ(origin_str, result.begin()->origin_identifier.c_str()); + EXPECT_STREQ(db, result.begin()->database_name.c_str()); } } // namespace diff --git a/chrome/browser/browsing_data_file_system_helper.cc b/chrome/browser/browsing_data_file_system_helper.cc index f2870e8..0c16a75 100644 --- a/chrome/browser/browsing_data_file_system_helper.cc +++ b/chrome/browser/browsing_data_file_system_helper.cc @@ -26,7 +26,7 @@ class BrowsingDataFileSystemHelperImpl : public BrowsingDataFileSystemHelper { // BrowsingDataFileSystemHelper implementation explicit BrowsingDataFileSystemHelperImpl(Profile* profile); virtual void StartFetching( - Callback1<const std::vector<FileSystemInfo>& >::Type* callback); + Callback1<const std::list<FileSystemInfo>& >::Type* callback); virtual void CancelNotification(); virtual void DeleteFileSystemOrigin(const GURL& origin); @@ -51,12 +51,12 @@ class BrowsingDataFileSystemHelperImpl : public BrowsingDataFileSystemHelper { // Holds the current list of file systems returned to the client after // StartFetching is called. This only mutates in the FILE thread. - std::vector<FileSystemInfo> file_system_info_; + std::list<FileSystemInfo> file_system_info_; // Holds the callback passed in at the beginning of the StartFetching workflow // so that it can be triggered via NotifyOnUIThread. This only mutates on the // UI thread. - scoped_ptr<Callback1<const std::vector<FileSystemInfo>& >::Type > + scoped_ptr<Callback1<const std::list<FileSystemInfo>& >::Type > completion_callback_; // Indicates whether or not we're currently fetching information: set to true @@ -79,7 +79,7 @@ BrowsingDataFileSystemHelperImpl::~BrowsingDataFileSystemHelperImpl() { } void BrowsingDataFileSystemHelperImpl::StartFetching( - Callback1<const std::vector<FileSystemInfo>& >::Type* callback) { + Callback1<const std::list<FileSystemInfo>& >::Type* callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!is_fetching_); DCHECK(callback); @@ -221,7 +221,7 @@ void CannedBrowsingDataFileSystemHelper::AddFileSystem( // out that we want to start using this in a context with many, many origins, // we should think about reworking the implementation. bool duplicate_origin = false; - for (std::vector<FileSystemInfo>::iterator + for (std::list<FileSystemInfo>::iterator file_system = file_system_info_.begin(); file_system != file_system_info_.end(); ++file_system) { @@ -257,7 +257,7 @@ bool CannedBrowsingDataFileSystemHelper::empty() const { } void CannedBrowsingDataFileSystemHelper::StartFetching( - Callback1<const std::vector<FileSystemInfo>& >::Type* callback) { + Callback1<const std::list<FileSystemInfo>& >::Type* callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!is_fetching_); DCHECK(callback); diff --git a/chrome/browser/browsing_data_file_system_helper.h b/chrome/browser/browsing_data_file_system_helper.h index 4dae0d4..1bfdc26 100644 --- a/chrome/browser/browsing_data_file_system_helper.h +++ b/chrome/browser/browsing_data_file_system_helper.h @@ -6,8 +6,8 @@ #define CHROME_BROWSER_BROWSING_DATA_FILE_SYSTEM_HELPER_H_ #pragma once +#include <list> #include <string> -#include <vector> #include "base/callback_old.h" #include "base/file_path.h" @@ -32,7 +32,7 @@ class Profile; // the process before completion (it's destroyed, for example) then it must call // CancelNotification. // -// The client's callback is passed a vector of FileSystemInfo objects containing +// The client's callback is passed a list of FileSystemInfo objects containing // usage information for each origin's temporary and persistent file systems. // // Clients may remove an origin's file systems at any time (even before fetching @@ -76,14 +76,14 @@ class BrowsingDataFileSystemHelper static BrowsingDataFileSystemHelper* Create(Profile* profile); // Starts the process of fetching file system data, which will call |callback| - // upon completion, passing it a constant vector of FileSystemInfo objects. + // upon completion, passing it a constant list of FileSystemInfo objects. // StartFetching must be called only in the UI thread; the provided Callback1 // will likewise be executed asynchronously on the UI thread. // // BrowsingDataFileSystemHelper takes ownership of the Callback1, and is // responsible for deleting it once it's no longer needed. virtual void StartFetching( - Callback1<const std::vector<FileSystemInfo>& >::Type* callback) = 0; + Callback1<const std::list<FileSystemInfo>& >::Type* callback) = 0; // Cancels the notification callback associated with StartFetching. Clients // that are destroyed before the callback is triggered must call this, and @@ -138,7 +138,7 @@ class CannedBrowsingDataFileSystemHelper // BrowsingDataFileSystemHelper methods. virtual void StartFetching( - Callback1<const std::vector<FileSystemInfo>& >::Type* callback); + Callback1<const std::list<FileSystemInfo>& >::Type* callback); virtual void CancelNotification(); // Note that this doesn't actually have an implementation for this canned @@ -158,11 +158,11 @@ class CannedBrowsingDataFileSystemHelper // Holds the current list of file systems returned to the client after // StartFetching is called. - std::vector<FileSystemInfo> file_system_info_; + std::list<FileSystemInfo> file_system_info_; // Holds the callback passed in at the beginning of the StartFetching workflow // so that it can be triggered via NotifyOnUIThread. - scoped_ptr<Callback1<const std::vector<FileSystemInfo>& >::Type > + scoped_ptr<Callback1<const std::list<FileSystemInfo>& >::Type > completion_callback_; // Indicates whether or not we're currently fetching information: set to true diff --git a/chrome/browser/browsing_data_file_system_helper_unittest.cc b/chrome/browser/browsing_data_file_system_helper_unittest.cc index 2b769d1..12facb2 100644 --- a/chrome/browser/browsing_data_file_system_helper_unittest.cc +++ b/chrome/browser/browsing_data_file_system_helper_unittest.cc @@ -35,9 +35,9 @@ const GURL kOrigin3(kTestOrigin3); // is concluded. const int kEmptyFileSystemSize = 0; -typedef std::vector<BrowsingDataFileSystemHelper::FileSystemInfo> - FileSystemInfoVector; -typedef scoped_ptr<FileSystemInfoVector> ScopedFileSystemInfoVector; +typedef std::list<BrowsingDataFileSystemHelper::FileSystemInfo> + FileSystemInfoList; +typedef scoped_ptr<FileSystemInfoList> ScopedFileSystemInfoList; // The FileSystem APIs are all asynchronous; this testing class wraps up the // boilerplate code necessary to deal with waiting for responses. In a nutshell, @@ -97,10 +97,10 @@ class BrowsingDataFileSystemHelperTest : public TestingBrowserProcessTest { // Callback that should be executed in response to StartFetching(), and stores // found file systems locally so that they are available via GetFileSystems(). void CallbackStartFetching( - const std::vector<BrowsingDataFileSystemHelper::FileSystemInfo>& + const std::list<BrowsingDataFileSystemHelper::FileSystemInfo>& file_system_info_list) { file_system_info_list_.reset( - new std::vector<BrowsingDataFileSystemHelper::FileSystemInfo>( + new std::list<BrowsingDataFileSystemHelper::FileSystemInfo>( file_system_info_list)); Notify(); } @@ -151,14 +151,14 @@ class BrowsingDataFileSystemHelperTest : public TestingBrowserProcessTest { // Returns a list of the FileSystemInfo objects gathered in the most recent // call to StartFetching(). - FileSystemInfoVector* GetFileSystems() { + FileSystemInfoList* GetFileSystems() { return file_system_info_list_.get(); } // Temporary storage to pass information back from callbacks. bool found_file_system_; - ScopedFileSystemInfoVector file_system_info_list_; + ScopedFileSystemInfoList file_system_info_list_; scoped_refptr<BrowsingDataFileSystemHelper> helper_; scoped_refptr<CannedBrowsingDataFileSystemHelper> canned_helper_; @@ -190,32 +190,32 @@ TEST_F(BrowsingDataFileSystemHelperTest, FetchData) { // Order is arbitrary, verify all three origins. bool test_hosts_found[3] = {false, false, false}; - for (size_t i = 0; i < file_system_info_list_->size(); i++) { - BrowsingDataFileSystemHelper::FileSystemInfo info = - file_system_info_list_->at(i); - if (info.origin == kOrigin1) { + for (std::list<BrowsingDataFileSystemHelper::FileSystemInfo>::iterator info = + file_system_info_list_->begin(); info != file_system_info_list_->end(); + ++info) { + if (info->origin == kOrigin1) { EXPECT_FALSE(test_hosts_found[0]); test_hosts_found[0] = true; - EXPECT_FALSE(info.has_persistent); - EXPECT_TRUE(info.has_temporary); - EXPECT_EQ(0, info.usage_persistent); - EXPECT_EQ(kEmptyFileSystemSize, info.usage_temporary); - } else if (info.origin == kOrigin2) { + EXPECT_FALSE(info->has_persistent); + EXPECT_TRUE(info->has_temporary); + EXPECT_EQ(0, info->usage_persistent); + EXPECT_EQ(kEmptyFileSystemSize, info->usage_temporary); + } else if (info->origin == kOrigin2) { EXPECT_FALSE(test_hosts_found[1]); test_hosts_found[1] = true; - EXPECT_TRUE(info.has_persistent); - EXPECT_FALSE(info.has_temporary); - EXPECT_EQ(kEmptyFileSystemSize, info.usage_persistent); - EXPECT_EQ(0, info.usage_temporary); - } else if (info.origin == kOrigin3) { + EXPECT_TRUE(info->has_persistent); + EXPECT_FALSE(info->has_temporary); + EXPECT_EQ(kEmptyFileSystemSize, info->usage_persistent); + EXPECT_EQ(0, info->usage_temporary); + } else if (info->origin == kOrigin3) { EXPECT_FALSE(test_hosts_found[2]); test_hosts_found[2] = true; - EXPECT_TRUE(info.has_persistent); - EXPECT_TRUE(info.has_temporary); - EXPECT_EQ(kEmptyFileSystemSize, info.usage_persistent); - EXPECT_EQ(kEmptyFileSystemSize, info.usage_temporary); + EXPECT_TRUE(info->has_persistent); + EXPECT_TRUE(info->has_temporary); + EXPECT_EQ(kEmptyFileSystemSize, info->usage_persistent); + EXPECT_EQ(kEmptyFileSystemSize, info->usage_temporary); } else { - ADD_FAILURE() << info.origin.spec() << " isn't an origin we added."; + ADD_FAILURE() << info->origin.spec() << " isn't an origin we added."; } } for (size_t i = 0; i < arraysize(test_hosts_found); i++) { @@ -235,7 +235,7 @@ TEST_F(BrowsingDataFileSystemHelperTest, DeleteData) { EXPECT_EQ(1UL, file_system_info_list_->size()); BrowsingDataFileSystemHelper::FileSystemInfo info = - file_system_info_list_->at(0); + *(file_system_info_list_->begin()); EXPECT_EQ(kOrigin3, info.origin); EXPECT_TRUE(info.has_persistent); EXPECT_TRUE(info.has_temporary); @@ -262,16 +262,20 @@ TEST_F(BrowsingDataFileSystemHelperTest, CannedAddFileSystem) { FetchCannedFileSystems(); EXPECT_EQ(2U, file_system_info_list_->size()); - EXPECT_EQ(kOrigin1, file_system_info_list_->at(0).origin); - EXPECT_TRUE(file_system_info_list_->at(0).has_persistent); - EXPECT_FALSE(file_system_info_list_->at(0).has_temporary); - EXPECT_EQ(200, file_system_info_list_->at(0).usage_persistent); - EXPECT_EQ(0, file_system_info_list_->at(0).usage_temporary); - EXPECT_EQ(kOrigin2, file_system_info_list_->at(1).origin); - EXPECT_FALSE(file_system_info_list_->at(1).has_persistent); - EXPECT_TRUE(file_system_info_list_->at(1).has_temporary); - EXPECT_EQ(0, file_system_info_list_->at(1).usage_persistent); - EXPECT_EQ(100, file_system_info_list_->at(1).usage_temporary); + std::list<BrowsingDataFileSystemHelper::FileSystemInfo>::iterator info = + file_system_info_list_->begin(); + EXPECT_EQ(kOrigin1, info->origin); + EXPECT_TRUE(info->has_persistent); + EXPECT_FALSE(info->has_temporary); + EXPECT_EQ(200, info->usage_persistent); + EXPECT_EQ(0, info->usage_temporary); + + info++; + EXPECT_EQ(kOrigin2, info->origin); + EXPECT_FALSE(info->has_persistent); + EXPECT_TRUE(info->has_temporary); + EXPECT_EQ(0, info->usage_persistent); + EXPECT_EQ(100, info->usage_temporary); } } // namespace diff --git a/chrome/browser/browsing_data_helper_browsertest.h b/chrome/browser/browsing_data_helper_browsertest.h index d62db7a2..32c1f69 100644 --- a/chrome/browser/browsing_data_helper_browsertest.h +++ b/chrome/browser/browsing_data_helper_browsertest.h @@ -8,7 +8,7 @@ #define CHROME_BROWSER_BROWSING_DATA_HELPER_BROWSERTEST_H_ #pragma once -#include <vector> +#include <list> #include "base/basictypes.h" #include "base/logging.h" @@ -24,13 +24,13 @@ class BrowsingDataHelperCallback { : has_result_(false) { } - const std::vector<T>& result() { + const std::list<T>& result() { MessageLoop::current()->Run(); DCHECK(has_result_); return result_; } - void callback(const std::vector<T>& info) { + void callback(const std::list<T>& info) { result_ = info; has_result_ = true; MessageLoop::current()->Quit(); @@ -38,7 +38,7 @@ class BrowsingDataHelperCallback { private: bool has_result_; - std::vector<T> result_; + std::list<T> result_; DISALLOW_COPY_AND_ASSIGN(BrowsingDataHelperCallback); }; diff --git a/chrome/browser/browsing_data_indexed_db_helper.cc b/chrome/browser/browsing_data_indexed_db_helper.cc index 85c3dbf..d597d77 100644 --- a/chrome/browser/browsing_data_indexed_db_helper.cc +++ b/chrome/browser/browsing_data_indexed_db_helper.cc @@ -27,7 +27,7 @@ class BrowsingDataIndexedDBHelperImpl : public BrowsingDataIndexedDBHelper { explicit BrowsingDataIndexedDBHelperImpl(Profile* profile); virtual void StartFetching( - Callback1<const std::vector<IndexedDBInfo>& >::Type* callback); + Callback1<const std::list<IndexedDBInfo>& >::Type* callback); virtual void CancelNotification(); virtual void DeleteIndexedDBFile(const FilePath& file_path); @@ -44,10 +44,10 @@ class BrowsingDataIndexedDBHelperImpl : public BrowsingDataIndexedDBHelper { Profile* profile_; // This only mutates in the WEBKIT thread. - std::vector<IndexedDBInfo> indexed_db_info_; + std::list<IndexedDBInfo> indexed_db_info_; // This only mutates on the UI thread. - scoped_ptr<Callback1<const std::vector<IndexedDBInfo>& >::Type > + scoped_ptr<Callback1<const std::list<IndexedDBInfo>& >::Type > completion_callback_; // Indicates whether or not we're currently fetching information: // it's true when StartFetching() is called in the UI thread, and it's reset @@ -70,7 +70,7 @@ BrowsingDataIndexedDBHelperImpl::~BrowsingDataIndexedDBHelperImpl() { } void BrowsingDataIndexedDBHelperImpl::StartFetching( - Callback1<const std::vector<IndexedDBInfo>& >::Type* callback) { + Callback1<const std::list<IndexedDBInfo>& >::Type* callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!is_fetching_); DCHECK(callback); @@ -238,7 +238,7 @@ bool CannedBrowsingDataIndexedDBHelper::empty() const { } void CannedBrowsingDataIndexedDBHelper::StartFetching( - Callback1<const std::vector<IndexedDBInfo>& >::Type* callback) { + Callback1<const std::list<IndexedDBInfo>& >::Type* callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!is_fetching_); DCHECK(callback); @@ -253,7 +253,7 @@ CannedBrowsingDataIndexedDBHelper::~CannedBrowsingDataIndexedDBHelper() {} void CannedBrowsingDataIndexedDBHelper::ConvertPendingInfoInWebKitThread() { base::AutoLock auto_lock(lock_); - for (std::vector<PendingIndexedDBInfo>::const_iterator + for (std::list<PendingIndexedDBInfo>::const_iterator info = pending_indexed_db_info_.begin(); info != pending_indexed_db_info_.end(); ++info) { WebSecurityOrigin web_security_origin = @@ -262,7 +262,7 @@ void CannedBrowsingDataIndexedDBHelper::ConvertPendingInfoInWebKitThread() { std::string security_origin(web_security_origin.toString().utf8()); bool duplicate = false; - for (std::vector<IndexedDBInfo>::iterator + for (std::list<IndexedDBInfo>::iterator indexed_db = indexed_db_info_.begin(); indexed_db != indexed_db_info_.end(); ++indexed_db) { if (indexed_db->origin == security_origin) { diff --git a/chrome/browser/browsing_data_indexed_db_helper.h b/chrome/browser/browsing_data_indexed_db_helper.h index 36254e7..104077d 100644 --- a/chrome/browser/browsing_data_indexed_db_helper.h +++ b/chrome/browser/browsing_data_indexed_db_helper.h @@ -6,8 +6,8 @@ #define CHROME_BROWSER_BROWSING_DATA_INDEXED_DB_HELPER_H_ #pragma once +#include <list> #include <string> -#include <vector> #include "base/callback_old.h" #include "base/file_path.h" @@ -64,7 +64,7 @@ class BrowsingDataIndexedDBHelper // callback. // This must be called only in the UI thread. virtual void StartFetching( - Callback1<const std::vector<IndexedDBInfo>& >::Type* callback) = 0; + Callback1<const std::list<IndexedDBInfo>& >::Type* 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. @@ -103,7 +103,7 @@ class CannedBrowsingDataIndexedDBHelper // BrowsingDataIndexedDBHelper methods. virtual void StartFetching( - Callback1<const std::vector<IndexedDBInfo>& >::Type* callback); + Callback1<const std::list<IndexedDBInfo>& >::Type* callback); virtual void CancelNotification(); virtual void DeleteIndexedDBFile(const FilePath& file_path) {} @@ -130,13 +130,13 @@ class CannedBrowsingDataIndexedDBHelper mutable base::Lock lock_; // This may mutate on WEBKIT and UI threads. - std::vector<PendingIndexedDBInfo> pending_indexed_db_info_; + std::list<PendingIndexedDBInfo> pending_indexed_db_info_; // This only mutates on the WEBKIT thread. - std::vector<IndexedDBInfo> indexed_db_info_; + std::list<IndexedDBInfo> indexed_db_info_; // This only mutates on the UI thread. - scoped_ptr<Callback1<const std::vector<IndexedDBInfo>& >::Type > + scoped_ptr<Callback1<const std::list<IndexedDBInfo>& >::Type > completion_callback_; // Indicates whether or not we're currently fetching information: diff --git a/chrome/browser/browsing_data_indexed_db_helper_browsertest.cc b/chrome/browser/browsing_data_indexed_db_helper_browsertest.cc index b1f9ead..ae76c35 100644 --- a/chrome/browser/browsing_data_indexed_db_helper_browsertest.cc +++ b/chrome/browser/browsing_data_indexed_db_helper_browsertest.cc @@ -42,12 +42,15 @@ IN_PROC_BROWSER_TEST_F(BrowsingDataIndexedDBHelperTest, CannedAddIndexedDB) { helper->StartFetching( NewCallback(&callback, &TestCompletionCallback::callback)); - std::vector<BrowsingDataIndexedDBHelper::IndexedDBInfo> result = + std::list<BrowsingDataIndexedDBHelper::IndexedDBInfo> result = callback.result(); ASSERT_EQ(2U, result.size()); - EXPECT_EQ(FilePath(file1).value(), result[0].file_path.BaseName().value()); - EXPECT_EQ(FilePath(file2).value(), result[1].file_path.BaseName().value()); + std::list<BrowsingDataIndexedDBHelper::IndexedDBInfo>::iterator info = + result.begin(); + EXPECT_EQ(FilePath(file1).value(), info->file_path.BaseName().value()); + info++; + EXPECT_EQ(FilePath(file2).value(), info->file_path.BaseName().value()); } IN_PROC_BROWSER_TEST_F(BrowsingDataIndexedDBHelperTest, CannedUnique) { @@ -65,10 +68,11 @@ IN_PROC_BROWSER_TEST_F(BrowsingDataIndexedDBHelperTest, CannedUnique) { helper->StartFetching( NewCallback(&callback, &TestCompletionCallback::callback)); - std::vector<BrowsingDataIndexedDBHelper::IndexedDBInfo> result = + std::list<BrowsingDataIndexedDBHelper::IndexedDBInfo> result = callback.result(); ASSERT_EQ(1U, result.size()); - EXPECT_EQ(FilePath(file).value(), result[0].file_path.BaseName().value()); + EXPECT_EQ(FilePath(file).value(), + result.begin()->file_path.BaseName().value()); } } // namespace diff --git a/chrome/browser/browsing_data_local_storage_helper.cc b/chrome/browser/browsing_data_local_storage_helper.cc index a732cf9..243eec2 100644 --- a/chrome/browser/browsing_data_local_storage_helper.cc +++ b/chrome/browser/browsing_data_local_storage_helper.cc @@ -56,7 +56,7 @@ BrowsingDataLocalStorageHelper::~BrowsingDataLocalStorageHelper() { } void BrowsingDataLocalStorageHelper::StartFetching( - Callback1<const std::vector<LocalStorageInfo>& >::Type* callback) { + Callback1<const std::list<LocalStorageInfo>& >::Type* callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!is_fetching_); DCHECK(callback); @@ -181,7 +181,7 @@ bool CannedBrowsingDataLocalStorageHelper::empty() const { } void CannedBrowsingDataLocalStorageHelper::StartFetching( - Callback1<const std::vector<LocalStorageInfo>& >::Type* callback) { + Callback1<const std::list<LocalStorageInfo>& >::Type* callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!is_fetching_); DCHECK(callback); @@ -207,7 +207,7 @@ void CannedBrowsingDataLocalStorageHelper::ConvertPendingInfoInWebKitThread() { std::string security_origin(web_security_origin.toString().utf8()); bool duplicate = false; - for (std::vector<LocalStorageInfo>::iterator + for (std::list<LocalStorageInfo>::iterator local_storage = local_storage_info_.begin(); local_storage != local_storage_info_.end(); ++local_storage) { if (local_storage->origin == security_origin) { diff --git a/chrome/browser/browsing_data_local_storage_helper.h b/chrome/browser/browsing_data_local_storage_helper.h index b5306a7..53a88a9 100644 --- a/chrome/browser/browsing_data_local_storage_helper.h +++ b/chrome/browser/browsing_data_local_storage_helper.h @@ -6,9 +6,9 @@ #define CHROME_BROWSER_BROWSING_DATA_LOCAL_STORAGE_HELPER_H_ #pragma once +#include <list> #include <set> #include <string> -#include <vector> #include "base/callback_old.h" #include "base/file_path.h" @@ -64,7 +64,7 @@ class BrowsingDataLocalStorageHelper // callback. // This must be called only in the UI thread. virtual void StartFetching( - Callback1<const std::vector<LocalStorageInfo>& >::Type* callback); + Callback1<const std::list<LocalStorageInfo>& >::Type* callback); // Cancels the notification callback (i.e., the window that created it no // longer exists). // This must be called only in the UI thread. @@ -82,7 +82,7 @@ class BrowsingDataLocalStorageHelper Profile* profile_; // This only mutates on the UI thread. - scoped_ptr<Callback1<const std::vector<LocalStorageInfo>& >::Type > + scoped_ptr<Callback1<const std::list<LocalStorageInfo>& >::Type > completion_callback_; // Indicates whether or not we're currently fetching information: @@ -92,7 +92,7 @@ class BrowsingDataLocalStorageHelper bool is_fetching_; // This only mutates in the WEBKIT thread. - std::vector<LocalStorageInfo> local_storage_info_; + std::list<LocalStorageInfo> local_storage_info_; private: // Enumerates all local storage files in the WEBKIT thread. @@ -128,7 +128,7 @@ class CannedBrowsingDataLocalStorageHelper // BrowsingDataLocalStorageHelper methods. virtual void StartFetching( - Callback1<const std::vector<LocalStorageInfo>& >::Type* callback); + Callback1<const std::list<LocalStorageInfo>& >::Type* callback); virtual void CancelNotification() {} private: diff --git a/chrome/browser/browsing_data_local_storage_helper_browsertest.cc b/chrome/browser/browsing_data_local_storage_helper_browsertest.cc index af7e968..6687973 100644 --- a/chrome/browser/browsing_data_local_storage_helper_browsertest.cc +++ b/chrome/browser/browsing_data_local_storage_helper_browsertest.cc @@ -71,19 +71,21 @@ class StopTestOnCallback { } void Callback( - const std::vector<BrowsingDataLocalStorageHelper::LocalStorageInfo>& + const std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo>& local_storage_info) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); // There's no guarantee on the order, ensure these files are there. const char* const kTestHosts[] = {"www.chromium.org", "www.google.com"}; bool test_hosts_found[arraysize(kTestHosts)] = {false, false}; ASSERT_EQ(arraysize(kTestHosts), local_storage_info.size()); + typedef std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo> + LocalStorageInfoList; for (size_t i = 0; i < arraysize(kTestHosts); ++i) { - for (size_t j = 0; j < local_storage_info.size(); ++j) { - BrowsingDataLocalStorageHelper::LocalStorageInfo info = - local_storage_info.at(j); - ASSERT_EQ("http", info.protocol); - if (info.host == kTestHosts[i]) { + for (LocalStorageInfoList::const_iterator info = + local_storage_info.begin(); info != local_storage_info.end(); + ++info) { + ASSERT_EQ("http", info->protocol); + if (info->host == kTestHosts[i]) { ASSERT_FALSE(test_hosts_found[i]); test_hosts_found[i] = true; } @@ -153,12 +155,15 @@ IN_PROC_BROWSER_TEST_F(BrowsingDataLocalStorageHelperTest, helper->StartFetching( NewCallback(&callback, &TestCompletionCallback::callback)); - std::vector<BrowsingDataLocalStorageHelper::LocalStorageInfo> result = + std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo> result = callback.result(); ASSERT_EQ(2u, result.size()); - EXPECT_EQ(FilePath(file1).value(), result[0].file_path.BaseName().value()); - EXPECT_EQ(FilePath(file2).value(), result[1].file_path.BaseName().value()); + std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo>::iterator info = + result.begin(); + EXPECT_EQ(FilePath(file1).value(), info->file_path.BaseName().value()); + info++; + EXPECT_EQ(FilePath(file2).value(), info->file_path.BaseName().value()); } IN_PROC_BROWSER_TEST_F(BrowsingDataLocalStorageHelperTest, CannedUnique) { @@ -175,10 +180,11 @@ IN_PROC_BROWSER_TEST_F(BrowsingDataLocalStorageHelperTest, CannedUnique) { helper->StartFetching( NewCallback(&callback, &TestCompletionCallback::callback)); - std::vector<BrowsingDataLocalStorageHelper::LocalStorageInfo> result = + std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo> result = callback.result(); ASSERT_EQ(1u, result.size()); - EXPECT_EQ(FilePath(file).value(), result[0].file_path.BaseName().value()); + EXPECT_EQ(FilePath(file).value(), + result.begin()->file_path.BaseName().value()); } } // namespace diff --git a/chrome/browser/browsing_data_quota_helper.h b/chrome/browser/browsing_data_quota_helper.h index 2ed0c1b..d3aac1b 100644 --- a/chrome/browser/browsing_data_quota_helper.h +++ b/chrome/browser/browsing_data_quota_helper.h @@ -6,8 +6,8 @@ #define CHROME_BROWSER_BROWSING_DATA_QUOTA_HELPER_H_ #pragma once +#include <list> #include <string> -#include <vector> #include "base/callback_old.h" #include "base/memory/ref_counted.h" @@ -57,7 +57,7 @@ class BrowsingDataQuotaHelper int64 persistent_usage; }; - typedef std::vector<QuotaInfo> QuotaInfoArray; + typedef std::list<QuotaInfo> QuotaInfoArray; typedef Callback1<const QuotaInfoArray&>::Type FetchResultCallback; static BrowsingDataQuotaHelper* Create(Profile* profile); diff --git a/chrome/browser/browsing_data_quota_helper_impl.cc b/chrome/browser/browsing_data_quota_helper_impl.cc index a3e9e1d..bb4e9da 100644 --- a/chrome/browser/browsing_data_quota_helper_impl.cc +++ b/chrome/browser/browsing_data_quota_helper_impl.cc @@ -143,7 +143,6 @@ void BrowsingDataQuotaHelperImpl::OnComplete() { is_fetching_ = false; QuotaInfoArray result; - result.reserve(quota_info_.size()); for (std::map<std::string, QuotaInfo>::iterator itr = quota_info_.begin(); itr != quota_info_.end(); diff --git a/chrome/browser/browsing_data_quota_helper_impl.h b/chrome/browser/browsing_data_quota_helper_impl.h index 83e4516..09fa36b 100644 --- a/chrome/browser/browsing_data_quota_helper_impl.h +++ b/chrome/browser/browsing_data_quota_helper_impl.h @@ -10,7 +10,6 @@ #include <set> #include <string> #include <utility> -#include <vector> #include "base/callback_old.h" #include "base/memory/ref_counted.h" diff --git a/chrome/browser/cookies_tree_model.cc b/chrome/browser/cookies_tree_model.cc index d198fa2..b2660ec 100644 --- a/chrome/browser/cookies_tree_model.cc +++ b/chrome/browser/cookies_tree_model.cc @@ -49,7 +49,7 @@ CookiesTreeModel* CookieTreeNode::GetModel() const { // CookieTreeCookieNode, public: CookieTreeCookieNode::CookieTreeCookieNode( - net::CookieMonster::CanonicalCookie* cookie) + std::list<net::CookieMonster::CanonicalCookie>::iterator cookie) : CookieTreeNode(UTF8ToUTF16(cookie->Name())), cookie_(cookie) { } @@ -58,19 +58,14 @@ CookieTreeCookieNode::~CookieTreeCookieNode() {} void CookieTreeCookieNode::DeleteStoredObjects() { // notify CookieMonster that we should delete this cookie - // We have stored a copy of all the cookies in the model, and our model is - // never re-calculated. Thus, we just need to delete the nodes from our - // model, and tell CookieMonster to delete the cookies. We can keep the - // vector storing the cookies in-tact and not delete from there (that would - // invalidate our pointers), and the fact that it contains semi out-of-date - // data is not problematic as we don't re-build the model based on that. GetModel()->cookie_helper_->DeleteCookie(*cookie_); + GetModel()->cookie_list_.erase(cookie_); } CookieTreeNode::DetailedInfo CookieTreeCookieNode::GetDetailedInfo() const { return DetailedInfo(parent()->parent()->GetTitle(), DetailedInfo::TYPE_COOKIE, - cookie_, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + &*cookie_, NULL, NULL, NULL, NULL, NULL, NULL, NULL); } namespace { @@ -136,28 +131,35 @@ class OriginNodeComparator { // CookieTreeAppCacheNode, public: CookieTreeAppCacheNode::CookieTreeAppCacheNode( - const appcache::AppCacheInfo* appcache_info) + const GURL& origin_url, + std::list<appcache::AppCacheInfo>::iterator appcache_info) : CookieTreeNode(UTF8ToUTF16(appcache_info->manifest_url.spec())), + origin_url_(origin_url), appcache_info_(appcache_info) { } +CookieTreeAppCacheNode::~CookieTreeAppCacheNode() { +} + void CookieTreeAppCacheNode::DeleteStoredObjects() { DCHECK(GetModel()->appcache_helper_); GetModel()->appcache_helper_->DeleteAppCacheGroup( appcache_info_->manifest_url); + GetModel()->appcache_info_[origin_url_].erase(appcache_info_); } CookieTreeNode::DetailedInfo CookieTreeAppCacheNode::GetDetailedInfo() const { return DetailedInfo(parent()->parent()->GetTitle(), DetailedInfo::TYPE_APPCACHE, - NULL, NULL, NULL, NULL, appcache_info_, NULL, NULL, NULL); + NULL, NULL, NULL, NULL, &*appcache_info_, + NULL, NULL, NULL); } /////////////////////////////////////////////////////////////////////////////// // CookieTreeDatabaseNode, public: CookieTreeDatabaseNode::CookieTreeDatabaseNode( - BrowsingDataDatabaseHelper::DatabaseInfo* database_info) + std::list<BrowsingDataDatabaseHelper::DatabaseInfo>::iterator database_info) : CookieTreeNode(database_info->database_name.empty() ? l10n_util::GetStringUTF16(IDS_COOKIES_WEB_DATABASE_UNNAMED_NAME) : UTF8ToUTF16(database_info->database_name)), @@ -169,19 +171,22 @@ CookieTreeDatabaseNode::~CookieTreeDatabaseNode() {} void CookieTreeDatabaseNode::DeleteStoredObjects() { GetModel()->database_helper_->DeleteDatabase( database_info_->origin_identifier, database_info_->database_name); + GetModel()->database_info_list_.erase(database_info_); } CookieTreeNode::DetailedInfo CookieTreeDatabaseNode::GetDetailedInfo() const { return DetailedInfo(parent()->parent()->GetTitle(), DetailedInfo::TYPE_DATABASE, - NULL, database_info_, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, &*database_info_, + NULL, NULL, NULL, NULL, NULL, NULL); } /////////////////////////////////////////////////////////////////////////////// // CookieTreeLocalStorageNode, public: CookieTreeLocalStorageNode::CookieTreeLocalStorageNode( - BrowsingDataLocalStorageHelper::LocalStorageInfo* local_storage_info) + std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo>::iterator + local_storage_info) : CookieTreeNode(UTF8ToUTF16( local_storage_info->origin.empty() ? local_storage_info->database_identifier : @@ -194,13 +199,14 @@ CookieTreeLocalStorageNode::~CookieTreeLocalStorageNode() {} void CookieTreeLocalStorageNode::DeleteStoredObjects() { GetModel()->local_storage_helper_->DeleteLocalStorageFile( local_storage_info_->file_path); + GetModel()->local_storage_info_list_.erase(local_storage_info_); } CookieTreeNode::DetailedInfo CookieTreeLocalStorageNode::GetDetailedInfo() const { return DetailedInfo(parent()->parent()->GetTitle(), DetailedInfo::TYPE_LOCAL_STORAGE, - NULL, NULL, local_storage_info_, NULL, NULL, NULL, NULL, + NULL, NULL, &*local_storage_info_, NULL, NULL, NULL, NULL, NULL); } @@ -208,7 +214,8 @@ CookieTreeLocalStorageNode::GetDetailedInfo() const { // CookieTreeSessionStorageNode, public: CookieTreeSessionStorageNode::CookieTreeSessionStorageNode( - BrowsingDataLocalStorageHelper::LocalStorageInfo* session_storage_info) + std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo>::iterator + session_storage_info) : CookieTreeNode(UTF8ToUTF16( session_storage_info->origin.empty() ? session_storage_info->database_identifier : @@ -218,11 +225,15 @@ CookieTreeSessionStorageNode::CookieTreeSessionStorageNode( CookieTreeSessionStorageNode::~CookieTreeSessionStorageNode() {} +void CookieTreeSessionStorageNode::DeleteStoredObjects() { + GetModel()->session_storage_info_list_.erase(session_storage_info_); +} + CookieTreeNode::DetailedInfo CookieTreeSessionStorageNode::GetDetailedInfo() const { return DetailedInfo(parent()->parent()->GetTitle(), DetailedInfo::TYPE_SESSION_STORAGE, - NULL, NULL, NULL, session_storage_info_, NULL, NULL, + NULL, NULL, NULL, &*session_storage_info_, NULL, NULL, NULL, NULL); } @@ -230,7 +241,8 @@ CookieTreeSessionStorageNode::GetDetailedInfo() const { // CookieTreeIndexedDBNode, public: CookieTreeIndexedDBNode::CookieTreeIndexedDBNode( - BrowsingDataIndexedDBHelper::IndexedDBInfo* indexed_db_info) + std::list<BrowsingDataIndexedDBHelper::IndexedDBInfo>::iterator + indexed_db_info) : CookieTreeNode(UTF8ToUTF16( indexed_db_info->origin.empty() ? indexed_db_info->database_identifier : @@ -243,12 +255,13 @@ CookieTreeIndexedDBNode::~CookieTreeIndexedDBNode() {} void CookieTreeIndexedDBNode::DeleteStoredObjects() { GetModel()->indexed_db_helper_->DeleteIndexedDBFile( indexed_db_info_->file_path); + GetModel()->indexed_db_info_list_.erase(indexed_db_info_); } CookieTreeNode::DetailedInfo CookieTreeIndexedDBNode::GetDetailedInfo() const { return DetailedInfo(parent()->parent()->GetTitle(), DetailedInfo::TYPE_INDEXED_DB, - NULL, NULL, NULL, NULL, NULL, indexed_db_info_, NULL, + NULL, NULL, NULL, NULL, NULL, &*indexed_db_info_, NULL, NULL); } @@ -256,7 +269,8 @@ CookieTreeNode::DetailedInfo CookieTreeIndexedDBNode::GetDetailedInfo() const { // CookieTreeFileSystemNode, public: CookieTreeFileSystemNode::CookieTreeFileSystemNode( - BrowsingDataFileSystemHelper::FileSystemInfo* file_system_info) + std::list<BrowsingDataFileSystemHelper::FileSystemInfo>::iterator + file_system_info) : CookieTreeNode(UTF8ToUTF16( file_system_info->origin.spec())), file_system_info_(file_system_info) { @@ -267,12 +281,13 @@ CookieTreeFileSystemNode::~CookieTreeFileSystemNode() {} void CookieTreeFileSystemNode::DeleteStoredObjects() { GetModel()->file_system_helper_->DeleteFileSystemOrigin( file_system_info_->origin); + GetModel()->file_system_info_list_.erase(file_system_info_); } CookieTreeNode::DetailedInfo CookieTreeFileSystemNode::GetDetailedInfo() const { return DetailedInfo(parent()->parent()->GetTitle(), DetailedInfo::TYPE_FILE_SYSTEM, - NULL, NULL, NULL, NULL, NULL, NULL, file_system_info_, + NULL, NULL, NULL, NULL, NULL, NULL, &*file_system_info_, NULL); } @@ -280,7 +295,7 @@ CookieTreeNode::DetailedInfo CookieTreeFileSystemNode::GetDetailedInfo() const { // CookieTreeQuotaNode, public: CookieTreeQuotaNode::CookieTreeQuotaNode( - BrowsingDataQuotaHelper::QuotaInfo* quota_info) + std::list<BrowsingDataQuotaHelper::QuotaInfo>::iterator quota_info) : CookieTreeNode(UTF8ToUTF16(quota_info->host)), quota_info_(quota_info) { } @@ -289,12 +304,13 @@ CookieTreeQuotaNode::~CookieTreeQuotaNode() {} void CookieTreeQuotaNode::DeleteStoredObjects() { GetModel()->quota_helper_->DeleteQuotaHost(quota_info_->host); + GetModel()->quota_info_list_.erase(quota_info_); } CookieTreeNode::DetailedInfo CookieTreeQuotaNode::GetDetailedInfo() const { return DetailedInfo(parent()->parent()->GetTitle(), DetailedInfo::TYPE_QUOTA, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, quota_info_); + NULL, NULL, NULL, NULL, NULL, NULL, NULL, &*quota_info_); } /////////////////////////////////////////////////////////////////////////////// @@ -427,7 +443,7 @@ CookieTreeFileSystemsNode* CookieTreeOriginNode::GetOrCreateFileSystemsNode() { } CookieTreeQuotaNode* CookieTreeOriginNode::UpdateOrCreateQuotaNode( - BrowsingDataQuotaHelper::QuotaInfo* quota_info) { + std::list<BrowsingDataQuotaHelper::QuotaInfo>::iterator quota_info) { if (quota_child_) return quota_child_; quota_child_ = new CookieTreeQuotaNode(quota_info); @@ -759,24 +775,39 @@ void CookiesTreeModel::RemoveCookiesTreeObserver(Observer* observer) { } void CookiesTreeModel::OnAppCacheModelInfoLoaded() { - appcache_info_ = appcache_helper_->info_collection(); + using appcache::AppCacheInfo; + using appcache::AppCacheInfoCollection; + using appcache::AppCacheInfoVector; + typedef std::map<GURL, AppCacheInfoVector> InfoByOrigin; + + scoped_refptr<AppCacheInfoCollection> appcache_info = + appcache_helper_->info_collection(); + if (!appcache_info || appcache_info->infos_by_origin.empty()) + return; + + for (InfoByOrigin::const_iterator origin = + appcache_info->infos_by_origin.begin(); + origin != appcache_info->infos_by_origin.end(); ++origin) { + std::list<AppCacheInfo>& info_list = appcache_info_[origin->first]; + info_list.insert( + info_list.begin(), origin->second.begin(), origin->second.end()); + } + PopulateAppCacheInfoWithFilter(std::wstring()); } void CookiesTreeModel::PopulateAppCacheInfoWithFilter( const std::wstring& filter) { using appcache::AppCacheInfo; - using appcache::AppCacheInfoVector; - typedef std::map<GURL, AppCacheInfoVector> InfoByOrigin; + typedef std::map<GURL, std::list<AppCacheInfo> > InfoByOrigin; - if (!appcache_info_ || appcache_info_->infos_by_origin.empty()) + if (appcache_info_.empty()) return; CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(GetRoot()); NotifyObserverBeginBatch(); - for (InfoByOrigin::const_iterator origin = - appcache_info_->infos_by_origin.begin(); - origin != appcache_info_->infos_by_origin.end(); ++origin) { + for (InfoByOrigin::iterator origin = appcache_info_.begin(); + origin != appcache_info_.end(); ++origin) { std::wstring origin_node_name = UTF8ToWide(origin->first.host()); if (filter.empty() || (origin_node_name.find(filter) != std::wstring::npos)) { @@ -785,10 +816,10 @@ void CookiesTreeModel::PopulateAppCacheInfoWithFilter( CookieTreeAppCachesNode* appcaches_node = origin_node->GetOrCreateAppCachesNode(); - for (AppCacheInfoVector::const_iterator info = origin->second.begin(); + for (std::list<AppCacheInfo>::iterator info = origin->second.begin(); info != origin->second.end(); ++info) { appcaches_node->AddAppCacheNode( - new CookieTreeAppCacheNode(&(*info))); + new CookieTreeAppCacheNode(origin->first, info)); } } } @@ -797,8 +828,10 @@ void CookiesTreeModel::PopulateAppCacheInfoWithFilter( } void CookiesTreeModel::OnCookiesModelInfoLoaded( - const CookieList& cookie_list) { - cookie_list_ = cookie_list; + const net::CookieList& cookie_list) { + cookie_list_.insert(cookie_list_.begin(), + cookie_list.begin(), + cookie_list.end()); PopulateCookieInfoWithFilter(std::wstring()); } @@ -828,7 +861,7 @@ void CookiesTreeModel::PopulateCookieInfoWithFilter( root->GetOrCreateOriginNode(source); CookieTreeCookiesNode* cookies_node = origin_node->GetOrCreateCookiesNode(); - CookieTreeCookieNode* new_cookie = new CookieTreeCookieNode(&*it); + CookieTreeCookieNode* new_cookie = new CookieTreeCookieNode(it); cookies_node->AddCookieNode(new_cookie); } } @@ -859,7 +892,7 @@ void CookiesTreeModel::PopulateDatabaseInfoWithFilter( CookieTreeDatabasesNode* databases_node = origin_node->GetOrCreateDatabasesNode(); databases_node->AddDatabaseNode( - new CookieTreeDatabaseNode(&(*database_info))); + new CookieTreeDatabaseNode(database_info)); } } NotifyObserverTreeNodeChanged(root); @@ -892,7 +925,7 @@ void CookiesTreeModel::PopulateLocalStorageInfoWithFilter( CookieTreeLocalStoragesNode* local_storages_node = origin_node->GetOrCreateLocalStoragesNode(); local_storages_node->AddLocalStorageNode( - new CookieTreeLocalStorageNode(&(*local_storage_info))); + new CookieTreeLocalStorageNode(local_storage_info)); } } NotifyObserverTreeNodeChanged(root); @@ -925,7 +958,7 @@ void CookiesTreeModel::PopulateSessionStorageInfoWithFilter( CookieTreeSessionStoragesNode* session_storages_node = origin_node->GetOrCreateSessionStoragesNode(); session_storages_node->AddSessionStorageNode( - new CookieTreeSessionStorageNode(&(*session_storage_info))); + new CookieTreeSessionStorageNode(session_storage_info)); } } NotifyObserverTreeNodeChanged(root); @@ -958,7 +991,7 @@ void CookiesTreeModel::PopulateIndexedDBInfoWithFilter( CookieTreeIndexedDBsNode* indexed_dbs_node = origin_node->GetOrCreateIndexedDBsNode(); indexed_dbs_node->AddIndexedDBNode( - new CookieTreeIndexedDBNode(&(*indexed_db_info))); + new CookieTreeIndexedDBNode(indexed_db_info)); } } NotifyObserverTreeNodeChanged(root); @@ -991,7 +1024,7 @@ void CookiesTreeModel::PopulateFileSystemInfoWithFilter( CookieTreeFileSystemsNode* file_systems_node = origin_node->GetOrCreateFileSystemsNode(); file_systems_node->AddFileSystemNode( - new CookieTreeFileSystemNode(&(*file_system_info))); + new CookieTreeFileSystemNode(file_system_info)); } } NotifyObserverTreeNodeChanged(root); @@ -1017,7 +1050,7 @@ void CookiesTreeModel::PopulateQuotaInfoWithFilter( (UTF8ToWide(quota_info->host).find(filter) != std::wstring::npos)) { CookieTreeOriginNode* origin_node = root->GetOrCreateOriginNode(GURL("http://" + quota_info->host)); - origin_node->UpdateOrCreateQuotaNode(&*quota_info); + origin_node->UpdateOrCreateQuotaNode(quota_info); } } NotifyObserverTreeNodeChanged(root); diff --git a/chrome/browser/cookies_tree_model.h b/chrome/browser/cookies_tree_model.h index d908cc6..f7aa859 100644 --- a/chrome/browser/cookies_tree_model.h +++ b/chrome/browser/cookies_tree_model.h @@ -9,6 +9,7 @@ // TODO(viettrungluu): This header file #includes far too much and has too much // inline code (which shouldn't be inline). +#include <list> #include <string> #include <vector> @@ -223,7 +224,7 @@ class CookieTreeOriginNode : public CookieTreeNode { CookieTreeIndexedDBsNode* GetOrCreateIndexedDBsNode(); CookieTreeFileSystemsNode* GetOrCreateFileSystemsNode(); CookieTreeQuotaNode* UpdateOrCreateQuotaNode( - BrowsingDataQuotaHelper::QuotaInfo* quota_info); + std::list<BrowsingDataQuotaHelper::QuotaInfo>::iterator quota_info); // Creates an content exception for this origin of type // CONTENT_SETTINGS_TYPE_COOKIES. @@ -259,9 +260,10 @@ class CookieTreeCookieNode : public CookieTreeNode { public: friend class CookieTreeCookiesNode; - // Does not take ownership of cookie, and cookie should remain valid at least - // as long as the CookieTreeCookieNode is valid. - explicit CookieTreeCookieNode(net::CookieMonster::CanonicalCookie* cookie); + // The cookie should remain valid at least as long as the + // CookieTreeCookieNode is valid. + explicit CookieTreeCookieNode( + std::list<net::CookieMonster::CanonicalCookie>::iterator cookie); virtual ~CookieTreeCookieNode(); // CookieTreeNode methods: @@ -269,9 +271,9 @@ class CookieTreeCookieNode : public CookieTreeNode { virtual DetailedInfo GetDetailedInfo() const; private: - // Cookie_ is not owned by the node, and is expected to remain valid as long - // as the CookieTreeCookieNode is valid. - net::CookieMonster::CanonicalCookie* cookie_; + // cookie_ is expected to remain valid as long as the CookieTreeCookieNode is + // valid. + std::list<net::CookieMonster::CanonicalCookie>::iterator cookie_; DISALLOW_COPY_AND_ASSIGN(CookieTreeCookieNode); }; @@ -296,17 +298,19 @@ class CookieTreeAppCacheNode : public CookieTreeNode { public: friend class CookieTreeAppCachesNode; - // Does not take ownership of appcache_info, and appcache_info should remain - // valid at least as long as the CookieTreeAppCacheNode is valid. + // appcache_info should remain valid at least as long as the + // CookieTreeAppCacheNode is valid. explicit CookieTreeAppCacheNode( - const appcache::AppCacheInfo* appcache_info); - virtual ~CookieTreeAppCacheNode() {} + const GURL& origin_url, + std::list<appcache::AppCacheInfo>::iterator appcache_info); + virtual ~CookieTreeAppCacheNode(); virtual void DeleteStoredObjects(); virtual DetailedInfo GetDetailedInfo() const; private: - const appcache::AppCacheInfo* appcache_info_; + GURL origin_url_; + std::list<appcache::AppCacheInfo>::iterator appcache_info_; DISALLOW_COPY_AND_ASSIGN(CookieTreeAppCacheNode); }; @@ -330,19 +334,21 @@ class CookieTreeDatabaseNode : public CookieTreeNode { public: friend class CookieTreeDatabasesNode; - // Does not take ownership of database_info, and database_info should remain - // valid at least as long as the CookieTreeDatabaseNode is valid. + // database_info should remain valid at least as long as the + // CookieTreeDatabaseNode is valid. explicit CookieTreeDatabaseNode( - BrowsingDataDatabaseHelper::DatabaseInfo* database_info); + std::list<BrowsingDataDatabaseHelper::DatabaseInfo>::iterator + database_info); virtual ~CookieTreeDatabaseNode(); virtual void DeleteStoredObjects(); virtual DetailedInfo GetDetailedInfo() const; private: - // database_info_ is not owned by the node, and is expected to remain - // valid as long as the CookieTreeDatabaseNode is valid. - BrowsingDataDatabaseHelper::DatabaseInfo* database_info_; + // database_info_ is expected to remain valid as long as the + // CookieTreeDatabaseNode is valid. + std::list<BrowsingDataDatabaseHelper::DatabaseInfo>::iterator + database_info_; DISALLOW_COPY_AND_ASSIGN(CookieTreeDatabaseNode); }; @@ -367,19 +373,21 @@ class CookieTreeFileSystemNode : public CookieTreeNode { public: friend class CookieTreeFileSystemsNode; - // Does not take ownership of file_system_info, and file_system_info should - // remain valid at least as long as the CookieTreeFileSystemNode is valid. + // file_system_info should remain valid at least as long as the + // CookieTreeFileSystemNode is valid. explicit CookieTreeFileSystemNode( - BrowsingDataFileSystemHelper::FileSystemInfo* file_system_info); + std::list<BrowsingDataFileSystemHelper::FileSystemInfo>::iterator + file_system_info); virtual ~CookieTreeFileSystemNode(); virtual void DeleteStoredObjects(); virtual DetailedInfo GetDetailedInfo() const; private: - // file_system_info_ is not owned by the node, and is expected to remain - // valid as long as the CookieTreeFileSystemNode is valid. - BrowsingDataFileSystemHelper::FileSystemInfo* file_system_info_; + // file_system_info_ expected to remain valid as long as the + // CookieTreeFileSystemNode is valid. + std::list<BrowsingDataFileSystemHelper::FileSystemInfo>::iterator + file_system_info_; DISALLOW_COPY_AND_ASSIGN(CookieTreeFileSystemNode); }; @@ -402,11 +410,11 @@ class CookieTreeFileSystemsNode : public CookieTreeNode { // CookieTreeLocalStorageNode ------------------------------------------------- class CookieTreeLocalStorageNode : public CookieTreeNode { public: - // Does not take ownership of local_storage_info, and local_storage_info - // should remain valid at least as long as the CookieTreeLocalStorageNode is - // valid. + // local_storage_info should remain valid at least as long as the + // CookieTreeLocalStorageNode is valid. explicit CookieTreeLocalStorageNode( - BrowsingDataLocalStorageHelper::LocalStorageInfo* local_storage_info); + std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo>::iterator + local_storage_info); virtual ~CookieTreeLocalStorageNode(); // CookieTreeNode methods: @@ -414,9 +422,10 @@ class CookieTreeLocalStorageNode : public CookieTreeNode { virtual DetailedInfo GetDetailedInfo() const; private: - // local_storage_info_ is not owned by the node, and is expected to remain - // valid as long as the CookieTreeLocalStorageNode is valid. - BrowsingDataLocalStorageHelper::LocalStorageInfo* local_storage_info_; + // local_storage_info_ is expected to remain valid as long as the + // CookieTreeLocalStorageNode is valid. + std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo>::iterator + local_storage_info_; DISALLOW_COPY_AND_ASSIGN(CookieTreeLocalStorageNode); }; @@ -441,20 +450,22 @@ class CookieTreeLocalStoragesNode : public CookieTreeNode { // CookieTreeSessionStorageNode ----------------------------------------------- class CookieTreeSessionStorageNode : public CookieTreeNode { public: - // Does not take ownership of session_storage_info, and session_storage_info - // should remain valid at least as long as the CookieTreeSessionStorageNode - // is valid. + // session_storage_info should remain valid at least as long as the + // CookieTreeSessionStorageNode is valid. explicit CookieTreeSessionStorageNode( - BrowsingDataLocalStorageHelper::LocalStorageInfo* session_storage_info); + std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo>::iterator + session_storage_info); virtual ~CookieTreeSessionStorageNode(); // CookieTreeNode methods: + virtual void DeleteStoredObjects(); virtual DetailedInfo GetDetailedInfo() const; private: - // session_storage_info_ is not owned by the node, and is expected to remain - // valid as long as the CookieTreeSessionStorageNode is valid. - BrowsingDataLocalStorageHelper::LocalStorageInfo* session_storage_info_; + // session_storage_info_ is expected to remain valid as long as the + // CookieTreeSessionStorageNode is valid. + std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo>::iterator + session_storage_info_; DISALLOW_COPY_AND_ASSIGN(CookieTreeSessionStorageNode); }; @@ -478,11 +489,11 @@ class CookieTreeSessionStoragesNode : public CookieTreeNode { // CookieTreeIndexedDBNode ----------------------------------------------- class CookieTreeIndexedDBNode : public CookieTreeNode { public: - // Does not take ownership of session_storage_info, and session_storage_info - // should remain valid at least as long as the CookieTreeSessionStorageNode - // is valid. + // indexed_db_info should remain valid at least as long as the + // CookieTreeIndexedDBNode is valid. explicit CookieTreeIndexedDBNode( - BrowsingDataIndexedDBHelper::IndexedDBInfo* indexed_db_info); + std::list<BrowsingDataIndexedDBHelper::IndexedDBInfo>::iterator + indexed_db_info); virtual ~CookieTreeIndexedDBNode(); // CookieTreeNode methods: @@ -490,9 +501,10 @@ class CookieTreeIndexedDBNode : public CookieTreeNode { virtual DetailedInfo GetDetailedInfo() const; private: - // indexed_db_info_ is not owned by the node, and is expected to remain - // valid as long as the CookieTreeIndexedDBNode is valid. - BrowsingDataIndexedDBHelper::IndexedDBInfo* indexed_db_info_; + // indexed_db_info_ is expected to remain valid as long as the + // CookieTreeIndexedDBNode is valid. + std::list<BrowsingDataIndexedDBHelper::IndexedDBInfo>::iterator + indexed_db_info_; DISALLOW_COPY_AND_ASSIGN(CookieTreeIndexedDBNode); }; @@ -515,18 +527,19 @@ class CookieTreeIndexedDBsNode : public CookieTreeNode { // CookieTreeQuotaNode -------------------------------------------------- class CookieTreeQuotaNode : public CookieTreeNode { public: - // Does not take ownership of quota_info, and quota_info should remain valid - // at least as long as the CookieTreeQuotaNode is valid. - explicit CookieTreeQuotaNode(BrowsingDataQuotaHelper::QuotaInfo* quota_info); + // quota_info should remain valid at least as long as the CookieTreeQuotaNode + // is valid. + explicit CookieTreeQuotaNode( + std::list<BrowsingDataQuotaHelper::QuotaInfo>::iterator quota_info); virtual ~CookieTreeQuotaNode(); virtual void DeleteStoredObjects(); virtual DetailedInfo GetDetailedInfo() const; private: - // quota_info_ is not owned by the node, and is expected to remain valid as - // long as the CookieTreeQuotaNode is valid. - BrowsingDataQuotaHelper::QuotaInfo* quota_info_; + // quota_info_ is expected to remain valid as long as the CookieTreeQuotaNode + // is valid. + std::list<BrowsingDataQuotaHelper::QuotaInfo>::iterator quota_info_; DISALLOW_COPY_AND_ASSIGN(CookieTreeQuotaNode); }; @@ -587,21 +600,21 @@ class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> { COOKIE = 1, DATABASE = 2 }; - typedef net::CookieList CookieList; - typedef std::vector<BrowsingDataDatabaseHelper::DatabaseInfo> + typedef std::list<net::CookieMonster::CanonicalCookie> CookieList; + typedef std::list<BrowsingDataDatabaseHelper::DatabaseInfo> DatabaseInfoList; - typedef std::vector<BrowsingDataLocalStorageHelper::LocalStorageInfo> + typedef std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo> LocalStorageInfoList; - typedef std::vector<BrowsingDataLocalStorageHelper::LocalStorageInfo> + typedef std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo> SessionStorageInfoList; - typedef std::vector<BrowsingDataIndexedDBHelper::IndexedDBInfo> + typedef std::list<BrowsingDataIndexedDBHelper::IndexedDBInfo> IndexedDBInfoList; - typedef std::vector<BrowsingDataFileSystemHelper::FileSystemInfo> + typedef std::list<BrowsingDataFileSystemHelper::FileSystemInfo> FileSystemInfoList; - typedef std::vector<BrowsingDataQuotaHelper::QuotaInfo> QuotaInfoArray; + typedef std::list<BrowsingDataQuotaHelper::QuotaInfo> QuotaInfoArray; void OnAppCacheModelInfoLoaded(); - void OnCookiesModelInfoLoaded(const CookieList& cookie_list); + void OnCookiesModelInfoLoaded(const net::CookieList& cookie_list); void OnDatabaseModelInfoLoaded(const DatabaseInfoList& database_info); void OnLocalStorageModelInfoLoaded( const LocalStorageInfoList& local_storage_info); @@ -634,7 +647,7 @@ class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> { scoped_refptr<BrowsingDataFileSystemHelper> file_system_helper_; scoped_refptr<BrowsingDataQuotaHelper> quota_helper_; - scoped_refptr<appcache::AppCacheInfoCollection> appcache_info_; + std::map<GURL, std::list<appcache::AppCacheInfo> > appcache_info_; CookieList cookie_list_; DatabaseInfoList database_info_list_; LocalStorageInfoList local_storage_info_list_; @@ -660,6 +673,7 @@ class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> { friend class CookieTreeCookieNode; friend class CookieTreeDatabaseNode; friend class CookieTreeLocalStorageNode; + friend class CookieTreeSessionStorageNode; friend class CookieTreeIndexedDBNode; friend class CookieTreeFileSystemNode; friend class CookieTreeQuotaNode; diff --git a/chrome/browser/cookies_tree_model_unittest.cc b/chrome/browser/cookies_tree_model_unittest.cc index 03e2f9e..787c125 100644 --- a/chrome/browser/cookies_tree_model_unittest.cc +++ b/chrome/browser/cookies_tree_model_unittest.cc @@ -325,6 +325,10 @@ TEST_F(CookiesTreeModelTest, RemoveAll) { cookies_model->DeleteAllStoredObjects(); + // Make sure the nodes are also deleted from the model's cache. + // http://crbug.com/43249 + cookies_model->UpdateSearchResults(std::wstring()); + { SCOPED_TRACE("After removing"); EXPECT_EQ(1, cookies_model->GetRoot()->GetTotalNodeCount()); diff --git a/chrome/browser/mock_browsing_data_database_helper.cc b/chrome/browser/mock_browsing_data_database_helper.cc index c62445e..1c2484b 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) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -16,7 +16,7 @@ MockBrowsingDataDatabaseHelper::~MockBrowsingDataDatabaseHelper() { } void MockBrowsingDataDatabaseHelper::StartFetching( - Callback1<const std::vector<DatabaseInfo>& >::Type* callback) { + Callback1<const std::list<DatabaseInfo>& >::Type* callback) { callback_.reset(callback); } diff --git a/chrome/browser/mock_browsing_data_database_helper.h b/chrome/browser/mock_browsing_data_database_helper.h index e925e0b..cd3a784 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) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -6,22 +6,22 @@ #define CHROME_BROWSER_MOCK_BROWSING_DATA_DATABASE_HELPER_H_ #pragma once +#include <list> #include <map> -#include <vector> #include "base/callback.h" #include "chrome/browser/browsing_data_database_helper.h" // Mock for BrowsingDataDatabaseHelper. -// Use AddDatabaseSamples() or add directly to response_ vector, then call +// Use AddDatabaseSamples() or add directly to response_ list, then call // Notify(). class MockBrowsingDataDatabaseHelper : public BrowsingDataDatabaseHelper { public: explicit MockBrowsingDataDatabaseHelper(Profile* profile); virtual void StartFetching( - Callback1<const std::vector<DatabaseInfo>& >::Type* callback); + Callback1<const std::list<DatabaseInfo>& >::Type* callback); virtual void CancelNotification(); @@ -50,13 +50,13 @@ class MockBrowsingDataDatabaseHelper : public BrowsingDataDatabaseHelper { Profile* profile_; - scoped_ptr<Callback1<const std::vector<DatabaseInfo>& >::Type > + scoped_ptr<Callback1<const std::list<DatabaseInfo>& >::Type > callback_; // Stores which databases exist. std::map<const std::string, bool> databases_; - std::vector<DatabaseInfo> response_; + std::list<DatabaseInfo> response_; }; #endif // CHROME_BROWSER_MOCK_BROWSING_DATA_DATABASE_HELPER_H_ diff --git a/chrome/browser/mock_browsing_data_file_system_helper.cc b/chrome/browser/mock_browsing_data_file_system_helper.cc index 0c8c5ba..7194362 100644 --- a/chrome/browser/mock_browsing_data_file_system_helper.cc +++ b/chrome/browser/mock_browsing_data_file_system_helper.cc @@ -15,7 +15,7 @@ MockBrowsingDataFileSystemHelper::~MockBrowsingDataFileSystemHelper() { } void MockBrowsingDataFileSystemHelper::StartFetching( - Callback1<const std::vector<FileSystemInfo>& >::Type* callback) { + Callback1<const std::list<FileSystemInfo>& >::Type* callback) { callback_.reset(callback); } diff --git a/chrome/browser/mock_browsing_data_file_system_helper.h b/chrome/browser/mock_browsing_data_file_system_helper.h index de55d52..6e172ee 100644 --- a/chrome/browser/mock_browsing_data_file_system_helper.h +++ b/chrome/browser/mock_browsing_data_file_system_helper.h @@ -6,22 +6,22 @@ #define CHROME_BROWSER_MOCK_BROWSING_DATA_FILE_SYSTEM_HELPER_H_ #pragma once +#include <list> #include <map> -#include <vector> #include "base/callback.h" #include "chrome/browser/browsing_data_file_system_helper.h" #include "webkit/fileapi/file_system_types.h" // Mock for BrowsingDataFileSystemHelper. -// Use AddFileSystemSamples() or add directly to response_ vector, then call +// Use AddFileSystemSamples() or add directly to response_ list, then call // Notify(). class MockBrowsingDataFileSystemHelper : public BrowsingDataFileSystemHelper { public: explicit MockBrowsingDataFileSystemHelper(Profile* profile); virtual void StartFetching( - Callback1<const std::vector<FileSystemInfo>& >::Type* callback); + Callback1<const std::list<FileSystemInfo>& >::Type* callback); virtual void CancelNotification(); @@ -52,13 +52,13 @@ class MockBrowsingDataFileSystemHelper : public BrowsingDataFileSystemHelper { Profile* profile_; - scoped_ptr<Callback1<const std::vector<FileSystemInfo>& >::Type > + scoped_ptr<Callback1<const std::list<FileSystemInfo>& >::Type > callback_; // Stores which filesystems exist. std::map<const std::string, bool> file_systems_; - std::vector<FileSystemInfo> response_; + std::list<FileSystemInfo> response_; }; #endif // CHROME_BROWSER_MOCK_BROWSING_DATA_FILE_SYSTEM_HELPER_H_ diff --git a/chrome/browser/mock_browsing_data_indexed_db_helper.cc b/chrome/browser/mock_browsing_data_indexed_db_helper.cc index 06e4039..9530c8f 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) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -16,7 +16,7 @@ MockBrowsingDataIndexedDBHelper::~MockBrowsingDataIndexedDBHelper() { } void MockBrowsingDataIndexedDBHelper::StartFetching( - Callback1<const std::vector<IndexedDBInfo>& >::Type* callback) { + Callback1<const std::list<IndexedDBInfo>& >::Type* callback) { callback_.reset(callback); } diff --git a/chrome/browser/mock_browsing_data_indexed_db_helper.h b/chrome/browser/mock_browsing_data_indexed_db_helper.h index 3a6a282..ff38d79 100644 --- a/chrome/browser/mock_browsing_data_indexed_db_helper.h +++ b/chrome/browser/mock_browsing_data_indexed_db_helper.h @@ -6,15 +6,15 @@ #define CHROME_BROWSER_MOCK_BROWSING_DATA_INDEXED_DB_HELPER_H_ #pragma once +#include <list> #include <map> -#include <vector> #include "base/callback.h" #include "base/memory/scoped_ptr.h" #include "chrome/browser/browsing_data_indexed_db_helper.h" // Mock for BrowsingDataIndexedDBHelper. -// Use AddIndexedDBSamples() or add directly to response_ vector, then +// Use AddIndexedDBSamples() or add directly to response_ list, then // call Notify(). class MockBrowsingDataIndexedDBHelper : public BrowsingDataIndexedDBHelper { @@ -36,7 +36,7 @@ class MockBrowsingDataIndexedDBHelper // BrowsingDataIndexedDBHelper. virtual void StartFetching( - Callback1<const std::vector<IndexedDBInfo>& >::Type* callback); + Callback1<const std::list<IndexedDBInfo>& >::Type* callback); virtual void CancelNotification(); virtual void DeleteIndexedDBFile(const FilePath& file_path); @@ -47,12 +47,12 @@ class MockBrowsingDataIndexedDBHelper Profile* profile_; - scoped_ptr<Callback1<const std::vector<IndexedDBInfo>& >::Type > + scoped_ptr<Callback1<const std::list<IndexedDBInfo>& >::Type > callback_; std::map<const FilePath::StringType, bool> files_; - std::vector<IndexedDBInfo> response_; + std::list<IndexedDBInfo> response_; }; #endif // CHROME_BROWSER_MOCK_BROWSING_DATA_INDEXED_DB_HELPER_H_ diff --git a/chrome/browser/mock_browsing_data_local_storage_helper.cc b/chrome/browser/mock_browsing_data_local_storage_helper.cc index 0b80d37..9bdbda7 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) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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,7 @@ MockBrowsingDataLocalStorageHelper::~MockBrowsingDataLocalStorageHelper() { } void MockBrowsingDataLocalStorageHelper::StartFetching( - Callback1<const std::vector<LocalStorageInfo>& >::Type* callback) { + Callback1<const std::list<LocalStorageInfo>& >::Type* callback) { callback_.reset(callback); } diff --git a/chrome/browser/mock_browsing_data_local_storage_helper.h b/chrome/browser/mock_browsing_data_local_storage_helper.h index 0dba0b1..0163184 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) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -6,14 +6,14 @@ #define CHROME_BROWSER_MOCK_BROWSING_DATA_LOCAL_STORAGE_HELPER_H_ #pragma once +#include <list> #include <map> -#include <vector> #include "base/callback.h" #include "chrome/browser/browsing_data_local_storage_helper.h" // Mock for BrowsingDataLocalStorageHelper. -// Use AddLocalStorageSamples() or add directly to response_ vector, then +// Use AddLocalStorageSamples() or add directly to response_ list, then // call Notify(). class MockBrowsingDataLocalStorageHelper : public BrowsingDataLocalStorageHelper { @@ -21,7 +21,7 @@ class MockBrowsingDataLocalStorageHelper explicit MockBrowsingDataLocalStorageHelper(Profile* profile); virtual void StartFetching( - Callback1<const std::vector<LocalStorageInfo>& >::Type* callback); + Callback1<const std::list<LocalStorageInfo>& >::Type* callback); virtual void CancelNotification(); @@ -47,12 +47,12 @@ class MockBrowsingDataLocalStorageHelper Profile* profile_; - scoped_ptr<Callback1<const std::vector<LocalStorageInfo>& >::Type > + scoped_ptr<Callback1<const std::list<LocalStorageInfo>& >::Type > callback_; std::map<const FilePath::StringType, bool> files_; - std::vector<LocalStorageInfo> response_; + std::list<LocalStorageInfo> response_; }; #endif // CHROME_BROWSER_MOCK_BROWSING_DATA_LOCAL_STORAGE_HELPER_H_ diff --git a/chrome/browser/mock_browsing_data_quota_helper.h b/chrome/browser/mock_browsing_data_quota_helper.h index 333e632..0c4c3c4 100644 --- a/chrome/browser/mock_browsing_data_quota_helper.h +++ b/chrome/browser/mock_browsing_data_quota_helper.h @@ -6,8 +6,8 @@ #define CHROME_BROWSER_MOCK_BROWSING_DATA_QUOTA_HELPER_H_ #pragma once +#include <list> #include <string> -#include <vector> #include "base/compiler_specific.h" #include "base/memory/scoped_ptr.h" @@ -30,7 +30,7 @@ class MockBrowsingDataQuotaHelper : public BrowsingDataQuotaHelper { virtual ~MockBrowsingDataQuotaHelper(); scoped_ptr<FetchResultCallback> callback_; - std::vector<QuotaInfo> response_; + std::list<QuotaInfo> response_; Profile* profile_; }; |