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

Side by Side Diff: chrome/test/chromedriver/server/chromedriver_server.cc

Issue 2950803002: Use ContainsValue() instead of std::find() in chrome/browser/ and chrome/test/ (Closed)
Patch Set: Reverted code for file thumbnail_cache.cc 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 | « chrome/browser/safe_browsing/local_database_manager.cc ('k') | no next file » | 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include <locale> 9 #include <locale>
10 #include <memory> 10 #include <memory>
11 #include <string> 11 #include <string>
12 #include <utility> 12 #include <utility>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/at_exit.h" 15 #include "base/at_exit.h"
16 #include "base/bind.h" 16 #include "base/bind.h"
17 #include "base/callback.h" 17 #include "base/callback.h"
18 #include "base/command_line.h" 18 #include "base/command_line.h"
19 #include "base/files/file_path.h" 19 #include "base/files/file_path.h"
20 #include "base/lazy_instance.h" 20 #include "base/lazy_instance.h"
21 #include "base/logging.h" 21 #include "base/logging.h"
22 #include "base/macros.h" 22 #include "base/macros.h"
23 #include "base/message_loop/message_loop.h" 23 #include "base/message_loop/message_loop.h"
24 #include "base/run_loop.h" 24 #include "base/run_loop.h"
25 #include "base/single_thread_task_runner.h" 25 #include "base/single_thread_task_runner.h"
26 #include "base/stl_util.h"
26 #include "base/strings/string_number_conversions.h" 27 #include "base/strings/string_number_conversions.h"
27 #include "base/strings/string_split.h" 28 #include "base/strings/string_split.h"
28 #include "base/strings/string_util.h" 29 #include "base/strings/string_util.h"
29 #include "base/strings/stringprintf.h" 30 #include "base/strings/stringprintf.h"
30 #include "base/synchronization/waitable_event.h" 31 #include "base/synchronization/waitable_event.h"
31 #include "base/threading/thread.h" 32 #include "base/threading/thread.h"
32 #include "base/threading/thread_local.h" 33 #include "base/threading/thread_local.h"
33 #include "base/threading/thread_task_runner_handle.h" 34 #include "base/threading/thread_task_runner_handle.h"
34 #include "build/build_config.h" 35 #include "build/build_config.h"
35 #include "chrome/test/chromedriver/logging.h" 36 #include "chrome/test/chromedriver/logging.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 } 139 }
139 140
140 void HandleRequestOnCmdThread( 141 void HandleRequestOnCmdThread(
141 HttpHandler* handler, 142 HttpHandler* handler,
142 const std::vector<std::string>& whitelisted_ips, 143 const std::vector<std::string>& whitelisted_ips,
143 const net::HttpServerRequestInfo& request, 144 const net::HttpServerRequestInfo& request,
144 const HttpResponseSenderFunc& send_response_func) { 145 const HttpResponseSenderFunc& send_response_func) {
145 if (!whitelisted_ips.empty()) { 146 if (!whitelisted_ips.empty()) {
146 std::string peer_address = request.peer.ToStringWithoutPort(); 147 std::string peer_address = request.peer.ToStringWithoutPort();
147 if (peer_address != net::IPAddress::IPv4Localhost().ToString() && 148 if (peer_address != net::IPAddress::IPv4Localhost().ToString() &&
148 std::find(whitelisted_ips.begin(), whitelisted_ips.end(), 149 !base::ContainsValue(whitelisted_ips, peer_address)) {
149 peer_address) == whitelisted_ips.end()) {
150 LOG(WARNING) << "unauthorized access from " << request.peer.ToString(); 150 LOG(WARNING) << "unauthorized access from " << request.peer.ToString();
151 std::unique_ptr<net::HttpServerResponseInfo> response( 151 std::unique_ptr<net::HttpServerResponseInfo> response(
152 new net::HttpServerResponseInfo(net::HTTP_UNAUTHORIZED)); 152 new net::HttpServerResponseInfo(net::HTTP_UNAUTHORIZED));
153 response->SetBody("Unauthorized access", "text/plain"); 153 response->SetBody("Unauthorized access", "text/plain");
154 send_response_func.Run(std::move(response)); 154 send_response_func.Run(std::move(response));
155 return; 155 return;
156 } 156 }
157 } 157 }
158 158
159 handler->Handle(request, send_response_func); 159 handler->Handle(request, send_response_func);
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 } 332 }
333 333
334 if (!InitLogging()) { 334 if (!InitLogging()) {
335 printf("Unable to initialize logging. Exiting...\n"); 335 printf("Unable to initialize logging. Exiting...\n");
336 return 1; 336 return 1;
337 } 337 }
338 RunServer(port, allow_remote, whitelisted_ips, url_base, adb_port, 338 RunServer(port, allow_remote, whitelisted_ips, url_base, adb_port,
339 std::move(port_server)); 339 std::move(port_server));
340 return 0; 340 return 0;
341 } 341 }
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/local_database_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698