| 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/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| 11 #include "mojo/application/application_runner_chromium.h" | 11 #include "mojo/application/application_runner_chromium.h" |
| 12 #include "mojo/common/data_pipe_utils.h" | 12 #include "mojo/common/data_pipe_utils.h" |
| 13 #include "mojo/public/c/system/main.h" | 13 #include "mojo/public/c/system/main.h" |
| 14 #include "mojo/public/cpp/application/application_delegate.h" | 14 #include "mojo/public/cpp/application/application_delegate.h" |
| 15 #include "mojo/public/cpp/application/application_impl.h" | 15 #include "mojo/public/cpp/application/application_impl.h" |
| 16 #include "mojo/public/cpp/bindings/binding.h" | 16 #include "mojo/public/cpp/bindings/binding.h" |
| 17 #include "mojo/services/network/public/interfaces/net_address.mojom.h" |
| 17 #include "mojo/services/window_manager/public/interfaces/window_manager.mojom.h" | 18 #include "mojo/services/window_manager/public/interfaces/window_manager.mojom.h" |
| 18 #include "services/http_server/public/http_server.mojom.h" | 19 #include "services/http_server/public/http_server.mojom.h" |
| 19 #include "services/http_server/public/http_server_factory.mojom.h" | 20 #include "services/http_server/public/http_server_factory.mojom.h" |
| 20 #include "services/http_server/public/http_server_util.h" | 21 #include "services/http_server/public/http_server_util.h" |
| 21 #include "services/tracing/tracing.mojom.h" | 22 #include "services/tracing/tracing.mojom.h" |
| 22 #include "sky/tools/debugger/trace_collector.h" | 23 #include "sky/tools/debugger/trace_collector.h" |
| 23 | 24 |
| 24 namespace sky { | 25 namespace sky { |
| 25 namespace debugger { | 26 namespace debugger { |
| 26 | 27 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 38 | 39 |
| 39 // Format: --args-for="app_url command_port" | 40 // Format: --args-for="app_url command_port" |
| 40 if (app->args().size() < 2) { | 41 if (app->args().size() < 2) { |
| 41 LOG(ERROR) << "--args-for required to specify command_port"; | 42 LOG(ERROR) << "--args-for required to specify command_port"; |
| 42 mojo::ApplicationImpl::Terminate(); | 43 mojo::ApplicationImpl::Terminate(); |
| 43 return; | 44 return; |
| 44 } | 45 } |
| 45 base::StringToUint(app->args()[1], &command_port_); | 46 base::StringToUint(app->args()[1], &command_port_); |
| 46 http_server::HttpServerFactoryPtr http_server_factory; | 47 http_server::HttpServerFactoryPtr http_server_factory; |
| 47 app->ConnectToService("mojo:http_server", &http_server_factory); | 48 app->ConnectToService("mojo:http_server", &http_server_factory); |
| 49 |
| 50 mojo::NetAddressPtr local_address(mojo::NetAddress::New()); |
| 51 local_address->family = mojo::NET_ADDRESS_FAMILY_IPV4; |
| 52 local_address->ipv4 = mojo::NetAddressIPv4::New(); |
| 53 local_address->ipv4->addr.resize(4); |
| 54 local_address->ipv4->addr[0] = 0; |
| 55 local_address->ipv4->addr[1] = 0; |
| 56 local_address->ipv4->addr[2] = 0; |
| 57 local_address->ipv4->addr[3] = 0; |
| 58 local_address->ipv4->port = command_port_; |
| 48 http_server_factory->CreateHttpServer(GetProxy(&http_server_).Pass(), | 59 http_server_factory->CreateHttpServer(GetProxy(&http_server_).Pass(), |
| 49 command_port_); | 60 local_address.Pass()); |
| 50 | 61 |
| 51 http_server::HttpHandlerPtr handler_ptr; | 62 http_server::HttpHandlerPtr handler_ptr; |
| 52 handler_binding_.Bind(GetProxy(&handler_ptr).Pass()); | 63 handler_binding_.Bind(GetProxy(&handler_ptr).Pass()); |
| 53 http_server_->SetHandler(".*", handler_ptr.Pass(), | 64 http_server_->SetHandler(".*", handler_ptr.Pass(), |
| 54 [](bool result) { DCHECK(result); }); | 65 [](bool result) { DCHECK(result); }); |
| 55 } | 66 } |
| 56 | 67 |
| 57 bool ConfigureIncomingConnection( | 68 bool ConfigureIncomingConnection( |
| 58 mojo::ApplicationConnection* connection) override { | 69 mojo::ApplicationConnection* connection) override { |
| 59 return true; | 70 return true; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 }; | 199 }; |
| 189 | 200 |
| 190 } // namespace debugger | 201 } // namespace debugger |
| 191 } // namespace sky | 202 } // namespace sky |
| 192 | 203 |
| 193 MojoResult MojoMain(MojoHandle shell_handle) { | 204 MojoResult MojoMain(MojoHandle shell_handle) { |
| 194 mojo::ApplicationRunnerChromium runner(new sky::debugger::SkyDebugger); | 205 mojo::ApplicationRunnerChromium runner(new sky::debugger::SkyDebugger); |
| 195 runner.set_message_loop_type(base::MessageLoop::TYPE_IO); | 206 runner.set_message_loop_type(base::MessageLoop::TYPE_IO); |
| 196 return runner.Run(shell_handle); | 207 return runner.Run(shell_handle); |
| 197 } | 208 } |
| OLD | NEW |