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

Unified Diff: content/browser/trace_controller_impl.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 side-by-side diff with in-line comments
Download patch
Index: content/browser/trace_controller_impl.h
===================================================================
--- content/browser/trace_controller_impl.h (revision 126271)
+++ content/browser/trace_controller_impl.h (working copy)
@@ -2,49 +2,25 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CONTENT_BROWSER_TRACE_CONTROLLER_H_
-#define CONTENT_BROWSER_TRACE_CONTROLLER_H_
+#ifndef CONTENT_BROWSER_TRACE_CONTROLLER_IMPL_H_
+#define CONTENT_BROWSER_TRACE_CONTROLLER_IMPL_H_
#include <set>
#include <string>
#include <vector>
#include "base/debug/trace_event.h"
-#include "base/memory/ref_counted_memory.h"
#include "base/memory/singleton.h"
-#include "content/common/content_export.h"
+#include "content/public/browser/trace_controller.h"
class CommandLine;
class TraceMessageFilter;
-// Objects interested in receiving trace data derive from TraceSubscriber.
-// See also: trace_message_filter.h
-// See also: child_trace_message_filter.h
-class CONTENT_EXPORT TraceSubscriber {
- public:
- // Called once after TraceController::EndTracingAsync.
- virtual void OnEndTracingComplete() = 0;
- // Called 0 or more times between TraceController::BeginTracing and
- // OnEndTracingComplete. Use base::debug::TraceResultBuffer to convert one or
- // more trace fragments to JSON.
- virtual void OnTraceDataCollected(
- const scoped_refptr<base::RefCountedString>& trace_fragment) = 0;
- // Called once after TraceController::GetKnownCategoriesAsync.
- virtual void OnKnownCategoriesCollected(
- const std::set<std::string>& known_categories);
- virtual void OnTraceBufferPercentFullReply(float percent_full);
+namespace content {
- protected:
- virtual ~TraceSubscriber();
-};
-
-// TraceController is used on the browser processes to enable/disable
-// trace status and collect trace data. Only the browser UI thread is allowed
-// to interact with the TraceController object. All calls on the TraceSubscriber
-// happen on the UI thread.
-class CONTENT_EXPORT TraceController {
+class TraceControllerImpl : public TraceController {
public:
- static TraceController* GetInstance();
+ static TraceControllerImpl* GetInstance();
// Called on the main thread of the browser process to initialize
// startup tracing.
@@ -55,19 +31,6 @@
// when once the categories are retrieved from child processes.
bool GetKnownCategoriesAsync(TraceSubscriber* subscriber);
- // Called by browser process to start tracing events on all processes.
- //
- // Currently only one subscriber is allowed at a time.
- // Tracing begins immediately locally, and asynchronously on child processes
- // as soon as they receive the BeginTracing request.
- // By default, all categories are traced except those matching "test_*".
- //
- // If BeginTracing was already called previously,
- // or if an EndTracingAsync is pending,
- // or if another subscriber is tracing,
- // BeginTracing will return false meaning it failed.
- bool BeginTracing(TraceSubscriber* subscriber);
-
// Same as above, but specifies which categories to trace.
// If both included_categories and excluded_categories are empty,
// all categories are traced.
@@ -77,57 +40,23 @@
const std::vector<std::string>& included_categories,
const std::vector<std::string>& excluded_categories);
- // |categories| is a comma-delimited list of category wildcards.
- // A category can have an optional '-' prefix to make it an excluded category.
- // All the same rules apply above, so for example, having both included and
- // excluded categories in the same list would not be supported.
- //
- // Example: BeginTracing("test_MyTest*");
- // Example: BeginTracing("test_MyTest*,test_OtherStuff");
- // Example: BeginTracing("-excluded_category1,-excluded_category2");
- bool BeginTracing(TraceSubscriber* subscriber, const std::string& categories);
+ // TraceController implementation:
+ virtual bool BeginTracing(TraceSubscriber* subscriber) OVERRIDE;
+ virtual bool BeginTracing(TraceSubscriber* subscriber,
+ const std::string& categories) OVERRIDE;
+ virtual bool EndTracingAsync(TraceSubscriber* subscriber) OVERRIDE;
+ virtual bool GetTraceBufferPercentFullAsync(
+ TraceSubscriber* subscriber) OVERRIDE;
+ virtual void CancelSubscriber(TraceSubscriber* subscriber) OVERRIDE;
- // Called by browser process to stop tracing events on all processes.
- //
- // Child processes typically are caching trace data and only rarely flush
- // and send trace data back to the browser process. That is because it may be
- // an expensive operation to send the trace data over IPC, and we would like
- // to avoid much runtime overhead of tracing. So, to end tracing, we must
- // asynchronously ask all child processes to flush any pending trace data.
- //
- // Once all child processes have acked the EndTracing request,
- // TraceSubscriber will be called with OnEndTracingComplete.
- //
- // If a previous call to EndTracingAsync is already pending,
- // or if another subscriber is tracing,
- // EndTracingAsync will return false meaning it failed.
- bool EndTracingAsync(TraceSubscriber* subscriber);
-
- // Get the maximum across processes of trace buffer percent full state.
- // When the TraceBufferPercentFull value is determined,
- // subscriber->OnTraceBufferPercentFullReply is called.
- // When any child process reaches 100% full, the TraceController will end
- // tracing, and call TraceSubscriber::OnEndTracingComplete.
- // GetTraceBufferPercentFullAsync fails in the following conditions:
- // trace is ending or disabled;
- // a previous call to GetTraceBufferPercentFullAsync is pending; or
- // the caller is not the current subscriber.
- bool GetTraceBufferPercentFullAsync(TraceSubscriber* subscriber);
-
- // Cancel the subscriber so that it will not be called when EndTracingAsync is
- // acked by all child processes. This will also call EndTracingAsync
- // internally if necessary.
- // Safe to call even if caller is not the current subscriber.
- void CancelSubscriber(TraceSubscriber* subscriber);
-
private:
typedef std::set<scoped_refptr<TraceMessageFilter> > FilterMap;
- friend struct DefaultSingletonTraits<TraceController>;
- friend class TraceMessageFilter;
+ friend struct DefaultSingletonTraits<TraceControllerImpl>;
+ friend class ::TraceMessageFilter;
- TraceController();
- ~TraceController();
+ TraceControllerImpl();
+ virtual ~TraceControllerImpl();
bool is_tracing_enabled() const {
return can_end_tracing();
@@ -173,8 +102,10 @@
std::vector<std::string> included_categories_;
std::vector<std::string> excluded_categories_;
- DISALLOW_COPY_AND_ASSIGN(TraceController);
+ DISALLOW_COPY_AND_ASSIGN(TraceControllerImpl);
};
-#endif // CONTENT_BROWSER_TRACE_CONTROLLER_H_
+} // namespace content
+#endif // CONTENT_BROWSER_TRACE_CONTROLLER_IMPL_H_
+

Powered by Google App Engine
This is Rietveld 408576698