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

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

Issue 2256193002: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 web::WebThread::GetBlockingPool()->GetSequencedTaskRunner( 42 web::WebThread::GetBlockingPool()->GetSequencedTaskRunner(
43 web::WebThread::GetBlockingPool()->GetSequenceToken()), 43 web::WebThread::GetBlockingPool()->GetSequenceToken()),
44 restore_old_session_cookies, crypto_delegate)); 44 restore_old_session_cookies, crypto_delegate));
45 } 45 }
46 46
47 // Creates a CookieMonster configured by |config|. 47 // Creates a CookieMonster configured by |config|.
48 std::unique_ptr<net::CookieMonster> CreateCookieMonster( 48 std::unique_ptr<net::CookieMonster> CreateCookieMonster(
49 const CookieStoreConfig& config) { 49 const CookieStoreConfig& config) {
50 if (config.path.empty()) { 50 if (config.path.empty()) {
51 // Empty path means in-memory store. 51 // Empty path means in-memory store.
52 return base::WrapUnique(new net::CookieMonster(nullptr, nullptr)); 52 return base::MakeUnique<net::CookieMonster>(nullptr, nullptr);
53 } 53 }
54 54
55 const bool restore_old_session_cookies = 55 const bool restore_old_session_cookies =
56 config.session_cookie_mode == CookieStoreConfig::RESTORED_SESSION_COOKIES; 56 config.session_cookie_mode == CookieStoreConfig::RESTORED_SESSION_COOKIES;
57 scoped_refptr<net::SQLitePersistentCookieStore> persistent_store = 57 scoped_refptr<net::SQLitePersistentCookieStore> persistent_store =
58 CreatePersistentCookieStore(config.path, restore_old_session_cookies, 58 CreatePersistentCookieStore(config.path, restore_old_session_cookies,
59 config.crypto_delegate); 59 config.crypto_delegate);
60 std::unique_ptr<net::CookieMonster> cookie_monster( 60 std::unique_ptr<net::CookieMonster> cookie_monster(
61 new net::CookieMonster(persistent_store.get(), nullptr)); 61 new net::CookieMonster(persistent_store.get(), nullptr));
62 if (restore_old_session_cookies) 62 if (restore_old_session_cookies)
(...skipping 22 matching lines...) Expand all
85 return CreateCookieMonster(config); 85 return CreateCookieMonster(config);
86 86
87 scoped_refptr<net::SQLitePersistentCookieStore> persistent_store = nullptr; 87 scoped_refptr<net::SQLitePersistentCookieStore> persistent_store = nullptr;
88 if (config.session_cookie_mode == 88 if (config.session_cookie_mode ==
89 CookieStoreConfig::RESTORED_SESSION_COOKIES) { 89 CookieStoreConfig::RESTORED_SESSION_COOKIES) {
90 DCHECK(!config.path.empty()); 90 DCHECK(!config.path.empty());
91 persistent_store = CreatePersistentCookieStore( 91 persistent_store = CreatePersistentCookieStore(
92 config.path, true /* restore_old_session_cookies */, 92 config.path, true /* restore_old_session_cookies */,
93 config.crypto_delegate); 93 config.crypto_delegate);
94 } 94 }
95 return base::WrapUnique(new net::CookieStoreIOS(persistent_store.get())); 95 return base::MakeUnique<net::CookieStoreIOS>(persistent_store.get());
96 } 96 }
97 97
98 bool ShouldClearSessionCookies() { 98 bool ShouldClearSessionCookies() {
99 NSUserDefaults* standardDefaults = [NSUserDefaults standardUserDefaults]; 99 NSUserDefaults* standardDefaults = [NSUserDefaults standardUserDefaults];
100 struct timeval boottime; 100 struct timeval boottime;
101 int mib[2] = {CTL_KERN, KERN_BOOTTIME}; 101 int mib[2] = {CTL_KERN, KERN_BOOTTIME};
102 size_t size = sizeof(boottime); 102 size_t size = sizeof(boottime);
103 time_t lastCookieDeletionDate = 103 time_t lastCookieDeletionDate =
104 [standardDefaults integerForKey:kLastCookieDeletionDate]; 104 [standardDefaults integerForKey:kLastCookieDeletionDate];
105 time_t now; 105 time_t now;
(...skipping 14 matching lines...) Expand all
120 browser_state->GetRequestContext(); 120 browser_state->GetRequestContext();
121 web::WebThread::PostTask( 121 web::WebThread::PostTask(
122 web::WebThread::IO, FROM_HERE, base::BindBlock(^{ 122 web::WebThread::IO, FROM_HERE, base::BindBlock(^{
123 getter->GetURLRequestContext() 123 getter->GetURLRequestContext()
124 ->cookie_store() 124 ->cookie_store()
125 ->DeleteSessionCookiesAsync(base::Bind(&DoNothing)); 125 ->DeleteSessionCookiesAsync(base::Bind(&DoNothing));
126 })); 126 }));
127 } 127 }
128 128
129 } // namespace cookie_util 129 } // namespace cookie_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698