| OLD | NEW |
| 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 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 #pragma mark - | 698 #pragma mark - |
| 699 #pragma mark Private methods | 699 #pragma mark Private methods |
| 700 | 700 |
| 701 CookieStoreIOS::CookieStoreIOS( | 701 CookieStoreIOS::CookieStoreIOS( |
| 702 net::CookieMonster::PersistentCookieStore* persistent_store, | 702 net::CookieMonster::PersistentCookieStore* persistent_store, |
| 703 NSHTTPCookieStorage* system_store) | 703 NSHTTPCookieStorage* system_store) |
| 704 : cookie_monster_(new net::CookieMonster(persistent_store, nullptr)), | 704 : cookie_monster_(new net::CookieMonster(persistent_store, nullptr)), |
| 705 system_store_(system_store), | 705 system_store_(system_store), |
| 706 creation_time_manager_(new CookieCreationTimeManager), | 706 creation_time_manager_(new CookieCreationTimeManager), |
| 707 metrics_enabled_(false), | 707 metrics_enabled_(false), |
| 708 flush_delay_(base::TimeDelta::FromSeconds(10)), | |
| 709 synchronization_state_(NOT_SYNCHRONIZED), | 708 synchronization_state_(NOT_SYNCHRONIZED), |
| 710 cookie_cache_(new CookieCache()), | 709 cookie_cache_(new CookieCache()), |
| 711 weak_factory_(this) { | 710 weak_factory_(this) { |
| 712 DCHECK(system_store); | 711 DCHECK(system_store); |
| 713 | 712 |
| 714 NotificationTrampoline::GetInstance()->AddObserver(this); | 713 NotificationTrampoline::GetInstance()->AddObserver(this); |
| 715 | 714 |
| 716 cookie_monster_->SetPersistSessionCookies(true); | 715 cookie_monster_->SetPersistSessionCookies(true); |
| 717 cookie_monster_->SetForceKeepSessionState(); | 716 cookie_monster_->SetForceKeepSessionState(); |
| 718 } | 717 } |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 } | 801 } |
| 803 } | 802 } |
| 804 | 803 |
| 805 // Do not schedule a flush if one is already scheduled. | 804 // Do not schedule a flush if one is already scheduled. |
| 806 if (!flush_closure_.IsCancelled()) | 805 if (!flush_closure_.IsCancelled()) |
| 807 return; | 806 return; |
| 808 | 807 |
| 809 flush_closure_.Reset(base::Bind(&CookieStoreIOS::FlushStore, | 808 flush_closure_.Reset(base::Bind(&CookieStoreIOS::FlushStore, |
| 810 weak_factory_.GetWeakPtr(), base::Closure())); | 809 weak_factory_.GetWeakPtr(), base::Closure())); |
| 811 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 810 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 812 FROM_HERE, flush_closure_.callback(), flush_delay_); | 811 FROM_HERE, flush_closure_.callback(), base::TimeDelta::FromSeconds(10)); |
| 813 } | 812 } |
| 814 | 813 |
| 815 std::unique_ptr<net::CookieStore::CookieChangedSubscription> | 814 std::unique_ptr<net::CookieStore::CookieChangedSubscription> |
| 816 CookieStoreIOS::AddCallbackForCookie(const GURL& gurl, | 815 CookieStoreIOS::AddCallbackForCookie(const GURL& gurl, |
| 817 const std::string& name, | 816 const std::string& name, |
| 818 const CookieChangedCallback& callback) { | 817 const CookieChangedCallback& callback) { |
| 819 DCHECK(thread_checker_.CalledOnValidThread()); | 818 DCHECK(thread_checker_.CalledOnValidThread()); |
| 820 | 819 |
| 821 // Prefill cookie cache with all pertinent cookies for |url| if needed. | 820 // Prefill cookie cache with all pertinent cookies for |url| if needed. |
| 822 std::pair<GURL, std::string> key(gurl, name); | 821 std::pair<GURL, std::string> key(gurl, name); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 986 weak_factory_.GetWeakPtr(), callback); | 985 weak_factory_.GetWeakPtr(), callback); |
| 987 } | 986 } |
| 988 | 987 |
| 989 base::Closure CookieStoreIOS::WrapClosure(const base::Closure& callback) { | 988 base::Closure CookieStoreIOS::WrapClosure(const base::Closure& callback) { |
| 990 DCHECK(thread_checker_.CalledOnValidThread()); | 989 DCHECK(thread_checker_.CalledOnValidThread()); |
| 991 return base::Bind(&CookieStoreIOS::UpdateCachesAfterClosure, | 990 return base::Bind(&CookieStoreIOS::UpdateCachesAfterClosure, |
| 992 weak_factory_.GetWeakPtr(), callback); | 991 weak_factory_.GetWeakPtr(), callback); |
| 993 } | 992 } |
| 994 | 993 |
| 995 } // namespace net | 994 } // namespace net |
| OLD | NEW |