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

Side by Side Diff: ios/chrome/browser/net/cookie_util.mm

Issue 1701063002: CookieStore: Remove reference counting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@threadsafe
Patch Set: merge Created 4 years, 9 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "ios/chrome/browser/net/cookie_util.h" 5 #include "ios/chrome/browser/net/cookie_util.h"
6 6
7 #import <Foundation/Foundation.h> 7 #import <Foundation/Foundation.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <sys/sysctl.h> 9 #include <sys/sysctl.h>
10 10
(...skipping 26 matching lines...) Expand all
37 net::CookieCryptoDelegate* crypto_delegate) { 37 net::CookieCryptoDelegate* crypto_delegate) {
38 return scoped_refptr<net::SQLitePersistentCookieStore>( 38 return scoped_refptr<net::SQLitePersistentCookieStore>(
39 new net::SQLitePersistentCookieStore( 39 new net::SQLitePersistentCookieStore(
40 path, web::WebThread::GetTaskRunnerForThread(web::WebThread::IO), 40 path, web::WebThread::GetTaskRunnerForThread(web::WebThread::IO),
41 web::WebThread::GetBlockingPool()->GetSequencedTaskRunner( 41 web::WebThread::GetBlockingPool()->GetSequencedTaskRunner(
42 web::WebThread::GetBlockingPool()->GetSequenceToken()), 42 web::WebThread::GetBlockingPool()->GetSequenceToken()),
43 restore_old_session_cookies, crypto_delegate)); 43 restore_old_session_cookies, crypto_delegate));
44 } 44 }
45 45
46 // Creates a CookieMonster configured by |config|. 46 // Creates a CookieMonster configured by |config|.
47 net::CookieMonster* CreateCookieMonster(const CookieStoreConfig& config) { 47 scoped_ptr<net::CookieMonster> CreateCookieMonster(
48 const CookieStoreConfig& config) {
48 if (config.path.empty()) { 49 if (config.path.empty()) {
49 // Empty path means in-memory store. 50 // Empty path means in-memory store.
50 return new net::CookieMonster(nullptr, nullptr); 51 return make_scoped_ptr(new net::CookieMonster(nullptr, nullptr));
51 } 52 }
52 53
53 const bool restore_old_session_cookies = 54 const bool restore_old_session_cookies =
54 config.session_cookie_mode == CookieStoreConfig::RESTORED_SESSION_COOKIES; 55 config.session_cookie_mode == CookieStoreConfig::RESTORED_SESSION_COOKIES;
55 scoped_refptr<net::SQLitePersistentCookieStore> persistent_store = 56 scoped_refptr<net::SQLitePersistentCookieStore> persistent_store =
56 CreatePersistentCookieStore(config.path, restore_old_session_cookies, 57 CreatePersistentCookieStore(config.path, restore_old_session_cookies,
57 config.crypto_delegate); 58 config.crypto_delegate);
58 net::CookieMonster* cookie_monster = 59 scoped_ptr<net::CookieMonster> cookie_monster(
59 new net::CookieMonster(persistent_store.get(), nullptr); 60 new net::CookieMonster(persistent_store.get(), nullptr));
60 if (restore_old_session_cookies) 61 if (restore_old_session_cookies)
61 cookie_monster->SetPersistSessionCookies(true); 62 cookie_monster->SetPersistSessionCookies(true);
62 return cookie_monster; 63 return cookie_monster;
63 } 64 }
64 65
65 } // namespace 66 } // namespace
66 67
67 CookieStoreConfig::CookieStoreConfig(const base::FilePath& path, 68 CookieStoreConfig::CookieStoreConfig(const base::FilePath& path,
68 SessionCookieMode session_cookie_mode, 69 SessionCookieMode session_cookie_mode,
69 CookieStoreType cookie_store_type, 70 CookieStoreType cookie_store_type,
70 net::CookieCryptoDelegate* crypto_delegate) 71 net::CookieCryptoDelegate* crypto_delegate)
71 : path(path), 72 : path(path),
72 session_cookie_mode(session_cookie_mode), 73 session_cookie_mode(session_cookie_mode),
73 cookie_store_type(cookie_store_type), 74 cookie_store_type(cookie_store_type),
74 crypto_delegate(crypto_delegate) { 75 crypto_delegate(crypto_delegate) {
75 CHECK(!path.empty() || session_cookie_mode == EPHEMERAL_SESSION_COOKIES); 76 CHECK(!path.empty() || session_cookie_mode == EPHEMERAL_SESSION_COOKIES);
76 } 77 }
77 78
78 CookieStoreConfig::~CookieStoreConfig() {} 79 CookieStoreConfig::~CookieStoreConfig() {}
79 80
80 net::CookieStore* CreateCookieStore(const CookieStoreConfig& config) { 81 scoped_ptr<net::CookieStore> CreateCookieStore(
82 const CookieStoreConfig& config) {
81 if (config.cookie_store_type == CookieStoreConfig::COOKIE_MONSTER) 83 if (config.cookie_store_type == CookieStoreConfig::COOKIE_MONSTER)
82 return CreateCookieMonster(config); 84 return CreateCookieMonster(config);
83 85
84 scoped_refptr<net::SQLitePersistentCookieStore> persistent_store = nullptr; 86 scoped_refptr<net::SQLitePersistentCookieStore> persistent_store = nullptr;
85 if (config.session_cookie_mode == 87 if (config.session_cookie_mode ==
86 CookieStoreConfig::RESTORED_SESSION_COOKIES) { 88 CookieStoreConfig::RESTORED_SESSION_COOKIES) {
87 DCHECK(!config.path.empty()); 89 DCHECK(!config.path.empty());
88 persistent_store = CreatePersistentCookieStore( 90 persistent_store = CreatePersistentCookieStore(
89 config.path, true /* restore_old_session_cookies */, 91 config.path, true /* restore_old_session_cookies */,
90 config.crypto_delegate); 92 config.crypto_delegate);
91 } 93 }
92 return new net::CookieStoreIOS(persistent_store.get()); 94 return make_scoped_ptr(new net::CookieStoreIOS(persistent_store.get()));
93 } 95 }
94 96
95 bool ShouldClearSessionCookies() { 97 bool ShouldClearSessionCookies() {
96 NSUserDefaults* standardDefaults = [NSUserDefaults standardUserDefaults]; 98 NSUserDefaults* standardDefaults = [NSUserDefaults standardUserDefaults];
97 struct timeval boottime; 99 struct timeval boottime;
98 int mib[2] = {CTL_KERN, KERN_BOOTTIME}; 100 int mib[2] = {CTL_KERN, KERN_BOOTTIME};
99 size_t size = sizeof(boottime); 101 size_t size = sizeof(boottime);
100 time_t lastCookieDeletionDate = 102 time_t lastCookieDeletionDate =
101 [standardDefaults integerForKey:kLastCookieDeletionDate]; 103 [standardDefaults integerForKey:kLastCookieDeletionDate];
102 time_t now; 104 time_t now;
(...skipping 14 matching lines...) Expand all
117 browser_state->GetRequestContext(); 119 browser_state->GetRequestContext();
118 web::WebThread::PostTask( 120 web::WebThread::PostTask(
119 web::WebThread::IO, FROM_HERE, base::BindBlock(^{ 121 web::WebThread::IO, FROM_HERE, base::BindBlock(^{
120 getter->GetURLRequestContext() 122 getter->GetURLRequestContext()
121 ->cookie_store() 123 ->cookie_store()
122 ->DeleteSessionCookiesAsync(base::Bind(&DoNothing)); 124 ->DeleteSessionCookiesAsync(base::Bind(&DoNothing));
123 })); 125 }));
124 } 126 }
125 127
126 } // namespace cookie_util 128 } // namespace cookie_util
OLDNEW
« no previous file with comments | « ios/chrome/browser/net/cookie_util.h ('k') | ios/chrome/browser/safe_browsing/safe_browsing_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698