Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Side by Side Diff: content/public/browser/trace_controller.h

Issue 9694028: Add a Content API around TracingController. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix linux Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_PUBLIC_BROWSER_TRACE_CONTROLLER_H_
6 #define CONTENT_PUBLIC_BROWSER_TRACE_CONTROLLER_H_
7
8 #include "content/common/content_export.h"
9
10 namespace content {
11
12 class TraceSubscriber;
13
14 // TraceController is used on the browser processes to enable/disable
15 // trace status and collect trace data. Only the browser UI thread is allowed
16 // to interact with the TraceController object. All calls on the TraceSubscriber
17 // happen on the UI thread.
18 class TraceController {
19 public:
20 CONTENT_EXPORT static TraceController* GetInstance();
21
22 // Called by browser process to start tracing events on all processes.
23 //
24 // Currently only one subscriber is allowed at a time.
25 // Tracing begins immediately locally, and asynchronously on child processes
26 // as soon as they receive the BeginTracing request.
27 // By default, all categories are traced except those matching "test_*".
28 //
29 // If BeginTracing was already called previously,
30 // or if an EndTracingAsync is pending,
31 // or if another subscriber is tracing,
32 // BeginTracing will return false meaning it failed.
33 virtual bool BeginTracing(TraceSubscriber* subscriber) = 0;
34
35 // |categories| is a comma-delimited list of category wildcards.
36 // A category can have an optional '-' prefix to make it an excluded category.
37 // All the same rules apply above, so for example, having both included and
38 // excluded categories in the same list would not be supported.
39 //
40 // Example: BeginTracing("test_MyTest*");
41 // Example: BeginTracing("test_MyTest*,test_OtherStuff");
42 // Example: BeginTracing("-excluded_category1,-excluded_category2");
43 virtual bool BeginTracing(TraceSubscriber* subscriber,
44 const std::string& categories) = 0;
45
46 // Called by browser process to stop tracing events on all processes.
47 //
48 // Child processes typically are caching trace data and only rarely flush
49 // and send trace data back to the browser process. That is because it may be
50 // an expensive operation to send the trace data over IPC, and we would like
51 // to avoid much runtime overhead of tracing. So, to end tracing, we must
52 // asynchronously ask all child processes to flush any pending trace data.
53 //
54 // Once all child processes have acked the EndTracing request,
55 // TraceSubscriber will be called with OnEndTracingComplete.
56 //
57 // If a previous call to EndTracingAsync is already pending,
58 // or if another subscriber is tracing,
59 // EndTracingAsync will return false meaning it failed.
60 virtual bool EndTracingAsync(TraceSubscriber* subscriber) = 0;
61
62 // Get the maximum across processes of trace buffer percent full state.
63 // When the TraceBufferPercentFull value is determined,
64 // subscriber->OnTraceBufferPercentFullReply is called.
65 // When any child process reaches 100% full, the TraceController will end
66 // tracing, and call TraceSubscriber::OnEndTracingComplete.
67 // GetTraceBufferPercentFullAsync fails in the following conditions:
68 // trace is ending or disabled;
69 // a previous call to GetTraceBufferPercentFullAsync is pending; or
70 // the caller is not the current subscriber.
71 virtual bool GetTraceBufferPercentFullAsync(TraceSubscriber* subscriber) = 0;
72
73 // Cancel the subscriber so that it will not be called when EndTracingAsync is
74 // acked by all child processes. This will also call EndTracingAsync
75 // internally if necessary.
76 // Safe to call even if caller is not the current subscriber.
77 virtual void CancelSubscriber(TraceSubscriber* subscriber) = 0;
78
79 protected:
80 virtual ~TraceController() {}
81 };
82
83 } // namespace content
84
85 #endif // CONTENT_PUBLIC_BROWSER_TRACE_CONTROLLER_H_
86
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698