Chromium Code Reviews| Index: chrome/browser/chromeos/arc/trace/arc_trace_bridge.h |
| diff --git a/chrome/browser/chromeos/arc/trace/arc_trace_bridge.h b/chrome/browser/chromeos/arc/trace/arc_trace_bridge.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a2939ff09eb1529bf208c819c42a5b71223e794c |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/arc/trace/arc_trace_bridge.h |
| @@ -0,0 +1,75 @@ |
| +// 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 CHROME_BROWSER_CHROMEOS_ARC_TRACE_ARC_TRACE_BRIDGE_H_ |
| +#define CHROME_BROWSER_CHROMEOS_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 "chromeos/dbus/arc_trace_agent.h" |
| +#include "components/arc/arc_service.h" |
| +#include "components/arc/common/trace.mojom.h" |
| +#include "components/arc/instance_holder.h" |
| + |
| +namespace arc { |
| + |
| +class ArcBridgeService; |
| + |
| +// This class provides the interface to trigger tracing in the container. |
| +class ArcTraceBridge : public ArcService, |
| + public chromeos::ArcTraceAgent::ArcTraceBridge, |
| + public InstanceHolder<mojom::TraceInstance>::Observer { |
| + public: |
| + // Gets the singleton of this class. |
| + static ArcTraceBridge* Get(); |
| + |
| + explicit ArcTraceBridge(ArcBridgeService* bridge_service); |
| + ~ArcTraceBridge() override; |
| + |
| + // InstanceHolder<mojom::TraceInstance>::Observer overrides: |
| + void OnInstanceReady() override; |
| + |
| + 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; |
| + }; |
| + // Query the available categories for tracing. |
| + void QueryAvailableCategories(); |
| + |
| + // Callback for QueryAvailableCategories. |
| + void OnCategoriesReady(const std::vector<std::string>& categories); |
| + |
| + // Callback for StartTracing. |
| + void OnTraceStart(bool success); |
| + |
| + // Callback for StopTracing. |
| + void OnTraceStop(bool success); |
| + |
| + virtual void StartTracing( |
|
Luis Héctor Chávez
2016/12/27 19:15:58
These two functions are overriden, so they should
shunhsingou
2016/12/28 09:15:15
Done.
|
| + const base::trace_event::TraceConfig& trace_config); |
| + |
| + virtual void StopTracing(); |
| + |
| + base::ThreadChecker thread_checker_; |
|
Luis Héctor Chávez
2016/12/27 19:15:58
Since you are in chrome/browser/chromeos, the pref
shunhsingou
2016/12/28 09:15:15
Done.
|
| + |
| + // List of available categories. |
| + std::vector<Category> categories_; |
| + |
| + base::WeakPtrFactory<ArcTraceBridge> weak_ptr_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ArcTraceBridge); |
| +}; |
| + |
| +} // namespace arc |
| + |
| +#endif // CHROME_BROWSER_CHROMEOS_ARC_TRACE_ARC_TRACE_BRIDGE_H_ |