Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Unified Diff: net/cookies/cookie_monster.cc

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/cookies/cookie_monster.cc
diff --git a/net/cookies/cookie_monster.cc b/net/cookies/cookie_monster.cc
index f2023b6caa89819af1a2ce28794d4cc57b2d0bc0..2c4f5ed932f3e9b62e8dce56bf9fcc595d25fd0a 100644
--- a/net/cookies/cookie_monster.cc
+++ b/net/cookies/cookie_monster.cc
@@ -96,18 +96,18 @@ namespace net {
// See comments at declaration of these variables in cookie_monster.h
// for details.
-const size_t CookieMonster::kDomainMaxCookies = 180;
-const size_t CookieMonster::kDomainPurgeCookies = 30;
-const size_t CookieMonster::kMaxCookies = 3300;
-const size_t CookieMonster::kPurgeCookies = 300;
+const size_t CookieMonster::kDomainMaxCookies = 180;
+const size_t CookieMonster::kDomainPurgeCookies = 30;
+const size_t CookieMonster::kMaxCookies = 3300;
+const size_t CookieMonster::kPurgeCookies = 300;
-const size_t CookieMonster::kDomainCookiesQuotaLow = 30;
+const size_t CookieMonster::kDomainCookiesQuotaLow = 30;
const size_t CookieMonster::kDomainCookiesQuotaMedium = 50;
-const size_t CookieMonster::kDomainCookiesQuotaHigh =
- kDomainMaxCookies - kDomainPurgeCookies
- - kDomainCookiesQuotaLow - kDomainCookiesQuotaMedium;
+const size_t CookieMonster::kDomainCookiesQuotaHigh =
+ kDomainMaxCookies - kDomainPurgeCookies - kDomainCookiesQuotaLow -
+ kDomainCookiesQuotaMedium;
-const int CookieMonster::kSafeFromGlobalPurgeDays = 30;
+const int CookieMonster::kSafeFromGlobalPurgeDays = 30;
namespace {
@@ -176,8 +176,7 @@ struct CookieSignature {
CookieSignature(const std::string& name,
const std::string& domain,
const std::string& path)
- : name(name), domain(domain), path(path) {
- }
+ : name(name), domain(domain), path(path) {}
// To be a key for a map this class needs to be assignable, copyable,
// and have an operator<. The default assignment operator
@@ -205,10 +204,9 @@ struct CookieSignature {
// sorts the first |num_sort| + 1 elements by LastAccessDate().
// The + 1 element exists so for any interval of length <= |num_sort| starting
// from |cookies_its_begin|, a LastAccessDate() bound can be found.
-void SortLeastRecentlyAccessed(
- CookieMonster::CookieItVector::iterator it_begin,
- CookieMonster::CookieItVector::iterator it_end,
- size_t num_sort) {
+void SortLeastRecentlyAccessed(CookieMonster::CookieItVector::iterator it_begin,
+ CookieMonster::CookieItVector::iterator it_end,
+ size_t num_sort) {
DCHECK_LT(static_cast<int>(num_sort), it_end - it_begin);
std::partial_sort(it_begin, it_begin + num_sort + 1, it_end, LRACookieSorter);
}
@@ -216,8 +214,7 @@ void SortLeastRecentlyAccessed(
// Predicate to support PartitionCookieByPriority().
struct CookiePriorityEqualsTo
: std::unary_function<const CookieMonster::CookieMap::iterator, bool> {
- CookiePriorityEqualsTo(CookiePriority priority)
- : priority_(priority) {}
+ CookiePriorityEqualsTo(CookiePriority priority) : priority_(priority) {}
bool operator()(const CookieMonster::CookieMap::iterator it) const {
return it->second->Priority() == priority_;
@@ -237,8 +234,8 @@ CookieMonster::CookieItVector::iterator PartitionCookieByPriority(
return std::partition(it_begin, it_end, CookiePriorityEqualsTo(priority));
}
-bool LowerBoundAccessDateComparator(
- const CookieMonster::CookieMap::iterator it, const Time& access_date) {
+bool LowerBoundAccessDateComparator(const CookieMonster::CookieMap::iterator it,
+ const Time& access_date) {
return it->second->LastAccessDate() < access_date;
}
@@ -250,8 +247,8 @@ CookieMonster::CookieItVector::iterator LowerBoundAccessDate(
const CookieMonster::CookieItVector::iterator its_begin,
const CookieMonster::CookieItVector::iterator its_end,
const Time& access_date) {
- return std::lower_bound(its_begin, its_end, access_date,
- LowerBoundAccessDateComparator);
+ return std::lower_bound(
+ its_begin, its_end, access_date, LowerBoundAccessDateComparator);
}
// Mapping between DeletionCause and CookieMonsterDelegate::ChangeCause; the
@@ -262,38 +259,38 @@ typedef struct ChangeCausePair_struct {
bool notify;
} ChangeCausePair;
ChangeCausePair ChangeCauseMapping[] = {
- // DELETE_COOKIE_EXPLICIT
- { CookieMonsterDelegate::CHANGE_COOKIE_EXPLICIT, true },
- // DELETE_COOKIE_OVERWRITE
- { CookieMonsterDelegate::CHANGE_COOKIE_OVERWRITE, true },
- // DELETE_COOKIE_EXPIRED
- { CookieMonsterDelegate::CHANGE_COOKIE_EXPIRED, true },
- // DELETE_COOKIE_EVICTED
- { CookieMonsterDelegate::CHANGE_COOKIE_EVICTED, true },
- // DELETE_COOKIE_DUPLICATE_IN_BACKING_STORE
- { CookieMonsterDelegate::CHANGE_COOKIE_EXPLICIT, false },
- // DELETE_COOKIE_DONT_RECORD
- { CookieMonsterDelegate::CHANGE_COOKIE_EXPLICIT, false },
- // DELETE_COOKIE_EVICTED_DOMAIN
- { CookieMonsterDelegate::CHANGE_COOKIE_EVICTED, true },
- // DELETE_COOKIE_EVICTED_GLOBAL
- { CookieMonsterDelegate::CHANGE_COOKIE_EVICTED, true },
- // DELETE_COOKIE_EVICTED_DOMAIN_PRE_SAFE
- { CookieMonsterDelegate::CHANGE_COOKIE_EVICTED, true },
- // DELETE_COOKIE_EVICTED_DOMAIN_POST_SAFE
- { CookieMonsterDelegate::CHANGE_COOKIE_EVICTED, true },
- // DELETE_COOKIE_EXPIRED_OVERWRITE
- { CookieMonsterDelegate::CHANGE_COOKIE_EXPIRED_OVERWRITE, true },
- // DELETE_COOKIE_CONTROL_CHAR
- { CookieMonsterDelegate::CHANGE_COOKIE_EVICTED, true},
- // DELETE_COOKIE_LAST_ENTRY
- { CookieMonsterDelegate::CHANGE_COOKIE_EXPLICIT, false }
-};
+ // DELETE_COOKIE_EXPLICIT
+ {CookieMonsterDelegate::CHANGE_COOKIE_EXPLICIT, true},
+ // DELETE_COOKIE_OVERWRITE
+ {CookieMonsterDelegate::CHANGE_COOKIE_OVERWRITE, true},
+ // DELETE_COOKIE_EXPIRED
+ {CookieMonsterDelegate::CHANGE_COOKIE_EXPIRED, true},
+ // DELETE_COOKIE_EVICTED
+ {CookieMonsterDelegate::CHANGE_COOKIE_EVICTED, true},
+ // DELETE_COOKIE_DUPLICATE_IN_BACKING_STORE
+ {CookieMonsterDelegate::CHANGE_COOKIE_EXPLICIT, false},
+ // DELETE_COOKIE_DONT_RECORD
+ {CookieMonsterDelegate::CHANGE_COOKIE_EXPLICIT, false},
+ // DELETE_COOKIE_EVICTED_DOMAIN
+ {CookieMonsterDelegate::CHANGE_COOKIE_EVICTED, true},
+ // DELETE_COOKIE_EVICTED_GLOBAL
+ {CookieMonsterDelegate::CHANGE_COOKIE_EVICTED, true},
+ // DELETE_COOKIE_EVICTED_DOMAIN_PRE_SAFE
+ {CookieMonsterDelegate::CHANGE_COOKIE_EVICTED, true},
+ // DELETE_COOKIE_EVICTED_DOMAIN_POST_SAFE
+ {CookieMonsterDelegate::CHANGE_COOKIE_EVICTED, true},
+ // DELETE_COOKIE_EXPIRED_OVERWRITE
+ {CookieMonsterDelegate::CHANGE_COOKIE_EXPIRED_OVERWRITE, true},
+ // DELETE_COOKIE_CONTROL_CHAR
+ {CookieMonsterDelegate::CHANGE_COOKIE_EVICTED, true},
+ // DELETE_COOKIE_LAST_ENTRY
+ {CookieMonsterDelegate::CHANGE_COOKIE_EXPLICIT, false}};
std::string BuildCookieLine(const CanonicalCookieVector& cookies) {
std::string cookie_line;
for (CanonicalCookieVector::const_iterator it = cookies.begin();
- it != cookies.end(); ++it) {
+ it != cookies.end();
+ ++it) {
if (it != cookies.begin())
cookie_line += "; ";
// In Mozilla if you set a cookie like AAAA, it will have an empty token
@@ -339,7 +336,6 @@ CookieMonster::CookieMonster(PersistentCookieStore* store,
SetDefaultCookieableSchemes();
}
-
// Task classes for queueing the coming request.
class CookieMonster::CookieMonsterTask
@@ -359,9 +355,7 @@ class CookieMonster::CookieMonsterTask
// instance until the callback completes.
void InvokeCallback(base::Closure callback);
- CookieMonster* cookie_monster() {
- return cookie_monster_;
- }
+ CookieMonster* cookie_monster() { return cookie_monster_; }
private:
friend class base::RefCountedThreadSafe<CookieMonsterTask>;
@@ -378,7 +372,8 @@ CookieMonster::CookieMonsterTask::CookieMonsterTask(
thread_(base::MessageLoopProxy::current()) {
}
-CookieMonster::CookieMonsterTask::~CookieMonsterTask() {}
+CookieMonster::CookieMonsterTask::~CookieMonsterTask() {
+}
// Unfortunately, one cannot re-bind a Callback with parameters into a closure.
// Therefore, the closure passed to InvokeCallback is a clumsy binding of
@@ -394,8 +389,9 @@ void CookieMonster::CookieMonsterTask::InvokeCallback(base::Closure callback) {
if (thread_->BelongsToCurrentThread()) {
callback.Run();
} else {
- thread_->PostTask(FROM_HERE, base::Bind(
- &CookieMonsterTask::InvokeCallback, this, callback));
+ thread_->PostTask(
+ FROM_HERE,
+ base::Bind(&CookieMonsterTask::InvokeCallback, this, callback));
}
}
@@ -423,8 +419,7 @@ class CookieMonster::SetCookieWithDetailsTask : public CookieMonsterTask {
secure_(secure),
http_only_(http_only),
priority_(priority),
- callback_(callback) {
- }
+ callback_(callback) {}
// CookieMonsterTask:
virtual void Run() OVERRIDE;
@@ -448,12 +443,18 @@ class CookieMonster::SetCookieWithDetailsTask : public CookieMonsterTask {
};
void CookieMonster::SetCookieWithDetailsTask::Run() {
- bool success = this->cookie_monster()->
- SetCookieWithDetails(url_, name_, value_, domain_, path_,
- expiration_time_, secure_, http_only_, priority_);
+ bool success = this->cookie_monster()->SetCookieWithDetails(url_,
+ name_,
+ value_,
+ domain_,
+ path_,
+ expiration_time_,
+ secure_,
+ http_only_,
+ priority_);
if (!callback_.is_null()) {
- this->InvokeCallback(base::Bind(&SetCookiesCallback::Run,
- base::Unretained(&callback_), success));
+ this->InvokeCallback(base::Bind(
+ &SetCookiesCallback::Run, base::Unretained(&callback_), success));
}
}
@@ -462,9 +463,7 @@ class CookieMonster::GetAllCookiesTask : public CookieMonsterTask {
public:
GetAllCookiesTask(CookieMonster* cookie_monster,
const GetCookieListCallback& callback)
- : CookieMonsterTask(cookie_monster),
- callback_(callback) {
- }
+ : CookieMonsterTask(cookie_monster), callback_(callback) {}
// CookieMonsterTask
virtual void Run() OVERRIDE;
@@ -481,25 +480,23 @@ class CookieMonster::GetAllCookiesTask : public CookieMonsterTask {
void CookieMonster::GetAllCookiesTask::Run() {
if (!callback_.is_null()) {
CookieList cookies = this->cookie_monster()->GetAllCookies();
- this->InvokeCallback(base::Bind(&GetCookieListCallback::Run,
- base::Unretained(&callback_), cookies));
- }
+ this->InvokeCallback(base::Bind(
+ &GetCookieListCallback::Run, base::Unretained(&callback_), cookies));
+ }
}
// Task class for GetAllCookiesForURLWithOptions call.
class CookieMonster::GetAllCookiesForURLWithOptionsTask
: public CookieMonsterTask {
public:
- GetAllCookiesForURLWithOptionsTask(
- CookieMonster* cookie_monster,
- const GURL& url,
- const CookieOptions& options,
- const GetCookieListCallback& callback)
+ GetAllCookiesForURLWithOptionsTask(CookieMonster* cookie_monster,
+ const GURL& url,
+ const CookieOptions& options,
+ const GetCookieListCallback& callback)
: CookieMonsterTask(cookie_monster),
url_(url),
options_(options),
- callback_(callback) {
- }
+ callback_(callback) {}
// CookieMonsterTask:
virtual void Run() OVERRIDE;
@@ -517,18 +514,20 @@ class CookieMonster::GetAllCookiesForURLWithOptionsTask
void CookieMonster::GetAllCookiesForURLWithOptionsTask::Run() {
if (!callback_.is_null()) {
- CookieList cookies = this->cookie_monster()->
- GetAllCookiesForURLWithOptions(url_, options_);
- this->InvokeCallback(base::Bind(&GetCookieListCallback::Run,
- base::Unretained(&callback_), cookies));
+ CookieList cookies =
+ this->cookie_monster()->GetAllCookiesForURLWithOptions(url_, options_);
+ this->InvokeCallback(base::Bind(
+ &GetCookieListCallback::Run, base::Unretained(&callback_), cookies));
}
}
-template <typename Result> struct CallbackType {
+template <typename Result>
+struct CallbackType {
typedef base::Callback<void(Result)> Type;
};
-template <> struct CallbackType<void> {
+template <>
+struct CallbackType<void> {
typedef base::Closure Type;
};
@@ -538,9 +537,7 @@ class CookieMonster::DeleteTask : public CookieMonsterTask {
public:
DeleteTask(CookieMonster* cookie_monster,
const typename CallbackType<Result>::Type& callback)
- : CookieMonsterTask(cookie_monster),
- callback_(callback) {
- }
+ : CookieMonsterTask(cookie_monster), callback_(callback) {}
// CookieMonsterTask:
virtual void Run() OVERRIDE;
@@ -557,8 +554,8 @@ class CookieMonster::DeleteTask : public CookieMonsterTask {
};
template <typename Result>
-base::Closure CookieMonster::DeleteTask<Result>::
-RunDeleteTaskAndBindCallback() {
+base::Closure
+CookieMonster::DeleteTask<Result>::RunDeleteTaskAndBindCallback() {
Result result = RunDeleteTask();
if (callback_.is_null())
return base::Closure();
@@ -573,9 +570,8 @@ base::Closure CookieMonster::DeleteTask<void>::RunDeleteTaskAndBindCallback() {
template <typename Result>
void CookieMonster::DeleteTask<Result>::Run() {
- this->cookie_monster()->FlushStore(
- base::Bind(&DeleteTask<Result>::FlushDone, this,
- RunDeleteTaskAndBindCallback()));
+ this->cookie_monster()->FlushStore(base::Bind(
+ &DeleteTask<Result>::FlushDone, this, RunDeleteTaskAndBindCallback()));
}
template <typename Result>
@@ -589,10 +585,8 @@ void CookieMonster::DeleteTask<Result>::FlushDone(
// Task class for DeleteAll call.
class CookieMonster::DeleteAllTask : public DeleteTask<int> {
public:
- DeleteAllTask(CookieMonster* cookie_monster,
- const DeleteCallback& callback)
- : DeleteTask<int>(cookie_monster, callback) {
- }
+ DeleteAllTask(CookieMonster* cookie_monster, const DeleteCallback& callback)
+ : DeleteTask<int>(cookie_monster, callback) {}
// DeleteTask:
virtual int RunDeleteTask() OVERRIDE;
@@ -617,8 +611,7 @@ class CookieMonster::DeleteAllCreatedBetweenTask : public DeleteTask<int> {
const DeleteCallback& callback)
: DeleteTask<int>(cookie_monster, callback),
delete_begin_(delete_begin),
- delete_end_(delete_end) {
- }
+ delete_end_(delete_end) {}
// DeleteTask:
virtual int RunDeleteTask() OVERRIDE;
@@ -634,8 +627,8 @@ class CookieMonster::DeleteAllCreatedBetweenTask : public DeleteTask<int> {
};
int CookieMonster::DeleteAllCreatedBetweenTask::RunDeleteTask() {
- return this->cookie_monster()->
- DeleteAllCreatedBetween(delete_begin_, delete_end_);
+ return this->cookie_monster()->DeleteAllCreatedBetween(delete_begin_,
+ delete_end_);
}
// Task class for DeleteAllForHost call.
@@ -644,9 +637,7 @@ class CookieMonster::DeleteAllForHostTask : public DeleteTask<int> {
DeleteAllForHostTask(CookieMonster* cookie_monster,
const GURL& url,
const DeleteCallback& callback)
- : DeleteTask<int>(cookie_monster, callback),
- url_(url) {
- }
+ : DeleteTask<int>(cookie_monster, callback), url_(url) {}
// DeleteTask:
virtual int RunDeleteTask() OVERRIDE;
@@ -668,17 +659,15 @@ int CookieMonster::DeleteAllForHostTask::RunDeleteTask() {
class CookieMonster::DeleteAllCreatedBetweenForHostTask
: public DeleteTask<int> {
public:
- DeleteAllCreatedBetweenForHostTask(
- CookieMonster* cookie_monster,
- Time delete_begin,
- Time delete_end,
- const GURL& url,
- const DeleteCallback& callback)
+ DeleteAllCreatedBetweenForHostTask(CookieMonster* cookie_monster,
+ Time delete_begin,
+ Time delete_end,
+ const GURL& url,
+ const DeleteCallback& callback)
: DeleteTask<int>(cookie_monster, callback),
delete_begin_(delete_begin),
delete_end_(delete_end),
- url_(url) {
- }
+ url_(url) {}
// DeleteTask:
virtual int RunDeleteTask() OVERRIDE;
@@ -705,9 +694,7 @@ class CookieMonster::DeleteCanonicalCookieTask : public DeleteTask<bool> {
DeleteCanonicalCookieTask(CookieMonster* cookie_monster,
const CanonicalCookie& cookie,
const DeleteCookieCallback& callback)
- : DeleteTask<bool>(cookie_monster, callback),
- cookie_(cookie) {
- }
+ : DeleteTask<bool>(cookie_monster, callback), cookie_(cookie) {}
// DeleteTask:
virtual bool RunDeleteTask() OVERRIDE;
@@ -737,8 +724,7 @@ class CookieMonster::SetCookieWithOptionsTask : public CookieMonsterTask {
url_(url),
cookie_line_(cookie_line),
options_(options),
- callback_(callback) {
- }
+ callback_(callback) {}
// CookieMonsterTask:
virtual void Run() OVERRIDE;
@@ -756,11 +742,11 @@ class CookieMonster::SetCookieWithOptionsTask : public CookieMonsterTask {
};
void CookieMonster::SetCookieWithOptionsTask::Run() {
- bool result = this->cookie_monster()->
- SetCookieWithOptions(url_, cookie_line_, options_);
+ bool result = this->cookie_monster()->SetCookieWithOptions(
+ url_, cookie_line_, options_);
if (!callback_.is_null()) {
- this->InvokeCallback(base::Bind(&SetCookiesCallback::Run,
- base::Unretained(&callback_), result));
+ this->InvokeCallback(base::Bind(
+ &SetCookiesCallback::Run, base::Unretained(&callback_), result));
}
}
@@ -774,8 +760,7 @@ class CookieMonster::GetCookiesWithOptionsTask : public CookieMonsterTask {
: CookieMonsterTask(cookie_monster),
url_(url),
options_(options),
- callback_(callback) {
- }
+ callback_(callback) {}
// CookieMonsterTask:
virtual void Run() OVERRIDE;
@@ -792,11 +777,11 @@ class CookieMonster::GetCookiesWithOptionsTask : public CookieMonsterTask {
};
void CookieMonster::GetCookiesWithOptionsTask::Run() {
- std::string cookie = this->cookie_monster()->
- GetCookiesWithOptions(url_, options_);
+ std::string cookie =
+ this->cookie_monster()->GetCookiesWithOptions(url_, options_);
if (!callback_.is_null()) {
- this->InvokeCallback(base::Bind(&GetCookiesCallback::Run,
- base::Unretained(&callback_), cookie));
+ this->InvokeCallback(base::Bind(
+ &GetCookiesCallback::Run, base::Unretained(&callback_), cookie));
}
}
@@ -809,8 +794,7 @@ class CookieMonster::DeleteCookieTask : public DeleteTask<void> {
const base::Closure& callback)
: DeleteTask<void>(cookie_monster, callback),
url_(url),
- cookie_name_(cookie_name) {
- }
+ cookie_name_(cookie_name) {}
// DeleteTask:
virtual void RunDeleteTask() OVERRIDE;
@@ -834,8 +818,7 @@ class CookieMonster::DeleteSessionCookiesTask : public DeleteTask<int> {
public:
DeleteSessionCookiesTask(CookieMonster* cookie_monster,
const DeleteCallback& callback)
- : DeleteTask<int>(cookie_monster, callback) {
- }
+ : DeleteTask<int>(cookie_monster, callback) {}
// DeleteTask:
virtual int RunDeleteTask() OVERRIDE;
@@ -844,7 +827,6 @@ class CookieMonster::DeleteSessionCookiesTask : public DeleteTask<int> {
virtual ~DeleteSessionCookiesTask() {}
private:
-
DISALLOW_COPY_AND_ASSIGN(DeleteSessionCookiesTask);
};
@@ -855,14 +837,12 @@ int CookieMonster::DeleteSessionCookiesTask::RunDeleteTask() {
// Task class for HasCookiesForETLDP1Task call.
class CookieMonster::HasCookiesForETLDP1Task : public CookieMonsterTask {
public:
- HasCookiesForETLDP1Task(
- CookieMonster* cookie_monster,
- const std::string& etldp1,
- const HasCookiesForETLDP1Callback& callback)
+ HasCookiesForETLDP1Task(CookieMonster* cookie_monster,
+ const std::string& etldp1,
+ const HasCookiesForETLDP1Callback& callback)
: CookieMonsterTask(cookie_monster),
etldp1_(etldp1),
- callback_(callback) {
- }
+ callback_(callback) {}
// CookieMonsterTask:
virtual void Run() OVERRIDE;
@@ -880,9 +860,9 @@ class CookieMonster::HasCookiesForETLDP1Task : public CookieMonsterTask {
void CookieMonster::HasCookiesForETLDP1Task::Run() {
bool result = this->cookie_monster()->HasCookiesForETLDP1(etldp1_);
if (!callback_.is_null()) {
- this->InvokeCallback(
- base::Bind(&HasCookiesForETLDP1Callback::Run,
- base::Unretained(&callback_), result));
+ this->InvokeCallback(base::Bind(&HasCookiesForETLDP1Callback::Run,
+ base::Unretained(&callback_),
+ result));
}
}
@@ -900,21 +880,27 @@ void CookieMonster::SetCookieWithDetailsAsync(
CookiePriority priority,
const SetCookiesCallback& callback) {
scoped_refptr<SetCookieWithDetailsTask> task =
- new SetCookieWithDetailsTask(this, url, name, value, domain, path,
- expiration_time, secure, http_only, priority,
+ new SetCookieWithDetailsTask(this,
+ url,
+ name,
+ value,
+ domain,
+ path,
+ expiration_time,
+ secure,
+ http_only,
+ priority,
callback);
DoCookieTaskForURL(task, url);
}
void CookieMonster::GetAllCookiesAsync(const GetCookieListCallback& callback) {
- scoped_refptr<GetAllCookiesTask> task =
- new GetAllCookiesTask(this, callback);
+ scoped_refptr<GetAllCookiesTask> task = new GetAllCookiesTask(this, callback);
DoCookieTask(task);
}
-
void CookieMonster::GetAllCookiesForURLWithOptionsAsync(
const GURL& url,
const CookieOptions& options,
@@ -926,7 +912,8 @@ void CookieMonster::GetAllCookiesForURLWithOptionsAsync(
}
void CookieMonster::GetAllCookiesForURLAsync(
- const GURL& url, const GetCookieListCallback& callback) {
+ const GURL& url,
+ const GetCookieListCallback& callback) {
CookieOptions options;
options.set_include_httponly();
scoped_refptr<GetAllCookiesForURLWithOptionsTask> task =
@@ -945,18 +932,17 @@ void CookieMonster::HasCookiesForETLDP1Async(
}
void CookieMonster::DeleteAllAsync(const DeleteCallback& callback) {
- scoped_refptr<DeleteAllTask> task =
- new DeleteAllTask(this, callback);
+ scoped_refptr<DeleteAllTask> task = new DeleteAllTask(this, callback);
DoCookieTask(task);
}
void CookieMonster::DeleteAllCreatedBetweenAsync(
- const Time& delete_begin, const Time& delete_end,
+ const Time& delete_begin,
+ const Time& delete_end,
const DeleteCallback& callback) {
scoped_refptr<DeleteAllCreatedBetweenTask> task =
- new DeleteAllCreatedBetweenTask(this, delete_begin, delete_end,
- callback);
+ new DeleteAllCreatedBetweenTask(this, delete_begin, delete_end, callback);
DoCookieTask(task);
}
@@ -973,8 +959,8 @@ void CookieMonster::DeleteAllCreatedBetweenForHostAsync(
DoCookieTaskForURL(task, url);
}
-void CookieMonster::DeleteAllForHostAsync(
- const GURL& url, const DeleteCallback& callback) {
+void CookieMonster::DeleteAllForHostAsync(const GURL& url,
+ const DeleteCallback& callback) {
scoped_refptr<DeleteAllForHostTask> task =
new DeleteAllForHostTask(this, url, callback);
@@ -1052,16 +1038,19 @@ void CookieMonster::DoCookieTaskForURL(
// then run the task, otherwise load from DB.
if (!loaded_) {
// Checks if the domain key has been loaded.
- std::string key(cookie_util::GetEffectiveDomain(url.scheme(),
- url.host()));
+ std::string key(
+ cookie_util::GetEffectiveDomain(url.scheme(), url.host()));
if (keys_loaded_.find(key) == keys_loaded_.end()) {
- std::map<std::string, std::deque<scoped_refptr<CookieMonsterTask> > >
- ::iterator it = tasks_pending_for_key_.find(key);
+ std::map<std::string,
+ std::deque<scoped_refptr<CookieMonsterTask> > >::iterator it =
+ tasks_pending_for_key_.find(key);
if (it == tasks_pending_for_key_.end()) {
- store_->LoadCookiesForKey(key,
- base::Bind(&CookieMonster::OnKeyLoaded, this, key));
- it = tasks_pending_for_key_.insert(std::make_pair(key,
- std::deque<scoped_refptr<CookieMonsterTask> >())).first;
+ store_->LoadCookiesForKey(
+ key, base::Bind(&CookieMonster::OnKeyLoaded, this, key));
+ it = tasks_pending_for_key_
+ .insert(std::make_pair(
+ key, std::deque<scoped_refptr<CookieMonsterTask> >()))
+ .first;
}
it->second.push_back(task_item);
return;
@@ -1089,9 +1078,16 @@ bool CookieMonster::SetCookieWithDetails(const GURL& url,
last_time_seen_ = creation_time;
scoped_ptr<CanonicalCookie> cc;
- cc.reset(CanonicalCookie::Create(url, name, value, domain, path,
- creation_time, expiration_time,
- secure, http_only, priority));
+ cc.reset(CanonicalCookie::Create(url,
+ name,
+ value,
+ domain,
+ path,
+ creation_time,
+ expiration_time,
+ secure,
+ http_only,
+ priority));
if (!cc.get())
return false;
@@ -1104,8 +1100,8 @@ bool CookieMonster::SetCookieWithDetails(const GURL& url,
bool CookieMonster::InitializeFrom(const CookieList& list) {
base::AutoLock autolock(lock_);
InitIfNecessary();
- for (net::CookieList::const_iterator iter = list.begin();
- iter != list.end(); ++iter) {
+ for (net::CookieList::const_iterator iter = list.begin(); iter != list.end();
+ ++iter) {
scoped_ptr<CanonicalCookie> cookie(new CanonicalCookie(*iter));
net::CookieOptions options;
options.set_include_httponly();
@@ -1126,9 +1122,8 @@ CookieList CookieMonster::GetAllCookies() {
//
// Note that this does not prune cookies to be below our limits (if we've
// exceeded them) the way that calling GarbageCollect() would.
- GarbageCollectExpired(Time::Now(),
- CookieMapItPair(cookies_.begin(), cookies_.end()),
- NULL);
+ GarbageCollectExpired(
+ Time::Now(), CookieMapItPair(cookies_.begin(), cookies_.end()), NULL);
// Copy the CanonicalCookie pointers from the map so that we can use the same
// sorter as elsewhere, then copy the result out.
@@ -1141,7 +1136,8 @@ CookieList CookieMonster::GetAllCookies() {
CookieList cookie_list;
cookie_list.reserve(cookie_ptrs.size());
for (std::vector<CanonicalCookie*>::const_iterator it = cookie_ptrs.begin();
- it != cookie_ptrs.end(); ++it)
+ it != cookie_ptrs.end();
+ ++it)
cookie_list.push_back(**it);
return cookie_list;
@@ -1158,7 +1154,8 @@ CookieList CookieMonster::GetAllCookiesForURLWithOptions(
CookieList cookies;
for (std::vector<CanonicalCookie*>::const_iterator it = cookie_ptrs.begin();
- it != cookie_ptrs.end(); it++)
+ it != cookie_ptrs.end();
+ it++)
cookies.push_back(**it);
return cookies;
@@ -1178,9 +1175,11 @@ int CookieMonster::DeleteAll(bool sync_to_store) {
for (CookieMap::iterator it = cookies_.begin(); it != cookies_.end();) {
CookieMap::iterator curit = it;
++it;
- InternalDeleteCookie(curit, sync_to_store,
- sync_to_store ? DELETE_COOKIE_EXPLICIT :
- DELETE_COOKIE_DONT_RECORD /* Destruction. */);
+ InternalDeleteCookie(curit,
+ sync_to_store,
+ sync_to_store
+ ? DELETE_COOKIE_EXPLICIT
+ : DELETE_COOKIE_DONT_RECORD /* Destruction. */);
++num_deleted;
}
@@ -1200,7 +1199,7 @@ int CookieMonster::DeleteAllCreatedBetween(const Time& delete_begin,
if (cc->CreationDate() >= delete_begin &&
(delete_end.is_null() || cc->CreationDate() < delete_end)) {
InternalDeleteCookie(curit,
- true, /*sync_to_store*/
+ true, /*sync_to_store*/
DELETE_COOKIE_EXPLICIT);
++num_deleted;
}
@@ -1248,12 +1247,12 @@ int CookieMonster::DeleteAllForHost(const GURL& url) {
return DeleteAllCreatedBetweenForHost(Time(), Time::Max(), url);
}
-
bool CookieMonster::DeleteCanonicalCookie(const CanonicalCookie& cookie) {
base::AutoLock autolock(lock_);
for (CookieMapItPair its = cookies_.equal_range(GetKey(cookie.Domain()));
- its.first != its.second; ++its.first) {
+ its.first != its.second;
+ ++its.first) {
// The creation date acts as our unique index...
if (its.first->second->CreationDate() == cookie.CreationDate()) {
InternalDeleteCookie(its.first, true, DELETE_COOKIE_EXPLICIT);
@@ -1271,15 +1270,15 @@ void CookieMonster::SetCookieableSchemes(const char* schemes[],
DCHECK(!initialized_);
cookieable_schemes_.clear();
- cookieable_schemes_.insert(cookieable_schemes_.end(),
- schemes, schemes + num_schemes);
+ cookieable_schemes_.insert(
+ cookieable_schemes_.end(), schemes, schemes + num_schemes);
}
void CookieMonster::SetEnableFileScheme(bool accept) {
// This assumes "file" is always at the end of the array. See the comment
// above kDefaultCookieableSchemes.
- int num_schemes = accept ? kDefaultCookieableSchemesCount :
- kDefaultCookieableSchemesCount - 1;
+ int num_schemes = accept ? kDefaultCookieableSchemesCount
+ : kDefaultCookieableSchemesCount - 1;
SetCookieableSchemes(kDefaultCookieableSchemes, num_schemes);
}
@@ -1344,7 +1343,8 @@ void CookieMonster::DeleteCookie(const GURL& url,
std::set<CanonicalCookie*> matching_cookies;
for (std::vector<CanonicalCookie*>::const_iterator it = cookies.begin();
- it != cookies.end(); ++it) {
+ it != cookies.end();
+ ++it) {
if ((*it)->Name() != cookie_name)
continue;
if (url.path().find((*it)->Path()))
@@ -1372,7 +1372,7 @@ int CookieMonster::DeleteSessionCookies() {
if (!cc->IsPersistent()) {
InternalDeleteCookie(curit,
- true, /*sync_to_store*/
+ true, /*sync_to_store*/
DELETE_COOKIE_EXPIRED);
++num_deleted;
}
@@ -1421,8 +1421,8 @@ bool CookieMonster::SetCookieWithCreationTime(const GURL& url,
}
InitIfNecessary();
- return SetCookieWithCreationTimeAndOptions(url, cookie_line, creation_time,
- CookieOptions());
+ return SetCookieWithCreationTimeAndOptions(
+ url, cookie_line, creation_time, CookieOptions());
}
void CookieMonster::InitStore() {
@@ -1454,8 +1454,9 @@ void CookieMonster::OnKeyLoaded(const std::string& key,
while (true) {
{
base::AutoLock autolock(lock_);
- std::map<std::string, std::deque<scoped_refptr<CookieMonsterTask> > >
- ::iterator it = tasks_pending_for_key_.find(key);
+ std::map<std::string,
+ std::deque<scoped_refptr<CookieMonsterTask> > >::iterator it =
+ tasks_pending_for_key_.find(key);
if (it == tasks_pending_for_key_.end()) {
keys_loaded_.insert(key);
return;
@@ -1486,7 +1487,8 @@ void CookieMonster::StoreLoadedCookies(
CookieItVector cookies_with_control_chars;
for (std::vector<CanonicalCookie*>::const_iterator it = cookies.begin();
- it != cookies.end(); ++it) {
+ it != cookies.end();
+ ++it) {
int64 cookie_creation_time = (*it)->CreationDate().ToInternalValue();
if (creation_times_.insert(cookie_creation_time).second) {
@@ -1499,15 +1501,16 @@ void CookieMonster::StoreLoadedCookies(
if (ContainsControlCharacter((*it)->Name()) ||
ContainsControlCharacter((*it)->Value())) {
- cookies_with_control_chars.push_back(inserted);
+ cookies_with_control_chars.push_back(inserted);
}
} else {
- LOG(ERROR) << base::StringPrintf("Found cookies with duplicate creation "
- "times in backing store: "
- "{name='%s', domain='%s', path='%s'}",
- (*it)->Name().c_str(),
- (*it)->Domain().c_str(),
- (*it)->Path().c_str());
+ LOG(ERROR) << base::StringPrintf(
+ "Found cookies with duplicate creation "
+ "times in backing store: "
+ "{name='%s', domain='%s', path='%s'}",
+ (*it)->Name().c_str(),
+ (*it)->Domain().c_str(),
+ (*it)->Path().c_str());
// We've been given ownership of the cookie and are throwing it
// away; reclaim the space.
delete (*it);
@@ -1575,10 +1578,9 @@ void CookieMonster::EnsureCookiesMapIsValid() {
histogram_cookie_deletion_cause_->Add(num_duplicates_trimmed);
}
-int CookieMonster::TrimDuplicateCookiesForKey(
- const std::string& key,
- CookieMap::iterator begin,
- CookieMap::iterator end) {
+int CookieMonster::TrimDuplicateCookiesForKey(const std::string& key,
+ CookieMap::iterator begin,
+ CookieMap::iterator end) {
lock_.AssertAcquired();
// Set of cookies ordered by creation time.
@@ -1597,8 +1599,7 @@ int CookieMonster::TrimDuplicateCookiesForKey(
DCHECK_EQ(key, it->first);
CanonicalCookie* cookie = it->second;
- CookieSignature signature(cookie->Name(), cookie->Domain(),
- cookie->Path());
+ CookieSignature signature(cookie->Name(), cookie->Domain(), cookie->Path());
CookieSet& set = equivalent_cookies[signature];
// We found a duplicate!
@@ -1608,8 +1609,8 @@ int CookieMonster::TrimDuplicateCookiesForKey(
// We save the iterator into |cookies_| rather than the actual cookie
// pointer, since we may need to delete it later.
bool insert_success = set.insert(it).second;
- DCHECK(insert_success) <<
- "Duplicate creation times found in duplicate cookie name scan.";
+ DCHECK(insert_success)
+ << "Duplicate creation times found in duplicate cookie name scan.";
}
// If there were no duplicates, we are done!
@@ -1636,22 +1637,21 @@ int CookieMonster::TrimDuplicateCookiesForKey(
dupes.erase(dupes.begin());
LOG(ERROR) << base::StringPrintf(
- "Found %d duplicate cookies for host='%s', "
- "with {name='%s', domain='%s', path='%s'}",
- static_cast<int>(dupes.size()),
- key.c_str(),
- signature.name.c_str(),
- signature.domain.c_str(),
- signature.path.c_str());
+ "Found %d duplicate cookies for host='%s', "
+ "with {name='%s', domain='%s', path='%s'}",
+ static_cast<int>(dupes.size()),
+ key.c_str(),
+ signature.name.c_str(),
+ signature.domain.c_str(),
+ signature.path.c_str());
// Remove all the cookies identified by |dupes|. It is valid to delete our
// list of iterators one at a time, since |cookies_| is a multimap (they
// don't invalidate existing iterators following deletion).
- for (CookieSet::iterator dupes_it = dupes.begin();
- dupes_it != dupes.end();
+ for (CookieSet::iterator dupes_it = dupes.begin(); dupes_it != dupes.end();
++dupes_it) {
- InternalDeleteCookie(*dupes_it, true,
- DELETE_COOKIE_DUPLICATE_IN_BACKING_STORE);
+ InternalDeleteCookie(
+ *dupes_it, true, DELETE_COOKIE_DUPLICATE_IN_BACKING_STORE);
}
}
DCHECK_EQ(num_duplicates, num_duplicates_found);
@@ -1660,8 +1660,8 @@ int CookieMonster::TrimDuplicateCookiesForKey(
}
// Note: file must be the last scheme.
-const char* CookieMonster::kDefaultCookieableSchemes[] =
- { "http", "https", "ws", "wss", "file" };
+const char* CookieMonster::kDefaultCookieableSchemes[] = {"http", "https", "ws",
+ "wss", "file"};
const int CookieMonster::kDefaultCookieableSchemesCount =
arraysize(kDefaultCookieableSchemes);
@@ -1687,8 +1687,8 @@ void CookieMonster::FindCookiesForHostAndDomain(
// Can just dispatch to FindCookiesForKey
const std::string key(GetKey(url.host()));
- FindCookiesForKey(key, url, options, current_time,
- update_access_time, cookies);
+ FindCookiesForKey(
+ key, url, options, current_time, update_access_time, cookies);
}
void CookieMonster::FindCookiesForKey(const std::string& key,
@@ -1700,7 +1700,7 @@ void CookieMonster::FindCookiesForKey(const std::string& key,
lock_.AssertAcquired();
for (CookieMapItPair its = cookies_.equal_range(key);
- its.first != its.second; ) {
+ its.first != its.second;) {
CookieMap::iterator curit = its.first;
CanonicalCookie* cc = curit->second;
++its.first;
@@ -1735,7 +1735,7 @@ bool CookieMonster::DeleteAnyEquivalentCookie(const std::string& key,
bool found_equivalent_cookie = false;
bool skipped_httponly = false;
for (CookieMapItPair its = cookies_.equal_range(key);
- its.first != its.second; ) {
+ its.first != its.second;) {
CookieMap::iterator curit = its.first;
CanonicalCookie* cc = curit->second;
++its.first;
@@ -1743,13 +1743,15 @@ bool CookieMonster::DeleteAnyEquivalentCookie(const std::string& key,
if (ecc.IsEquivalent(*cc)) {
// We should never have more than one equivalent cookie, since they should
// overwrite each other.
- CHECK(!found_equivalent_cookie) <<
- "Duplicate equivalent cookies found, cookie store is corrupted.";
+ CHECK(!found_equivalent_cookie)
+ << "Duplicate equivalent cookies found, cookie store is corrupted.";
if (skip_httponly && cc->IsHttpOnly()) {
skipped_httponly = true;
} else {
- InternalDeleteCookie(curit, true, already_expired ?
- DELETE_COOKIE_EXPIRED_OVERWRITE : DELETE_COOKIE_OVERWRITE);
+ InternalDeleteCookie(curit,
+ true,
+ already_expired ? DELETE_COOKIE_EXPIRED_OVERWRITE
+ : DELETE_COOKIE_OVERWRITE);
}
found_equivalent_cookie = true;
}
@@ -1806,14 +1808,14 @@ bool CookieMonster::SetCanonicalCookie(scoped_ptr<CanonicalCookie>* cc,
const CookieOptions& options) {
const std::string key(GetKey((*cc)->Domain()));
bool already_expired = (*cc)->IsExpired(creation_time);
- if (DeleteAnyEquivalentCookie(key, **cc, options.exclude_httponly(),
- already_expired)) {
+ if (DeleteAnyEquivalentCookie(
+ key, **cc, options.exclude_httponly(), already_expired)) {
VLOG(kVlogSetCookies) << "SetCookie() not clobbering httponly cookie";
return false;
}
- VLOG(kVlogSetCookies) << "SetCookie() key: " << key << " cc: "
- << (*cc)->DebugString();
+ VLOG(kVlogSetCookies) << "SetCookie() key: " << key
+ << " cc: " << (*cc)->DebugString();
// Realize that we might be setting an expired cookie, and the only point
// was to delete the cookie which we've already done.
@@ -1894,21 +1896,19 @@ void CookieMonster::InternalDeleteCookie(CookieMap::iterator it,
// Domain expiry behavior is unchanged by key/expiry scheme (the
// meaning of the key is different, but that's not visible to this routine).
-int CookieMonster::GarbageCollect(const Time& current,
- const std::string& key) {
+int CookieMonster::GarbageCollect(const Time& current, const std::string& key) {
lock_.AssertAcquired();
int num_deleted = 0;
- Time safe_date(
- Time::Now() - TimeDelta::FromDays(kSafeFromGlobalPurgeDays));
+ Time safe_date(Time::Now() - TimeDelta::FromDays(kSafeFromGlobalPurgeDays));
// Collect garbage for this key, minding cookie priorities.
if (cookies_.count(key) > kDomainMaxCookies) {
VLOG(kVlogGarbageCollection) << "GarbageCollect() key: " << key;
CookieItVector cookie_its;
- num_deleted += GarbageCollectExpired(
- current, cookies_.equal_range(key), &cookie_its);
+ num_deleted +=
+ GarbageCollectExpired(current, cookies_.equal_range(key), &cookie_its);
if (cookie_its.size() > kDomainMaxCookies) {
VLOG(kVlogGarbageCollection) << "Deep Garbage Collect domain.";
size_t purge_goal =
@@ -1921,15 +1921,12 @@ int CookieMonster::GarbageCollect(const Time& current,
// Schematic: [MLLHMHHLMM] => [LLL|MMMM|HHH], with 4 boundaries.
it_bdd[0] = cookie_its.begin();
it_bdd[3] = cookie_its.end();
- it_bdd[1] = PartitionCookieByPriority(it_bdd[0], it_bdd[3],
- COOKIE_PRIORITY_LOW);
- it_bdd[2] = PartitionCookieByPriority(it_bdd[1], it_bdd[3],
- COOKIE_PRIORITY_MEDIUM);
- size_t quota[3] = {
- kDomainCookiesQuotaLow,
- kDomainCookiesQuotaMedium,
- kDomainCookiesQuotaHigh
- };
+ it_bdd[1] =
+ PartitionCookieByPriority(it_bdd[0], it_bdd[3], COOKIE_PRIORITY_LOW);
+ it_bdd[2] = PartitionCookieByPriority(
+ it_bdd[1], it_bdd[3], COOKIE_PRIORITY_MEDIUM);
+ size_t quota[3] = {kDomainCookiesQuotaLow, kDomainCookiesQuotaMedium,
+ kDomainCookiesQuotaHigh};
// Purge domain cookies in 3 rounds.
// Round 1: consider low-priority cookies only: evict least-recently
@@ -1958,17 +1955,17 @@ int CookieMonster::GarbageCollect(const Time& current,
CookieItVector::iterator it_purge_middle =
LowerBoundAccessDate(it_purge_begin, it_purge_end, safe_date);
// Delete cookies accessed before |safe_date|.
- num_deleted += GarbageCollectDeleteRange(
- current,
- DELETE_COOKIE_EVICTED_DOMAIN_PRE_SAFE,
- it_purge_begin,
- it_purge_middle);
+ num_deleted +=
+ GarbageCollectDeleteRange(current,
+ DELETE_COOKIE_EVICTED_DOMAIN_PRE_SAFE,
+ it_purge_begin,
+ it_purge_middle);
// Delete cookies accessed on or after |safe_date|.
- num_deleted += GarbageCollectDeleteRange(
- current,
- DELETE_COOKIE_EVICTED_DOMAIN_POST_SAFE,
- it_purge_middle,
- it_purge_end);
+ num_deleted +=
+ GarbageCollectDeleteRange(current,
+ DELETE_COOKIE_EVICTED_DOMAIN_POST_SAFE,
+ it_purge_middle,
+ it_purge_end);
it_purge_begin = it_purge_end;
}
DCHECK_EQ(0U, purge_goal);
@@ -1977,13 +1974,13 @@ int CookieMonster::GarbageCollect(const Time& current,
// Collect garbage for everything. With firefox style we want to preserve
// cookies accessed in kSafeFromGlobalPurgeDays, otherwise evict.
- if (cookies_.size() > kMaxCookies &&
- earliest_access_time_ < safe_date) {
+ if (cookies_.size() > kMaxCookies && earliest_access_time_ < safe_date) {
VLOG(kVlogGarbageCollection) << "GarbageCollect() everything";
CookieItVector cookie_its;
- num_deleted += GarbageCollectExpired(
- current, CookieMapItPair(cookies_.begin(), cookies_.end()),
- &cookie_its);
+ num_deleted +=
+ GarbageCollectExpired(current,
+ CookieMapItPair(cookies_.begin(), cookies_.end()),
+ &cookie_its);
if (cookie_its.size() > kMaxCookies) {
VLOG(kVlogGarbageCollection) << "Deep Garbage Collect everything.";
size_t purge_goal = cookie_its.size() - (kMaxCookies - kPurgeCookies);
@@ -1991,19 +1988,16 @@ int CookieMonster::GarbageCollect(const Time& current,
// Sorts up to *and including* |cookie_its[purge_goal]|, so
// |earliest_access_time| will be properly assigned even if
// |global_purge_it| == |cookie_its.begin() + purge_goal|.
- SortLeastRecentlyAccessed(cookie_its.begin(), cookie_its.end(),
- purge_goal);
+ SortLeastRecentlyAccessed(
+ cookie_its.begin(), cookie_its.end(), purge_goal);
// Find boundary to cookies older than safe_date.
- CookieItVector::iterator global_purge_it =
- LowerBoundAccessDate(cookie_its.begin(),
- cookie_its.begin() + purge_goal,
- safe_date);
+ CookieItVector::iterator global_purge_it = LowerBoundAccessDate(
+ cookie_its.begin(), cookie_its.begin() + purge_goal, safe_date);
// Only delete the old cookies.
- num_deleted += GarbageCollectDeleteRange(
- current,
- DELETE_COOKIE_EVICTED_GLOBAL,
- cookie_its.begin(),
- global_purge_it);
+ num_deleted += GarbageCollectDeleteRange(current,
+ DELETE_COOKIE_EVICTED_GLOBAL,
+ cookie_its.begin(),
+ global_purge_it);
// Set access day to the oldest cookie that wasn't deleted.
earliest_access_time_ = (*global_purge_it)->second->LastAccessDate();
}
@@ -2012,10 +2006,9 @@ int CookieMonster::GarbageCollect(const Time& current,
return num_deleted;
}
-int CookieMonster::GarbageCollectExpired(
- const Time& current,
- const CookieMapItPair& itpair,
- CookieItVector* cookie_its) {
+int CookieMonster::GarbageCollectExpired(const Time& current,
+ const CookieMapItPair& itpair,
+ CookieItVector* cookie_its) {
if (keep_expired_cookies_)
return 0;
@@ -2037,11 +2030,10 @@ int CookieMonster::GarbageCollectExpired(
return num_deleted;
}
-int CookieMonster::GarbageCollectDeleteRange(
- const Time& current,
- DeletionCause cause,
- CookieItVector::iterator it_begin,
- CookieItVector::iterator it_end) {
+int CookieMonster::GarbageCollectDeleteRange(const Time& current,
+ DeletionCause cause,
+ CookieItVector::iterator it_begin,
+ CookieItVector::iterator it_end) {
for (CookieItVector::iterator it = it_begin; it != it_end; it++) {
histogram_evicted_last_access_minutes_->Add(
(current - (*it)->second->LastAccessDate()).InMinutes());
@@ -2088,7 +2080,8 @@ std::string CookieMonster::GetKey(const std::string& domain) const {
bool CookieMonster::IsCookieableScheme(const std::string& scheme) {
base::AutoLock autolock(lock_);
- return std::find(cookieable_schemes_.begin(), cookieable_schemes_.end(),
+ return std::find(cookieable_schemes_.begin(),
+ cookieable_schemes_.end(),
scheme) != cookieable_schemes_.end();
}
@@ -2105,8 +2098,8 @@ bool CookieMonster::HasCookieableScheme(const GURL& url) {
}
// The scheme didn't match any in our whitelist.
- VLOG(kVlogPerCookieMonster) << "WARNING: Unsupported cookie scheme: "
- << url.scheme();
+ VLOG(kVlogPerCookieMonster)
+ << "WARNING: Unsupported cookie scheme: " << url.scheme();
return false;
}
@@ -2135,7 +2128,7 @@ void CookieMonster::RecordPeriodicStats(const base::Time& current_time) {
TimeTicks beginning_of_time(TimeTicks::Now());
for (CookieMap::const_iterator it_key = cookies_.begin();
- it_key != cookies_.end(); ) {
+ it_key != cookies_.end();) {
const std::string& key(it_key->first);
int key_count = 0;
@@ -2152,15 +2145,16 @@ void CookieMonster::RecordPeriodicStats(const base::Time& current_time) {
histogram_etldp1_count_->Add(key_count);
histogram_domain_per_etldp1_count_->Add(domain_map.size());
for (DomainMap::const_iterator domain_map_it = domain_map.begin();
- domain_map_it != domain_map.end(); domain_map_it++)
+ domain_map_it != domain_map.end();
+ domain_map_it++)
histogram_domain_count_->Add(domain_map_it->second);
it_key = its_cookies.second;
}
- VLOG(kVlogPeriodic)
- << "Time for recording cookie stats (us): "
- << (TimeTicks::Now() - beginning_of_time).InMicroseconds();
+ VLOG(kVlogPeriodic) << "Time for recording cookie stats (us): "
+ << (TimeTicks::Now() - beginning_of_time)
+ .InMicroseconds();
last_statistic_record_time_ = current_time;
}
@@ -2190,58 +2184,82 @@ void CookieMonster::RecordPeriodicStats(const base::Time& current_time) {
// initialization is based are included in comments below.
void CookieMonster::InitializeHistograms() {
// From UMA_HISTOGRAM_CUSTOM_COUNTS
- histogram_expiration_duration_minutes_ = base::Histogram::FactoryGet(
- "Cookie.ExpirationDurationMinutes",
- 1, kMinutesInTenYears, 50,
- base::Histogram::kUmaTargetedHistogramFlag);
- histogram_between_access_interval_minutes_ = base::Histogram::FactoryGet(
- "Cookie.BetweenAccessIntervalMinutes",
- 1, kMinutesInTenYears, 50,
- base::Histogram::kUmaTargetedHistogramFlag);
- histogram_evicted_last_access_minutes_ = base::Histogram::FactoryGet(
- "Cookie.EvictedLastAccessMinutes",
- 1, kMinutesInTenYears, 50,
- base::Histogram::kUmaTargetedHistogramFlag);
+ histogram_expiration_duration_minutes_ =
+ base::Histogram::FactoryGet("Cookie.ExpirationDurationMinutes",
+ 1,
+ kMinutesInTenYears,
+ 50,
+ base::Histogram::kUmaTargetedHistogramFlag);
+ histogram_between_access_interval_minutes_ =
+ base::Histogram::FactoryGet("Cookie.BetweenAccessIntervalMinutes",
+ 1,
+ kMinutesInTenYears,
+ 50,
+ base::Histogram::kUmaTargetedHistogramFlag);
+ histogram_evicted_last_access_minutes_ =
+ base::Histogram::FactoryGet("Cookie.EvictedLastAccessMinutes",
+ 1,
+ kMinutesInTenYears,
+ 50,
+ base::Histogram::kUmaTargetedHistogramFlag);
histogram_count_ = base::Histogram::FactoryGet(
- "Cookie.Count", 1, 4000, 50,
- base::Histogram::kUmaTargetedHistogramFlag);
- histogram_domain_count_ = base::Histogram::FactoryGet(
- "Cookie.DomainCount", 1, 4000, 50,
- base::Histogram::kUmaTargetedHistogramFlag);
- histogram_etldp1_count_ = base::Histogram::FactoryGet(
- "Cookie.Etldp1Count", 1, 4000, 50,
- base::Histogram::kUmaTargetedHistogramFlag);
- histogram_domain_per_etldp1_count_ = base::Histogram::FactoryGet(
- "Cookie.DomainPerEtldp1Count", 1, 4000, 50,
- base::Histogram::kUmaTargetedHistogramFlag);
+ "Cookie.Count", 1, 4000, 50, base::Histogram::kUmaTargetedHistogramFlag);
+ histogram_domain_count_ =
+ base::Histogram::FactoryGet("Cookie.DomainCount",
+ 1,
+ 4000,
+ 50,
+ base::Histogram::kUmaTargetedHistogramFlag);
+ histogram_etldp1_count_ =
+ base::Histogram::FactoryGet("Cookie.Etldp1Count",
+ 1,
+ 4000,
+ 50,
+ base::Histogram::kUmaTargetedHistogramFlag);
+ histogram_domain_per_etldp1_count_ =
+ base::Histogram::FactoryGet("Cookie.DomainPerEtldp1Count",
+ 1,
+ 4000,
+ 50,
+ base::Histogram::kUmaTargetedHistogramFlag);
// From UMA_HISTOGRAM_COUNTS_10000 & UMA_HISTOGRAM_CUSTOM_COUNTS
- histogram_number_duplicate_db_cookies_ = base::Histogram::FactoryGet(
- "Net.NumDuplicateCookiesInDb", 1, 10000, 50,
- base::Histogram::kUmaTargetedHistogramFlag);
+ histogram_number_duplicate_db_cookies_ =
+ base::Histogram::FactoryGet("Net.NumDuplicateCookiesInDb",
+ 1,
+ 10000,
+ 50,
+ base::Histogram::kUmaTargetedHistogramFlag);
// From UMA_HISTOGRAM_ENUMERATION
histogram_cookie_deletion_cause_ = base::LinearHistogram::FactoryGet(
- "Cookie.DeletionCause", 1,
- DELETE_COOKIE_LAST_ENTRY - 1, DELETE_COOKIE_LAST_ENTRY,
+ "Cookie.DeletionCause",
+ 1,
+ DELETE_COOKIE_LAST_ENTRY - 1,
+ DELETE_COOKIE_LAST_ENTRY,
base::Histogram::kUmaTargetedHistogramFlag);
// From UMA_HISTOGRAM_{CUSTOM_,}TIMES
- histogram_time_get_ = base::Histogram::FactoryTimeGet("Cookie.TimeGet",
- base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMinutes(1),
- 50, base::Histogram::kUmaTargetedHistogramFlag);
+ histogram_time_get_ = base::Histogram::FactoryTimeGet(
+ "Cookie.TimeGet",
+ base::TimeDelta::FromMilliseconds(1),
+ base::TimeDelta::FromMinutes(1),
+ 50,
+ base::Histogram::kUmaTargetedHistogramFlag);
histogram_time_blocked_on_load_ = base::Histogram::FactoryTimeGet(
"Cookie.TimeBlockedOnLoad",
- base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMinutes(1),
- 50, base::Histogram::kUmaTargetedHistogramFlag);
+ base::TimeDelta::FromMilliseconds(1),
+ base::TimeDelta::FromMinutes(1),
+ 50,
+ base::Histogram::kUmaTargetedHistogramFlag);
}
-
// The system resolution is not high enough, so we can have multiple
// set cookies that result in the same system time. When this happens, we
// increment by one Time unit. Let's hope computers don't get too fast.
Time CookieMonster::CurrentTime() {
- return std::max(Time::Now(),
+ return std::max(
+ Time::Now(),
Time::FromInternalValue(last_time_seen_.ToInternalValue() + 1));
}

Powered by Google App Engine
This is Rietveld 408576698