| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/profiler.h" | 8 #include "base/debug/profiler.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 : is_tracing_(false), | 35 : is_tracing_(false), |
| 36 weak_ptr_factory_(this) { | 36 weak_ptr_factory_(this) { |
| 37 } | 37 } |
| 38 virtual ~Prompt() { | 38 virtual ~Prompt() { |
| 39 } | 39 } |
| 40 | 40 |
| 41 private: | 41 private: |
| 42 // Overridden from mojo::ApplicationDelegate: | 42 // Overridden from mojo::ApplicationDelegate: |
| 43 virtual void Initialize(mojo::ApplicationImpl* app) override { | 43 virtual void Initialize(mojo::ApplicationImpl* app) override { |
| 44 app->ConnectToService("mojo:tracing", &tracing_); | 44 app->ConnectToService("mojo:tracing", &tracing_); |
| 45 // app_url, command_port, url_to_load | 45 // Format: --args-for="app_url command_port" |
| 46 if (app->args().size() < 2) { | 46 if (app->args().size() < 2) { |
| 47 LOG(ERROR) << "--args-for required to specify command_port"; | 47 LOG(ERROR) << "--args-for required to specify command_port"; |
| 48 exit(2); | 48 mojo::ApplicationImpl::Terminate(); |
| 49 return; |
| 49 } | 50 } |
| 50 | 51 |
| 51 base::StringToUint(app->args()[1], &command_port_); | 52 base::StringToUint(app->args()[1], &command_port_); |
| 52 | 53 |
| 53 scoped_ptr<net::ServerSocket> server_socket( | 54 scoped_ptr<net::ServerSocket> server_socket( |
| 54 new net::TCPServerSocket(NULL, net::NetLog::Source())); | 55 new net::TCPServerSocket(NULL, net::NetLog::Source())); |
| 55 int result = server_socket->ListenWithAddressAndPort("0.0.0.0", command_port
_, 1); | 56 int result = server_socket->ListenWithAddressAndPort("0.0.0.0", command_port
_, 1); |
| 56 if (result != net::OK) { | 57 if (result != net::OK) { |
| 57 // FIXME: Should we quit here? | |
| 58 LOG(ERROR) << "Failed to bind to port " << command_port_ | 58 LOG(ERROR) << "Failed to bind to port " << command_port_ |
| 59 << " skydb commands will not work, exiting."; | 59 << " skydb commands will not work."; |
| 60 exit(2); | 60 mojo::ApplicationImpl::Terminate(); |
| 61 return; | 61 return; |
| 62 } | 62 } |
| 63 web_server_.reset(new net::HttpServer(server_socket.Pass(), this)); | 63 web_server_.reset(new net::HttpServer(server_socket.Pass(), this)); |
| 64 } | 64 } |
| 65 | 65 |
| 66 virtual bool ConfigureIncomingConnection( | 66 virtual bool ConfigureIncomingConnection( |
| 67 mojo::ApplicationConnection* connection) override { | 67 mojo::ApplicationConnection* connection) override { |
| 68 connection->ConnectToService(&debugger_); | 68 connection->ConnectToService(&debugger_); |
| 69 return true; | 69 return true; |
| 70 } | 70 } |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 }; | 214 }; |
| 215 | 215 |
| 216 } // namespace debugger | 216 } // namespace debugger |
| 217 } // namespace sky | 217 } // namespace sky |
| 218 | 218 |
| 219 MojoResult MojoMain(MojoHandle shell_handle) { | 219 MojoResult MojoMain(MojoHandle shell_handle) { |
| 220 mojo::ApplicationRunnerChromium runner(new sky::debugger::Prompt); | 220 mojo::ApplicationRunnerChromium runner(new sky::debugger::Prompt); |
| 221 runner.set_message_loop_type(base::MessageLoop::TYPE_IO); | 221 runner.set_message_loop_type(base::MessageLoop::TYPE_IO); |
| 222 return runner.Run(shell_handle); | 222 return runner.Run(shell_handle); |
| 223 } | 223 } |
| OLD | NEW |