OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 // Portions of this code based on Mozilla: | 5 // Portions of this code based on Mozilla: |
6 // (netwerk/cookie/src/nsCookieService.cpp) | 6 // (netwerk/cookie/src/nsCookieService.cpp) |
7 /* ***** BEGIN LICENSE BLOCK ***** | 7 /* ***** BEGIN LICENSE BLOCK ***** |
8 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 8 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
9 * | 9 * |
10 * The contents of this file are subject to the Mozilla Public License Version | 10 * The contents of this file are subject to the Mozilla Public License Version |
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
856 const SetCookiesCallback& callback) { | 856 const SetCookiesCallback& callback) { |
857 scoped_refptr<SetCookieWithDetailsTask> task = new SetCookieWithDetailsTask( | 857 scoped_refptr<SetCookieWithDetailsTask> task = new SetCookieWithDetailsTask( |
858 this, url, name, value, domain, path, creation_time, expiration_time, | 858 this, url, name, value, domain, path, creation_time, expiration_time, |
859 last_access_time, secure, http_only, same_site, enforce_strict_secure, | 859 last_access_time, secure, http_only, same_site, enforce_strict_secure, |
860 priority, callback); | 860 priority, callback); |
861 DoCookieTaskForURL(task, url); | 861 DoCookieTaskForURL(task, url); |
862 } | 862 } |
863 | 863 |
864 void CookieMonster::FlushStore(const base::Closure& callback) { | 864 void CookieMonster::FlushStore(const base::Closure& callback) { |
865 DCHECK(thread_checker_.CalledOnValidThread()); | 865 DCHECK(thread_checker_.CalledOnValidThread()); |
| 866 |
866 if (initialized_ && store_.get()) | 867 if (initialized_ && store_.get()) |
867 store_->Flush(callback); | 868 store_->Flush(callback); |
868 else if (!callback.is_null()) | 869 else if (!callback.is_null()) |
869 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback); | 870 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback); |
870 } | 871 } |
871 | 872 |
872 void CookieMonster::SetForceKeepSessionState() { | 873 void CookieMonster::SetForceKeepSessionState() { |
873 DCHECK(thread_checker_.CalledOnValidThread()); | 874 DCHECK(thread_checker_.CalledOnValidThread()); |
| 875 |
874 if (store_) | 876 if (store_) |
875 store_->SetForceKeepSessionState(); | 877 store_->SetForceKeepSessionState(); |
876 } | 878 } |
877 | 879 |
878 void CookieMonster::SetAllCookiesAsync(const CookieList& list, | 880 void CookieMonster::SetAllCookiesAsync(const CookieList& list, |
879 const SetCookiesCallback& callback) { | 881 const SetCookiesCallback& callback) { |
880 scoped_refptr<SetAllCookiesTask> task = | 882 scoped_refptr<SetAllCookiesTask> task = |
881 new SetAllCookiesTask(this, list, callback); | 883 new SetAllCookiesTask(this, list, callback); |
882 DoCookieTask(task); | 884 DoCookieTask(task); |
883 } | 885 } |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 const char* const CookieMonster::kDefaultCookieableSchemes[] = {"http", "https", | 997 const char* const CookieMonster::kDefaultCookieableSchemes[] = {"http", "https", |
996 "ws", "wss"}; | 998 "ws", "wss"}; |
997 const int CookieMonster::kDefaultCookieableSchemesCount = | 999 const int CookieMonster::kDefaultCookieableSchemesCount = |
998 arraysize(kDefaultCookieableSchemes); | 1000 arraysize(kDefaultCookieableSchemes); |
999 | 1001 |
1000 scoped_ptr<CookieStore::CookieChangedSubscription> | 1002 scoped_ptr<CookieStore::CookieChangedSubscription> |
1001 CookieMonster::AddCallbackForCookie(const GURL& gurl, | 1003 CookieMonster::AddCallbackForCookie(const GURL& gurl, |
1002 const std::string& name, | 1004 const std::string& name, |
1003 const CookieChangedCallback& callback) { | 1005 const CookieChangedCallback& callback) { |
1004 DCHECK(thread_checker_.CalledOnValidThread()); | 1006 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1007 |
1005 std::pair<GURL, std::string> key(gurl, name); | 1008 std::pair<GURL, std::string> key(gurl, name); |
1006 if (hook_map_.count(key) == 0) | 1009 if (hook_map_.count(key) == 0) |
1007 hook_map_[key] = make_linked_ptr(new CookieChangedCallbackList()); | 1010 hook_map_[key] = make_linked_ptr(new CookieChangedCallbackList()); |
1008 return hook_map_[key]->Add( | 1011 return hook_map_[key]->Add( |
1009 base::Bind(&RunAsync, base::ThreadTaskRunnerHandle::Get(), callback)); | 1012 base::Bind(&RunAsync, base::ThreadTaskRunnerHandle::Get(), callback)); |
1010 } | 1013 } |
1011 | 1014 |
1012 CookieMonster::~CookieMonster() { | 1015 CookieMonster::~CookieMonster() { |
1013 DCHECK(thread_checker_.CalledOnValidThread()); | 1016 DCHECK(thread_checker_.CalledOnValidThread()); |
1014 | 1017 |
| 1018 // TODO(mmenke): Does it really make sense to run |delegate_| and |
| 1019 // CookieChanged callbacks when the CookieStore is destroyed? |
1015 for (CookieMap::iterator cookie_it = cookies_.begin(); | 1020 for (CookieMap::iterator cookie_it = cookies_.begin(); |
1016 cookie_it != cookies_.end();) { | 1021 cookie_it != cookies_.end();) { |
1017 CookieMap::iterator current_cookie_it = cookie_it; | 1022 CookieMap::iterator current_cookie_it = cookie_it; |
1018 ++cookie_it; | 1023 ++cookie_it; |
1019 InternalDeleteCookie(current_cookie_it, false /* sync_to_store */, | 1024 InternalDeleteCookie(current_cookie_it, false /* sync_to_store */, |
1020 DELETE_COOKIE_DONT_RECORD); | 1025 DELETE_COOKIE_DONT_RECORD); |
1021 } | 1026 } |
1022 } | 1027 } |
1023 | 1028 |
1024 bool CookieMonster::SetCookieWithDetails(const GURL& url, | 1029 bool CookieMonster::SetCookieWithDetails(const GURL& url, |
(...skipping 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2317 it != hook_map_.end(); ++it) { | 2322 it != hook_map_.end(); ++it) { |
2318 std::pair<GURL, std::string> key = it->first; | 2323 std::pair<GURL, std::string> key = it->first; |
2319 if (cookie.IncludeForRequestURL(key.first, opts) && | 2324 if (cookie.IncludeForRequestURL(key.first, opts) && |
2320 cookie.Name() == key.second) { | 2325 cookie.Name() == key.second) { |
2321 it->second->Notify(cookie, removed); | 2326 it->second->Notify(cookie, removed); |
2322 } | 2327 } |
2323 } | 2328 } |
2324 } | 2329 } |
2325 | 2330 |
2326 } // namespace net | 2331 } // namespace net |
OLD | NEW |