| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/memory/weak_ptr.h" | 6 #include "base/memory/weak_ptr.h" |
| 7 #include "mojo/application/application_runner_chromium.h" | 7 #include "mojo/application/application_runner_chromium.h" |
| 8 #include "mojo/common/tracing.mojom.h" | |
| 9 #include "mojo/public/c/system/main.h" | 8 #include "mojo/public/c/system/main.h" |
| 10 #include "mojo/public/cpp/application/application_delegate.h" | 9 #include "mojo/public/cpp/application/application_delegate.h" |
| 11 #include "mojo/public/cpp/application/application_impl.h" | 10 #include "mojo/public/cpp/application/application_impl.h" |
| 11 #include "services/tracing/tracing.mojom.h" |
| 12 #include "sky/tools/debugger/debugger.mojom.h" | 12 #include "sky/tools/debugger/debugger.mojom.h" |
| 13 #include <iostream> | 13 #include <iostream> |
| 14 | 14 |
| 15 namespace sky { | 15 namespace sky { |
| 16 namespace debugger { | 16 namespace debugger { |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 std::string GetCommand() { | 19 std::string GetCommand() { |
| 20 std::cout << "(skydb) "; | 20 std::cout << "(skydb) "; |
| 21 std::cout.flush(); | 21 std::cout.flush(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 35 Prompt() | 35 Prompt() |
| 36 : is_tracing_(false), | 36 : is_tracing_(false), |
| 37 weak_ptr_factory_(this) { | 37 weak_ptr_factory_(this) { |
| 38 } | 38 } |
| 39 virtual ~Prompt() { | 39 virtual ~Prompt() { |
| 40 } | 40 } |
| 41 | 41 |
| 42 private: | 42 private: |
| 43 // Overridden from mojo::ApplicationDelegate: | 43 // Overridden from mojo::ApplicationDelegate: |
| 44 virtual void Initialize(mojo::ApplicationImpl* app) override { | 44 virtual void Initialize(mojo::ApplicationImpl* app) override { |
| 45 app->ConnectToService("mojo:sky_viewer", &tracing_); | 45 app->ConnectToService("mojo:tracing", &tracing_); |
| 46 if (app->args().size() > 1) | 46 if (app->args().size() > 1) |
| 47 url_ = app->args()[1]; | 47 url_ = app->args()[1]; |
| 48 else { | 48 else { |
| 49 url_ = "https://raw.githubusercontent.com/domokit/mojo/master/sky/" | 49 url_ = "https://raw.githubusercontent.com/domokit/mojo/master/sky/" |
| 50 "examples/home.sky"; | 50 "examples/home.sky"; |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 | 53 |
| 54 virtual bool ConfigureIncomingConnection( | 54 virtual bool ConfigureIncomingConnection( |
| 55 mojo::ApplicationConnection* connection) override { | 55 mojo::ApplicationConnection* connection) override { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 } | 131 } |
| 132 | 132 |
| 133 void Quit() { | 133 void Quit() { |
| 134 std::cout << "quitting" << std::endl; | 134 std::cout << "quitting" << std::endl; |
| 135 debugger_->Shutdown(); | 135 debugger_->Shutdown(); |
| 136 } | 136 } |
| 137 | 137 |
| 138 void ToggleTracing() { | 138 void ToggleTracing() { |
| 139 if (is_tracing_) { | 139 if (is_tracing_) { |
| 140 std::cout << "Stopping trace (writing to sky_viewer.trace)" << std::endl; | 140 std::cout << "Stopping trace (writing to sky_viewer.trace)" << std::endl; |
| 141 tracing_->Stop(); | 141 tracing_->StopAndFlush(); |
| 142 } else { | 142 } else { |
| 143 std::cout << "Starting trace (type 'trace' to stop tracing)" << std::endl; | 143 std::cout << "Starting trace (type 'trace' to stop tracing)" << std::endl; |
| 144 tracing_->Start(); | 144 tracing_->Start(mojo::String("sky_viewer"), mojo::String("*")); |
| 145 } | 145 } |
| 146 is_tracing_ = !is_tracing_; | 146 is_tracing_ = !is_tracing_; |
| 147 } | 147 } |
| 148 | 148 |
| 149 bool is_tracing_; | 149 bool is_tracing_; |
| 150 DebuggerPtr debugger_; | 150 DebuggerPtr debugger_; |
| 151 mojo::TracingPtr tracing_; | 151 tracing::TraceCoordinatorPtr tracing_; |
| 152 std::string url_; | 152 std::string url_; |
| 153 base::WeakPtrFactory<Prompt> weak_ptr_factory_; | 153 base::WeakPtrFactory<Prompt> weak_ptr_factory_; |
| 154 | 154 |
| 155 DISALLOW_COPY_AND_ASSIGN(Prompt); | 155 DISALLOW_COPY_AND_ASSIGN(Prompt); |
| 156 }; | 156 }; |
| 157 | 157 |
| 158 } // namespace debugger | 158 } // namespace debugger |
| 159 } // namespace sky | 159 } // namespace sky |
| 160 | 160 |
| 161 MojoResult MojoMain(MojoHandle shell_handle) { | 161 MojoResult MojoMain(MojoHandle shell_handle) { |
| 162 mojo::ApplicationRunnerChromium runner(new sky::debugger::Prompt); | 162 mojo::ApplicationRunnerChromium runner(new sky::debugger::Prompt); |
| 163 return runner.Run(shell_handle); | 163 return runner.Run(shell_handle); |
| 164 } | 164 } |
| OLD | NEW |