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

Side by Side Diff: chrome/browser/sessions/session_data_deleter.cc

Issue 2971733002: Change CookieStore::DeleteCallback to take uint32_t. (Closed)
Patch Set: Got rid of rest of <cstdint> stuff. Created 3 years, 5 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h>
6 7
7 #include "base/bind.h" 8 #include "base/bind.h"
8 #include "base/command_line.h" 9 #include "base/command_line.h"
9 #include "base/macros.h" 10 #include "base/macros.h"
10 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
11 #include "build/build_config.h" 12 #include "build/build_config.h"
12 #include "chrome/browser/browser_shutdown.h" 13 #include "chrome/browser/browser_shutdown.h"
13 #include "chrome/browser/prefs/session_startup_pref.h" 14 #include "chrome/browser/prefs/session_startup_pref.h"
14 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/startup/startup_browser_creator.h" 16 #include "chrome/browser/ui/startup/startup_browser_creator.h"
16 #include "content/public/browser/browser_context.h" 17 #include "content/public/browser/browser_context.h"
17 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
18 #include "content/public/browser/dom_storage_context.h" 19 #include "content/public/browser/dom_storage_context.h"
19 #include "content/public/browser/local_storage_usage_info.h" 20 #include "content/public/browser/local_storage_usage_info.h"
20 #include "content/public/browser/storage_partition.h" 21 #include "content/public/browser/storage_partition.h"
21 #include "net/cookies/cookie_store.h" 22 #include "net/cookies/cookie_store.h"
22 #include "net/cookies/cookie_util.h" 23 #include "net/cookies/cookie_util.h"
23 #include "net/url_request/url_request_context.h" 24 #include "net/url_request/url_request_context.h"
24 #include "net/url_request/url_request_context_getter.h" 25 #include "net/url_request/url_request_context_getter.h"
25 #include "storage/browser/quota/special_storage_policy.h" 26 #include "storage/browser/quota/special_storage_policy.h"
26 27
27 namespace { 28 namespace {
28 29
29 void CookieDeleted(int num_cookies_deleted) { 30 void CookieDeleted(uint32_t num_cookies_deleted) {
30 DCHECK_EQ(1, num_cookies_deleted); 31 DCHECK_EQ(1u, num_cookies_deleted);
31 } 32 }
32 33
33 class SessionDataDeleter 34 class SessionDataDeleter
34 : public base::RefCountedThreadSafe<SessionDataDeleter> { 35 : public base::RefCountedThreadSafe<SessionDataDeleter> {
35 public: 36 public:
36 SessionDataDeleter(storage::SpecialStoragePolicy* storage_policy, 37 SessionDataDeleter(storage::SpecialStoragePolicy* storage_policy,
37 bool delete_only_by_session_only_policy); 38 bool delete_only_by_session_only_policy);
38 39
39 void Run( 40 void Run(
40 content::StoragePartition* storage_partition, 41 content::StoragePartition* storage_partition,
(...skipping 11 matching lines...) Expand all
52 53
53 // Deletes all cookies that are session only if 54 // Deletes all cookies that are session only if
54 // |delete_only_by_session_only_policy_| is false. Once completed or skipped, 55 // |delete_only_by_session_only_policy_| is false. Once completed or skipped,
55 // this arranges for DeleteSessionOnlyOriginCookies to be called with a list 56 // this arranges for DeleteSessionOnlyOriginCookies to be called with a list
56 // of all remaining cookies. 57 // of all remaining cookies.
57 void DeleteSessionCookiesOnIOThread( 58 void DeleteSessionCookiesOnIOThread(
58 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter); 59 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter);
59 60
60 // Called when all session-only cookies have been deleted. 61 // Called when all session-only cookies have been deleted.
61 void DeleteSessionCookiesDone(net::CookieStore* cookie_store, 62 void DeleteSessionCookiesDone(net::CookieStore* cookie_store,
62 int num_deleted); 63 uint32_t num_deleted);
63 64
64 // Deletes the cookies in |cookies| that are for origins which are 65 // Deletes the cookies in |cookies| that are for origins which are
65 // session-only. 66 // session-only.
66 void DeleteSessionOnlyOriginCookies(net::CookieStore* cookie_store, 67 void DeleteSessionOnlyOriginCookies(net::CookieStore* cookie_store,
67 const net::CookieList& cookies); 68 const net::CookieList& cookies);
68 69
69 scoped_refptr<storage::SpecialStoragePolicy> storage_policy_; 70 scoped_refptr<storage::SpecialStoragePolicy> storage_policy_;
70 const bool delete_only_by_session_only_policy_; 71 const bool delete_only_by_session_only_policy_;
71 72
72 DISALLOW_COPY_AND_ASSIGN(SessionDataDeleter); 73 DISALLOW_COPY_AND_ASSIGN(SessionDataDeleter);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 base::Unretained(cookie_store))); 128 base::Unretained(cookie_store)));
128 } else { 129 } else {
129 cookie_store->DeleteSessionCookiesAsync( 130 cookie_store->DeleteSessionCookiesAsync(
130 base::Bind(&SessionDataDeleter::DeleteSessionCookiesDone, this, 131 base::Bind(&SessionDataDeleter::DeleteSessionCookiesDone, this,
131 base::Unretained(cookie_store))); 132 base::Unretained(cookie_store)));
132 } 133 }
133 } 134 }
134 135
135 void SessionDataDeleter::DeleteSessionCookiesDone( 136 void SessionDataDeleter::DeleteSessionCookiesDone(
136 net::CookieStore* cookie_store, 137 net::CookieStore* cookie_store,
137 int num_deleted) { 138 uint32_t num_deleted) {
138 // If these callbacks are invoked, |cookie_store| is gauranteed to still 139 // If these callbacks are invoked, |cookie_store| is gauranteed to still
139 // exist, since deleting the CookieStore will cancel pending callbacks. 140 // exist, since deleting the CookieStore will cancel pending callbacks.
140 cookie_store->GetAllCookiesAsync( 141 cookie_store->GetAllCookiesAsync(
141 base::Bind(&SessionDataDeleter::DeleteSessionOnlyOriginCookies, this, 142 base::Bind(&SessionDataDeleter::DeleteSessionOnlyOriginCookies, this,
142 base::Unretained(cookie_store))); 143 base::Unretained(cookie_store)));
143 } 144 }
144 145
145 void SessionDataDeleter::DeleteSessionOnlyOriginCookies( 146 void SessionDataDeleter::DeleteSessionOnlyOriginCookies(
146 net::CookieStore* cookie_store, 147 net::CookieStore* cookie_store,
147 const net::CookieList& cookies) { 148 const net::CookieList& cookies) {
(...skipping 26 matching lines...) Expand all
174 StartupBrowserCreator::GetSessionStartupPref( 175 StartupBrowserCreator::GetSessionStartupPref(
175 *base::CommandLine::ForCurrentProcess(), profile).type; 176 *base::CommandLine::ForCurrentProcess(), profile).type;
176 #endif 177 #endif
177 178
178 scoped_refptr<SessionDataDeleter> deleter( 179 scoped_refptr<SessionDataDeleter> deleter(
179 new SessionDataDeleter(profile->GetSpecialStoragePolicy(), 180 new SessionDataDeleter(profile->GetSpecialStoragePolicy(),
180 startup_pref_type == SessionStartupPref::LAST)); 181 startup_pref_type == SessionStartupPref::LAST));
181 deleter->Run(Profile::GetDefaultStoragePartition(profile), 182 deleter->Run(Profile::GetDefaultStoragePartition(profile),
182 profile->GetRequestContext()); 183 profile->GetRequestContext());
183 } 184 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698