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 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
846 const SetCookiesCallback& callback) { | 846 const SetCookiesCallback& callback) { |
847 scoped_refptr<SetCookieWithDetailsTask> task = new SetCookieWithDetailsTask( | 847 scoped_refptr<SetCookieWithDetailsTask> task = new SetCookieWithDetailsTask( |
848 this, url, name, value, domain, path, creation_time, expiration_time, | 848 this, url, name, value, domain, path, creation_time, expiration_time, |
849 last_access_time, secure, http_only, same_site, enforce_strict_secure, | 849 last_access_time, secure, http_only, same_site, enforce_strict_secure, |
850 priority, callback); | 850 priority, callback); |
851 DoCookieTaskForURL(task, url); | 851 DoCookieTaskForURL(task, url); |
852 } | 852 } |
853 | 853 |
854 void CookieMonster::FlushStore(const base::Closure& callback) { | 854 void CookieMonster::FlushStore(const base::Closure& callback) { |
855 DCHECK(thread_checker_.CalledOnValidThread()); | 855 DCHECK(thread_checker_.CalledOnValidThread()); |
| 856 |
856 if (initialized_ && store_.get()) | 857 if (initialized_ && store_.get()) |
857 store_->Flush(callback); | 858 store_->Flush(callback); |
858 else if (!callback.is_null()) | 859 else if (!callback.is_null()) |
859 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback); | 860 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback); |
860 } | 861 } |
861 | 862 |
862 void CookieMonster::SetForceKeepSessionState() { | 863 void CookieMonster::SetForceKeepSessionState() { |
863 DCHECK(thread_checker_.CalledOnValidThread()); | 864 DCHECK(thread_checker_.CalledOnValidThread()); |
| 865 |
864 if (store_) | 866 if (store_) |
865 store_->SetForceKeepSessionState(); | 867 store_->SetForceKeepSessionState(); |
866 } | 868 } |
867 | 869 |
868 void CookieMonster::SetAllCookiesAsync(const CookieList& list, | 870 void CookieMonster::SetAllCookiesAsync(const CookieList& list, |
869 const SetCookiesCallback& callback) { | 871 const SetCookiesCallback& callback) { |
870 scoped_refptr<SetAllCookiesTask> task = | 872 scoped_refptr<SetAllCookiesTask> task = |
871 new SetAllCookiesTask(this, list, callback); | 873 new SetAllCookiesTask(this, list, callback); |
872 DoCookieTask(task); | 874 DoCookieTask(task); |
873 } | 875 } |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
985 const char* const CookieMonster::kDefaultCookieableSchemes[] = {"http", "https", | 987 const char* const CookieMonster::kDefaultCookieableSchemes[] = {"http", "https", |
986 "ws", "wss"}; | 988 "ws", "wss"}; |
987 const int CookieMonster::kDefaultCookieableSchemesCount = | 989 const int CookieMonster::kDefaultCookieableSchemesCount = |
988 arraysize(kDefaultCookieableSchemes); | 990 arraysize(kDefaultCookieableSchemes); |
989 | 991 |
990 scoped_ptr<CookieStore::CookieChangedSubscription> | 992 scoped_ptr<CookieStore::CookieChangedSubscription> |
991 CookieMonster::AddCallbackForCookie(const GURL& gurl, | 993 CookieMonster::AddCallbackForCookie(const GURL& gurl, |
992 const std::string& name, | 994 const std::string& name, |
993 const CookieChangedCallback& callback) { | 995 const CookieChangedCallback& callback) { |
994 DCHECK(thread_checker_.CalledOnValidThread()); | 996 DCHECK(thread_checker_.CalledOnValidThread()); |
| 997 |
995 std::pair<GURL, std::string> key(gurl, name); | 998 std::pair<GURL, std::string> key(gurl, name); |
996 if (hook_map_.count(key) == 0) | 999 if (hook_map_.count(key) == 0) |
997 hook_map_[key] = make_linked_ptr(new CookieChangedCallbackList()); | 1000 hook_map_[key] = make_linked_ptr(new CookieChangedCallbackList()); |
998 return hook_map_[key]->Add( | 1001 return hook_map_[key]->Add( |
999 base::Bind(&RunAsync, base::ThreadTaskRunnerHandle::Get(), callback)); | 1002 base::Bind(&RunAsync, base::ThreadTaskRunnerHandle::Get(), callback)); |
1000 } | 1003 } |
1001 | 1004 |
1002 CookieMonster::~CookieMonster() { | 1005 CookieMonster::~CookieMonster() { |
1003 DCHECK(thread_checker_.CalledOnValidThread()); | 1006 DCHECK(thread_checker_.CalledOnValidThread()); |
1004 | 1007 |
| 1008 // TODO(mmenke): Does it really make sense to run |delegate_| and |
| 1009 // CookieChanged callbacks when the CookieStore is destroyed? |
1005 for (CookieMap::iterator cookie_it = cookies_.begin(); | 1010 for (CookieMap::iterator cookie_it = cookies_.begin(); |
1006 cookie_it != cookies_.end();) { | 1011 cookie_it != cookies_.end();) { |
1007 CookieMap::iterator current_cookie_it = cookie_it; | 1012 CookieMap::iterator current_cookie_it = cookie_it; |
1008 ++cookie_it; | 1013 ++cookie_it; |
1009 InternalDeleteCookie(current_cookie_it, false /* sync_to_store */, | 1014 InternalDeleteCookie(current_cookie_it, false /* sync_to_store */, |
1010 DELETE_COOKIE_DONT_RECORD); | 1015 DELETE_COOKIE_DONT_RECORD); |
1011 } | 1016 } |
1012 } | 1017 } |
1013 | 1018 |
1014 bool CookieMonster::SetCookieWithDetails(const GURL& url, | 1019 bool CookieMonster::SetCookieWithDetails(const GURL& url, |
(...skipping 1393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2408 it != hook_map_.end(); ++it) { | 2413 it != hook_map_.end(); ++it) { |
2409 std::pair<GURL, std::string> key = it->first; | 2414 std::pair<GURL, std::string> key = it->first; |
2410 if (cookie.IncludeForRequestURL(key.first, opts) && | 2415 if (cookie.IncludeForRequestURL(key.first, opts) && |
2411 cookie.Name() == key.second) { | 2416 cookie.Name() == key.second) { |
2412 it->second->Notify(cookie, removed); | 2417 it->second->Notify(cookie, removed); |
2413 } | 2418 } |
2414 } | 2419 } |
2415 } | 2420 } |
2416 | 2421 |
2417 } // namespace net | 2422 } // namespace net |
OLD | NEW |