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

Unified Diff: content/browser/net/cookie_store_map.cc

Issue 12546016: Remove the Extensions URLRequestContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: android webview init fix merged in. Created 7 years, 4 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
« no previous file with comments | « content/browser/net/cookie_store_map.h ('k') | content/browser/net/sqlite_persistent_cookie_store.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/net/cookie_store_map.cc
diff --git a/content/browser/net/cookie_store_map.cc b/content/browser/net/cookie_store_map.cc
new file mode 100644
index 0000000000000000000000000000000000000000..141fbaf64edef168cfe539e9370aaa6f2c5331cc
--- /dev/null
+++ b/content/browser/net/cookie_store_map.cc
@@ -0,0 +1,104 @@
+// Copyright (c) 2013 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 "content/browser/net/cookie_store_map.h"
+
+#include "base/bind.h"
+#include "base/bind_helpers.h"
+#include "base/callback.h"
+#include "base/logging.h"
+#include "base/threading/thread_checker.h"
+#include "net/cookies/cookie_monster.h"
+#include "net/cookies/cookie_store.h"
+#include "url/gurl.h"
+
+namespace {
+
+class CookieClearBarrier {
+ public:
+ CookieClearBarrier(int n, const base::Closure& done)
+ : left_(n),
+ all_done_(done) {
+ }
+
+ void OnCookieCleared(int num_deleted) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+
+ // We don't care how many are deleted.
+ DCHECK_GT(left_, 0);
+
+ if (--left_ == 0) {
+ all_done_.Run();
+ all_done_.Reset();
+ }
+ }
+
+ static base::Callback<void(int)> NewBarrierClosure(
+ int n, const base::Closure& done) {
+ DCHECK_GT(n, 0);
+ CookieClearBarrier* barrier = new CookieClearBarrier(n, done);
+ return base::Bind(&CookieClearBarrier::OnCookieCleared,
+ base::Owned(barrier));
+ }
+
+ private:
+ int left_;
+ base::Closure all_done_;
+ base::ThreadChecker thread_checker_;
+};
+
+} // namespace
+
+namespace content {
+
+CookieStoreMap::CookieStoreMap() {
+}
+
+CookieStoreMap::~CookieStoreMap() {
+}
+
+net::CookieStore* CookieStoreMap::GetForScheme(
+ const std::string& scheme) const {
+ MapType::const_iterator it = scheme_map_.find(scheme);
+ if (it == scheme_map_.end())
+ return NULL;
+ return it->second;
+}
+
+void CookieStoreMap::SetForScheme(const std::string& scheme,
+ net::CookieStore* cookie_store) {
+ DCHECK(scheme_map_.find(scheme) == scheme_map_.end());
+ DCHECK(cookie_store);
+ scheme_map_[scheme] = cookie_store;
+}
+
+void CookieStoreMap::DeleteCookies(const GURL& origin,
+ const base::Time begin,
+ const base::Time end,
+ const base::Closure& done) {
+ if (origin.is_empty()) {
+ net::CookieStore::DeleteCallback on_delete =
+ CookieClearBarrier::NewBarrierClosure(scheme_map_.size(), done);
+ for (MapType::const_iterator it = scheme_map_.begin();
+ it != scheme_map_.end(); ++it) {
+ it->second->DeleteAllCreatedBetweenAsync(begin, end, on_delete);
+ }
+ } else {
+ net::CookieStore* cookie_store = GetForScheme(origin.scheme());
+ if (!cookie_store) {
+ done.Run();
+ return;
+ }
+ cookie_store->GetCookieMonster()->DeleteAllCreatedBetweenForHostAsync(
+ begin, end, origin, CookieClearBarrier::NewBarrierClosure(1, done));
+ }
+}
+
+CookieStoreMap* CookieStoreMap::Clone() const {
+ CookieStoreMap* cloned_map = new CookieStoreMap();
+ cloned_map->scheme_map_ = scheme_map_;
+ return cloned_map;
+}
+
+} // namespace content
« no previous file with comments | « content/browser/net/cookie_store_map.h ('k') | content/browser/net/sqlite_persistent_cookie_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698