Index: components/arc/trace/arc_trace_bridge.h |
diff --git a/components/arc/trace/arc_trace_bridge.h b/components/arc/trace/arc_trace_bridge.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..72f7126032b82bd5dc1c78092c1d5541c251d61f |
--- /dev/null |
+++ b/components/arc/trace/arc_trace_bridge.h |
@@ -0,0 +1,81 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef COMPONENTS_ARC_TRACE_ARC_TRACE_BRIDGE_H_ |
+#define COMPONENTS_ARC_TRACE_ARC_TRACE_BRIDGE_H_ |
+ |
+#include <string> |
+#include <utility> |
+#include <vector> |
+ |
+#include "base/macros.h" |
+#include "base/memory/weak_ptr.h" |
+#include "base/threading/thread_checker.h" |
+#include "base/trace_event/trace_event.h" |
+#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.
|
+#include "components/arc/arc_service.h" |
+#include "components/arc/instance_holder.h" |
+#include "mojo/public/cpp/bindings/binding.h" |
+ |
+namespace arc { |
+ |
+// This class provides the interface to trigger tracing in the container. |
+class ArcTraceBridge : public ArcService, |
+ public InstanceHolder<mojom::TraceInstance>::Observer, |
+ 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
|
+ public: |
+ // Gets the singleton of this class. |
+ static ArcTraceBridge* Get(); |
+ |
+ explicit ArcTraceBridge(ArcBridgeService* bridge_service); |
+ ~ArcTraceBridge() override; |
+ |
+ // 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.
|
+ void OnInstanceReady() override; |
+ |
+ // Starts tracing in the container. |
+ void StartTracing(const base::trace_event::TraceConfig& trace_config); |
+ |
+ // Stops tracing in the container. |
+ void StopTracing(); |
+ |
+ private: |
+ struct Category { |
+ // The name used by Android to trigger tracing. |
+ const std::string name; |
+ // The full name shown in the tracing UI in chrome://tracing. |
+ const std::string full_name; |
+ |
+ 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.
|
+ : name(name), full_name(full_name) {} |
+ }; |
+ mojo::Binding<mojom::TraceHost> binding_; |
Yusuke Sato
2016/10/12 05:58:14
same, remove?
shunhsingou
2016/12/22 04:04:35
Done.
|
+ |
+ 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.
|
+ |
+ base::ThreadChecker thread_checker_; |
+ |
+ // 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.
|
+ // first string is the category name, and the second string is the full name |
+ // shown in the trace menu UI. |
+ 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.
|
+ |
+ // Query the available categories for tracing. |
+ void QueryAvailableCategories(); |
+ |
+ // Callback for QueryAvailableCategories. |
+ void OnCategoriesReady(mojo::Array<mojo::String> categories); |
+ |
+ // Callback for StartTracing. |
+ void OnTraceStart(bool success); |
+ |
+ // Callback for StopTracing. |
+ void OnTraceStop(bool success); |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ArcTraceBridge); |
+}; |
+ |
+} // namespace arc |
+ |
+#endif // COMPONENTS_ARC_TRACE_ARC_TRACE_BRIDGE_H_ |