Commit cd9adcb8 authored by tzik@chromium.org's avatar tzik@chromium.org

Adding usage entry to chrome://settings/cookies.


BUG=88644
TEST='BrowsingDataQuotaHelperTest.*'


Review URL: http://codereview.chromium.org/7387007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95607 0039d316-1c4b-4281-b951-d872f2087c98
parent 18c685f5
// 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 "chrome/browser/browsing_data_quota_helper.h"
BrowsingDataQuotaHelper::QuotaInfo::QuotaInfo()
: temporary_usage(0),
persistent_usage(0) {}
BrowsingDataQuotaHelper::QuotaInfo::QuotaInfo(const std::string& host)
: host(host),
temporary_usage(0),
persistent_usage(0) {}
BrowsingDataQuotaHelper::QuotaInfo::QuotaInfo(const std::string& host,
int64 temporary_usage,
int64 persistent_usage)
: host(host),
temporary_usage(temporary_usage),
persistent_usage(persistent_usage) {}
BrowsingDataQuotaHelper::QuotaInfo::~QuotaInfo() {}
// static
void BrowsingDataQuotaHelperDeleter::Destruct(
const BrowsingDataQuotaHelper* helper) {
helper->io_thread_->DeleteSoon(FROM_HERE, helper);
}
BrowsingDataQuotaHelper::BrowsingDataQuotaHelper(
base::MessageLoopProxy* io_thread)
: io_thread_(io_thread) {
}
BrowsingDataQuotaHelper::~BrowsingDataQuotaHelper() {
}
bool operator <(const BrowsingDataQuotaHelper::QuotaInfo& lhs,
const BrowsingDataQuotaHelper::QuotaInfo& rhs) {
if (lhs.host != rhs.host)
return lhs.host < rhs.host;
if (lhs.temporary_usage != rhs.temporary_usage)
return lhs.temporary_usage < rhs.temporary_usage;
return lhs.persistent_usage < rhs.persistent_usage;
}
bool operator ==(const BrowsingDataQuotaHelper::QuotaInfo& lhs,
const BrowsingDataQuotaHelper::QuotaInfo& rhs) {
return lhs.host == rhs.host &&
lhs.temporary_usage == rhs.temporary_usage &&
lhs.persistent_usage == rhs.persistent_usage;
}
// 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.
#ifndef CHROME_BROWSER_BROWSING_DATA_QUOTA_HELPER_H_
#define CHROME_BROWSER_BROWSING_DATA_QUOTA_HELPER_H_
#pragma once
#include <string>
#include <vector>
#include "base/callback_old.h"
#include "base/memory/ref_counted.h"
#include "base/message_loop_proxy.h"
#include "base/time.h"
#include "content/browser/browser_thread.h"
#include "webkit/quota/quota_types.h"
class Profile;
namespace quota {
class QuotaManager;
}
class BrowsingDataQuotaHelper;
struct BrowsingDataQuotaHelperDeleter {
static void Destruct(const BrowsingDataQuotaHelper* helper);
};
// This class is an interface class to bridge between Cookies Tree and Unified
// Quota System. This class provides a way to get usage and quota information
// through the instance.
//
// Call Create to create an instance for a profile and call StartFetching with
// a callback to fetch information asynchronously. If result is no longer needed
// after StartFetching, call CancelNotification to prevent callback.
//
// Parallel fetching is not allowed, a fetching task should start after end of
// previous task. All method of this class should called from UI thread.
class BrowsingDataQuotaHelper
: public base::RefCountedThreadSafe<BrowsingDataQuotaHelper,
BrowsingDataQuotaHelperDeleter> {
public:
// QuotaInfo contains host-based quota and usage information for persistent
// and temporary storage.
struct QuotaInfo {
QuotaInfo();
explicit QuotaInfo(const std::string& host);
QuotaInfo(const std::string& host,
int64 temporary_usage,
int64 persistent_usage);
~QuotaInfo();
std::string host;
int64 temporary_usage;
int64 persistent_usage;
};
typedef std::vector<QuotaInfo> QuotaInfoArray;
typedef Callback1<const QuotaInfoArray&>::Type FetchResultCallback;
static BrowsingDataQuotaHelper* Create(Profile* profile);
virtual void StartFetching(FetchResultCallback* callback) = 0;
virtual void CancelNotification() = 0;
// We don't support deletion now.
virtual void DeleteQuotaHost(const std::string& host) {}
protected:
explicit BrowsingDataQuotaHelper(base::MessageLoopProxy* io_thread_);
virtual ~BrowsingDataQuotaHelper();
private:
friend class DeleteTask<const BrowsingDataQuotaHelper>;
friend struct BrowsingDataQuotaHelperDeleter;
scoped_refptr<base::MessageLoopProxy> io_thread_;
DISALLOW_COPY_AND_ASSIGN(BrowsingDataQuotaHelper);
};
bool operator <(const BrowsingDataQuotaHelper::QuotaInfo& lhs,
const BrowsingDataQuotaHelper::QuotaInfo& rhs);
bool operator ==(const BrowsingDataQuotaHelper::QuotaInfo& lhs,
const BrowsingDataQuotaHelper::QuotaInfo& rhs);
#endif // CHROME_BROWSER_BROWSING_DATA_QUOTA_HELPER_H_
// 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 "chrome/browser/browsing_data_quota_helper_impl.h"
#include <map>
#include <set>
#include "base/logging.h"
#include "chrome/browser/profiles/profile.h"
#include "webkit/quota/quota_manager.h"
// static
BrowsingDataQuotaHelper* BrowsingDataQuotaHelper::Create(Profile* profile) {
return new BrowsingDataQuotaHelperImpl(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
profile->GetQuotaManager());
}
BrowsingDataQuotaHelperImpl::BrowsingDataQuotaHelperImpl(
base::MessageLoopProxy* ui_thread,
base::MessageLoopProxy* io_thread,
quota::QuotaManager* quota_manager)
: BrowsingDataQuotaHelper(io_thread),
quota_manager_(quota_manager),
is_fetching_(false),
ui_thread_(ui_thread),
io_thread_(io_thread),
callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
DCHECK(quota_manager);
}
BrowsingDataQuotaHelperImpl::~BrowsingDataQuotaHelperImpl() {}
void BrowsingDataQuotaHelperImpl::StartFetching(FetchResultCallback* callback) {
DCHECK(callback);
DCHECK(!callback_.get());
DCHECK(!is_fetching_);
callback_.reset(callback);
quota_info_.clear();
is_fetching_ = true;
FetchQuotaInfo();
}
void BrowsingDataQuotaHelperImpl::CancelNotification() {
callback_.reset();
}
void BrowsingDataQuotaHelperImpl::FetchQuotaInfo() {
if (!io_thread_->BelongsToCurrentThread()) {
io_thread_->PostTask(
FROM_HERE,
NewRunnableMethod(
this,
&BrowsingDataQuotaHelperImpl::FetchQuotaInfo));
return;
}
quota_manager_->GetOriginsModifiedSince(
quota::kStorageTypeTemporary,
base::Time(),
callback_factory_.NewCallback(
&BrowsingDataQuotaHelperImpl::GotOrigins));
}
void BrowsingDataQuotaHelperImpl::GotOrigins(
const std::set<GURL>& origins, quota::StorageType type) {
for (std::set<GURL>::const_iterator itr = origins.begin();
itr != origins.end();
++itr)
pending_hosts_.insert(std::make_pair(itr->host(), type));
DCHECK(type == quota::kStorageTypeTemporary ||
type == quota::kStorageTypePersistent);
if (type == quota::kStorageTypeTemporary) {
quota_manager_->GetOriginsModifiedSince(
quota::kStorageTypePersistent,
base::Time(),
callback_factory_.NewCallback(
&BrowsingDataQuotaHelperImpl::GotOrigins));
} else {
// type == quota::kStorageTypePersistent
ProcessPendingHosts();
}
}
void BrowsingDataQuotaHelperImpl::ProcessPendingHosts() {
if (pending_hosts_.empty()) {
OnComplete();
return;
}
PendingHosts::iterator itr = pending_hosts_.begin();
std::string host = itr->first;
quota::StorageType type = itr->second;
pending_hosts_.erase(itr);
GetHostUsage(host, type);
}
void BrowsingDataQuotaHelperImpl::GetHostUsage(const std::string& host,
quota::StorageType type) {
DCHECK(quota_manager_.get());
quota_manager_->GetHostUsage(
host, type,
callback_factory_.NewCallback(
&BrowsingDataQuotaHelperImpl::GotHostUsage));
}
void BrowsingDataQuotaHelperImpl::GotHostUsage(const std::string& host,
quota::StorageType type,
int64 usage) {
switch (type) {
case quota::kStorageTypeTemporary:
quota_info_[host].temporary_usage = usage;
break;
case quota::kStorageTypePersistent:
quota_info_[host].persistent_usage = usage;
break;
default:
NOTREACHED();
}
ProcessPendingHosts();
}
void BrowsingDataQuotaHelperImpl::OnComplete() {
// Check if CancelNotification was called
if (!callback_.get())
return;
if (!ui_thread_->BelongsToCurrentThread()) {
ui_thread_->PostTask(
FROM_HERE,
NewRunnableMethod(
this,
&BrowsingDataQuotaHelperImpl::OnComplete));
return;
}
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();
++itr) {
QuotaInfo* info = &itr->second;
// Skip unused entries
if (info->temporary_usage <= 0 &&
info->persistent_usage <= 0)
continue;
info->host = itr->first;
result.push_back(*info);
}
callback_->Run(result);
callback_.reset();
}
// 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.
#ifndef CHROME_BROWSER_BROWSING_DATA_QUOTA_HELPER_IMPL_H_
#define CHROME_BROWSER_BROWSING_DATA_QUOTA_HELPER_IMPL_H_
#pragma once
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include "base/callback_old.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_callback_factory.h"
#include "base/memory/scoped_ptr.h"
#include "base/time.h"
#include "chrome/browser/browsing_data_quota_helper.h"
#include "content/browser/browser_thread.h"
#include "webkit/quota/quota_types.h"
namespace quota {
class QuotaManager;
}
// Implementation of BrowsingDataQuotaHelper. Since a client of
// BrowsingDataQuotaHelper should live in UI thread and QuotaManager lives in
// IO thread, we have to communicate over thread using PostTask.
class BrowsingDataQuotaHelperImpl : public BrowsingDataQuotaHelper {
public:
virtual void StartFetching(FetchResultCallback* callback) OVERRIDE;
virtual void CancelNotification() OVERRIDE;
private:
void FetchQuotaInfo();
void OnComplete();
void GetHostUsage(const std::string& host, quota::StorageType type);
void ProcessPendingHosts();
// Callback function for GetOriginModifiedSince.
void GotOrigins(const std::set<GURL>& origins, quota::StorageType type);
// Callback function for GetHostUsage.
void GotHostUsage(const std::string& host,
quota::StorageType type,
int64 usage);
explicit BrowsingDataQuotaHelperImpl(base::MessageLoopProxy* ui_thread,
base::MessageLoopProxy* io_thread,
quota::QuotaManager* quota_manager);
virtual ~BrowsingDataQuotaHelperImpl();
scoped_refptr<quota::QuotaManager> quota_manager_;
scoped_ptr<FetchResultCallback> callback_;
typedef std::set<std::pair<std::string, quota::StorageType> > PendingHosts;
PendingHosts pending_hosts_;
std::map<std::string, QuotaInfo> quota_info_;
bool is_fetching_;
scoped_refptr<base::MessageLoopProxy> ui_thread_;
scoped_refptr<base::MessageLoopProxy> io_thread_;
base::ScopedCallbackFactory<BrowsingDataQuotaHelperImpl> callback_factory_;
friend class BrowsingDataQuotaHelper;
friend class BrowsingDataQuotaHelperTest;
DISALLOW_COPY_AND_ASSIGN(BrowsingDataQuotaHelperImpl);
};
#endif // CHROME_BROWSER_BROWSING_DATA_QUOTA_HELPER_IMPL_H_
// 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 "testing/gtest/include/gtest/gtest.h"
#include "base/memory/scoped_callback_factory.h"
#include "base/message_loop_proxy.h"
#include "base/scoped_temp_dir.h"
#include "chrome/browser/browsing_data_quota_helper_impl.h"
#include "webkit/quota/mock_storage_client.h"
#include "webkit/quota/quota_manager.h"
class BrowsingDataQuotaHelperTest : public testing::Test {
public:
typedef BrowsingDataQuotaHelper::QuotaInfo QuotaInfo;
typedef BrowsingDataQuotaHelper::QuotaInfoArray QuotaInfoArray;
BrowsingDataQuotaHelperTest()
: ui_thread_(BrowserThread::UI, &message_loop_),
db_thread_(BrowserThread::DB, &message_loop_),
io_thread_(BrowserThread::IO, &message_loop_),
fetching_completed_(true),
callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {}
virtual ~BrowsingDataQuotaHelperTest() {}
virtual void SetUp() OVERRIDE {
EXPECT_TRUE(dir_.CreateUniqueTempDir());
quota_manager_ = new quota::QuotaManager(
false, dir_.path(),
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB),
NULL);
helper_ = new BrowsingDataQuotaHelperImpl(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
quota_manager_);
}
virtual void TearDown() OVERRIDE {
helper_ = NULL;
quota_manager_ = NULL;
quota_info_.clear();
}
protected:
const QuotaInfoArray& quota_info() const {
return quota_info_;
}
bool fetching_completed() const {
return fetching_completed_;
}
void StartFetching() {
fetching_completed_ = false;
helper_->StartFetching(
callback_factory_.NewCallback(
&BrowsingDataQuotaHelperTest::FetchCompleted));
}
void RegisterClient(const quota::MockOriginData* data, std::size_t data_len) {
quota::MockStorageClient* client =
new quota::MockStorageClient(
quota_manager_->proxy(), data, data_len);
quota_manager_->proxy()->RegisterClient(client);
client->TouchAllOriginsAndNotify();
}
private:
void FetchCompleted(const QuotaInfoArray& quota_info) {
quota_info_ = quota_info;
fetching_completed_ = true;
}
MessageLoop message_loop_;
BrowserThread ui_thread_;
BrowserThread db_thread_;
BrowserThread io_thread_;
scoped_refptr<quota::QuotaManager> quota_manager_;
ScopedTempDir dir_;
scoped_refptr<BrowsingDataQuotaHelper> helper_;
bool fetching_completed_;
QuotaInfoArray quota_info_;
base::ScopedCallbackFactory<BrowsingDataQuotaHelperTest> callback_factory_;
DISALLOW_COPY_AND_ASSIGN(BrowsingDataQuotaHelperTest);
};
TEST_F(BrowsingDataQuotaHelperTest, Empty) {
StartFetching();
MessageLoop::current()->RunAllPending();
EXPECT_TRUE(fetching_completed());
EXPECT_TRUE(quota_info().empty());
}
TEST_F(BrowsingDataQuotaHelperTest, FetchData) {
const quota::MockOriginData kOrigins[] = {
{"http://example.com/", quota::kStorageTypeTemporary, 1},
{"https://example.com/", quota::kStorageTypeTemporary, 10},
{"http://example.com/", quota::kStorageTypePersistent, 100},
{"http://example2.com/", quota::kStorageTypeTemporary, 1000},
};
RegisterClient(kOrigins, arraysize(kOrigins));
StartFetching();
MessageLoop::current()->RunAllPending();
EXPECT_TRUE(fetching_completed());
std::set<QuotaInfo> expected, actual;
actual.insert(quota_info().begin(), quota_info().end());
expected.insert(QuotaInfo("example.com", 11, 100));
expected.insert(QuotaInfo("example2.com", 1000, 0));
EXPECT_TRUE(expected == actual);
}
...@@ -526,5 +526,6 @@ TabSpecificContentSettings::LocalSharedObjectsContainer::GetCookiesTreeModel() { ...@@ -526,5 +526,6 @@ TabSpecificContentSettings::LocalSharedObjectsContainer::GetCookiesTreeModel() {
appcaches_->Clone(), appcaches_->Clone(),
indexed_dbs_->Clone(), indexed_dbs_->Clone(),
file_systems_->Clone(), file_systems_->Clone(),
NULL,
true); true);
} }
This diff is collapsed.
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "chrome/browser/browsing_data_file_system_helper.h" #include "chrome/browser/browsing_data_file_system_helper.h"
#include "chrome/browser/browsing_data_indexed_db_helper.h" #include "chrome/browser/browsing_data_indexed_db_helper.h"
#include "chrome/browser/browsing_data_local_storage_helper.h" #include "chrome/browser/browsing_data_local_storage_helper.h"
#include "chrome/browser/browsing_data_quota_helper.h"
#include "chrome/common/content_settings.h" #include "chrome/common/content_settings.h"
#include "net/base/cookie_monster.h" #include "net/base/cookie_monster.h"
#include "ui/base/models/tree_node_model.h" #include "ui/base/models/tree_node_model.h"
...@@ -36,6 +37,7 @@ class CookieTreeFileSystemsNode; ...@@ -36,6 +37,7 @@ class CookieTreeFileSystemsNode;
class CookieTreeFileSystemNode; class CookieTreeFileSystemNode;
class CookieTreeLocalStorageNode; class CookieTreeLocalStorageNode;
class CookieTreeLocalStoragesNode; class CookieTreeLocalStoragesNode;
class CookieTreeQuotaNode;
class CookieTreeSessionStorageNode; class CookieTreeSessionStorageNode;
class CookieTreeSessionStoragesNode; class CookieTreeSessionStoragesNode;
class CookieTreeIndexedDBNode; class CookieTreeIndexedDBNode;
...@@ -69,8 +71,9 @@ class CookieTreeNode : public ui::TreeNode<CookieTreeNode> { ...@@ -69,8 +71,9 @@ class CookieTreeNode : public ui::TreeNode<CookieTreeNode> {
TYPE_APPCACHE, // This is used for CookieTreeAppCacheNode. TYPE_APPCACHE, // This is used for CookieTreeAppCacheNode.
TYPE_INDEXED_DBS, // This is used for CookieTreeIndexedDBsNode. TYPE_INDEXED_DBS, // This is used for CookieTreeIndexedDBsNode.
TYPE_INDEXED_DB, // This is used for CookieTreeIndexedDBNode. TYPE_INDEXED_DB, // This is used for CookieTreeIndexedDBNode.
TYPE_FILE_SYSTEMS, // This is used for CookieTreeFileSystemsNode. TYPE_FILE_SYSTEMS, // This is used for CookieTreeFileSystemsNode.
TYPE_FILE_SYSTEM, // This is used for CookieTreeFileSystemNode. TYPE_FILE_SYSTEM, // This is used for CookieTreeFileSystemNode.
TYPE_QUOTA, // This is used for CookieTreeQuotaNode.
}; };
// TODO(viettrungluu): Figure out whether we want to store |origin| as a // TODO(viettrungluu): Figure out whether we want to store |origin| as a
...@@ -85,7 +88,8 @@ class CookieTreeNode : public ui::TreeNode<CookieTreeNode> { ...@@ -85,7 +88,8 @@ class CookieTreeNode : public ui::TreeNode<CookieTreeNode> {
session_storage_info, session_storage_info,
const appcache::AppCacheInfo* appcache_info, const appcache::AppCacheInfo* appcache_info,
const BrowsingDataIndexedDBHelper::IndexedDBInfo* indexed_db_info, const BrowsingDataIndexedDBHelper::IndexedDBInfo* indexed_db_info,
const BrowsingDataFileSystemHelper::FileSystemInfo* file_system_info) const BrowsingDataFileSystemHelper::FileSystemInfo* file_system_info,
const BrowsingDataQuotaHelper::QuotaInfo* quota_info)
: origin(UTF16ToWideHack(origin)), : origin(UTF16ToWideHack(origin)),
node_type(node_type), node_type(node_type),
cookie(cookie), cookie(cookie),
...@@ -94,13 +98,15 @@ class CookieTreeNode : public ui::TreeNode<CookieTreeNode> { ...@@ -94,13 +98,15 @@ class CookieTreeNode : public ui::TreeNode<CookieTreeNode> {
session_storage_info(session_storage_info), session_storage_info(session_storage_info),
appcache_info(appcache_info), appcache_info(appcache_info),
indexed_db_info(indexed_db_info), indexed_db_info(indexed_db_info),
file_system_info(file_system_info) { file_system_info(file_system_info),
quota_info(quota_info) {
DCHECK((node_type != TYPE_DATABASE) || database_info); DCHECK((node_type != TYPE_DATABASE) || database_info);
DCHECK((node_type != TYPE_LOCAL_STORAGE) || local_storage_info); DCHECK((node_type != TYPE_LOCAL_STORAGE) || local_storage_info);
DCHECK((node_type != TYPE_SESSION_STORAGE) || session_storage_info); DCHECK((node_type != TYPE_SESSION_STORAGE) || session_storage_info);
DCHECK((node_type != TYPE_APPCACHE) || appcache_info); DCHECK((node_type != TYPE_APPCACHE) || appcache_info);
DCHECK((node_type != TYPE_INDEXED_DB) || indexed_db_info); DCHECK((node_type != TYPE_INDEXED_DB) || indexed_db_info);
DCHECK((node_type != TYPE_FILE_SYSTEM) || file_system_info); DCHECK((node_type != TYPE_FILE_SYSTEM) || file_system_info);
DCHECK((node_type != TYPE_QUOTA) || quota_info);
} }
#if !defined(WCHAR_T_IS_UTF16) #if !defined(WCHAR_T_IS_UTF16)
DetailedInfo(const std::wstring& origin, NodeType node_type, DetailedInfo(const std::wstring& origin, NodeType node_type,
...@@ -112,7 +118,8 @@ class CookieTreeNode : public ui::TreeNode<CookieTreeNode> { ...@@ -112,7 +118,8 @@ class CookieTreeNode : public ui::TreeNode<CookieTreeNode> {
session_storage_info, session_storage_info,
const appcache::AppCacheInfo* appcache_info, const appcache::AppCacheInfo* appcache_info,
const BrowsingDataIndexedDBHelper::IndexedDBInfo* indexed_db_info, const BrowsingDataIndexedDBHelper::IndexedDBInfo* indexed_db_info,
const BrowsingDataFileSystemHelper::FileSystemInfo* file_system_info) const BrowsingDataFileSystemHelper::FileSystemInfo* file_system_info,
const BrowsingDataQuotaHelper::QuotaInfo* quota_info)
: origin(origin), : origin(origin),
node_type(node_type), node_type(node_type),
cookie(cookie), cookie(cookie),
...@@ -121,13 +128,15 @@ class CookieTreeNode : public ui::TreeNode<CookieTreeNode> { ...@@ -121,13 +128,15 @@ class CookieTreeNode : public ui::TreeNode<CookieTreeNode> {
session_storage_info(session_storage_info), session_storage_info(session_storage_info),
appcache_info(appcache_info), appcache_info(appcache_info),
indexed_db_info(indexed_db_info), indexed_db_info(indexed_db_info),
file_system_info(file_system_info) { file_system_info(file_system_info),
quota_info(quota_info) {
DCHECK((node_type != TYPE_DATABASE) || database_info); DCHECK((node_type != TYPE_DATABASE) || database_info);
DCHECK((node_type != TYPE_LOCAL_STORAGE) || local_storage_info); DCHECK((node_type != TYPE_LOCAL_STORAGE) || local_storage_info);
DCHECK((node_type != TYPE_SESSION_STORAGE) || session_storage_info); DCHECK((node_type != TYPE_SESSION_STORAGE) || session_storage_info);
DCHECK((node_type != TYPE_APPCACHE) || appcache_info); DCHECK((node_type != TYPE_APPCACHE) || appcache_info);
DCHECK((node_type != TYPE_INDEXED_DB) || indexed_db_info); DCHECK((node_type != TYPE_INDEXED_DB) || indexed_db_info);
DCHECK((node_type != TYPE_FILE_SYSTEM) || file_system_info); DCHECK((node_type != TYPE_FILE_SYSTEM) || file_system_info);
DCHECK((node_type != TYPE_QUOTA) || quota_info);
} }
#endif #endif
...@@ -141,6 +150,7 @@ class CookieTreeNode : public ui::TreeNode<CookieTreeNode> { ...@@ -141,6 +150,7 @@ class CookieTreeNode : public ui::TreeNode<CookieTreeNode> {
const appcache::AppCacheInfo* appcache_info; const appcache::AppCacheInfo* appcache_info;
const BrowsingDataIndexedDBHelper::IndexedDBInfo* indexed_db_info; const BrowsingDataIndexedDBHelper::IndexedDBInfo* indexed_db_info;
const BrowsingDataFileSystemHelper::FileSystemInfo* file_system_info; const BrowsingDataFileSystemHelper::FileSystemInfo* file_system_info;
const BrowsingDataQuotaHelper::QuotaInfo* quota_info;
}; };
CookieTreeNode() {} CookieTreeNode() {}
...@@ -211,6 +221,8 @@ class CookieTreeOriginNode : public CookieTreeNode { ...@@ -211,6 +221,8 @@ class CookieTreeOriginNode : public CookieTreeNode {
CookieTreeAppCachesNode* GetOrCreateAppCachesNode(); CookieTreeAppCachesNode* GetOrCreateAppCachesNode();
CookieTreeIndexedDBsNode* GetOrCreateIndexedDBsNode(); CookieTreeIndexedDBsNode* GetOrCreateIndexedDBsNode();
CookieTreeFileSystemsNode* GetOrCreateFileSystemsNode(); CookieTreeFileSystemsNode* GetOrCreateFileSystemsNode();
CookieTreeQuotaNode* UpdateOrCreateQuotaNode(
BrowsingDataQuotaHelper::QuotaInfo* quota_info);
// Creates an content exception for this origin of type // Creates an content exception for this origin of type
// CONTENT_SETTINGS_TYPE_COOKIES. // CONTENT_SETTINGS_TYPE_COOKIES.
...@@ -233,6 +245,7 @@ class CookieTreeOriginNode : public CookieTreeNode { ...@@ -233,6 +245,7 @@ class CookieTreeOriginNode : public CookieTreeNode {
CookieTreeAppCachesNode* appcaches_child_; CookieTreeAppCachesNode* appcaches_child_;
CookieTreeIndexedDBsNode* indexed_dbs_child_; CookieTreeIndexedDBsNode* indexed_dbs_child_;
CookieTreeFileSystemsNode* file_systems_child_; CookieTreeFileSystemsNode* file_systems_child_;
CookieTreeQuotaNode* quota_child_;
// The URL for which this node was initially created. // The URL for which this node was initially created.
GURL url_; GURL url_;
...@@ -498,6 +511,24 @@ class CookieTreeIndexedDBsNode : public CookieTreeNode { ...@@ -498,6 +511,24 @@ class CookieTreeIndexedDBsNode : public CookieTreeNode {
DISALLOW_COPY_AND_ASSIGN(CookieTreeIndexedDBsNode); DISALLOW_COPY_AND_ASSIGN(CookieTreeIndexedDBsNode);
}; };
// 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);
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_;
DISALLOW_COPY_AND_ASSIGN(CookieTreeQuotaNode);
};
// CookiesTreeModel ----------------------------------------------------------- // CookiesTreeModel -----------------------------------------------------------
class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> { class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> {
...@@ -521,6 +552,7 @@ class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> { ...@@ -521,6 +552,7 @@ class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> {
BrowsingDataAppCacheHelper* appcache_helper, BrowsingDataAppCacheHelper* appcache_helper,
BrowsingDataIndexedDBHelper* indexed_db_helper, BrowsingDataIndexedDBHelper* indexed_db_helper,
BrowsingDataFileSystemHelper* file_system_helper, BrowsingDataFileSystemHelper* file_system_helper,
BrowsingDataQuotaHelper* quota_helper,
bool use_cookie_source); bool use_cookie_source);
virtual ~CookiesTreeModel(); virtual ~CookiesTreeModel();
...@@ -565,6 +597,7 @@ class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> { ...@@ -565,6 +597,7 @@ class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> {
IndexedDBInfoList; IndexedDBInfoList;
typedef std::vector<BrowsingDataFileSystemHelper::FileSystemInfo> typedef std::vector<BrowsingDataFileSystemHelper::FileSystemInfo>
FileSystemInfoList; FileSystemInfoList;
typedef std::vector<BrowsingDataQuotaHelper::QuotaInfo> QuotaInfoArray;
void LoadCookies(); void LoadCookies();
void LoadCookiesWithFilter(const std::wstring& filter); void LoadCookiesWithFilter(const std::wstring& filter);
...@@ -579,6 +612,7 @@ class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> { ...@@ -579,6 +612,7 @@ class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> {
const IndexedDBInfoList& indexed_db_info); const IndexedDBInfoList& indexed_db_info);
void OnFileSystemModelInfoLoaded( void OnFileSystemModelInfoLoaded(
const FileSystemInfoList& file_system_info); const FileSystemInfoList& file_system_info);
void OnQuotaModelInfoLoaded(const QuotaInfoArray& quota_info);
void PopulateAppCacheInfoWithFilter(const std::wstring& filter); void PopulateAppCacheInfoWithFilter(const std::wstring& filter);
void PopulateDatabaseInfoWithFilter(const std::wstring& filter); void PopulateDatabaseInfoWithFilter(const std::wstring& filter);
...@@ -586,6 +620,7 @@ class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> { ...@@ -586,6 +620,7 @@ class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> {
void PopulateSessionStorageInfoWithFilter(const std::wstring& filter); void PopulateSessionStorageInfoWithFilter(const std::wstring& filter);
void PopulateIndexedDBInfoWithFilter(const std::wstring& filter); void PopulateIndexedDBInfoWithFilter(const std::wstring& filter);
void PopulateFileSystemInfoWithFilter(const std::wstring& filter); void PopulateFileSystemInfoWithFilter(const std::wstring& filter);
void PopulateQuotaInfoWithFilter(const std::wstring& filter);
void NotifyObserverBeginBatch(); void NotifyObserverBeginBatch();
void NotifyObserverEndBatch(); void NotifyObserverEndBatch();
...@@ -602,10 +637,12 @@ class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> { ...@@ -602,10 +637,12 @@ class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> {
scoped_refptr<BrowsingDataLocalStorageHelper> session_storage_helper_; scoped_refptr<BrowsingDataLocalStorageHelper> session_storage_helper_;
scoped_refptr<BrowsingDataIndexedDBHelper> indexed_db_helper_; scoped_refptr<BrowsingDataIndexedDBHelper> indexed_db_helper_;
scoped_refptr<BrowsingDataFileSystemHelper> file_system_helper_; scoped_refptr<BrowsingDataFileSystemHelper> file_system_helper_;
scoped_refptr<BrowsingDataQuotaHelper> quota_helper_;
LocalStorageInfoList local_storage_info_list_; LocalStorageInfoList local_storage_info_list_;
LocalStorageInfoList session_storage_info_list_; LocalStorageInfoList session_storage_info_list_;
IndexedDBInfoList indexed_db_info_list_; IndexedDBInfoList indexed_db_info_list_;
FileSystemInfoList file_system_info_list_; FileSystemInfoList file_system_info_list_;
QuotaInfoArray quota_info_list_;
// The CookiesTreeModel maintains a separate list of observers that are // The CookiesTreeModel maintains a separate list of observers that are
// specifically of the type CookiesTreeModel::Observer. // specifically of the type CookiesTreeModel::Observer.
...@@ -626,6 +663,7 @@ class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> { ...@@ -626,6 +663,7 @@ class CookiesTreeModel : public ui::TreeNodeModel<CookieTreeNode> {
friend class CookieTreeLocalStorageNode; friend class CookieTreeLocalStorageNode;
friend class CookieTreeIndexedDBNode; friend class CookieTreeIndexedDBNode;
friend class CookieTreeFileSystemNode; friend class CookieTreeFileSystemNode;
friend class CookieTreeQuotaNode;
DISALLOW_COPY_AND_ASSIGN(CookiesTreeModel); DISALLOW_COPY_AND_ASSIGN(CookiesTreeModel);
}; };
......
// 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 "chrome/browser/mock_browsing_data_quota_helper.h"
MockBrowsingDataQuotaHelper::MockBrowsingDataQuotaHelper(Profile* profile)
: BrowsingDataQuotaHelper(BrowserThread::GetMessageLoopProxyForThread(
BrowserThread::IO)) {}
MockBrowsingDataQuotaHelper::~MockBrowsingDataQuotaHelper() {}
void MockBrowsingDataQuotaHelper::StartFetching(
FetchResultCallback* callback) {
callback_.reset(callback);
}
void MockBrowsingDataQuotaHelper::CancelNotification() {
callback_.reset(NULL);
}
void MockBrowsingDataQuotaHelper::AddHost(
const std::string& host,
int64 temporary_usage,
int64 persistent_usage) {
response_.push_back(QuotaInfo(
host,
temporary_usage,
persistent_usage));
}
void MockBrowsingDataQuotaHelper::AddQuotaSamples() {
AddHost("quotahost1", 1, 2);
AddHost("quotahost2", 10, 20);
}
void MockBrowsingDataQuotaHelper::Notify() {
CHECK(callback_.get());
callback_->Run(response_);
callback_.reset();
response_.clear();
}
// 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.
#ifndef CHROME_BROWSER_MOCK_BROWSING_DATA_QUOTA_HELPER_H_
#define CHROME_BROWSER_MOCK_BROWSING_DATA_QUOTA_HELPER_H_
#pragma once
#include <string>
#include <vector>
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/browsing_data_quota_helper.h"
class MockBrowsingDataQuotaHelper : public BrowsingDataQuotaHelper {
public:
explicit MockBrowsingDataQuotaHelper(Profile* profile);
virtual void StartFetching(FetchResultCallback* callback) OVERRIDE;
virtual void CancelNotification() OVERRIDE;
void AddHost(const std::string& host,
int64 temporary_usage,
int64 persistent_usage);
void AddQuotaSamples();
void Notify();
private:
virtual ~MockBrowsingDataQuotaHelper();
scoped_ptr<FetchResultCallback> callback_;
std::vector<QuotaInfo> response_;
Profile* profile_;
};
#endif // CHROME_BROWSER_MOCK_BROWSING_DATA_QUOTA_HELPER_H_
...@@ -119,6 +119,8 @@ cr.define('options', function() { ...@@ -119,6 +119,8 @@ cr.define('options', function() {
this.siteChild.className = 'cookie-site'; this.siteChild.className = 'cookie-site';
this.dataChild = this.ownerDocument.createElement('div'); this.dataChild = this.ownerDocument.createElement('div');
this.dataChild.className = 'cookie-data'; this.dataChild.className = 'cookie-data';
this.sizeChild = this.ownerDocument.createElement('div');
this.sizeChild.className = 'cookie-size';
this.itemsChild = this.ownerDocument.createElement('div'); this.itemsChild = this.ownerDocument.createElement('div');
this.itemsChild.className = 'cookie-items'; this.itemsChild.className = 'cookie-items';
this.infoChild = this.ownerDocument.createElement('div'); this.infoChild = this.ownerDocument.createElement('div');
...@@ -131,6 +133,7 @@ cr.define('options', function() { ...@@ -131,6 +133,7 @@ cr.define('options', function() {
var content = this.contentElement; var content = this.contentElement;
content.appendChild(this.siteChild); content.appendChild(this.siteChild);
content.appendChild(this.dataChild); content.appendChild(this.dataChild);
content.appendChild(this.sizeChild);
content.appendChild(this.itemsChild); content.appendChild(this.itemsChild);
this.itemsChild.appendChild(this.infoChild); this.itemsChild.appendChild(this.infoChild);
if (this.origin && this.origin.data) { if (this.origin && this.origin.data) {
...@@ -250,6 +253,10 @@ cr.define('options', function() { ...@@ -250,6 +253,10 @@ cr.define('options', function() {
else else
text = list[i]; text = list[i];
this.dataChild.textContent = text; this.dataChild.textContent = text;
if (info.quota && info.quota.totalUsage) {
this.sizeChild.textContent = info.quota.totalUsage;
}
if (this.expanded) if (this.expanded)
this.updateItems_(); this.updateItems_();
}, },
...@@ -430,18 +437,21 @@ cr.define('options', function() { ...@@ -430,18 +437,21 @@ cr.define('options', function() {
for (var i = 0; i < this.children.length; ++i) for (var i = 0; i < this.children.length; ++i)
this.children[i].collectSummaryInfo(info); this.children[i].collectSummaryInfo(info);
} else if (this.data && !this.data.hasChildren) { } else if (this.data && !this.data.hasChildren) {
if (this.data.type == 'cookie') if (this.data.type == 'cookie') {
info.cookies++; info.cookies++;
else if (this.data.type == 'database') } else if (this.data.type == 'database') {
info.database = true; info.database = true;
else if (this.data.type == 'local_storage') } else if (this.data.type == 'local_storage') {
info.localStorage = true; info.localStorage = true;
else if (this.data.type == 'app_cache') } else if (this.data.type == 'app_cache') {
info.appCache = true; info.appCache = true;
else if (this.data.type == 'indexed_db') } else if (this.data.type == 'indexed_db') {
info.indexedDb = true; info.indexedDb = true;
else if (this.data.type == 'file_system') } else if (this.data.type == 'file_system') {
info.fileSystem = true; info.fileSystem = true;
} else if (this.data.type == 'quota') {
info.quota = this.data;
}
} }
}, },
...@@ -474,6 +484,8 @@ cr.define('options', function() { ...@@ -474,6 +484,8 @@ cr.define('options', function() {
text = localStrings.getString('cookie_file_system'); text = localStrings.getString('cookie_file_system');
break; break;
} }
if (!text)
return;
var div = item.ownerDocument.createElement('div'); var div = item.ownerDocument.createElement('div');
div.className = 'cookie-item'; div.className = 'cookie-item';
// Help out screen readers and such: this is a clickable thing. // Help out screen readers and such: this is a clickable thing.
......
/* /*
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 Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. found in the LICENSE file.
*/ */
...@@ -88,6 +88,12 @@ list.cookie-list > .deletable-item[selected] .cookie-site { ...@@ -88,6 +88,12 @@ list.cookie-list > .deletable-item[selected] .cookie-site {
display: inline-block; display: inline-block;
} }
.cookie-size {
display: inline-block;
float: right;
margin-right: 3em;
}
list.cookie-list > .deletable-item[selected] .cookie-data { list.cookie-list > .deletable-item[selected] .cookie-data {
-webkit-user-select: text; -webkit-user-select: text;
} }
......
...@@ -41,6 +41,13 @@ static const char kKeyModified[] = "modified"; ...@@ -41,6 +41,13 @@ static const char kKeyModified[] = "modified";
static const char kKeyPersistent[] = "persistent"; static const char kKeyPersistent[] = "persistent";
static const char kKeyTemporary[] = "temporary"; static const char kKeyTemporary[] = "temporary";
static const char kKeyTotalUsage[] = "totalUsage";
static const char kKeyTemporaryUsage[] = "temporaryUsage";
static const char kKeyPersistentUsage[] = "persistentUsage";
static const char kKeyPersistentQuota[] = "persistentQuota";
static const int64 kNegligibleUsage = 1024; // 1KiB
// Encodes a pointer value into a hex string. // Encodes a pointer value into a hex string.
std::string PointerToHexString(const void* pointer) { std::string PointerToHexString(const void* pointer) {
return base::HexEncode(&pointer, sizeof(pointer)); return base::HexEncode(&pointer, sizeof(pointer));
...@@ -65,7 +72,7 @@ std::string GetTreeNodeId(CookieTreeNode* node) { ...@@ -65,7 +72,7 @@ std::string GetTreeNodeId(CookieTreeNode* node) {
return PointerToHexString(node); return PointerToHexString(node);
} }
void GetCookieTreeNodeDictionary(const CookieTreeNode& node, bool GetCookieTreeNodeDictionary(const CookieTreeNode& node,
DictionaryValue* dict) { DictionaryValue* dict) {
// Use node's address as an id for WebUI to look it up. // Use node's address as an id for WebUI to look it up.
dict->SetString(kKeyId, PointerToHexString(&node)); dict->SetString(kKeyId, PointerToHexString(&node));
...@@ -190,12 +197,36 @@ void GetCookieTreeNodeDictionary(const CookieTreeNode& node, ...@@ -190,12 +197,36 @@ void GetCookieTreeNodeDictionary(const CookieTreeNode& node,
IDS_COOKIES_FILE_SYSTEM_USAGE_NONE)); IDS_COOKIES_FILE_SYSTEM_USAGE_NONE));
break; break;
} }
case CookieTreeNode::DetailedInfo::TYPE_QUOTA: {
dict->SetString(kKeyType, "quota");
dict->SetString(kKeyIcon, "chrome://theme/IDR_COOKIE_STORAGE_ICON");
const BrowsingDataQuotaHelper::QuotaInfo& quota_info =
*node.GetDetailedInfo().quota_info;
if (quota_info.temporary_usage + quota_info.persistent_usage <=
kNegligibleUsage)
return false;
dict->SetString(kKeyOrigin, quota_info.host);
dict->SetString(kKeyTotalUsage,
UTF16ToUTF8(ui::FormatBytes(
quota_info.temporary_usage +
quota_info.persistent_usage)));
dict->SetString(kKeyTemporaryUsage,
UTF16ToUTF8(ui::FormatBytes(
quota_info.temporary_usage)));
dict->SetString(kKeyPersistentUsage,
UTF16ToUTF8(ui::FormatBytes(
quota_info.persistent_usage)));
break;
}
default: default:
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
dict->SetString(kKeyIcon, "chrome://theme/IDR_BOOKMARK_BAR_FOLDER"); dict->SetString(kKeyIcon, "chrome://theme/IDR_BOOKMARK_BAR_FOLDER");
#endif #endif
break; break;
} }
return true;
} }
void GetChildNodeList(CookieTreeNode* parent, int start, int count, void GetChildNodeList(CookieTreeNode* parent, int start, int count,
...@@ -203,8 +234,10 @@ void GetChildNodeList(CookieTreeNode* parent, int start, int count, ...@@ -203,8 +234,10 @@ void GetChildNodeList(CookieTreeNode* parent, int start, int count,
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
DictionaryValue* dict = new DictionaryValue; DictionaryValue* dict = new DictionaryValue;
CookieTreeNode* child = parent->GetChild(start + i); CookieTreeNode* child = parent->GetChild(start + i);
GetCookieTreeNodeDictionary(*child, dict); if (GetCookieTreeNodeDictionary(*child, dict))
nodes->Append(dict); nodes->Append(dict);
else
delete dict;
} }
} }
......
...@@ -21,7 +21,8 @@ namespace cookies_tree_model_util { ...@@ -21,7 +21,8 @@ namespace cookies_tree_model_util {
std::string GetTreeNodeId(CookieTreeNode* node); std::string GetTreeNodeId(CookieTreeNode* node);
// Populate given |dict| with cookie tree node properties. // Populate given |dict| with cookie tree node properties.
void GetCookieTreeNodeDictionary(const CookieTreeNode& node, // Returns false if the |node| does not need to be shown.
bool GetCookieTreeNodeDictionary(const CookieTreeNode& node,
base::DictionaryValue* dict); base::DictionaryValue* dict);
// Append the children nodes of |parent| in specified range to |nodes| list. // Append the children nodes of |parent| in specified range to |nodes| list.
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "chrome/browser/browsing_data_database_helper.h" #include "chrome/browser/browsing_data_database_helper.h"
#include "chrome/browser/browsing_data_file_system_helper.h" #include "chrome/browser/browsing_data_file_system_helper.h"
#include "chrome/browser/browsing_data_indexed_db_helper.h" #include "chrome/browser/browsing_data_indexed_db_helper.h"
#include "chrome/browser/browsing_data_quota_helper.h"
#include "chrome/browser/browsing_data_local_storage_helper.h" #include "chrome/browser/browsing_data_local_storage_helper.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/cookies_tree_model_util.h" #include "chrome/browser/ui/webui/cookies_tree_model_util.h"
...@@ -66,7 +67,7 @@ void CookiesViewHandler::GetLocalizedValues( ...@@ -66,7 +67,7 @@ void CookiesViewHandler::GetLocalizedValues(
{ "label_file_system_temporary_usage", { "label_file_system_temporary_usage",
IDS_COOKIES_FILE_SYSTEM_TEMPORARY_USAGE_LABEL }, IDS_COOKIES_FILE_SYSTEM_TEMPORARY_USAGE_LABEL },
{ "label_file_system_persistent_usage", { "label_file_system_persistent_usage",
IDS_COOKIES_FILE_SYSTEM_PERSISTENT_USAGE_LABEL } IDS_COOKIES_FILE_SYSTEM_PERSISTENT_USAGE_LABEL },
}; };
RegisterStrings(localized_strings, resources, arraysize(resources)); RegisterStrings(localized_strings, resources, arraysize(resources));
...@@ -151,6 +152,7 @@ void CookiesViewHandler::EnsureCookiesTreeModelCreated() { ...@@ -151,6 +152,7 @@ void CookiesViewHandler::EnsureCookiesTreeModelCreated() {
new BrowsingDataAppCacheHelper(profile), new BrowsingDataAppCacheHelper(profile),
BrowsingDataIndexedDBHelper::Create(profile), BrowsingDataIndexedDBHelper::Create(profile),
BrowsingDataFileSystemHelper::Create(profile), BrowsingDataFileSystemHelper::Create(profile),
BrowsingDataQuotaHelper::Create(profile),
false)); false));
cookies_tree_model_->AddCookiesTreeObserver(this); cookies_tree_model_->AddCookiesTreeObserver(this);
} }
......
...@@ -315,6 +315,10 @@ ...@@ -315,6 +315,10 @@
'browser/browsing_data_indexed_db_helper.h', 'browser/browsing_data_indexed_db_helper.h',
'browser/browsing_data_local_storage_helper.cc', 'browser/browsing_data_local_storage_helper.cc',
'browser/browsing_data_local_storage_helper.h', 'browser/browsing_data_local_storage_helper.h',
'browser/browsing_data_quota_helper.cc',
'browser/browsing_data_quota_helper.h',
'browser/browsing_data_quota_helper_impl.cc',
'browser/browsing_data_quota_helper_impl.h',
'browser/browsing_data_remover.cc', 'browser/browsing_data_remover.cc',
'browser/browsing_data_remover.h', 'browser/browsing_data_remover.h',
'browser/bug_report_data.cc', 'browser/bug_report_data.cc',
......
...@@ -87,6 +87,8 @@ ...@@ -87,6 +87,8 @@
'browser/mock_browsing_data_indexed_db_helper.h', 'browser/mock_browsing_data_indexed_db_helper.h',
'browser/mock_browsing_data_local_storage_helper.cc', 'browser/mock_browsing_data_local_storage_helper.cc',
'browser/mock_browsing_data_local_storage_helper.h', 'browser/mock_browsing_data_local_storage_helper.h',
'browser/mock_browsing_data_quota_helper.cc',
'browser/mock_browsing_data_quota_helper.h',
'browser/notifications/notification_test_util.cc', 'browser/notifications/notification_test_util.cc',
'browser/notifications/notification_test_util.h', 'browser/notifications/notification_test_util.h',
'browser/policy/mock_cloud_policy_data_store.cc', 'browser/policy/mock_cloud_policy_data_store.cc',
...@@ -1324,6 +1326,7 @@ ...@@ -1324,6 +1326,7 @@
'browser/browsing_data_file_system_helper_unittest.cc', 'browser/browsing_data_file_system_helper_unittest.cc',
'browser/browsing_data_indexed_db_helper_unittest.cc', 'browser/browsing_data_indexed_db_helper_unittest.cc',
'browser/browsing_data_local_storage_helper_unittest.cc', 'browser/browsing_data_local_storage_helper_unittest.cc',
'browser/browsing_data_quota_helper_unittest.cc',
'browser/browsing_data_remover_unittest.cc', 'browser/browsing_data_remover_unittest.cc',
'browser/chrome_browser_application_mac_unittest.mm', 'browser/chrome_browser_application_mac_unittest.mm',
'browser/chromeos/cros/network_library.cc', 'browser/chromeos/cros/network_library.cc',
...@@ -2078,6 +2081,8 @@ ...@@ -2078,6 +2081,8 @@
'../webkit/fileapi/file_writer_delegate_unittest.cc', '../webkit/fileapi/file_writer_delegate_unittest.cc',
'../webkit/fileapi/file_system_test_helper.cc', '../webkit/fileapi/file_system_test_helper.cc',
'../webkit/fileapi/file_system_test_helper.h', '../webkit/fileapi/file_system_test_helper.h',
'../webkit/quota/mock_storage_client.cc',
'../webkit/quota/mock_storage_client.h',
], ],
'conditions': [ 'conditions': [
['p2p_apis==1', { ['p2p_apis==1', {
......
...@@ -84,6 +84,15 @@ void MockStorageClient::ModifyOriginAndNotify( ...@@ -84,6 +84,15 @@ void MockStorageClient::ModifyOriginAndNotify(
id(), origin_url, type, delta, IncrementMockTime()); id(), origin_url, type, delta, IncrementMockTime());
} }
void MockStorageClient::TouchAllOriginsAndNotify() {
for (OriginDataMap::const_iterator itr = origin_data_.begin();
itr != origin_data_.end();
++itr) {
quota_manager_proxy_->quota_manager()->NotifyStorageModifiedInternal(
id(), itr->first.first, itr->first.second, 0, IncrementMockTime());
}
}
void MockStorageClient::AddOriginToErrorSet( void MockStorageClient::AddOriginToErrorSet(
const GURL& origin_url, StorageType type) { const GURL& origin_url, StorageType type) {
error_origins_.insert(make_pair(origin_url, type)); error_origins_.insert(make_pair(origin_url, type));
......
...@@ -37,6 +37,7 @@ class MockStorageClient : public QuotaClient { ...@@ -37,6 +37,7 @@ class MockStorageClient : public QuotaClient {
const GURL& origin_url, StorageType type, int64 size); const GURL& origin_url, StorageType type, int64 size);
void ModifyOriginAndNotify( void ModifyOriginAndNotify(
const GURL& origin_url, StorageType type, int64 delta); const GURL& origin_url, StorageType type, int64 delta);
void TouchAllOriginsAndNotify();
void AddOriginToErrorSet(const GURL& origin_url, StorageType type); void AddOriginToErrorSet(const GURL& origin_url, StorageType type);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment