| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_ARC_TRACING_ARC_TRACING_BRIDGE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_ARC_TRACING_ARC_TRACING_BRIDGE_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_ARC_TRACING_ARC_TRACING_BRIDGE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_ARC_TRACING_ARC_TRACING_BRIDGE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/files/scoped_file.h" |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 13 #include "base/trace_event/trace_event.h" | 14 #include "base/trace_event/trace_event.h" |
| 14 #include "components/arc/arc_service.h" | 15 #include "components/arc/arc_service.h" |
| 15 #include "components/arc/common/tracing.mojom.h" | 16 #include "components/arc/common/tracing.mojom.h" |
| 16 #include "components/arc/instance_holder.h" | 17 #include "components/arc/instance_holder.h" |
| 17 #include "content/browser/tracing/arc_tracing_agent.h" | 18 #include "content/browser/tracing/arc_tracing_agent.h" |
| 18 | 19 |
| 19 namespace arc { | 20 namespace arc { |
| 20 | 21 |
| 21 class ArcBridgeService; | 22 class ArcBridgeService; |
| 22 | 23 |
| 23 // This class provides the interface to trigger tracing in the container. | 24 // This class provides the interface to trigger tracing in the container. |
| 24 class ArcTracingBridge | 25 class ArcTracingBridge |
| 25 : public ArcService, | 26 : public ArcService, |
| 26 public content::ArcTracingAgent::Delegate, | 27 public content::ArcTracingAgent::Delegate, |
| 27 public InstanceHolder<mojom::TracingInstance>::Observer { | 28 public InstanceHolder<mojom::TracingInstance>::Observer { |
| 28 public: | 29 public: |
| 29 explicit ArcTracingBridge(ArcBridgeService* bridge_service); | 30 explicit ArcTracingBridge(ArcBridgeService* bridge_service); |
| 30 ~ArcTracingBridge() override; | 31 ~ArcTracingBridge() override; |
| 31 | 32 |
| 32 // InstanceHolder<mojom::TracingInstance>::Observer overrides: | 33 // InstanceHolder<mojom::TracingInstance>::Observer overrides: |
| 33 void OnInstanceReady() override; | 34 void OnInstanceReady() override; |
| 34 | 35 |
| 35 // content::ArcTracingAgent::Delegate overrides: | 36 // content::ArcTracingAgent::Delegate overrides: |
| 36 void StartTracing(const base::trace_event::TraceConfig& trace_config, | 37 void StartTracing(const base::trace_event::TraceConfig& trace_config, |
| 38 base::ScopedFD write_fd, |
| 37 const StartTracingCallback& callback) override; | 39 const StartTracingCallback& callback) override; |
| 38 void StopTracing(const StopTracingCallback& callback) override; | 40 void StopTracing(const StopTracingCallback& callback) override; |
| 39 | 41 |
| 40 private: | 42 private: |
| 41 struct Category; | 43 struct Category; |
| 42 | 44 |
| 43 // Callback for QueryAvailableCategories. | 45 // Callback for QueryAvailableCategories. |
| 44 void OnCategoriesReady(const std::vector<std::string>& categories); | 46 void OnCategoriesReady(const std::vector<std::string>& categories); |
| 45 | 47 |
| 46 // List of available categories. | 48 // List of available categories. |
| 47 std::vector<Category> categories_; | 49 std::vector<Category> categories_; |
| 48 | 50 |
| 49 // NOTE: Weak pointers must be invalidated before all other member variables | 51 // NOTE: Weak pointers must be invalidated before all other member variables |
| 50 // so it must be the last member. | 52 // so it must be the last member. |
| 51 base::WeakPtrFactory<ArcTracingBridge> weak_ptr_factory_; | 53 base::WeakPtrFactory<ArcTracingBridge> weak_ptr_factory_; |
| 52 | 54 |
| 53 DISALLOW_COPY_AND_ASSIGN(ArcTracingBridge); | 55 DISALLOW_COPY_AND_ASSIGN(ArcTracingBridge); |
| 54 }; | 56 }; |
| 55 | 57 |
| 56 } // namespace arc | 58 } // namespace arc |
| 57 | 59 |
| 58 #endif // CHROME_BROWSER_CHROMEOS_ARC_TRACING_ARC_TRACING_BRIDGE_H_ | 60 #endif // CHROME_BROWSER_CHROMEOS_ARC_TRACING_ARC_TRACING_BRIDGE_H_ |
| OLD | NEW |