Chromium Code Reviews| Index: chrome/browser/chromeos/arc/tracing/arc_tracing_bridge.h |
| diff --git a/chrome/browser/chromeos/arc/tracing/arc_tracing_bridge.h b/chrome/browser/chromeos/arc/tracing/arc_tracing_bridge.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..793655a2f738a946c318acaa0f2ef334004163d6 |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/arc/tracing/arc_tracing_bridge.h |
| @@ -0,0 +1,62 @@ |
| +// Copyright 2017 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_TRACING_ARC_TRACING_BRIDGE_H_ |
| +#define CHROME_BROWSER_CHROMEOS_ARC_TRACING_ARC_TRACING_BRIDGE_H_ |
| + |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "base/macros.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "base/trace_event/trace_event.h" |
| +#include "chromeos/tracing/arc_tracing_agent.h" |
| +#include "components/arc/arc_service.h" |
| +#include "components/arc/common/tracing.mojom.h" |
| +#include "components/arc/instance_holder.h" |
| + |
| +namespace arc { |
| + |
| +class ArcBridgeService; |
| + |
| +// This class provides the interface to trigger tracing in the container. |
| +class ArcTracingBridge |
| + : public ArcService, |
| + public chromeos::ArcTracingAgent::Delegate, |
| + public InstanceHolder<mojom::TracingInstance>::Observer { |
| + public: |
| + explicit ArcTracingBridge(ArcBridgeService* bridge_service); |
| + ~ArcTracingBridge() override; |
| + |
| + // InstanceHolder<mojom::TracingInstance>::Observer overrides: |
| + void OnInstanceReady() override; |
| + |
| + // chromeos::ArcTracingAgent::Delegate overrides: |
| + void StartTracing(const base::trace_event::TraceConfig& trace_config, |
| + const StartTracingCallback& callback) override; |
| + void StopTracing(const StopTracingCallback& callback) 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; |
| + }; |
| + // Callback for QueryAvailableCategories. |
| + void OnCategoriesReady(const std::vector<std::string>& categories); |
| + |
| + // List of available categories. |
| + std::vector<Category> categories_; |
| + |
| + // NOTE: Weak pointers must be invalidated before all other member variables |
| + // so it must be the last member. |
|
dcheng
2017/03/10 22:09:24
Nit: I don't think this comment is too useful (as
Earl Ou
2017/03/13 02:00:13
In my local machine, the build will still success
|
| + base::WeakPtrFactory<ArcTracingBridge> weak_ptr_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ArcTracingBridge); |
| +}; |
| + |
| +} // namespace arc |
| + |
| +#endif // CHROME_BROWSER_CHROMEOS_ARC_TRACING_ARC_TRACING_BRIDGE_H_ |