| 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 "mojo/application/application_runner_chromium.h" | 6 #include "mojo/application/application_runner_chromium.h" |
| 7 #include "mojo/common/weak_binding_set.h" | 7 #include "mojo/common/weak_binding_set.h" |
| 8 #include "mojo/public/c/system/main.h" | 8 #include "mojo/public/c/system/main.h" |
| 9 #include "mojo/public/cpp/application/application_delegate.h" | 9 #include "mojo/public/cpp/application/application_delegate.h" |
| 10 #include "mojo/public/cpp/application/application_impl.h" | 10 #include "mojo/public/cpp/application/application_impl.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 coordinator_bindings_.AddBinding(this, request.Pass()); | 37 coordinator_bindings_.AddBinding(this, request.Pass()); |
| 38 } | 38 } |
| 39 | 39 |
| 40 // mojo::InterfaceFactory<TraceDataCollector> implementation. | 40 // mojo::InterfaceFactory<TraceDataCollector> implementation. |
| 41 void Create(mojo::ApplicationConnection* connection, | 41 void Create(mojo::ApplicationConnection* connection, |
| 42 mojo::InterfaceRequest<TraceDataCollector> request) override { | 42 mojo::InterfaceRequest<TraceDataCollector> request) override { |
| 43 collector_bindings_.AddBinding(this, request.Pass()); | 43 collector_bindings_.AddBinding(this, request.Pass()); |
| 44 } | 44 } |
| 45 | 45 |
| 46 // tracing::TraceCoordinator implementation. | 46 // tracing::TraceCoordinator implementation. |
| 47 void Start(const mojo::String& base_name, | 47 void Start(mojo::ScopedDataPipeProducerHandle stream, |
| 48 const mojo::String& categories) override { | 48 const mojo::String& categories) override { |
| 49 base::FilePath base_name_path = | 49 sink_.reset(new TraceDataSink(stream.Pass())); |
| 50 base::FilePath::FromUTF8Unsafe(base_name.To<std::string>()); | |
| 51 sink_.reset(new TraceDataSink(base_name_path)); | |
| 52 collector_bindings_.ForAllBindings([categories]( | 50 collector_bindings_.ForAllBindings([categories]( |
| 53 TraceController* controller) { controller->StartTracing(categories); }); | 51 TraceController* controller) { controller->StartTracing(categories); }); |
| 54 } | 52 } |
| 55 void StopAndFlush() override { | 53 void StopAndFlush() override { |
| 56 collector_bindings_.ForAllBindings( | 54 collector_bindings_.ForAllBindings( |
| 57 [](TraceController* controller) { controller->StopTracing(); }); | 55 [](TraceController* controller) { controller->StopTracing(); }); |
| 58 | 56 |
| 59 // TODO: We really should keep track of how many connections we have here | 57 // TODO: We really should keep track of how many connections we have here |
| 60 // and flush + reset the sink after we receive a EndTracing or a detect a | 58 // and flush + reset the sink after we receive a EndTracing or a detect a |
| 61 // pipe closure on all pipes. | 59 // pipe closure on all pipes. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 79 | 77 |
| 80 DISALLOW_COPY_AND_ASSIGN(TracingApp); | 78 DISALLOW_COPY_AND_ASSIGN(TracingApp); |
| 81 }; | 79 }; |
| 82 | 80 |
| 83 } // namespace tracing | 81 } // namespace tracing |
| 84 | 82 |
| 85 MojoResult MojoMain(MojoHandle shell_handle) { | 83 MojoResult MojoMain(MojoHandle shell_handle) { |
| 86 mojo::ApplicationRunnerChromium runner(new tracing::TracingApp); | 84 mojo::ApplicationRunnerChromium runner(new tracing::TracingApp); |
| 87 return runner.Run(shell_handle); | 85 return runner.Run(shell_handle); |
| 88 } | 86 } |
| OLD | NEW |