Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_ARC_TRACE_ARC_TRACE_BRIDGE_H_ | |
| 6 #define COMPONENTS_ARC_TRACE_ARC_TRACE_BRIDGE_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <utility> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/macros.h" | |
| 13 #include "base/memory/weak_ptr.h" | |
| 14 #include "base/threading/thread_checker.h" | |
| 15 #include "base/trace_event/trace_event.h" | |
| 16 #include "components/arc/arc_bridge_service.h" | |
| 17 #include "components/arc/arc_service.h" | |
| 18 #include "components/arc/instance_holder.h" | |
| 19 #include "mojo/public/cpp/bindings/binding.h" | |
| 20 | |
| 21 namespace arc { | |
| 22 | |
| 23 // This class provides the interface to trigger tracing in the container. | |
| 24 class ArcTraceBridge : public ArcService, | |
| 25 public InstanceHolder<mojom::TraceInstance>::Observer, | |
| 26 public mojom::TraceHost { | |
| 27 public: | |
| 28 // Gets the singleton of this class. | |
| 29 static ArcTraceBridge* Get(); | |
| 30 | |
| 31 explicit ArcTraceBridge(ArcBridgeService* bridge_service); | |
| 32 ~ArcTraceBridge() override; | |
| 33 | |
| 34 // Callback when the bridge is ready. | |
| 35 void OnInstanceReady() override; | |
| 36 | |
| 37 // Starts tracing in the container. | |
| 38 void StartTracing(const base::trace_event::TraceConfig& trace_config); | |
| 39 | |
| 40 // Stops tracing in the container. | |
| 41 void StopTracing(); | |
| 42 | |
| 43 private: | |
| 44 mojo::Binding<mojom::TraceHost> binding_; | |
| 45 | |
| 46 base::WeakPtrFactory<ArcTraceBridge> weak_ptr_factory_; | |
| 47 | |
| 48 base::ThreadChecker thread_checker_; | |
| 49 | |
| 50 // List of available categories name. Each item is a pair of string. The | |
| 51 // first string is the category name, and the second string is the full name | |
| 52 // shown in the trace menu UI. | |
| 53 std::vector<std::pair<std::string, std::string>> categories_; | |
|
Luis Héctor Chávez
2016/10/11 13:13:03
can you create a struct to hold both strings? that
shunhsingou
2016/10/12 04:24:26
Done.
| |
| 54 | |
| 55 // Query the available categories for tracing. | |
| 56 void QueryAvailableCategories(); | |
| 57 | |
| 58 // Callback for QueryAvailableCategories. | |
| 59 void OnCategoriesReady(mojo::Array<mojo::String> categories); | |
| 60 | |
| 61 // Callback for StartTracing. | |
| 62 void OnTraceStart(bool success); | |
| 63 | |
| 64 // Callback for StopTracing. | |
| 65 void OnTraceStop(bool success); | |
| 66 | |
| 67 DISALLOW_COPY_AND_ASSIGN(ArcTraceBridge); | |
| 68 }; | |
| 69 | |
| 70 } // namespace arc | |
| 71 | |
| 72 #endif // COMPONENTS_ARC_TRACE_ARC_TRACE_BRIDGE_H_ | |
| OLD | NEW |