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

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

Issue 2349823003: Pass a RemovalCause to CookieChangedCallback (Closed)
Patch Set: rebase Created 4 years, 2 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 949 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 system_store_ != [NSHTTPCookieStorage sharedHTTPCookieStorage]) { 960 system_store_ != [NSHTTPCookieStorage sharedHTTPCookieStorage]) {
961 return; 961 return;
962 } 962 }
963 963
964 for (const auto& hook_map_entry : hook_map_) { 964 for (const auto& hook_map_entry : hook_map_) {
965 std::pair<GURL, std::string> key = hook_map_entry.first; 965 std::pair<GURL, std::string> key = hook_map_entry.first;
966 std::vector<net::CanonicalCookie> removed_cookies; 966 std::vector<net::CanonicalCookie> removed_cookies;
967 std::vector<net::CanonicalCookie> added_cookies; 967 std::vector<net::CanonicalCookie> added_cookies;
968 if (UpdateCacheForCookieFromSystem(key.first, key.second, &removed_cookies, 968 if (UpdateCacheForCookieFromSystem(key.first, key.second, &removed_cookies,
969 &added_cookies)) { 969 &added_cookies)) {
970 RunCallbacksForCookies(key.first, key.second, removed_cookies, true); 970 RunCallbacksForCookies(key.first, key.second, removed_cookies,
971 RunCallbacksForCookies(key.first, key.second, added_cookies, false); 971 net::CookieStore::ChangeCause::UNKNOWN_DELETION);
972 RunCallbacksForCookies(key.first, key.second, added_cookies,
973 net::CookieStore::ChangeCause::INSERTED);
972 } 974 }
973 } 975 }
974 976
975 // Do not schedule a flush if one is already scheduled. 977 // Do not schedule a flush if one is already scheduled.
976 if (!flush_closure_.IsCancelled()) 978 if (!flush_closure_.IsCancelled())
977 return; 979 return;
978 980
979 flush_closure_.Reset(base::Bind(&CookieStoreIOS::FlushStore, 981 flush_closure_.Reset(base::Bind(&CookieStoreIOS::FlushStore,
980 weak_factory_.GetWeakPtr(), base::Closure())); 982 weak_factory_.GetWeakPtr(), base::Closure()));
981 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 983 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 std::vector<net::CanonicalCookie> system_cookies; 1015 std::vector<net::CanonicalCookie> system_cookies;
1014 GetSystemCookies(gurl, name, &system_cookies); 1016 GetSystemCookies(gurl, name, &system_cookies);
1015 return cookie_cache_->Update(gurl, name, system_cookies, out_removed_cookies, 1017 return cookie_cache_->Update(gurl, name, system_cookies, out_removed_cookies,
1016 out_added_cookies); 1018 out_added_cookies);
1017 } 1019 }
1018 1020
1019 void CookieStoreIOS::RunCallbacksForCookies( 1021 void CookieStoreIOS::RunCallbacksForCookies(
1020 const GURL& url, 1022 const GURL& url,
1021 const std::string& name, 1023 const std::string& name,
1022 const std::vector<net::CanonicalCookie>& cookies, 1024 const std::vector<net::CanonicalCookie>& cookies,
1023 bool removed) { 1025 net::CookieStore::ChangeCause cause) {
1024 DCHECK(thread_checker_.CalledOnValidThread()); 1026 DCHECK(thread_checker_.CalledOnValidThread());
1025 if (cookies.empty()) 1027 if (cookies.empty())
1026 return; 1028 return;
1027 1029
1028 std::pair<GURL, std::string> key(url, name); 1030 std::pair<GURL, std::string> key(url, name);
1029 CookieChangedCallbackList* callbacks = hook_map_[key].get(); 1031 CookieChangedCallbackList* callbacks = hook_map_[key].get();
1030 for (const auto& cookie : cookies) { 1032 for (const auto& cookie : cookies) {
1031 DCHECK_EQ(name, cookie.Name()); 1033 DCHECK_EQ(name, cookie.Name());
1032 callbacks->Notify(cookie, removed); 1034 callbacks->Notify(cookie, cause);
1033 } 1035 }
1034 } 1036 }
1035 1037
1036 bool CookieStoreIOS::GetSystemCookies( 1038 bool CookieStoreIOS::GetSystemCookies(
1037 const GURL& gurl, 1039 const GURL& gurl,
1038 const std::string& name, 1040 const std::string& name,
1039 std::vector<net::CanonicalCookie>* cookies) { 1041 std::vector<net::CanonicalCookie>* cookies) {
1040 DCHECK(thread_checker_.CalledOnValidThread()); 1042 DCHECK(thread_checker_.CalledOnValidThread());
1041 NSURL* url = net::NSURLWithGURL(gurl); 1043 NSURL* url = net::NSURLWithGURL(gurl);
1042 NSArray* nscookies = [system_store_ cookiesForURL:url]; 1044 NSArray* nscookies = [system_store_ cookiesForURL:url];
(...skipping 12 matching lines...) Expand all
1055 void CookieStoreIOS::GotCookieListFor(const std::pair<GURL, std::string> key, 1057 void CookieStoreIOS::GotCookieListFor(const std::pair<GURL, std::string> key,
1056 const net::CookieList& cookies) { 1058 const net::CookieList& cookies) {
1057 DCHECK(thread_checker_.CalledOnValidThread()); 1059 DCHECK(thread_checker_.CalledOnValidThread());
1058 1060
1059 net::CookieList filtered; 1061 net::CookieList filtered;
1060 OnlyCookiesWithName(cookies, key.second, &filtered); 1062 OnlyCookiesWithName(cookies, key.second, &filtered);
1061 std::vector<net::CanonicalCookie> removed_cookies; 1063 std::vector<net::CanonicalCookie> removed_cookies;
1062 std::vector<net::CanonicalCookie> added_cookies; 1064 std::vector<net::CanonicalCookie> added_cookies;
1063 if (cookie_cache_->Update(key.first, key.second, filtered, &removed_cookies, 1065 if (cookie_cache_->Update(key.first, key.second, filtered, &removed_cookies,
1064 &added_cookies)) { 1066 &added_cookies)) {
1065 RunCallbacksForCookies(key.first, key.second, removed_cookies, true); 1067 RunCallbacksForCookies(key.first, key.second, removed_cookies,
1066 RunCallbacksForCookies(key.first, key.second, added_cookies, false); 1068 net::CookieStore::ChangeCause::UNKNOWN_DELETION);
1069 RunCallbacksForCookies(key.first, key.second, added_cookies,
1070 net::CookieStore::ChangeCause::INSERTED);
1067 } 1071 }
1068 } 1072 }
1069 1073
1070 void CookieStoreIOS::DidClearNSHTTPCookieStorageCookies( 1074 void CookieStoreIOS::DidClearNSHTTPCookieStorageCookies(
1071 const DeleteCallback& delete_callback, 1075 const DeleteCallback& delete_callback,
1072 int num_deleted) { 1076 int num_deleted) {
1073 DCHECK(thread_checker_.CalledOnValidThread()); 1077 DCHECK(thread_checker_.CalledOnValidThread());
1074 1078
1075 CookieStoreIOSClient* client = net::GetCookieStoreIOSClient(); 1079 CookieStoreIOSClient* client = net::GetCookieStoreIOSClient();
1076 DCHECK(client); 1080 DCHECK(client);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1154 weak_factory_.GetWeakPtr(), callback); 1158 weak_factory_.GetWeakPtr(), callback);
1155 } 1159 }
1156 1160
1157 base::Closure CookieStoreIOS::WrapClosure(const base::Closure& callback) { 1161 base::Closure CookieStoreIOS::WrapClosure(const base::Closure& callback) {
1158 DCHECK(thread_checker_.CalledOnValidThread()); 1162 DCHECK(thread_checker_.CalledOnValidThread());
1159 return base::Bind(&CookieStoreIOS::UpdateCachesAfterClosure, 1163 return base::Bind(&CookieStoreIOS::UpdateCachesAfterClosure,
1160 weak_factory_.GetWeakPtr(), callback); 1164 weak_factory_.GetWeakPtr(), callback);
1161 } 1165 }
1162 1166
1163 } // namespace net 1167 } // 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