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" | |
|
Yusuke Sato
2016/10/12 05:58:14
nit: is this #include necessary?
namespace arc
shunhsingou
2016/12/22 04:04:35
Done.
| |
| 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 { | |
|
Yusuke Sato
2016/10/12 05:58:13
Not sure if it makes sense to implement an empty h
shunhsingou
2016/12/22 04:04:35
Removed
| |
| 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. | |
|
Yusuke Sato
2016/10/12 05:58:14
// InstanceHolder<mojom::TraceInstance>::Observer
shunhsingou
2016/12/22 04:04:35
Done.
| |
| 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 struct Category { | |
| 45 // The name used by Android to trigger tracing. | |
| 46 const std::string name; | |
| 47 // The full name shown in the tracing UI in chrome://tracing. | |
| 48 const std::string full_name; | |
| 49 | |
| 50 Category(const std::string& name, const std::string& full_name) | |
|
Luis Héctor Chávez
2016/10/12 17:12:40
Can you use the uniform initialization syntax to a
shunhsingou
2016/12/22 04:04:35
Done.
| |
| 51 : name(name), full_name(full_name) {} | |
| 52 }; | |
| 53 mojo::Binding<mojom::TraceHost> binding_; | |
|
Yusuke Sato
2016/10/12 05:58:14
same, remove?
shunhsingou
2016/12/22 04:04:35
Done.
| |
| 54 | |
| 55 base::WeakPtrFactory<ArcTraceBridge> weak_ptr_factory_; | |
|
Yusuke Sato
2016/10/27 04:11:24
weak_ptr_factory_ must be the last member variable
shunhsingou
2016/12/22 04:04:35
Done.
| |
| 56 | |
| 57 base::ThreadChecker thread_checker_; | |
| 58 | |
| 59 // List of available categories name. Each item is a pair of string. The | |
|
Luis Héctor Chávez
2016/10/12 17:12:40
This comment is now out of date.
shunhsingou
2016/12/22 04:04:35
Done.
| |
| 60 // first string is the category name, and the second string is the full name | |
| 61 // shown in the trace menu UI. | |
| 62 std::vector<Category> categories_; | |
|
Yusuke Sato
2016/10/27 04:11:24
This does not seem to follow the class formatting
shunhsingou
2016/12/22 04:04:35
Done.
| |
| 63 | |
| 64 // Query the available categories for tracing. | |
| 65 void QueryAvailableCategories(); | |
| 66 | |
| 67 // Callback for QueryAvailableCategories. | |
| 68 void OnCategoriesReady(mojo::Array<mojo::String> categories); | |
| 69 | |
| 70 // Callback for StartTracing. | |
| 71 void OnTraceStart(bool success); | |
| 72 | |
| 73 // Callback for StopTracing. | |
| 74 void OnTraceStop(bool success); | |
| 75 | |
| 76 DISALLOW_COPY_AND_ASSIGN(ArcTraceBridge); | |
| 77 }; | |
| 78 | |
| 79 } // namespace arc | |
| 80 | |
| 81 #endif // COMPONENTS_ARC_TRACE_ARC_TRACE_BRIDGE_H_ | |
| OLD | NEW |