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

Side by Side 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, 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/browser/net/cookie_store_map.h"
6
7 #include "base/bind.h"
8 #include "base/bind_helpers.h"
9 #include "base/callback.h"
10 #include "base/logging.h"
11 #include "base/threading/thread_checker.h"
12 #include "net/cookies/cookie_monster.h"
13 #include "net/cookies/cookie_store.h"
14 #include "url/gurl.h"
15
16 namespace {
17
18 class CookieClearBarrier {
19 public:
20 CookieClearBarrier(int n, const base::Closure& done)
21 : left_(n),
22 all_done_(done) {
23 }
24
25 void OnCookieCleared(int num_deleted) {
26 DCHECK(thread_checker_.CalledOnValidThread());
27
28 // We don't care how many are deleted.
29 DCHECK_GT(left_, 0);
30
31 if (--left_ == 0) {
32 all_done_.Run();
33 all_done_.Reset();
34 }
35 }
36
37 static base::Callback<void(int)> NewBarrierClosure(
38 int n, const base::Closure& done) {
39 DCHECK_GT(n, 0);
40 CookieClearBarrier* barrier = new CookieClearBarrier(n, done);
41 return base::Bind(&CookieClearBarrier::OnCookieCleared,
42 base::Owned(barrier));
43 }
44
45 private:
46 int left_;
47 base::Closure all_done_;
48 base::ThreadChecker thread_checker_;
49 };
50
51 } // namespace
52
53 namespace content {
54
55 CookieStoreMap::CookieStoreMap() {
56 }
57
58 CookieStoreMap::~CookieStoreMap() {
59 }
60
61 net::CookieStore* CookieStoreMap::GetForScheme(
62 const std::string& scheme) const {
63 MapType::const_iterator it = scheme_map_.find(scheme);
64 if (it == scheme_map_.end())
65 return NULL;
66 return it->second;
67 }
68
69 void CookieStoreMap::SetForScheme(const std::string& scheme,
70 net::CookieStore* cookie_store) {
71 DCHECK(scheme_map_.find(scheme) == scheme_map_.end());
72 DCHECK(cookie_store);
73 scheme_map_[scheme] = cookie_store;
74 }
75
76 void CookieStoreMap::DeleteCookies(const GURL& origin,
77 const base::Time begin,
78 const base::Time end,
79 const base::Closure& done) {
80 if (origin.is_empty()) {
81 net::CookieStore::DeleteCallback on_delete =
82 CookieClearBarrier::NewBarrierClosure(scheme_map_.size(), done);
83 for (MapType::const_iterator it = scheme_map_.begin();
84 it != scheme_map_.end(); ++it) {
85 it->second->DeleteAllCreatedBetweenAsync(begin, end, on_delete);
86 }
87 } else {
88 net::CookieStore* cookie_store = GetForScheme(origin.scheme());
89 if (!cookie_store) {
90 done.Run();
91 return;
92 }
93 cookie_store->GetCookieMonster()->DeleteAllCreatedBetweenForHostAsync(
94 begin, end, origin, CookieClearBarrier::NewBarrierClosure(1, done));
95 }
96 }
97
98 CookieStoreMap* CookieStoreMap::Clone() const {
99 CookieStoreMap* cloned_map = new CookieStoreMap();
100 cloned_map->scheme_map_ = scheme_map_;
101 return cloned_map;
102 }
103
104 } // namespace content
OLDNEW
« 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