| 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 CONTENT_BROWSER_TRACING_ARC_TRACING_AGENT_H_ | 5 #ifndef CONTENT_BROWSER_TRACING_ARC_TRACING_AGENT_H_ |
| 6 #define CONTENT_BROWSER_TRACING_ARC_TRACING_AGENT_H_ | 6 #define CONTENT_BROWSER_TRACING_ARC_TRACING_AGENT_H_ |
| 7 | 7 |
| 8 #include "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
| 9 #include "base/files/scoped_file.h" |
| 9 #include "base/macros.h" | 10 #include "base/macros.h" |
| 10 #include "base/trace_event/trace_event.h" | 11 #include "base/trace_event/trace_event.h" |
| 11 #include "base/trace_event/tracing_agent.h" | 12 #include "base/trace_event/tracing_agent.h" |
| 12 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
| 13 | 14 |
| 14 namespace content { | 15 namespace content { |
| 15 | 16 |
| 16 // A wrapper for controlling tracing in ARC container. | 17 // A wrapper for controlling tracing in ARC container. |
| 17 // The overriden Stop/StartAgentTracing functions are implemented by the | 18 // The overriden Stop/StartAgentTracing functions are implemented by the |
| 18 // Delegate object to interact with ARC bridge. All the functions are expected | 19 // Delegate object to interact with ARC bridge. All the functions are expected |
| 19 // to be called on the browser's UI thread. | 20 // to be called on the browser's UI thread. |
| 20 class CONTENT_EXPORT ArcTracingAgent : public base::trace_event::TracingAgent { | 21 class CONTENT_EXPORT ArcTracingAgent : public base::trace_event::TracingAgent { |
| 21 public: | 22 public: |
| 22 class Delegate { | 23 class Delegate { |
| 23 public: | 24 public: |
| 24 // Callback for StartTracing, takes one boolean argument to indicate | 25 // Callback for StartTracing, takes one boolean argument to indicate |
| 25 // success or failure. | 26 // success or failure. |
| 26 using StartTracingCallback = base::Callback<void(bool)>; | 27 using StartTracingCallback = base::Callback<void(bool)>; |
| 27 // Callback for StopTracing, takes one boolean argument to indicate | 28 // Callback for StopTracing, takes one boolean argument to indicate |
| 28 // success or failure. | 29 // success or failure. |
| 29 using StopTracingCallback = base::Callback<void(bool)>; | 30 using StopTracingCallback = base::Callback<void(bool)>; |
| 30 | 31 |
| 31 virtual ~Delegate(); | 32 virtual ~Delegate(); |
| 32 | 33 |
| 33 // Starts tracing in ARC container. | 34 // Starts tracing in ARC container. |
| 34 virtual void StartTracing( | 35 virtual void StartTracing( |
| 35 const base::trace_event::TraceConfig& trace_config, | 36 const base::trace_event::TraceConfig& trace_config, |
| 37 base::ScopedFD write_fd, |
| 36 const StartTracingCallback& callback) = 0; | 38 const StartTracingCallback& callback) = 0; |
| 37 | 39 |
| 38 // Stops tracing in ARC container. | 40 // Stops tracing in ARC container. |
| 39 virtual void StopTracing(const StopTracingCallback& callback) = 0; | 41 virtual void StopTracing(const StopTracingCallback& callback) = 0; |
| 40 }; | 42 }; |
| 41 | 43 |
| 42 ArcTracingAgent(); | 44 ArcTracingAgent(); |
| 43 ~ArcTracingAgent() override; | 45 ~ArcTracingAgent() override; |
| 44 | 46 |
| 45 static ArcTracingAgent* GetInstance(); | 47 static ArcTracingAgent* GetInstance(); |
| 46 | 48 |
| 47 // Sets Delegate instance, which should implement the communication | 49 // Sets Delegate instance, which should implement the communication |
| 48 // using ARC bridge. If set to nullptr, calling of Start/StopAgentTracing | 50 // using ARC bridge. If set to nullptr, calling of Start/StopAgentTracing |
| 49 // does nothing. Ownership of |delegate| remains with the caller. | 51 // does nothing. Ownership of |delegate| remains with the caller. |
| 50 virtual void SetDelegate(Delegate* delegate) = 0; | 52 virtual void SetDelegate(Delegate* delegate) = 0; |
| 51 | 53 |
| 52 private: | 54 private: |
| 53 DISALLOW_COPY_AND_ASSIGN(ArcTracingAgent); | 55 DISALLOW_COPY_AND_ASSIGN(ArcTracingAgent); |
| 54 }; | 56 }; |
| 55 | 57 |
| 56 } // namespace content | 58 } // namespace content |
| 57 | 59 |
| 58 #endif // CONTENT_BROWSER_TRACING_ARC_TRACING_AGENT_H_ | 60 #endif // CONTENT_BROWSER_TRACING_ARC_TRACING_AGENT_H_ |
| OLD | NEW |