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

Side by Side Diff: net/cookies/cookie_monster.cc

Issue 2943703002: Use ContainsValue() instead of std::find() in net/ (Closed)
Patch Set: Created 3 years, 6 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 | « net/cert/x509_certificate_bytes.cc ('k') | net/dns/host_resolver_impl_unittest.cc » ('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 (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 26 matching lines...) Expand all
37 * use your version of this file under the terms of the MPL, indicate your 37 * use your version of this file under the terms of the MPL, indicate your
38 * decision by deleting the provisions above and replace them with the notice 38 * decision by deleting the provisions above and replace them with the notice
39 * and other provisions required by the GPL or the LGPL. If you do not delete 39 * and other provisions required by the GPL or the LGPL. If you do not delete
40 * the provisions above, a recipient may use your version of this file under 40 * the provisions above, a recipient may use your version of this file under
41 * the terms of any one of the MPL, the GPL or the LGPL. 41 * the terms of any one of the MPL, the GPL or the LGPL.
42 * 42 *
43 * ***** END LICENSE BLOCK ***** */ 43 * ***** END LICENSE BLOCK ***** */
44 44
45 #include "net/cookies/cookie_monster.h" 45 #include "net/cookies/cookie_monster.h"
46 46
47 #include <algorithm>
48 #include <functional> 47 #include <functional>
49 #include <memory> 48 #include <memory>
50 #include <set> 49 #include <set>
51 50
52 #include "base/bind.h" 51 #include "base/bind.h"
53 #include "base/callback.h" 52 #include "base/callback.h"
54 #include "base/location.h" 53 #include "base/location.h"
55 #include "base/logging.h" 54 #include "base/logging.h"
56 #include "base/macros.h" 55 #include "base/macros.h"
57 #include "base/memory/ptr_util.h" 56 #include "base/memory/ptr_util.h"
58 #include "base/metrics/field_trial.h" 57 #include "base/metrics/field_trial.h"
59 #include "base/metrics/histogram.h" 58 #include "base/metrics/histogram.h"
60 #include "base/profiler/scoped_tracker.h" 59 #include "base/profiler/scoped_tracker.h"
61 #include "base/single_thread_task_runner.h" 60 #include "base/single_thread_task_runner.h"
61 #include "base/stl_util.h"
62 #include "base/strings/string_util.h" 62 #include "base/strings/string_util.h"
63 #include "base/strings/stringprintf.h" 63 #include "base/strings/stringprintf.h"
64 #include "base/threading/thread_task_runner_handle.h" 64 #include "base/threading/thread_task_runner_handle.h"
65 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 65 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
66 #include "net/cookies/canonical_cookie.h" 66 #include "net/cookies/canonical_cookie.h"
67 #include "net/cookies/cookie_util.h" 67 #include "net/cookies/cookie_util.h"
68 #include "net/cookies/parsed_cookie.h" 68 #include "net/cookies/parsed_cookie.h"
69 #include "net/ssl/channel_id_service.h" 69 #include "net/ssl/channel_id_service.h"
70 #include "url/origin.h" 70 #include "url/origin.h"
71 71
(...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 // This function must be called before the CookieMonster is used. 1004 // This function must be called before the CookieMonster is used.
1005 void CookieMonster::SetPersistSessionCookies(bool persist_session_cookies) { 1005 void CookieMonster::SetPersistSessionCookies(bool persist_session_cookies) {
1006 DCHECK(thread_checker_.CalledOnValidThread()); 1006 DCHECK(thread_checker_.CalledOnValidThread());
1007 DCHECK(!initialized_); 1007 DCHECK(!initialized_);
1008 persist_session_cookies_ = persist_session_cookies; 1008 persist_session_cookies_ = persist_session_cookies;
1009 } 1009 }
1010 1010
1011 bool CookieMonster::IsCookieableScheme(const std::string& scheme) { 1011 bool CookieMonster::IsCookieableScheme(const std::string& scheme) {
1012 DCHECK(thread_checker_.CalledOnValidThread()); 1012 DCHECK(thread_checker_.CalledOnValidThread());
1013 1013
1014 return std::find(cookieable_schemes_.begin(), cookieable_schemes_.end(), 1014 return base::ContainsValue(cookieable_schemes_, scheme);
1015 scheme) != cookieable_schemes_.end();
1016 } 1015 }
1017 1016
1018 const char* const CookieMonster::kDefaultCookieableSchemes[] = {"http", "https", 1017 const char* const CookieMonster::kDefaultCookieableSchemes[] = {"http", "https",
1019 "ws", "wss"}; 1018 "ws", "wss"};
1020 const int CookieMonster::kDefaultCookieableSchemesCount = 1019 const int CookieMonster::kDefaultCookieableSchemesCount =
1021 arraysize(kDefaultCookieableSchemes); 1020 arraysize(kDefaultCookieableSchemes);
1022 1021
1023 std::unique_ptr<CookieStore::CookieChangedSubscription> 1022 std::unique_ptr<CookieStore::CookieChangedSubscription>
1024 CookieMonster::AddCallbackForCookie(const GURL& gurl, 1023 CookieMonster::AddCallbackForCookie(const GURL& gurl,
1025 const std::string& name, 1024 const std::string& name,
(...skipping 1416 matching lines...) Expand 10 before | Expand all | Expand 10 after
2442 it != hook_map_.end(); ++it) { 2441 it != hook_map_.end(); ++it) {
2443 std::pair<GURL, std::string> key = it->first; 2442 std::pair<GURL, std::string> key = it->first;
2444 if (cookie.IncludeForRequestURL(key.first, opts) && 2443 if (cookie.IncludeForRequestURL(key.first, opts) &&
2445 cookie.Name() == key.second) { 2444 cookie.Name() == key.second) {
2446 it->second->Notify(cookie, cause); 2445 it->second->Notify(cookie, cause);
2447 } 2446 }
2448 } 2447 }
2449 } 2448 }
2450 2449
2451 } // namespace net 2450 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/x509_certificate_bytes.cc ('k') | net/dns/host_resolver_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698