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

Side by Side Diff: chrome/browser/extensions/api/web_request/web_request_api_unittest.cc

Issue 2961033002: Use ContainsValue() instead of std::find() in chrome/browser/extensions (Closed)
Patch Set: Created 3 years, 5 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
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 #include <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <queue> 10 #include <queue>
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 ExtensionWebRequestEventRouter::EventResponse* response) { 106 ExtensionWebRequestEventRouter::EventResponse* response) {
107 ExtensionWebRequestEventRouter::GetInstance()->OnEventHandled( 107 ExtensionWebRequestEventRouter::GetInstance()->OnEventHandled(
108 profile, extension_id, event_name, sub_event_name, request_id, 108 profile, extension_id, event_name, sub_event_name, request_id,
109 response); 109 response);
110 } 110 }
111 111
112 // Searches |key| in |collection| by iterating over its elements and returns 112 // Searches |key| in |collection| by iterating over its elements and returns
113 // true if found. 113 // true if found.
114 template <typename Collection, typename Key> 114 template <typename Collection, typename Key>
115 bool Contains(const Collection& collection, const Key& key) { 115 bool Contains(const Collection& collection, const Key& key) {
116 return std::find(collection.begin(), collection.end(), key) != 116 return base::ContainsValue(collection, key);
Devlin 2017/06/30 01:51:59 Here, could we just replace all callers of Contain
Tripta 2017/07/03 05:34:43 Done.
117 collection.end();
118 } 117 }
119 118
120 // Returns whether |warnings| contains an extension for |extension_id|. 119 // Returns whether |warnings| contains an extension for |extension_id|.
121 bool HasWarning(const WarningSet& warnings, 120 bool HasWarning(const WarningSet& warnings,
122 const std::string& extension_id) { 121 const std::string& extension_id) {
123 for (WarningSet::const_iterator i = warnings.begin(); 122 for (WarningSet::const_iterator i = warnings.begin();
124 i != warnings.end(); ++i) { 123 i != warnings.end(); ++i) {
125 if (i->extension_id() == extension_id) 124 if (i->extension_id() == extension_id)
126 return true; 125 return true;
127 } 126 }
(...skipping 2354 matching lines...) Expand 10 before | Expand all | Expand 10 after
2482 EXPECT_TRUE(credentials_set); 2481 EXPECT_TRUE(credentials_set);
2483 EXPECT_FALSE(auth3.Empty()); 2482 EXPECT_FALSE(auth3.Empty());
2484 EXPECT_EQ(username, auth1.username()); 2483 EXPECT_EQ(username, auth1.username());
2485 EXPECT_EQ(password, auth1.password()); 2484 EXPECT_EQ(password, auth1.password());
2486 EXPECT_EQ(1u, warning_set.size()); 2485 EXPECT_EQ(1u, warning_set.size());
2487 EXPECT_TRUE(HasWarning(warning_set, "extid2")); 2486 EXPECT_TRUE(HasWarning(warning_set, "extid2"));
2488 EXPECT_EQ(3u, capturing_net_log.GetSize()); 2487 EXPECT_EQ(3u, capturing_net_log.GetSize());
2489 } 2488 }
2490 2489
2491 } // namespace extensions 2490 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698