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