| OLD | NEW |
| 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> |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 const HttpRequestHandlerFunc& handle_request_on_cmd_func, | 164 const HttpRequestHandlerFunc& handle_request_on_cmd_func, |
| 165 const net::HttpServerRequestInfo& request, | 165 const net::HttpServerRequestInfo& request, |
| 166 const HttpResponseSenderFunc& send_response_func) { | 166 const HttpResponseSenderFunc& send_response_func) { |
| 167 cmd_task_runner->PostTask( | 167 cmd_task_runner->PostTask( |
| 168 FROM_HERE, base::Bind(handle_request_on_cmd_func, request, | 168 FROM_HERE, base::Bind(handle_request_on_cmd_func, request, |
| 169 base::Bind(&SendResponseOnCmdThread, | 169 base::Bind(&SendResponseOnCmdThread, |
| 170 base::ThreadTaskRunnerHandle::Get(), | 170 base::ThreadTaskRunnerHandle::Get(), |
| 171 send_response_func))); | 171 send_response_func))); |
| 172 } | 172 } |
| 173 | 173 |
| 174 base::LazyInstance<base::ThreadLocalPointer<HttpServer> > | 174 base::LazyInstance<base::ThreadLocalPointer<HttpServer>>::DestructorAtExit |
| 175 lazy_tls_server = LAZY_INSTANCE_INITIALIZER; | 175 lazy_tls_server = LAZY_INSTANCE_INITIALIZER; |
| 176 | 176 |
| 177 void StopServerOnIOThread() { | 177 void StopServerOnIOThread() { |
| 178 // Note, |server| may be NULL. | 178 // Note, |server| may be NULL. |
| 179 HttpServer* server = lazy_tls_server.Pointer()->Get(); | 179 HttpServer* server = lazy_tls_server.Pointer()->Get(); |
| 180 lazy_tls_server.Pointer()->Set(NULL); | 180 lazy_tls_server.Pointer()->Set(NULL); |
| 181 delete server; | 181 delete server; |
| 182 } | 182 } |
| 183 | 183 |
| 184 void StartServerOnIOThread(uint16_t port, | 184 void StartServerOnIOThread(uint16_t port, |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 } |
| OLD | NEW |