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

Unified Diff: net/base/cookie_monster.cc

Issue 7864008: Split initial load of cookies by domains (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 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
« net/base/cookie_monster.h ('K') | « net/base/cookie_monster.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/cookie_monster.cc
===================================================================
--- net/base/cookie_monster.cc (revision 100935)
+++ net/base/cookie_monster.cc (working copy)
@@ -993,7 +993,7 @@
expiration_time, secure, http_only,
callback);
- DoCookieTask(task);
+ DoCookieTask(task, url);
}
void CookieMonster::GetAllCookiesAsync(const GetCookieListCallback& callback) {
@@ -1011,7 +1011,7 @@
scoped_refptr<GetAllCookiesForURLWithOptionsTask> task =
new GetAllCookiesForURLWithOptionsTask(this, url, options, callback);
- DoCookieTask(task);
+ DoCookieTask(task, url);
}
void CookieMonster::GetAllCookiesForURLAsync(
@@ -1021,7 +1021,7 @@
scoped_refptr<GetAllCookiesForURLWithOptionsTask> task =
new GetAllCookiesForURLWithOptionsTask(this, url, options, callback);
- DoCookieTask(task);
+ DoCookieTask(task, url);
}
void CookieMonster::DeleteAllAsync(const DeleteCallback& callback) {
@@ -1046,7 +1046,7 @@
scoped_refptr<DeleteAllForHostTask> task =
new DeleteAllForHostTask(this, url, callback);
- DoCookieTask(task);
+ DoCookieTask(task, url);
}
void CookieMonster::DeleteCanonicalCookieAsync(
@@ -1066,7 +1066,7 @@
scoped_refptr<SetCookieWithOptionsTask> task =
new SetCookieWithOptionsTask(this, url, cookie_line, options, callback);
- DoCookieTask(task);
+ DoCookieTask(task, url);
}
void CookieMonster::GetCookiesWithOptionsAsync(
@@ -1076,7 +1076,7 @@
scoped_refptr<GetCookiesWithOptionsTask> task =
new GetCookiesWithOptionsTask(this, url, options, callback);
- DoCookieTask(task);
+ DoCookieTask(task, url);
}
void CookieMonster::GetCookiesWithInfoAsync(
@@ -1086,7 +1086,7 @@
scoped_refptr<GetCookiesWithInfoTask> task =
new GetCookiesWithInfoTask(this, url, options, callback);
- DoCookieTask(task);
+ DoCookieTask(task, url);
}
void CookieMonster::DeleteCookieAsync(const GURL& url,
@@ -1095,7 +1095,7 @@
scoped_refptr<DeleteCookieTask> task =
new DeleteCookieTask(this, url, cookie_name, callback);
- DoCookieTask(task);
+ DoCookieTask(task, url);
}
void CookieMonster::DoCookieTask(
@@ -1113,6 +1113,32 @@
task_item->Run();
}
+void CookieMonster::DoCookieTask(
+ const scoped_refptr<CookieMonsterTask>& task_item,
+ const GURL& url) {
+ InitIfNecessary();
+
+ {
+ base::AutoLock autolock(lock_);
+ // If cookies for the requested domain key (eTLD+1) have been loaded from DB
+ // then run the task, otherwise load from DB.
+ if (!loaded_) {
+ // Check if the domain key has been loaded.
+ std::string key(GetEffectiveDomain(url.scheme(), url.host()));
+ if (keys_loaded_.find(key) == keys_loaded_.end()) {
+ store_->LoadCookiesForKey(key,
+ base::Bind(&CookieMonster::OnKeyLoaded, this,
+ base::Bind(&CookieMonsterTask::Run, task_item.get()),
+ key));
+ return;
+ }
+ }
+ }
+
+
erikwright (departed) 2011/09/15 20:56:27 Remove extra blank.
guohui 2011/09/16 18:21:09 Done.
+ task_item->Run();
+}
+
bool CookieMonster::SetCookieWithDetails(
const GURL& url, const std::string& name, const std::string& value,
const std::string& domain, const std::string& path,
@@ -1470,6 +1496,14 @@
InvokeQueue();
}
+void CookieMonster::OnKeyLoaded(
+ const base::Closure& request_task, const std::string& key,
+ const std::vector<CanonicalCookie*>& cookies) {
erikwright (departed) 2011/09/15 20:56:27 It seems you require lock_ in order to access keys
guohui 2011/09/16 18:21:09 Done.
+ StoreLoadedCookies(cookies);
+ keys_loaded_.insert(key);
+ request_task.Run();
+}
+
void CookieMonster::StoreLoadedCookies(
const std::vector<CanonicalCookie*>& cookies) {
// Initialize the store and sync in any saved persistent cookies. We don't
« net/base/cookie_monster.h ('K') | « net/base/cookie_monster.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698