summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/browsing_data_database_helper.cc119
-rw-r--r--chrome/browser/browsing_data_database_helper.h54
-rw-r--r--chrome/browser/browsing_data_database_helper_browsertest.cc65
-rw-r--r--chrome/browser/browsing_data_database_helper_unittest.cc88
-rw-r--r--chrome/browser/browsing_data_helper_browsertest.h46
-rw-r--r--chrome/browser/browsing_data_indexed_db_helper.cc115
-rw-r--r--chrome/browser/browsing_data_indexed_db_helper.h35
-rw-r--r--chrome/browser/browsing_data_indexed_db_helper_browsertest.cc75
-rw-r--r--chrome/browser/browsing_data_indexed_db_helper_unittest.cc86
-rw-r--r--chrome/browser/browsing_data_local_storage_helper.cc88
-rw-r--r--chrome/browser/browsing_data_local_storage_helper.h32
-rw-r--r--chrome/browser/browsing_data_local_storage_helper_browsertest.cc65
-rw-r--r--chrome/browser/browsing_data_local_storage_helper_unittest.cc82
-rw-r--r--chrome/chrome_tests.gypi2
-rw-r--r--ppapi/c/dev/ppb_opengles_dev.h2
-rw-r--r--ppapi/lib/gl/gles2/gles2.c2
-rw-r--r--webkit/plugins/ppapi/ppb_opengles_impl.cc2
17 files changed, 575 insertions, 383 deletions
diff --git a/chrome/browser/browsing_data_database_helper.cc b/chrome/browser/browsing_data_database_helper.cc
index 338e58c..c302b57 100644
--- a/chrome/browser/browsing_data_database_helper.cc
+++ b/chrome/browser/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.
@@ -15,6 +15,8 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
+using WebKit::WebSecurityOrigin;
+
BrowsingDataDatabaseHelper::DatabaseInfo::DatabaseInfo() {}
BrowsingDataDatabaseHelper::DatabaseInfo::DatabaseInfo(
@@ -43,9 +45,9 @@ bool BrowsingDataDatabaseHelper::DatabaseInfo::IsFileSchemeData() {
}
BrowsingDataDatabaseHelper::BrowsingDataDatabaseHelper(Profile* profile)
- : tracker_(profile->GetDatabaseTracker()),
- completion_callback_(NULL),
- is_fetching_(false) {
+ : completion_callback_(NULL),
+ is_fetching_(false),
+ tracker_(profile->GetDatabaseTracker()) {
}
BrowsingDataDatabaseHelper::~BrowsingDataDatabaseHelper() {
@@ -59,8 +61,8 @@ void BrowsingDataDatabaseHelper::StartFetching(
is_fetching_ = true;
database_info_.clear();
completion_callback_.reset(callback);
- BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, NewRunnableMethod(
- this, &BrowsingDataDatabaseHelper::FetchDatabaseInfoInFileThread));
+ BrowserThread::PostTask(BrowserThread::WEBKIT, FROM_HERE, NewRunnableMethod(
+ this, &BrowsingDataDatabaseHelper::FetchDatabaseInfoInWebKitThread));
}
void BrowsingDataDatabaseHelper::CancelNotification() {
@@ -71,13 +73,13 @@ void BrowsingDataDatabaseHelper::CancelNotification() {
void BrowsingDataDatabaseHelper::DeleteDatabase(const std::string& origin,
const std::string& name) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, NewRunnableMethod(
- this, &BrowsingDataDatabaseHelper::DeleteDatabaseInFileThread, origin,
+ BrowserThread::PostTask(BrowserThread::WEBKIT, FROM_HERE, NewRunnableMethod(
+ this, &BrowsingDataDatabaseHelper::DeleteDatabaseInWebKitThread, origin,
name));
}
-void BrowsingDataDatabaseHelper::FetchDatabaseInfoInFileThread() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+void BrowsingDataDatabaseHelper::FetchDatabaseInfoInWebKitThread() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
std::vector<webkit_database::OriginInfo> origins_info;
if (tracker_.get() && tracker_->GetAllOriginsInfo(&origins_info)) {
for (std::vector<webkit_database::OriginInfo>::const_iterator ori =
@@ -89,8 +91,8 @@ void BrowsingDataDatabaseHelper::FetchDatabaseInfoInFileThread() {
// Extension state is not considered browsing data.
continue;
}
- WebKit::WebSecurityOrigin web_security_origin =
- WebKit::WebSecurityOrigin::createFromDatabaseIdentifier(
+ WebSecurityOrigin web_security_origin =
+ WebSecurityOrigin::createFromDatabaseIdentifier(
ori->GetOrigin());
std::vector<string16> databases;
ori->GetAllDatabaseNames(&databases);
@@ -129,15 +131,28 @@ void BrowsingDataDatabaseHelper::NotifyInUIThread() {
database_info_.clear();
}
-void BrowsingDataDatabaseHelper::DeleteDatabaseInFileThread(
+void BrowsingDataDatabaseHelper::DeleteDatabaseInWebKitThread(
const std::string& origin,
const std::string& name) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
if (!tracker_.get())
return;
tracker_->DeleteDatabase(UTF8ToUTF16(origin), UTF8ToUTF16(name), NULL);
}
+CannedBrowsingDataDatabaseHelper::PendingDatabaseInfo::PendingDatabaseInfo() {}
+
+CannedBrowsingDataDatabaseHelper::PendingDatabaseInfo::PendingDatabaseInfo(
+ const GURL& origin,
+ const std::string& name,
+ const std::string& description)
+ : origin(origin),
+ name(name),
+ description(description) {
+}
+
+CannedBrowsingDataDatabaseHelper::PendingDatabaseInfo::~PendingDatabaseInfo() {}
+
CannedBrowsingDataDatabaseHelper::CannedBrowsingDataDatabaseHelper(
Profile* profile)
: BrowsingDataDatabaseHelper(profile) {
@@ -147,39 +162,67 @@ void CannedBrowsingDataDatabaseHelper::AddDatabase(
const GURL& origin,
const std::string& name,
const std::string& description) {
- WebKit::WebSecurityOrigin web_security_origin =
- WebKit::WebSecurityOrigin::createFromString(
- UTF8ToUTF16(origin.spec()));
- std::string origin_identifier =
- web_security_origin.databaseIdentifier().utf8();
-
- for (std::vector<DatabaseInfo>::iterator database = database_info_.begin();
- database != database_info_.end(); ++database) {
- if (database->origin_identifier == origin_identifier &&
- database->database_name == name)
- return;
- }
-
- database_info_.push_back(DatabaseInfo(
- web_security_origin.host().utf8(),
- name,
- origin_identifier,
- description,
- web_security_origin.toString().utf8(),
- 0,
- base::Time()));
+ base::AutoLock auto_lock(lock_);
+ pending_database_info_.push_back(PendingDatabaseInfo(
+ origin, name, description));
}
void CannedBrowsingDataDatabaseHelper::Reset() {
+ base::AutoLock auto_lock(lock_);
database_info_.clear();
+ pending_database_info_.clear();
}
bool CannedBrowsingDataDatabaseHelper::empty() const {
- return database_info_.empty();
+ base::AutoLock auto_lock(lock_);
+ return database_info_.empty() && pending_database_info_.empty();
}
void CannedBrowsingDataDatabaseHelper::StartFetching(
Callback1<const std::vector<DatabaseInfo>& >::Type* callback) {
- callback->Run(database_info_);
- delete callback;
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!is_fetching_);
+ DCHECK(callback);
+ is_fetching_ = true;
+ completion_callback_.reset(callback);
+ BrowserThread::PostTask(BrowserThread::WEBKIT, FROM_HERE, NewRunnableMethod(
+ this, &CannedBrowsingDataDatabaseHelper::ConvertInfoInWebKitThread));
+}
+
+void CannedBrowsingDataDatabaseHelper::ConvertInfoInWebKitThread() {
+ base::AutoLock auto_lock(lock_);
+ for (std::vector<PendingDatabaseInfo>::const_iterator
+ info = pending_database_info_.begin();
+ info != pending_database_info_.end(); ++info) {
+ WebSecurityOrigin web_security_origin =
+ WebSecurityOrigin::createFromString(
+ UTF8ToUTF16(info->origin.spec()));
+ std::string origin_identifier =
+ web_security_origin.databaseIdentifier().utf8();
+
+ bool duplicate = false;
+ for (std::vector<DatabaseInfo>::iterator database = database_info_.begin();
+ database != database_info_.end(); ++database) {
+ if (database->origin_identifier == origin_identifier &&
+ database->database_name == info->name) {
+ duplicate = true;
+ break;
+ }
+ }
+ if (duplicate)
+ continue;
+
+ database_info_.push_back(DatabaseInfo(
+ web_security_origin.host().utf8(),
+ info->name,
+ origin_identifier,
+ info->description,
+ web_security_origin.toString().utf8(),
+ 0,
+ base::Time()));
+ }
+ pending_database_info_.clear();
+
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, NewRunnableMethod(
+ this, &CannedBrowsingDataDatabaseHelper::NotifyInUIThread));
}
diff --git a/chrome/browser/browsing_data_database_helper.h b/chrome/browser/browsing_data_database_helper.h
index af506c0..fa1d069 100644
--- a/chrome/browser/browsing_data_database_helper.h
+++ b/chrome/browser/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.
@@ -11,14 +11,15 @@
#include "base/callback.h"
#include "base/scoped_ptr.h"
+#include "base/synchronization/lock.h"
#include "chrome/common/url_constants.h"
#include "googleurl/src/gurl.h"
#include "webkit/database/database_tracker.h"
class Profile;
-// This class fetches database information in the FILE thread, and notifies the
-// UI thread upon completion.
+// This class fetches database information in the WEBKIT thread, and notifies
+// the UI thread upon completion.
// 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.
@@ -63,7 +64,7 @@ class BrowsingDataDatabaseHelper
// 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
+ // Requests a single database to be deleted in the WEBKIT thread. This must be
// called in the UI thread.
virtual void DeleteDatabase(const std::string& origin,
const std::string& name);
@@ -72,21 +73,11 @@ class BrowsingDataDatabaseHelper
friend class base::RefCountedThreadSafe<BrowsingDataDatabaseHelper>;
virtual ~BrowsingDataDatabaseHelper();
- // This only mutates in the FILE thread.
- std::vector<DatabaseInfo> database_info_;
-
- private:
- // Enumerates all databases. This must be called in the FILE thread.
- void FetchDatabaseInfoInFileThread();
-
// Notifies the completion callback. This must be called in the UI thread.
void NotifyInUIThread();
- // Delete a single database file. This must be called in the FILE thread.
- void DeleteDatabaseInFileThread(const std::string& origin,
- const std::string& name);
-
- scoped_refptr<webkit_database::DatabaseTracker> tracker_;
+ // This only mutates in the WEBKIT thread.
+ std::vector<DatabaseInfo> database_info_;
// This only mutates on the UI thread.
scoped_ptr<Callback1<const std::vector<DatabaseInfo>& >::Type >
@@ -98,6 +89,16 @@ class BrowsingDataDatabaseHelper
// This only mutates on the UI thread.
bool is_fetching_;
+ private:
+ // Enumerates all databases. This must be called in the WEBKIT thread.
+ void FetchDatabaseInfoInWebKitThread();
+
+ // Delete a single database file. This must be called in the WEBKIT thread.
+ void DeleteDatabaseInWebKitThread(const std::string& origin,
+ const std::string& name);
+
+ scoped_refptr<webkit_database::DatabaseTracker> tracker_;
+
DISALLOW_COPY_AND_ASSIGN(BrowsingDataDatabaseHelper);
};
@@ -126,8 +127,29 @@ class CannedBrowsingDataDatabaseHelper : public BrowsingDataDatabaseHelper {
virtual void CancelNotification() {}
private:
+ struct PendingDatabaseInfo {
+ PendingDatabaseInfo();
+ PendingDatabaseInfo(const GURL& origin,
+ const std::string& name,
+ const std::string& description);
+ ~PendingDatabaseInfo();
+
+ GURL origin;
+ std::string name;
+ std::string description;
+ };
+
virtual ~CannedBrowsingDataDatabaseHelper() {}
+ // Converts the pending database info structs to database info structs.
+ void ConvertInfoInWebKitThread();
+
+ // Used to protect access to pending_database_info_.
+ mutable base::Lock lock_;
+
+ // This may mutate on WEBKIT and UI threads.
+ std::vector<PendingDatabaseInfo> pending_database_info_;
+
DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataDatabaseHelper);
};
diff --git a/chrome/browser/browsing_data_database_helper_browsertest.cc b/chrome/browser/browsing_data_database_helper_browsertest.cc
index 82b47fb..9d2c85f 100644
--- a/chrome/browser/browsing_data_database_helper_browsertest.cc
+++ b/chrome/browser/browsing_data_database_helper_browsertest.cc
@@ -1,18 +1,23 @@
-// 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.
#include "base/file_util.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/browsing_data_database_helper.h"
+#include "chrome/browser/browsing_data_helper_browsertest.h"
#include "chrome/browser/browser_thread.h"
#include "chrome/test/in_process_browser_test.h"
#include "chrome/test/testing_profile.h"
#include "chrome/test/ui_test_utils.h"
-static const char kTestIdentifier1[] = "http_www.google.com_0";
+namespace {
+typedef BrowsingDataHelperCallback<BrowsingDataDatabaseHelper::DatabaseInfo>
+ TestCompletionCallback;
-static const char kTestIdentifierExtension[] =
+const char kTestIdentifier1[] = "http_www.google.com_0";
+
+const char kTestIdentifierExtension[] =
"chrome-extension_behllobkkfkfnphdnhnkndlbkcpglgmj_0";
class BrowsingDataDatabaseHelperTest : public InProcessBrowserTest {
@@ -81,3 +86,57 @@ IN_PROC_BROWSER_TEST_F(BrowsingDataDatabaseHelperTest, FetchData) {
// Blocks until StopTestOnCallback::Callback is notified.
ui_test_utils::RunMessageLoop();
}
+
+IN_PROC_BROWSER_TEST_F(BrowsingDataDatabaseHelperTest, CannedAddDatabase) {
+ const GURL origin1("http://host1:1/");
+ const GURL origin2("http://host2:1/");
+ const char origin_str1[] = "http_host1_1";
+ const char origin_str2[] = "http_host2_1";
+ const char db1[] = "db1";
+ const char db2[] = "db2";
+ const char db3[] = "db3";
+
+ scoped_refptr<CannedBrowsingDataDatabaseHelper> helper(
+ new CannedBrowsingDataDatabaseHelper(&testing_profile_));
+ helper->AddDatabase(origin1, db1, "");
+ helper->AddDatabase(origin1, db2, "");
+ helper->AddDatabase(origin2, db3, "");
+
+ TestCompletionCallback callback;
+ helper->StartFetching(
+ NewCallback(&callback, &TestCompletionCallback::callback));
+
+ std::vector<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());
+}
+
+IN_PROC_BROWSER_TEST_F(BrowsingDataDatabaseHelperTest, CannedUnique) {
+ const GURL origin("http://host1:1/");
+ const char origin_str[] = "http_host1_1";
+ const char db[] = "db1";
+
+ scoped_refptr<CannedBrowsingDataDatabaseHelper> helper(
+ new CannedBrowsingDataDatabaseHelper(&testing_profile_));
+ helper->AddDatabase(origin, db, "");
+ helper->AddDatabase(origin, db, "");
+
+ TestCompletionCallback callback;
+ helper->StartFetching(
+ NewCallback(&callback, &TestCompletionCallback::callback));
+
+ std::vector<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());
+}
+} // namespace
diff --git a/chrome/browser/browsing_data_database_helper_unittest.cc b/chrome/browser/browsing_data_database_helper_unittest.cc
index ca23f39..75442ad 100644
--- a/chrome/browser/browsing_data_database_helper_unittest.cc
+++ b/chrome/browser/browsing_data_database_helper_unittest.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.
@@ -9,91 +9,6 @@
#include "testing/gtest/include/gtest/gtest.h"
namespace {
-class TestCompletionCallback {
- public:
- TestCompletionCallback()
- : have_result_(false) {
- }
-
- bool have_result() const { return have_result_; }
-
- const std::vector<BrowsingDataDatabaseHelper::DatabaseInfo>& result() {
- return result_;
- }
-
- void callback(const std::vector<
- BrowsingDataDatabaseHelper::DatabaseInfo>& info) {
- have_result_ = true;
- result_ = info;
- }
-
- private:
- bool have_result_;
- std::vector<BrowsingDataDatabaseHelper::DatabaseInfo> result_;
-
- DISALLOW_COPY_AND_ASSIGN(TestCompletionCallback);
-};
-} // namespace
-
-TEST(CannedBrowsingDataDatabaseTest, AddDatabase) {
- TestingProfile profile;
-
- const GURL origin1("http://host1:1/");
- const GURL origin2("http://host2:1/");
- const char origin_str1[] = "http_host1_1";
- const char origin_str2[] = "http_host2_1";
- const char db1[] = "db1";
- const char db2[] = "db2";
- const char db3[] = "db3";
-
- scoped_refptr<CannedBrowsingDataDatabaseHelper> helper(
- new CannedBrowsingDataDatabaseHelper(&profile));
- helper->AddDatabase(origin1, db1, "");
- helper->AddDatabase(origin1, db2, "");
- helper->AddDatabase(origin2, db3, "");
-
- TestCompletionCallback callback;
- helper->StartFetching(
- NewCallback(&callback, &TestCompletionCallback::callback));
- ASSERT_TRUE(callback.have_result());
-
- std::vector<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());
-}
-
-TEST(CannedBrowsingDataDatabaseTest, Unique) {
- TestingProfile profile;
-
- const GURL origin("http://host1:1/");
- const char origin_str[] = "http_host1_1";
- const char db[] = "db1";
-
- scoped_refptr<CannedBrowsingDataDatabaseHelper> helper(
- new CannedBrowsingDataDatabaseHelper(&profile));
- helper->AddDatabase(origin, db, "");
- helper->AddDatabase(origin, db, "");
-
- TestCompletionCallback callback;
- helper->StartFetching(
- NewCallback(&callback, &TestCompletionCallback::callback));
- ASSERT_TRUE(callback.have_result());
-
- std::vector<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());
-}
-
TEST(CannedBrowsingDataDatabaseTest, Empty) {
TestingProfile profile;
@@ -109,3 +24,4 @@ TEST(CannedBrowsingDataDatabaseTest, Empty) {
helper->Reset();
ASSERT_TRUE(helper->empty());
}
+} // namespace
diff --git a/chrome/browser/browsing_data_helper_browsertest.h b/chrome/browser/browsing_data_helper_browsertest.h
new file mode 100644
index 0000000..d62db7a2
--- /dev/null
+++ b/chrome/browser/browsing_data_helper_browsertest.h
@@ -0,0 +1,46 @@
+// 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.
+
+// Contains code shared by all browsing data browsertests.
+
+#ifndef CHROME_BROWSER_BROWSING_DATA_HELPER_BROWSERTEST_H_
+#define CHROME_BROWSER_BROWSING_DATA_HELPER_BROWSERTEST_H_
+#pragma once
+
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/logging.h"
+#include "base/message_loop.h"
+
+// This template can be used for the StartFetching methods of the browsing data
+// helper classes. It is supposed to be instantiated with the respective
+// browsing data info type.
+template <typename T>
+class BrowsingDataHelperCallback {
+ public:
+ BrowsingDataHelperCallback()
+ : has_result_(false) {
+ }
+
+ const std::vector<T>& result() {
+ MessageLoop::current()->Run();
+ DCHECK(has_result_);
+ return result_;
+ }
+
+ void callback(const std::vector<T>& info) {
+ result_ = info;
+ has_result_ = true;
+ MessageLoop::current()->Quit();
+ }
+
+ private:
+ bool has_result_;
+ std::vector<T> result_;
+
+ DISALLOW_COPY_AND_ASSIGN(BrowsingDataHelperCallback);
+};
+
+#endif // CHROME_BROWSER_BROWSING_DATA_HELPER_BROWSERTEST_H_
diff --git a/chrome/browser/browsing_data_indexed_db_helper.cc b/chrome/browser/browsing_data_indexed_db_helper.cc
index 6c02d213a..7afea58 100644
--- a/chrome/browser/browsing_data_indexed_db_helper.cc
+++ b/chrome/browser/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.
@@ -109,7 +109,7 @@ void BrowsingDataIndexedDBHelperImpl::FetchIndexedDBInfoInWebKitThread() {
file_path = file_enumerator.Next()) {
if (file_path.Extension() == IndexedDBContext::kIndexedDBExtension) {
WebSecurityOrigin web_security_origin =
- WebKit::WebSecurityOrigin::createFromDatabaseIdentifier(
+ WebSecurityOrigin::createFromDatabaseIdentifier(
webkit_glue::FilePathToWebString(file_path.BaseName()));
if (EqualsASCII(web_security_origin.protocol(),
chrome::kExtensionScheme)) {
@@ -185,50 +185,109 @@ BrowsingDataIndexedDBHelper* BrowsingDataIndexedDBHelper::Create(
return new BrowsingDataIndexedDBHelperImpl(profile);
}
+CannedBrowsingDataIndexedDBHelper::
+PendingIndexedDBInfo::PendingIndexedDBInfo() {
+}
+
+CannedBrowsingDataIndexedDBHelper::
+PendingIndexedDBInfo::PendingIndexedDBInfo(const GURL& origin,
+ const string16& description)
+ : origin(origin),
+ description(description) {
+}
+
+CannedBrowsingDataIndexedDBHelper::
+PendingIndexedDBInfo::~PendingIndexedDBInfo() {
+}
+
CannedBrowsingDataIndexedDBHelper::CannedBrowsingDataIndexedDBHelper(
Profile* profile)
- : profile_(profile) {
+ : profile_(profile),
+ completion_callback_(NULL),
+ is_fetching_(false) {
DCHECK(profile);
}
void CannedBrowsingDataIndexedDBHelper::AddIndexedDB(
const GURL& origin, const string16& description) {
- WebSecurityOrigin web_security_origin =
- WebSecurityOrigin::createFromString(
- UTF8ToUTF16(origin.spec()));
- std::string security_origin(web_security_origin.toString().utf8());
-
- for (std::vector<IndexedDBInfo>::iterator
- indexed_db = indexed_db_info_.begin();
- indexed_db != indexed_db_info_.end(); ++indexed_db) {
- if (indexed_db->origin == security_origin)
- return;
- }
-
- indexed_db_info_.push_back(IndexedDBInfo(
- web_security_origin.protocol().utf8(),
- web_security_origin.host().utf8(),
- web_security_origin.port(),
- web_security_origin.databaseIdentifier().utf8(),
- security_origin,
- profile_->GetWebKitContext()->indexed_db_context()->
- GetIndexedDBFilePath(web_security_origin.databaseIdentifier()),
- 0,
- base::Time()));
+ base::AutoLock auto_lock(lock_);
+ pending_indexed_db_info_.push_back(PendingIndexedDBInfo(origin, description));
}
void CannedBrowsingDataIndexedDBHelper::Reset() {
+ base::AutoLock auto_lock(lock_);
indexed_db_info_.clear();
+ pending_indexed_db_info_.clear();
}
bool CannedBrowsingDataIndexedDBHelper::empty() const {
- return indexed_db_info_.empty();
+ base::AutoLock auto_lock(lock_);
+ return indexed_db_info_.empty() && pending_indexed_db_info_.empty();
}
void CannedBrowsingDataIndexedDBHelper::StartFetching(
Callback1<const std::vector<IndexedDBInfo>& >::Type* callback) {
- callback->Run(indexed_db_info_);
- delete callback;
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!is_fetching_);
+ DCHECK(callback);
+ is_fetching_ = true;
+ completion_callback_.reset(callback);
+ BrowserThread::PostTask(BrowserThread::WEBKIT, FROM_HERE, NewRunnableMethod(
+ this,
+ &CannedBrowsingDataIndexedDBHelper::ConvertPendingInfoInWebKitThread));
}
CannedBrowsingDataIndexedDBHelper::~CannedBrowsingDataIndexedDBHelper() {}
+
+void CannedBrowsingDataIndexedDBHelper::ConvertPendingInfoInWebKitThread() {
+ base::AutoLock auto_lock(lock_);
+ for (std::vector<PendingIndexedDBInfo>::const_iterator
+ info = pending_indexed_db_info_.begin();
+ info != pending_indexed_db_info_.end(); ++info) {
+ WebSecurityOrigin web_security_origin =
+ WebSecurityOrigin::createFromString(
+ UTF8ToUTF16(info->origin.spec()));
+ std::string security_origin(web_security_origin.toString().utf8());
+
+ bool duplicate = false;
+ for (std::vector<IndexedDBInfo>::iterator
+ indexed_db = indexed_db_info_.begin();
+ indexed_db != indexed_db_info_.end(); ++indexed_db) {
+ if (indexed_db->origin == security_origin) {
+ duplicate = true;
+ break;
+ }
+ }
+ if (duplicate)
+ continue;
+
+ indexed_db_info_.push_back(IndexedDBInfo(
+ web_security_origin.protocol().utf8(),
+ web_security_origin.host().utf8(),
+ web_security_origin.port(),
+ web_security_origin.databaseIdentifier().utf8(),
+ security_origin,
+ profile_->GetWebKitContext()->indexed_db_context()->
+ GetIndexedDBFilePath(web_security_origin.databaseIdentifier()),
+ 0,
+ base::Time()));
+ }
+ pending_indexed_db_info_.clear();
+
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ NewRunnableMethod(
+ this, &CannedBrowsingDataIndexedDBHelper::NotifyInUIThread));
+}
+
+void CannedBrowsingDataIndexedDBHelper::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_ != NULL) {
+ 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 129987b..e0f25b6 100644
--- a/chrome/browser/browsing_data_indexed_db_helper.h
+++ b/chrome/browser/browsing_data_indexed_db_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.
@@ -12,6 +12,8 @@
#include "base/callback.h"
#include "base/file_path.h"
#include "base/ref_counted.h"
+#include "base/scoped_ptr.h"
+#include "base/synchronization/lock.h"
#include "base/time.h"
#include "chrome/common/url_constants.h"
#include "googleurl/src/gurl.h"
@@ -101,12 +103,43 @@ class CannedBrowsingDataIndexedDBHelper
virtual void DeleteIndexedDBFile(const FilePath& file_path) {}
private:
+ struct PendingIndexedDBInfo {
+ PendingIndexedDBInfo();
+ PendingIndexedDBInfo(const GURL& origin, const string16& description);
+ ~PendingIndexedDBInfo();
+
+ GURL origin;
+ string16 description;
+ };
+
virtual ~CannedBrowsingDataIndexedDBHelper();
+ // Convert the pending indexed db info to indexed db info objects.
+ void ConvertPendingInfoInWebKitThread();
+
+ void NotifyInUIThread();
+
Profile* profile_;
+ // Lock to protect access to pending_indexed_db_info_;
+ mutable base::Lock lock_;
+
+ // This may mutate on WEBKIT and UI threads.
+ std::vector<PendingIndexedDBInfo> pending_indexed_db_info_;
+
+ // This only mutates on the WEBKIT thread.
std::vector<IndexedDBInfo> indexed_db_info_;
+ // This only mutates on the UI thread.
+ scoped_ptr<Callback1<const std::vector<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
+ // after we notified the callback in the UI thread.
+ // This only mutates on the UI thread.
+ bool is_fetching_;
+
DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataIndexedDBHelper);
};
diff --git a/chrome/browser/browsing_data_indexed_db_helper_browsertest.cc b/chrome/browser/browsing_data_indexed_db_helper_browsertest.cc
new file mode 100644
index 0000000..73b005b
--- /dev/null
+++ b/chrome/browser/browsing_data_indexed_db_helper_browsertest.cc
@@ -0,0 +1,75 @@
+// 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.
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/callback.h"
+#include "base/file_path.h"
+#include "base/message_loop.h"
+#include "base/ref_counted.h"
+#include "base/utf_string_conversions.h"
+#include "chrome/browser/browsing_data_helper_browsertest.h"
+#include "chrome/browser/browsing_data_indexed_db_helper.h"
+#include "chrome/test/in_process_browser_test.h"
+#include "chrome/test/testing_profile.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+typedef BrowsingDataHelperCallback<BrowsingDataIndexedDBHelper::IndexedDBInfo>
+ TestCompletionCallback;
+
+class BrowsingDataIndexedDBHelperTest : public InProcessBrowserTest {
+ protected:
+ TestingProfile testing_profile_;
+};
+
+IN_PROC_BROWSER_TEST_F(BrowsingDataIndexedDBHelperTest, CannedAddIndexedDB) {
+ const GURL origin1("http://host1:1/");
+ const GURL origin2("http://host2:1/");
+ const string16 description(ASCIIToUTF16("description"));
+ const FilePath::CharType file1[] =
+ FILE_PATH_LITERAL("http_host1_1.indexeddb");
+ const FilePath::CharType file2[] =
+ FILE_PATH_LITERAL("http_host2_1.indexeddb");
+
+ scoped_refptr<CannedBrowsingDataIndexedDBHelper> helper(
+ new CannedBrowsingDataIndexedDBHelper(&testing_profile_));
+ helper->AddIndexedDB(origin1, description);
+ helper->AddIndexedDB(origin2, description);
+
+ TestCompletionCallback callback;
+ helper->StartFetching(
+ NewCallback(&callback, &TestCompletionCallback::callback));
+
+ std::vector<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());
+}
+
+IN_PROC_BROWSER_TEST_F(BrowsingDataIndexedDBHelperTest, CannedUnique) {
+ const GURL origin("http://host1:1/");
+ const string16 description(ASCIIToUTF16("description"));
+ const FilePath::CharType file[] =
+ FILE_PATH_LITERAL("http_host1_1.indexeddb");
+
+ scoped_refptr<CannedBrowsingDataIndexedDBHelper> helper(
+ new CannedBrowsingDataIndexedDBHelper(&testing_profile_));
+ helper->AddIndexedDB(origin, description);
+ helper->AddIndexedDB(origin, description);
+
+ TestCompletionCallback callback;
+ helper->StartFetching(
+ NewCallback(&callback, &TestCompletionCallback::callback));
+
+ std::vector<BrowsingDataIndexedDBHelper::IndexedDBInfo> result =
+ callback.result();
+
+ ASSERT_EQ(1U, result.size());
+ EXPECT_EQ(FilePath(file).value(), result[0].file_path.BaseName().value());
+}
+} // namespace
diff --git a/chrome/browser/browsing_data_indexed_db_helper_unittest.cc b/chrome/browser/browsing_data_indexed_db_helper_unittest.cc
index 8473a57..f7e1af4 100644
--- a/chrome/browser/browsing_data_indexed_db_helper_unittest.cc
+++ b/chrome/browser/browsing_data_indexed_db_helper_unittest.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.
@@ -7,91 +7,8 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/browsing_data_indexed_db_helper.h"
#include "chrome/test/testing_profile.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebCString.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
namespace {
-
-class TestCompletionCallback {
- public:
- TestCompletionCallback() : has_result_(false) {}
-
- bool has_result() const { return has_result_; }
-
- const std::vector<BrowsingDataIndexedDBHelper::IndexedDBInfo>& result() {
- return result_;
- }
-
- void callback(
- const std::vector<BrowsingDataIndexedDBHelper::IndexedDBInfo>& info) {
- has_result_ = true;
- result_ = info;
- }
-
- private:
- bool has_result_;
- std::vector<BrowsingDataIndexedDBHelper::IndexedDBInfo> result_;
-
- DISALLOW_COPY_AND_ASSIGN(TestCompletionCallback);
-};
-
-// Functionality incomplete, needs further refactoring, http://crbug.com/60532.
-TEST(CannedBrowsingDataIndexedDBHelperTest, DISABLED_AddIndexedDB) {
- TestingProfile profile;
-
- const GURL origin1("http://host1:1/");
- const GURL origin2("http://host2:1/");
- const string16 description(ASCIIToUTF16("description"));
- const FilePath::CharType file1[] =
- FILE_PATH_LITERAL("http_host1_1.indexeddb");
- const FilePath::CharType file2[] =
- FILE_PATH_LITERAL("http_host2_1.indexeddb");
-
- scoped_refptr<CannedBrowsingDataIndexedDBHelper> helper(
- new CannedBrowsingDataIndexedDBHelper(&profile));
- helper->AddIndexedDB(origin1, description);
- helper->AddIndexedDB(origin2, description);
-
- TestCompletionCallback callback;
- helper->StartFetching(
- NewCallback(&callback, &TestCompletionCallback::callback));
- ASSERT_TRUE(callback.has_result());
-
- std::vector<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());
-}
-
-// Functionality incomplete, needs further refactoring, http://crbug.com/60532.
-TEST(CannedBrowsingDataIndexedDBHelperTest, DISABLED_Unique) {
- TestingProfile profile;
-
- const GURL origin("http://host1:1/");
- const string16 description(ASCIIToUTF16("description"));
- const FilePath::CharType file[] =
- FILE_PATH_LITERAL("http_host1_1.indexeddb");
-
- scoped_refptr<CannedBrowsingDataIndexedDBHelper> helper(
- new CannedBrowsingDataIndexedDBHelper(&profile));
- helper->AddIndexedDB(origin, description);
- helper->AddIndexedDB(origin, description);
-
- TestCompletionCallback callback;
- helper->StartFetching(
- NewCallback(&callback, &TestCompletionCallback::callback));
- ASSERT_TRUE(callback.has_result());
-
- std::vector<BrowsingDataIndexedDBHelper::IndexedDBInfo> result =
- callback.result();
-
- ASSERT_EQ(1U, result.size());
- EXPECT_EQ(FilePath(file).value(), result[0].file_path.BaseName().value());
-}
-
TEST(CannedBrowsingDataIndexedDBHelperTest, Empty) {
TestingProfile profile;
@@ -107,5 +24,4 @@ TEST(CannedBrowsingDataIndexedDBHelperTest, Empty) {
helper->Reset();
ASSERT_TRUE(helper->empty());
}
-
} // namespace
diff --git a/chrome/browser/browsing_data_local_storage_helper.cc b/chrome/browser/browsing_data_local_storage_helper.cc
index 4a035d5..e16f24d 100644
--- a/chrome/browser/browsing_data_local_storage_helper.cc
+++ b/chrome/browser/browsing_data_local_storage_helper.cc
@@ -16,6 +16,8 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
#include "webkit/glue/webkit_glue.h"
+using WebKit::WebSecurityOrigin;
+
BrowsingDataLocalStorageHelper::LocalStorageInfo::LocalStorageInfo() {}
BrowsingDataLocalStorageHelper::LocalStorageInfo::LocalStorageInfo(
@@ -91,8 +93,8 @@ void BrowsingDataLocalStorageHelper::FetchLocalStorageInfoInWebKitThread() {
for (FilePath file_path = file_enumerator.Next(); !file_path.empty();
file_path = file_enumerator.Next()) {
if (file_path.Extension() == DOMStorageContext::kLocalStorageExtension) {
- WebKit::WebSecurityOrigin web_security_origin =
- WebKit::WebSecurityOrigin::createFromDatabaseIdentifier(
+ WebSecurityOrigin web_security_origin =
+ WebSecurityOrigin::createFromDatabaseIdentifier(
webkit_glue::FilePathToWebString(file_path.BaseName()));
if (EqualsASCII(web_security_origin.protocol(),
chrome::kExtensionScheme)) {
@@ -147,40 +149,72 @@ CannedBrowsingDataLocalStorageHelper::CannedBrowsingDataLocalStorageHelper(
void CannedBrowsingDataLocalStorageHelper::AddLocalStorage(
const GURL& origin) {
- WebKit::WebSecurityOrigin web_security_origin =
- WebKit::WebSecurityOrigin::createFromString(
- UTF8ToUTF16(origin.spec()));
- std::string security_origin(web_security_origin.toString().utf8());
-
- for (std::vector<LocalStorageInfo>::iterator
- local_storage = local_storage_info_.begin();
- local_storage != local_storage_info_.end(); ++local_storage) {
- if (local_storage->origin == security_origin)
- return;
- }
-
- local_storage_info_.push_back(LocalStorageInfo(
- web_security_origin.protocol().utf8(),
- web_security_origin.host().utf8(),
- web_security_origin.port(),
- web_security_origin.databaseIdentifier().utf8(),
- security_origin,
- profile_->GetWebKitContext()->dom_storage_context()->
- GetLocalStorageFilePath(web_security_origin.databaseIdentifier()),
- 0,
- base::Time()));
+ base::AutoLock auto_lock(lock_);
+ pending_local_storage_info_.push_back(origin);
}
void CannedBrowsingDataLocalStorageHelper::Reset() {
+ base::AutoLock auto_lock(lock_);
local_storage_info_.clear();
+ pending_local_storage_info_.clear();
}
bool CannedBrowsingDataLocalStorageHelper::empty() const {
- return local_storage_info_.empty();
+ base::AutoLock auto_lock(lock_);
+ return local_storage_info_.empty() && pending_local_storage_info_.empty();
}
void CannedBrowsingDataLocalStorageHelper::StartFetching(
Callback1<const std::vector<LocalStorageInfo>& >::Type* callback) {
- callback->Run(local_storage_info_);
- delete callback;
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!is_fetching_);
+ DCHECK(callback);
+ is_fetching_ = true;
+ completion_callback_.reset(callback);
+ BrowserThread::PostTask(
+ BrowserThread::WEBKIT, FROM_HERE,
+ NewRunnableMethod(
+ this,
+ &CannedBrowsingDataLocalStorageHelper::
+ ConvertPendingInfoInWebKitThread));
+}
+
+void CannedBrowsingDataLocalStorageHelper::ConvertPendingInfoInWebKitThread() {
+ base::AutoLock auto_lock(lock_);
+ for (std::vector<GURL>::iterator info = pending_local_storage_info_.begin();
+ info != pending_local_storage_info_.end(); ++info) {
+ WebSecurityOrigin web_security_origin =
+ WebSecurityOrigin::createFromString(
+ UTF8ToUTF16(info->spec()));
+ std::string security_origin(web_security_origin.toString().utf8());
+
+ bool duplicate = false;
+ for (std::vector<LocalStorageInfo>::iterator
+ local_storage = local_storage_info_.begin();
+ local_storage != local_storage_info_.end(); ++local_storage) {
+ if (local_storage->origin == security_origin) {
+ duplicate = true;
+ break;
+ }
+ }
+ if (duplicate)
+ continue;
+
+ local_storage_info_.push_back(LocalStorageInfo(
+ web_security_origin.protocol().utf8(),
+ web_security_origin.host().utf8(),
+ web_security_origin.port(),
+ web_security_origin.databaseIdentifier().utf8(),
+ security_origin,
+ profile_->GetWebKitContext()->dom_storage_context()->
+ GetLocalStorageFilePath(web_security_origin.databaseIdentifier()),
+ 0,
+ base::Time()));
+ }
+ pending_local_storage_info_.clear();
+
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ NewRunnableMethod(
+ this, &CannedBrowsingDataLocalStorageHelper::NotifyInUIThread));
}
diff --git a/chrome/browser/browsing_data_local_storage_helper.h b/chrome/browser/browsing_data_local_storage_helper.h
index f363542..227b200 100644
--- a/chrome/browser/browsing_data_local_storage_helper.h
+++ b/chrome/browser/browsing_data_local_storage_helper.h
@@ -12,6 +12,7 @@
#include "base/callback.h"
#include "base/file_path.h"
#include "base/scoped_ptr.h"
+#include "base/synchronization/lock.h"
#include "base/time.h"
#include "chrome/common/url_constants.h"
#include "googleurl/src/gurl.h"
@@ -74,28 +75,30 @@ class BrowsingDataLocalStorageHelper
friend class base::RefCountedThreadSafe<BrowsingDataLocalStorageHelper>;
virtual ~BrowsingDataLocalStorageHelper();
- Profile* profile_;
-
- // This only mutates in the WEBKIT thread.
- std::vector<LocalStorageInfo> local_storage_info_;
-
- private:
- // Enumerates all local storage files in the WEBKIT thread.
- void FetchLocalStorageInfoInWebKitThread();
// Notifies the completion callback in the UI thread.
void NotifyInUIThread();
- // Delete a single local storage file in the WEBKIT thread.
- void DeleteLocalStorageFileInWebKitThread(const FilePath& file_path);
+
+ Profile* profile_;
// This only mutates on the UI thread.
scoped_ptr<Callback1<const std::vector<LocalStorageInfo>& >::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
// after we notified the callback in the UI thread.
// This only mutates on the UI thread.
bool is_fetching_;
+ // This only mutates in the WEBKIT thread.
+ std::vector<LocalStorageInfo> local_storage_info_;
+
+ private:
+ // Enumerates all local storage files in the WEBKIT thread.
+ void FetchLocalStorageInfoInWebKitThread();
+ // Delete a single local storage file in the WEBKIT thread.
+ void DeleteLocalStorageFileInWebKitThread(const FilePath& file_path);
+
DISALLOW_COPY_AND_ASSIGN(BrowsingDataLocalStorageHelper);
};
@@ -125,6 +128,15 @@ class CannedBrowsingDataLocalStorageHelper
private:
virtual ~CannedBrowsingDataLocalStorageHelper() {}
+ // Convert the pending local storage info to local storage info objects.
+ void ConvertPendingInfoInWebKitThread();
+
+ // Used to protect access to pending_local_storage_info_.
+ mutable base::Lock lock_;
+
+ // May mutate on WEBKIT and UI threads.
+ std::vector<GURL> pending_local_storage_info_;
+
DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataLocalStorageHelper);
};
diff --git a/chrome/browser/browsing_data_local_storage_helper_browsertest.cc b/chrome/browser/browsing_data_local_storage_helper_browsertest.cc
index 8a94cbc1..90ee6b2 100644
--- a/chrome/browser/browsing_data_local_storage_helper_browsertest.cc
+++ b/chrome/browser/browsing_data_local_storage_helper_browsertest.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.
@@ -11,6 +11,7 @@
#include "base/ref_counted.h"
#include "chrome/browser/in_process_webkit/webkit_context.h"
#include "chrome/browser/in_process_webkit/webkit_thread.h"
+#include "chrome/browser/browsing_data_helper_browsertest.h"
#include "chrome/browser/browsing_data_local_storage_helper.h"
#include "chrome/test/in_process_browser_test.h"
#include "chrome/test/testing_profile.h"
@@ -18,20 +19,24 @@
#include "chrome/test/ui_test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
-static const FilePath::CharType kTestFile0[] =
+namespace {
+typedef
+ BrowsingDataHelperCallback<BrowsingDataLocalStorageHelper::LocalStorageInfo>
+ TestCompletionCallback;
+
+const FilePath::CharType kTestFile0[] =
FILE_PATH_LITERAL("http_www.chromium.org_0.localstorage");
-static const FilePath::CharType kTestFile1[] =
+const FilePath::CharType kTestFile1[] =
FILE_PATH_LITERAL("http_www.google.com_0.localstorage");
-static const FilePath::CharType kTestFileInvalid[] =
+const FilePath::CharType kTestFileInvalid[] =
FILE_PATH_LITERAL("http_www.google.com_localstorage_0.foo");
// This is only here to test that extension state is not listed by the helper.
-static const FilePath::CharType kTestFileExtension[] = FILE_PATH_LITERAL(
+const FilePath::CharType kTestFileExtension[] = FILE_PATH_LITERAL(
"chrome-extension_behllobkkfkfnphdnhnkndlbkcpglgmj_0.localstorage");
-
class BrowsingDataLocalStorageHelperTest : public InProcessBrowserTest {
protected:
void CreateLocalStorageFilesForTest() {
@@ -128,3 +133,51 @@ IN_PROC_BROWSER_TEST_F(BrowsingDataLocalStorageHelperTest, DeleteSingleFile) {
}
ASSERT_EQ(3, num_files);
}
+
+IN_PROC_BROWSER_TEST_F(BrowsingDataLocalStorageHelperTest,
+ CannedAddLocalStorage) {
+ const GURL origin1("http://host1:1/");
+ const GURL origin2("http://host2:1/");
+ const FilePath::CharType file1[] =
+ FILE_PATH_LITERAL("http_host1_1.localstorage");
+ const FilePath::CharType file2[] =
+ FILE_PATH_LITERAL("http_host2_1.localstorage");
+
+ scoped_refptr<CannedBrowsingDataLocalStorageHelper> helper(
+ new CannedBrowsingDataLocalStorageHelper(&testing_profile_));
+ helper->AddLocalStorage(origin1);
+ helper->AddLocalStorage(origin2);
+
+ TestCompletionCallback callback;
+ helper->StartFetching(
+ NewCallback(&callback, &TestCompletionCallback::callback));
+
+ std::vector<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());
+}
+
+IN_PROC_BROWSER_TEST_F(BrowsingDataLocalStorageHelperTest, CannedUnique) {
+ const GURL origin("http://host1:1/");
+ const FilePath::CharType file[] =
+ FILE_PATH_LITERAL("http_host1_1.localstorage");
+
+ scoped_refptr<CannedBrowsingDataLocalStorageHelper> helper(
+ new CannedBrowsingDataLocalStorageHelper(&testing_profile_));
+ helper->AddLocalStorage(origin);
+ helper->AddLocalStorage(origin);
+
+ TestCompletionCallback callback;
+ helper->StartFetching(
+ NewCallback(&callback, &TestCompletionCallback::callback));
+
+ std::vector<BrowsingDataLocalStorageHelper::LocalStorageInfo> result =
+ callback.result();
+
+ ASSERT_EQ(1u, result.size());
+ EXPECT_EQ(FilePath(file).value(), result[0].file_path.BaseName().value());
+}
+} // namespace
diff --git a/chrome/browser/browsing_data_local_storage_helper_unittest.cc b/chrome/browser/browsing_data_local_storage_helper_unittest.cc
index 6fbb1ee..7279151 100644
--- a/chrome/browser/browsing_data_local_storage_helper_unittest.cc
+++ b/chrome/browser/browsing_data_local_storage_helper_unittest.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.
@@ -8,85 +8,6 @@
#include "testing/gtest/include/gtest/gtest.h"
namespace {
-class TestCompletionCallback {
- public:
- TestCompletionCallback()
- : have_result_(false) {
- }
-
- bool have_result() const { return have_result_; }
-
- const std::vector<BrowsingDataLocalStorageHelper::LocalStorageInfo>& result()
- {
- return result_;
- }
-
- void callback(const std::vector<
- BrowsingDataLocalStorageHelper::LocalStorageInfo>& info) {
- have_result_ = true;
- result_ = info;
- }
-
- private:
- bool have_result_;
- std::vector<BrowsingDataLocalStorageHelper::LocalStorageInfo> result_;
-
- DISALLOW_COPY_AND_ASSIGN(TestCompletionCallback);
-};
-} // namespace
-
-TEST(CannedBrowsingDataLocalStorageTest, AddLocalStorage) {
- TestingProfile profile;
-
- const GURL origin1("http://host1:1/");
- const GURL origin2("http://host2:1/");
- const FilePath::CharType file1[] =
- FILE_PATH_LITERAL("http_host1_1.localstorage");
- const FilePath::CharType file2[] =
- FILE_PATH_LITERAL("http_host2_1.localstorage");
-
- scoped_refptr<CannedBrowsingDataLocalStorageHelper> helper(
- new CannedBrowsingDataLocalStorageHelper(&profile));
- helper->AddLocalStorage(origin1);
- helper->AddLocalStorage(origin2);
-
- TestCompletionCallback callback;
- helper->StartFetching(
- NewCallback(&callback, &TestCompletionCallback::callback));
- ASSERT_TRUE(callback.have_result());
-
- std::vector<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());
-}
-
-TEST(CannedBrowsingDataLocalStorageTest, Unique) {
- TestingProfile profile;
-
- const GURL origin("http://host1:1/");
- const FilePath::CharType file[] =
- FILE_PATH_LITERAL("http_host1_1.localstorage");
-
- scoped_refptr<CannedBrowsingDataLocalStorageHelper> helper(
- new CannedBrowsingDataLocalStorageHelper(&profile));
- helper->AddLocalStorage(origin);
- helper->AddLocalStorage(origin);
-
- TestCompletionCallback callback;
- helper->StartFetching(
- NewCallback(&callback, &TestCompletionCallback::callback));
- ASSERT_TRUE(callback.have_result());
-
- std::vector<BrowsingDataLocalStorageHelper::LocalStorageInfo> result =
- callback.result();
-
- ASSERT_EQ(1u, result.size());
- EXPECT_EQ(FilePath(file).value(), result[0].file_path.BaseName().value());
-}
-
TEST(CannedBrowsingDataLocalStorageTest, Empty) {
TestingProfile profile;
@@ -101,3 +22,4 @@ TEST(CannedBrowsingDataLocalStorageTest, Empty) {
helper->Reset();
ASSERT_TRUE(helper->empty());
}
+} // namespace
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index a561870..3c18cdd 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -2036,6 +2036,8 @@
'browser/autofill/form_structure_browsertest.cc',
'browser/browser_browsertest.cc',
'browser/browsing_data_database_helper_browsertest.cc',
+ 'browser/browsing_data_helper_browsertest.h',
+ 'browser/browsing_data_indexed_db_helper_browsertest.cc',
'browser/browsing_data_local_storage_helper_browsertest.cc',
'browser/child_process_security_policy_browsertest.cc',
'browser/chromeos/cros/cros_in_process_browser_test.cc',
diff --git a/ppapi/c/dev/ppb_opengles_dev.h b/ppapi/c/dev/ppb_opengles_dev.h
index a4caa84..254a313 100644
--- a/ppapi/c/dev/ppb_opengles_dev.h
+++ b/ppapi/c/dev/ppb_opengles_dev.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
diff --git a/ppapi/lib/gl/gles2/gles2.c b/ppapi/lib/gl/gles2/gles2.c
index 5dc1acc..fe27e1b 100644
--- a/ppapi/lib/gl/gles2/gles2.c
+++ b/ppapi/lib/gl/gles2/gles2.c
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
diff --git a/webkit/plugins/ppapi/ppb_opengles_impl.cc b/webkit/plugins/ppapi/ppb_opengles_impl.cc
index df0ce19..bd233d0 100644
--- a/webkit/plugins/ppapi/ppb_opengles_impl.cc
+++ b/webkit/plugins/ppapi/ppb_opengles_impl.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.