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" | |
10 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
11 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
12 #include "mojo/application/application_runner_chromium.h" | 11 #include "mojo/application/application_runner_chromium.h" |
13 #include "mojo/public/c/system/main.h" | 12 #include "mojo/public/c/system/main.h" |
14 #include "mojo/public/cpp/application/application_delegate.h" | 13 #include "mojo/public/cpp/application/application_delegate.h" |
15 #include "mojo/public/cpp/application/application_impl.h" | 14 #include "mojo/public/cpp/application/application_impl.h" |
16 #include "mojo/services/window_manager/public/interfaces/window_manager.mojom.h" | 15 #include "mojo/services/window_manager/public/interfaces/window_manager.mojom.h" |
17 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
18 #include "net/server/http_server.h" | 17 #include "net/server/http_server.h" |
19 #include "net/server/http_server_request_info.h" | 18 #include "net/server/http_server_request_info.h" |
20 #include "net/socket/tcp_server_socket.h" | 19 #include "net/socket/tcp_server_socket.h" |
21 #include "services/tracing/tracing.mojom.h" | 20 #include "services/tracing/tracing.mojom.h" |
22 #include "sky/tools/debugger/trace_collector.h" | 21 #include "sky/tools/debugger/trace_collector.h" |
23 | 22 |
24 namespace sky { | 23 namespace sky { |
25 namespace debugger { | 24 namespace debugger { |
26 namespace { | 25 namespace { |
27 | 26 |
28 const size_t kMinSendBufferSize = 1024 * 1024; | 27 const size_t kMinSendBufferSize = 1024 * 1024; |
29 } | 28 } |
30 | 29 |
31 class SkyDebugger : public mojo::ApplicationDelegate, | 30 class SkyDebugger : public mojo::ApplicationDelegate, |
32 public net::HttpServer::Delegate { | 31 public net::HttpServer::Delegate { |
33 public: | 32 public: |
34 SkyDebugger() : is_tracing_(false), weak_ptr_factory_(this) {} | 33 SkyDebugger() : is_tracing_(false) {} |
35 virtual ~SkyDebugger() {} | 34 virtual ~SkyDebugger() {} |
36 | 35 |
37 private: | 36 private: |
38 // Overridden from mojo::ApplicationDelegate: | 37 // Overridden from mojo::ApplicationDelegate: |
39 virtual void Initialize(mojo::ApplicationImpl* app) override { | 38 virtual void Initialize(mojo::ApplicationImpl* app) override { |
40 app->ConnectToService("mojo:tracing", &tracing_); | 39 app->ConnectToService("mojo:tracing", &tracing_); |
41 // Format: --args-for="app_url command_port" | 40 // Format: --args-for="app_url command_port" |
42 if (app->args().size() < 2) { | 41 if (app->args().size() < 2) { |
43 LOG(ERROR) << "--args-for required to specify command_port"; | 42 LOG(ERROR) << "--args-for required to specify command_port"; |
44 mojo::ApplicationImpl::Terminate(); | 43 mojo::ApplicationImpl::Terminate(); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 return; | 191 return; |
193 } | 192 } |
194 base::debug::StopProfiling(); | 193 base::debug::StopProfiling(); |
195 Respond(connection_id, "Stopped profiling"); | 194 Respond(connection_id, "Stopped profiling"); |
196 } | 195 } |
197 | 196 |
198 bool is_tracing_; | 197 bool is_tracing_; |
199 mojo::WindowManagerPtr window_manager_; | 198 mojo::WindowManagerPtr window_manager_; |
200 tracing::TraceCoordinatorPtr tracing_; | 199 tracing::TraceCoordinatorPtr tracing_; |
201 std::string url_; | 200 std::string url_; |
202 base::WeakPtrFactory<SkyDebugger> weak_ptr_factory_; | |
203 scoped_ptr<net::HttpServer> web_server_; | 201 scoped_ptr<net::HttpServer> web_server_; |
204 uint32_t command_port_; | 202 uint32_t command_port_; |
205 | 203 |
206 scoped_ptr<TraceCollector> trace_collector_; | 204 scoped_ptr<TraceCollector> trace_collector_; |
207 | 205 |
208 DISALLOW_COPY_AND_ASSIGN(SkyDebugger); | 206 DISALLOW_COPY_AND_ASSIGN(SkyDebugger); |
209 }; | 207 }; |
210 | 208 |
211 } // namespace debugger | 209 } // namespace debugger |
212 } // namespace sky | 210 } // namespace sky |
213 | 211 |
214 MojoResult MojoMain(MojoHandle shell_handle) { | 212 MojoResult MojoMain(MojoHandle shell_handle) { |
215 mojo::ApplicationRunnerChromium runner(new sky::debugger::SkyDebugger); | 213 mojo::ApplicationRunnerChromium runner(new sky::debugger::SkyDebugger); |
216 runner.set_message_loop_type(base::MessageLoop::TYPE_IO); | 214 runner.set_message_loop_type(base::MessageLoop::TYPE_IO); |
217 return runner.Run(shell_handle); | 215 return runner.Run(shell_handle); |
218 } | 216 } |
OLD | NEW |