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

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

Issue 2601103002: Made CookieStoreIOS(PersistentCookieStore, NSHTTPCookieStorage) private. (Closed)
Patch Set: Created 3 years, 11 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') | no next file » | 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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 280
281 #pragma mark - 281 #pragma mark -
282 #pragma mark CookieStoreIOS 282 #pragma mark CookieStoreIOS
283 283
284 CookieStoreIOS::CookieStoreIOS( 284 CookieStoreIOS::CookieStoreIOS(
285 net::CookieMonster::PersistentCookieStore* persistent_store) 285 net::CookieMonster::PersistentCookieStore* persistent_store)
286 : CookieStoreIOS(persistent_store, 286 : CookieStoreIOS(persistent_store,
287 [NSHTTPCookieStorage sharedHTTPCookieStorage]) { 287 [NSHTTPCookieStorage sharedHTTPCookieStorage]) {
288 } 288 }
289 289
290 CookieStoreIOS::CookieStoreIOS(
291 net::CookieMonster::PersistentCookieStore* persistent_store,
292 NSHTTPCookieStorage* system_store)
293 : cookie_monster_(new net::CookieMonster(persistent_store, nullptr)),
294 system_store_(system_store),
295 creation_time_manager_(new CookieCreationTimeManager),
296 metrics_enabled_(false),
297 flush_delay_(base::TimeDelta::FromSeconds(10)),
298 synchronization_state_(NOT_SYNCHRONIZED),
299 cookie_cache_(new CookieCache()),
300 weak_factory_(this) {
301 DCHECK(system_store);
302
303 NotificationTrampoline::GetInstance()->AddObserver(this);
304
305 cookie_monster_->SetPersistSessionCookies(true);
306 cookie_monster_->SetForceKeepSessionState();
307 }
308
309 CookieStoreIOS::~CookieStoreIOS() { 290 CookieStoreIOS::~CookieStoreIOS() {
310 NotificationTrampoline::GetInstance()->RemoveObserver(this); 291 NotificationTrampoline::GetInstance()->RemoveObserver(this);
311 } 292 }
312 293
313 // static 294 // static
314 std::unique_ptr<CookieStoreIOS> CookieStoreIOS::CreateCookieStore( 295 std::unique_ptr<CookieStoreIOS> CookieStoreIOS::CreateCookieStore(
315 NSHTTPCookieStorage* cookie_storage) { 296 NSHTTPCookieStorage* cookie_storage) {
316 DCHECK(cookie_storage); 297 DCHECK(cookie_storage);
317 // TODO(huey): Update this when CrNet supports multiple cookie jars. 298 // TODO(huey): Update this when CrNet supports multiple cookie jars.
318 [cookie_storage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways]; 299 [cookie_storage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways];
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 // stashed on disk. Do not delete the cookies on the disk in this case. 698 // stashed on disk. Do not delete the cookies on the disk in this case.
718 WriteToCookieMonster([system_store_ cookies]); 699 WriteToCookieMonster([system_store_ cookies]);
719 } 700 }
720 cookie_monster_->FlushStore(closure); 701 cookie_monster_->FlushStore(closure);
721 flush_closure_.Cancel(); 702 flush_closure_.Cancel();
722 } 703 }
723 704
724 #pragma mark - 705 #pragma mark -
725 #pragma mark Private methods 706 #pragma mark Private methods
726 707
708 CookieStoreIOS::CookieStoreIOS(
709 net::CookieMonster::PersistentCookieStore* persistent_store,
710 NSHTTPCookieStorage* system_store)
711 : cookie_monster_(new net::CookieMonster(persistent_store, nullptr)),
712 system_store_(system_store),
713 creation_time_manager_(new CookieCreationTimeManager),
714 metrics_enabled_(false),
715 flush_delay_(base::TimeDelta::FromSeconds(10)),
716 synchronization_state_(NOT_SYNCHRONIZED),
717 cookie_cache_(new CookieCache()),
718 weak_factory_(this) {
719 DCHECK(system_store);
720
721 NotificationTrampoline::GetInstance()->AddObserver(this);
722
723 cookie_monster_->SetPersistSessionCookies(true);
724 cookie_monster_->SetForceKeepSessionState();
725 }
726
727 void CookieStoreIOS::ClearSystemStore() { 727 void CookieStoreIOS::ClearSystemStore() {
728 DCHECK(thread_checker_.CalledOnValidThread()); 728 DCHECK(thread_checker_.CalledOnValidThread());
729 base::scoped_nsobject<NSArray> copy( 729 base::scoped_nsobject<NSArray> copy(
730 [[NSArray alloc] initWithArray:[system_store_ cookies]]); 730 [[NSArray alloc] initWithArray:[system_store_ cookies]]);
731 for (NSHTTPCookie* cookie in copy.get()) 731 for (NSHTTPCookie* cookie in copy.get())
732 [system_store_ deleteCookie:cookie]; 732 [system_store_ deleteCookie:cookie];
733 DCHECK_EQ(0u, [[system_store_ cookies] count]); 733 DCHECK_EQ(0u, [[system_store_ cookies] count]);
734 creation_time_manager_->Clear(); 734 creation_time_manager_->Clear();
735 } 735 }
736 736
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 weak_factory_.GetWeakPtr(), callback); 1088 weak_factory_.GetWeakPtr(), callback);
1089 } 1089 }
1090 1090
1091 base::Closure CookieStoreIOS::WrapClosure(const base::Closure& callback) { 1091 base::Closure CookieStoreIOS::WrapClosure(const base::Closure& callback) {
1092 DCHECK(thread_checker_.CalledOnValidThread()); 1092 DCHECK(thread_checker_.CalledOnValidThread());
1093 return base::Bind(&CookieStoreIOS::UpdateCachesAfterClosure, 1093 return base::Bind(&CookieStoreIOS::UpdateCachesAfterClosure,
1094 weak_factory_.GetWeakPtr(), callback); 1094 weak_factory_.GetWeakPtr(), callback);
1095 } 1095 }
1096 1096
1097 } // namespace net 1097 } // namespace net
OLDNEW
« no previous file with comments | « ios/net/cookies/cookie_store_ios.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698