| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_PUBLIC_BROWSER_BACKGROUND_TRACING_MANAGER_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_BACKGROUND_TRACING_MANAGER_H_ |
| 6 #define CONTENT_PUBLIC_BROWSER_BACKGROUND_TRACING_MANAGER_H_ | 6 #define CONTENT_PUBLIC_BROWSER_BACKGROUND_TRACING_MANAGER_H_ |
| 7 | 7 |
| 8 #include "base/trace_event/trace_event_impl.h" | 8 #include "base/trace_event/trace_event_impl.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
| 11 | 11 |
| 12 namespace content { | 12 namespace content { |
| 13 struct BackgroundTracingConfig; | 13 struct BackgroundTracingConfig; |
| 14 struct BackgroundTracingUploadConfig; | 14 struct BackgroundTracingUploadConfig; |
| 15 | 15 |
| 16 // BackgroundTracingManager is used on the browser process to trigger the | 16 // BackgroundTracingManager is used on the browser process to trigger the |
| 17 // collection of trace data and upload the results. Only the browser UI thread | 17 // collection of trace data and upload the results. Only the browser UI thread |
| 18 // is allowed to interact with the BackgroundTracingManager. All callbacks are | 18 // is allowed to interact with the BackgroundTracingManager. All callbacks are |
| 19 // called on the UI thread. | 19 // called on the UI thread. |
| 20 class BackgroundTracingManager { | 20 class BackgroundTracingManager { |
| 21 public: | 21 public: |
| 22 CONTENT_EXPORT static BackgroundTracingManager* GetInstance(); | 22 CONTENT_EXPORT static BackgroundTracingManager* GetInstance(); |
| 23 | 23 |
| 24 // ReceiveCallback will will be called on the UI thread every time the | 24 // ReceiveCallback will will be called on the UI thread every time the |
| 25 // BackgroundTracingManager finalizes a trace. The first parameter of | 25 // BackgroundTracingManager finalizes a trace. The first parameter of |
| 26 // this callback is the trace data. The second is a callback to | 26 // this callback is the trace data. The second is metadata that was |
| 27 // generated and embedded into the trace. The third is a callback to |
| 27 // notify the BackgroundTracingManager that you've finished processing | 28 // notify the BackgroundTracingManager that you've finished processing |
| 28 // the trace data. | 29 // the trace data. |
| 29 // | 30 // |
| 30 // Example: | 31 // Example: |
| 31 // | 32 // |
| 32 // void Upload(const base::RefCountedString* data, | 33 // void Upload(const scoped_refptr<base::RefCountedString>& data, |
| 34 // scoped_ptr<base::DictionaryValue>, |
| 33 // base::Closure done_callback) { | 35 // base::Closure done_callback) { |
| 34 // BrowserThread::PostTaskAndReply( | 36 // BrowserThread::PostTaskAndReply( |
| 35 // BrowserThread::FILE, | 37 // BrowserThread::FILE, |
| 36 // FROM_HERE, | 38 // FROM_HERE, |
| 37 // base::Bind(&DoUploadOnFileThread, data), | 39 // base::Bind(&DoUploadOnFileThread, data), |
| 38 // done_callback | 40 // done_callback |
| 39 // ); | 41 // ); |
| 40 // } | 42 // } |
| 41 // | 43 // |
| 42 typedef base::Callback<void(const scoped_refptr<base::RefCountedString>&, | 44 typedef base::Callback<void(const scoped_refptr<base::RefCountedString>&, |
| 45 scoped_ptr<base::DictionaryValue>, |
| 43 base::Closure)> ReceiveCallback; | 46 base::Closure)> ReceiveCallback; |
| 44 | 47 |
| 45 // Set the triggering rules for when to start recording. | 48 // Set the triggering rules for when to start recording. |
| 46 // | 49 // |
| 47 // In preemptive mode, recording begins immediately and any calls to | 50 // In preemptive mode, recording begins immediately and any calls to |
| 48 // TriggerNamedEvent() will potentially trigger the trace to finalize and get | 51 // TriggerNamedEvent() will potentially trigger the trace to finalize and get |
| 49 // uploaded to the specified upload_sink. Once the trace has been uploaded, | 52 // uploaded to the specified upload_sink. Once the trace has been uploaded, |
| 50 // tracing will be enabled again. | 53 // tracing will be enabled again. |
| 51 // | 54 // |
| 52 // In reactive mode, recording begins when TriggerNamedEvent() is called, and | 55 // In reactive mode, recording begins when TriggerNamedEvent() is called, and |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 const base::Closure& callback) = 0; | 95 const base::Closure& callback) = 0; |
| 93 virtual void FireTimerForTesting() = 0; | 96 virtual void FireTimerForTesting() = 0; |
| 94 | 97 |
| 95 protected: | 98 protected: |
| 96 virtual ~BackgroundTracingManager() {} | 99 virtual ~BackgroundTracingManager() {} |
| 97 }; | 100 }; |
| 98 | 101 |
| 99 } // namespace content | 102 } // namespace content |
| 100 | 103 |
| 101 #endif // CONTENT_PUBLIC_BROWSER_BACKGROUND_TRACING_MANAGER_H_ | 104 #endif // CONTENT_PUBLIC_BROWSER_BACKGROUND_TRACING_MANAGER_H_ |
| OLD | NEW |