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

Side by Side Diff: ios/net/cookies/cookie_store_ios.mm

Issue 1861593005: Convert //ios from scoped_ptr to std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase? Created 4 years, 8 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
« no previous file with comments | « ios/net/cookies/cookie_store_ios.h ('k') | ios/net/cookies/cookie_store_ios_unittest.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/net/cookies/cookie_store_ios.h" 5 #include "ios/net/cookies/cookie_store_ios.h"
6 6
7 #import <Foundation/Foundation.h> 7 #import <Foundation/Foundation.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 : NSHTTPCookieAcceptPolicyNever; 320 : NSHTTPCookieAcceptPolicyNever;
321 NSHTTPCookieStorage* store = [NSHTTPCookieStorage sharedHTTPCookieStorage]; 321 NSHTTPCookieStorage* store = [NSHTTPCookieStorage sharedHTTPCookieStorage];
322 NSHTTPCookieAcceptPolicy current_policy = [store cookieAcceptPolicy]; 322 NSHTTPCookieAcceptPolicy current_policy = [store cookieAcceptPolicy];
323 if (current_policy == policy) 323 if (current_policy == policy)
324 return; 324 return;
325 [store setCookieAcceptPolicy:policy]; 325 [store setCookieAcceptPolicy:policy];
326 NotificationTrampoline::GetInstance()->NotifyCookiePolicyChanged(); 326 NotificationTrampoline::GetInstance()->NotifyCookiePolicyChanged();
327 } 327 }
328 328
329 // static 329 // static
330 scoped_ptr<CookieStoreIOS> CookieStoreIOS::CreateCookieStore( 330 std::unique_ptr<CookieStoreIOS> CookieStoreIOS::CreateCookieStore(
331 NSHTTPCookieStorage* cookie_storage) { 331 NSHTTPCookieStorage* cookie_storage) {
332 DCHECK(cookie_storage); 332 DCHECK(cookie_storage);
333 // TODO(huey): Update this when CrNet supports multiple cookie jars. 333 // TODO(huey): Update this when CrNet supports multiple cookie jars.
334 [cookie_storage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways]; 334 [cookie_storage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways];
335 335
336 // Create a cookie store with no persistent store backing. Then, populate 336 // Create a cookie store with no persistent store backing. Then, populate
337 // it from the system's cookie jar. 337 // it from the system's cookie jar.
338 scoped_ptr<CookieStoreIOS> cookie_store( 338 std::unique_ptr<CookieStoreIOS> cookie_store(
339 new CookieStoreIOS(nullptr, cookie_storage)); 339 new CookieStoreIOS(nullptr, cookie_storage));
340 cookie_store->synchronization_state_ = SYNCHRONIZED; 340 cookie_store->synchronization_state_ = SYNCHRONIZED;
341 cookie_store->FlushStore(base::Closure()); 341 cookie_store->FlushStore(base::Closure());
342 return cookie_store; 342 return cookie_store;
343 } 343 }
344 344
345 // static 345 // static
346 void CookieStoreIOS::SwitchSynchronizedStore(CookieStoreIOS* old_store, 346 void CookieStoreIOS::SwitchSynchronizedStore(CookieStoreIOS* old_store,
347 CookieStoreIOS* new_store) { 347 CookieStoreIOS* new_store) {
348 DCHECK(new_store); 348 DCHECK(new_store);
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 // should be written there instead. 475 // should be written there instead.
476 DCHECK(SystemCookiesAllowed()); 476 DCHECK(SystemCookiesAllowed());
477 477
478 bool success = false; 478 bool success = false;
479 479
480 if (creation_time.is_null()) 480 if (creation_time.is_null())
481 creation_time = base::Time::Now(); 481 creation_time = base::Time::Now();
482 482
483 // First create a CanonicalCookie, to normalize the arguments, 483 // First create a CanonicalCookie, to normalize the arguments,
484 // particularly domain and path, and perform validation. 484 // particularly domain and path, and perform validation.
485 scoped_ptr<net::CanonicalCookie> canonical_cookie = 485 std::unique_ptr<net::CanonicalCookie> canonical_cookie =
486 net::CanonicalCookie::Create( 486 net::CanonicalCookie::Create(
487 url, name, value, domain, path, creation_time, expiration_time, 487 url, name, value, domain, path, creation_time, expiration_time,
488 secure, http_only, same_site, enforce_strict_secure, 488 secure, http_only, same_site, enforce_strict_secure, priority);
489 priority);
490 489
491 if (canonical_cookie) { 490 if (canonical_cookie) {
492 NSHTTPCookie* cookie = 491 NSHTTPCookie* cookie =
493 SystemCookieFromCanonicalCookie(*canonical_cookie); 492 SystemCookieFromCanonicalCookie(*canonical_cookie);
494 493
495 if (cookie != nil) { 494 if (cookie != nil) {
496 [system_store_ setCookie:cookie]; 495 [system_store_ setCookie:cookie];
497 creation_time_manager_->SetCreationTime( 496 creation_time_manager_->SetCreationTime(
498 cookie, creation_time_manager_->MakeUniqueCreationTime( 497 cookie, creation_time_manager_->MakeUniqueCreationTime(
499 canonical_cookie->CreationDate())); 498 canonical_cookie->CreationDate()));
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 // Do not schedule a flush if one is already scheduled. 973 // Do not schedule a flush if one is already scheduled.
975 if (!flush_closure_.IsCancelled()) 974 if (!flush_closure_.IsCancelled())
976 return; 975 return;
977 976
978 flush_closure_.Reset(base::Bind(&CookieStoreIOS::FlushStore, 977 flush_closure_.Reset(base::Bind(&CookieStoreIOS::FlushStore,
979 weak_factory_.GetWeakPtr(), base::Closure())); 978 weak_factory_.GetWeakPtr(), base::Closure()));
980 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 979 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
981 FROM_HERE, flush_closure_.callback(), flush_delay_); 980 FROM_HERE, flush_closure_.callback(), flush_delay_);
982 } 981 }
983 982
984 scoped_ptr<net::CookieStore::CookieChangedSubscription> 983 std::unique_ptr<net::CookieStore::CookieChangedSubscription>
985 CookieStoreIOS::AddCallbackForCookie(const GURL& gurl, 984 CookieStoreIOS::AddCallbackForCookie(const GURL& gurl,
986 const std::string& name, 985 const std::string& name,
987 const CookieChangedCallback& callback) { 986 const CookieChangedCallback& callback) {
988 DCHECK(thread_checker_.CalledOnValidThread()); 987 DCHECK(thread_checker_.CalledOnValidThread());
989 988
990 // Prefill cookie cache with all pertinent cookies for |url| if needed. 989 // Prefill cookie cache with all pertinent cookies for |url| if needed.
991 std::pair<GURL, std::string> key(gurl, name); 990 std::pair<GURL, std::string> key(gurl, name);
992 if (hook_map_.count(key) == 0) { 991 if (hook_map_.count(key) == 0) {
993 UpdateCacheForCookieFromSystem(gurl, name, nullptr, nullptr); 992 UpdateCacheForCookieFromSystem(gurl, name, nullptr, nullptr);
994 if (hook_map_.count(key) == 0) 993 if (hook_map_.count(key) == 0)
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1153 weak_factory_.GetWeakPtr(), callback); 1152 weak_factory_.GetWeakPtr(), callback);
1154 } 1153 }
1155 1154
1156 base::Closure CookieStoreIOS::WrapClosure(const base::Closure& callback) { 1155 base::Closure CookieStoreIOS::WrapClosure(const base::Closure& callback) {
1157 DCHECK(thread_checker_.CalledOnValidThread()); 1156 DCHECK(thread_checker_.CalledOnValidThread());
1158 return base::Bind(&CookieStoreIOS::UpdateCachesAfterClosure, 1157 return base::Bind(&CookieStoreIOS::UpdateCachesAfterClosure,
1159 weak_factory_.GetWeakPtr(), callback); 1158 weak_factory_.GetWeakPtr(), callback);
1160 } 1159 }
1161 1160
1162 } // namespace net 1161 } // namespace net
OLDNEW
« no previous file with comments | « ios/net/cookies/cookie_store_ios.h ('k') | ios/net/cookies/cookie_store_ios_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698