| 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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 // Create a cookie store with no persistent store backing. Then, populate | 320 // Create a cookie store with no persistent store backing. Then, populate |
| 321 // it from the system's cookie jar. | 321 // it from the system's cookie jar. |
| 322 std::unique_ptr<CookieStoreIOS> cookie_store( | 322 std::unique_ptr<CookieStoreIOS> cookie_store( |
| 323 new CookieStoreIOS(nullptr, cookie_storage)); | 323 new CookieStoreIOS(nullptr, cookie_storage)); |
| 324 cookie_store->synchronization_state_ = SYNCHRONIZED; | 324 cookie_store->synchronization_state_ = SYNCHRONIZED; |
| 325 cookie_store->FlushStore(base::Closure()); | 325 cookie_store->FlushStore(base::Closure()); |
| 326 return cookie_store; | 326 return cookie_store; |
| 327 } | 327 } |
| 328 | 328 |
| 329 // static | 329 // static |
| 330 void CookieStoreIOS::SwitchSynchronizedStore(CookieStoreIOS* old_store, | |
| 331 CookieStoreIOS* new_store) { | |
| 332 DCHECK(new_store); | |
| 333 DCHECK_NE(new_store, old_store); | |
| 334 if (old_store) | |
| 335 old_store->SetSynchronizedWithSystemStore(false); | |
| 336 new_store->SetSynchronizedWithSystemStore(true); | |
| 337 } | |
| 338 | |
| 339 // static | |
| 340 void CookieStoreIOS::NotifySystemCookiesChanged() { | 330 void CookieStoreIOS::NotifySystemCookiesChanged() { |
| 341 NotificationTrampoline::GetInstance()->NotifyCookiesChanged(); | 331 NotificationTrampoline::GetInstance()->NotifyCookiesChanged(); |
| 342 } | 332 } |
| 343 | 333 |
| 344 void CookieStoreIOS::UnSynchronize() { | |
| 345 SetSynchronizedWithSystemStore(false); | |
| 346 } | |
| 347 | |
| 348 void CookieStoreIOS::SetMetricsEnabled() { | 334 void CookieStoreIOS::SetMetricsEnabled() { |
| 349 static CookieStoreIOS* g_cookie_store_with_metrics = nullptr; | 335 static CookieStoreIOS* g_cookie_store_with_metrics = nullptr; |
| 350 DCHECK(!g_cookie_store_with_metrics || g_cookie_store_with_metrics == this) | 336 DCHECK(!g_cookie_store_with_metrics || g_cookie_store_with_metrics == this) |
| 351 << "Only one cookie store may use metrics."; | 337 << "Only one cookie store may use metrics."; |
| 352 g_cookie_store_with_metrics = this; | 338 g_cookie_store_with_metrics = this; |
| 353 metrics_enabled_ = true; | 339 metrics_enabled_ = true; |
| 354 } | 340 } |
| 355 | 341 |
| 356 #pragma mark - | 342 #pragma mark - |
| 357 #pragma mark CookieStore methods | 343 #pragma mark CookieStore methods |
| (...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1102 weak_factory_.GetWeakPtr(), callback); | 1088 weak_factory_.GetWeakPtr(), callback); |
| 1103 } | 1089 } |
| 1104 | 1090 |
| 1105 base::Closure CookieStoreIOS::WrapClosure(const base::Closure& callback) { | 1091 base::Closure CookieStoreIOS::WrapClosure(const base::Closure& callback) { |
| 1106 DCHECK(thread_checker_.CalledOnValidThread()); | 1092 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1107 return base::Bind(&CookieStoreIOS::UpdateCachesAfterClosure, | 1093 return base::Bind(&CookieStoreIOS::UpdateCachesAfterClosure, |
| 1108 weak_factory_.GetWeakPtr(), callback); | 1094 weak_factory_.GetWeakPtr(), callback); |
| 1109 } | 1095 } |
| 1110 | 1096 |
| 1111 } // namespace net | 1097 } // namespace net |
| OLD | NEW |