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

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

Issue 594393002: Add net::HttpServer::Delegate::OnConnect() function and set ChromeDriver buffer sizes to 100 MB (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Check for connection ids after the http request Created 6 years, 2 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) 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 <stdio.h> 5 #include <stdio.h>
6 #include <locale> 6 #include <locale>
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/at_exit.h" 10 #include "base/at_exit.h"
(...skipping 20 matching lines...) Expand all
31 #include "net/base/ip_endpoint.h" 31 #include "net/base/ip_endpoint.h"
32 #include "net/base/net_errors.h" 32 #include "net/base/net_errors.h"
33 #include "net/server/http_server.h" 33 #include "net/server/http_server.h"
34 #include "net/server/http_server_request_info.h" 34 #include "net/server/http_server_request_info.h"
35 #include "net/server/http_server_response_info.h" 35 #include "net/server/http_server_response_info.h"
36 #include "net/socket/tcp_server_socket.h" 36 #include "net/socket/tcp_server_socket.h"
37 37
38 namespace { 38 namespace {
39 39
40 const char* kLocalHostAddress = "127.0.0.1"; 40 const char* kLocalHostAddress = "127.0.0.1";
41 const int kBufferSize = 100 * 1024 * 1024; // 100 MB
41 42
42 typedef base::Callback< 43 typedef base::Callback<
43 void(const net::HttpServerRequestInfo&, const HttpResponseSenderFunc&)> 44 void(const net::HttpServerRequestInfo&, const HttpResponseSenderFunc&)>
44 HttpRequestHandlerFunc; 45 HttpRequestHandlerFunc;
45 46
46 class HttpServer : public net::HttpServer::Delegate { 47 class HttpServer : public net::HttpServer::Delegate {
47 public: 48 public:
48 explicit HttpServer(const HttpRequestHandlerFunc& handle_request_func) 49 explicit HttpServer(const HttpRequestHandlerFunc& handle_request_func)
49 : handle_request_func_(handle_request_func), 50 : handle_request_func_(handle_request_func),
50 weak_factory_(this) {} 51 weak_factory_(this) {}
51 52
52 virtual ~HttpServer() {} 53 virtual ~HttpServer() {}
53 54
54 bool Start(int port, bool allow_remote) { 55 bool Start(int port, bool allow_remote) {
55 std::string binding_ip = kLocalHostAddress; 56 std::string binding_ip = kLocalHostAddress;
56 if (allow_remote) 57 if (allow_remote)
57 binding_ip = "0.0.0.0"; 58 binding_ip = "0.0.0.0";
58 scoped_ptr<net::ServerSocket> server_socket( 59 scoped_ptr<net::ServerSocket> server_socket(
59 new net::TCPServerSocket(NULL, net::NetLog::Source())); 60 new net::TCPServerSocket(NULL, net::NetLog::Source()));
60 server_socket->ListenWithAddressAndPort(binding_ip, port, 1); 61 server_socket->ListenWithAddressAndPort(binding_ip, port, 1);
61 server_.reset(new net::HttpServer(server_socket.Pass(), this)); 62 server_.reset(new net::HttpServer(server_socket.Pass(), this));
62 net::IPEndPoint address; 63 net::IPEndPoint address;
63 return server_->GetLocalAddress(&address) == net::OK; 64 return server_->GetLocalAddress(&address) == net::OK;
64 } 65 }
65 66
66 // Overridden from net::HttpServer::Delegate: 67 // Overridden from net::HttpServer::Delegate:
68 virtual void OnConnect(int connection_id) OVERRIDE {
69 server_->SetSendBufferSize(connection_id, kBufferSize);
70 server_->SetReceiveBufferSize(connection_id, kBufferSize);
71 }
67 virtual void OnHttpRequest(int connection_id, 72 virtual void OnHttpRequest(int connection_id,
68 const net::HttpServerRequestInfo& info) OVERRIDE { 73 const net::HttpServerRequestInfo& info) OVERRIDE {
69 handle_request_func_.Run( 74 handle_request_func_.Run(
70 info, 75 info,
71 base::Bind(&HttpServer::OnResponse, 76 base::Bind(&HttpServer::OnResponse,
72 weak_factory_.GetWeakPtr(), 77 weak_factory_.GetWeakPtr(),
73 connection_id)); 78 connection_id));
74 } 79 }
75 virtual void OnWebSocketRequest( 80 virtual void OnWebSocketRequest(
76 int connection_id, 81 int connection_id,
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 } 308 }
304 309
305 if (!InitLogging()) { 310 if (!InitLogging()) {
306 printf("Unable to initialize logging. Exiting...\n"); 311 printf("Unable to initialize logging. Exiting...\n");
307 return 1; 312 return 1;
308 } 313 }
309 RunServer(port, allow_remote, whitelisted_ips, 314 RunServer(port, allow_remote, whitelisted_ips,
310 url_base, adb_port, port_server.Pass()); 315 url_base, adb_port, port_server.Pass());
311 return 0; 316 return 0;
312 } 317 }
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/net/test_http_server.cc ('k') | chrome/test/chromedriver/test/run_py_tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698