summaryrefslogtreecommitdiffstats
path: root/content/public
diff options
context:
space:
mode:
authorwangxianzhu@chromium.org <wangxianzhu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-03 17:31:35 +0000
committerwangxianzhu@chromium.org <wangxianzhu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-03 17:31:35 +0000
commitcece099151206e8e1c4d1166dad86c71d3092f1e (patch)
treec7017f288471d6c0836d7042d1a0046cfdd0859d /content/public
parent02c6ab4dd16ffd395b67f76baac4a2e3ecaa5b52 (diff)
downloadchromium_src-cece099151206e8e1c4d1166dad86c71d3092f1e.zip
chromium_src-cece099151206e8e1c4d1166dad86c71d3092f1e.tar.gz
chromium_src-cece099151206e8e1c4d1166dad86c71d3092f1e.tar.bz2
Revert of https://codereview.chromium.org/99103004/
Reason for revert: Bug 323749 still unresolved TBR= NOTREECHECKS=true NOTRY=true Review URL: https://codereview.chromium.org/101543004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238424 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/public')
-rw-r--r--content/public/browser/trace_controller.h107
-rw-r--r--content/public/browser/trace_subscriber.h43
-rw-r--r--content/public/browser/tracing_controller.h35
3 files changed, 160 insertions, 25 deletions
diff --git a/content/public/browser/trace_controller.h b/content/public/browser/trace_controller.h
new file mode 100644
index 0000000..dee5f91
--- /dev/null
+++ b/content/public/browser/trace_controller.h
@@ -0,0 +1,107 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_PUBLIC_BROWSER_TRACE_CONTROLLER_H_
+#define CONTENT_PUBLIC_BROWSER_TRACE_CONTROLLER_H_
+
+#include "base/debug/trace_event.h"
+#include "content/common/content_export.h"
+
+namespace content {
+
+class TraceSubscriber;
+
+// Note: TraceController is going to be deprecated and replaced with
+// TracingController.
+//
+// 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 TraceController {
+ public:
+ CONTENT_EXPORT static TraceController* GetInstance();
+
+ // 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.
+ //
+ // 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.
+ //
+ // |category_patterns| is a comma-delimited list of category wildcards.
+ // A category pattern can have an optional '-' prefix to exclude category
+ // groups that contain a matching category.
+ // All the same rules apply above, so for example, having both included and
+ // excluded category patterns in the same list would not be supported.
+ //
+ // |mode| is the tracing mode being used.
+ //
+ // Example: BeginTracing("test_MyTest*");
+ // Example: BeginTracing("test_MyTest*,test_OtherStuff");
+ // Example: BeginTracing("-excluded_category1,-excluded_category2");
+ virtual bool BeginTracing(TraceSubscriber* subscriber,
+ const std::string& category_patterns,
+ base::debug::TraceLog::Options options) = 0;
+
+ // 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.
+ virtual bool EndTracingAsync(TraceSubscriber* subscriber) = 0;
+
+ // 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.
+ virtual bool GetTraceBufferPercentFullAsync(TraceSubscriber* subscriber) = 0;
+
+ // |subscriber->OnEventWatchNotification()| will be called every time the
+ // given event occurs on any process.
+ virtual bool SetWatchEvent(TraceSubscriber* subscriber,
+ const std::string& category_name,
+ const std::string& event_name) = 0;
+
+ // Cancel the watch event. If tracing is enabled, this may race with the
+ // watch event notification firing.
+ virtual bool CancelWatchEvent(TraceSubscriber* subscriber) = 0;
+
+ // 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.
+ virtual void CancelSubscriber(TraceSubscriber* subscriber) = 0;
+
+ // Get set of known category groups. This can change as new code paths are
+ // reached. If true is returned, subscriber->OnKnownCategoriesCollected will
+ // be called once the categories are retrieved from child processes.
+ virtual bool GetKnownCategoryGroupsAsync(TraceSubscriber* subscriber) = 0;
+
+ protected:
+ virtual ~TraceController() {}
+};
+
+} // namespace content
+
+#endif // CONTENT_PUBLIC_BROWSER_TRACE_CONTROLLER_H_
+
diff --git a/content/public/browser/trace_subscriber.h b/content/public/browser/trace_subscriber.h
new file mode 100644
index 0000000..b8a7850
--- /dev/null
+++ b/content/public/browser/trace_subscriber.h
@@ -0,0 +1,43 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_PUBLIC_BROWSER_TRACE_SUBSCRIBER_H_
+#define CONTENT_PUBLIC_BROWSER_TRACE_SUBSCRIBER_H_
+
+#include <set>
+
+#include "base/memory/ref_counted_memory.h"
+
+namespace content {
+
+// Objects interested in receiving trace data derive from TraceSubscriber. All
+// callbacks occur on the UI thread.
+// See also: trace_message_filter.h
+// See also: child_trace_message_filter.h
+class TraceSubscriber {
+ public:
+ // Called once after TraceController::EndTracingAsync.
+ virtual void OnEndTracingComplete() {}
+
+ // 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::GetKnownCategoryGroupsAsync.
+ virtual void OnKnownCategoriesCollected(
+ const std::set<std::string>& known_categories) {}
+
+ virtual void OnTraceBufferPercentFullReply(float percent_full) {}
+
+ virtual void OnEventWatchNotification() {}
+
+ protected:
+ virtual ~TraceSubscriber() {}
+};
+
+} // namespace content
+
+#endif // CONTENT_PUBLIC_BROWSER_TRACE_SUBSCRIBER_H_
diff --git a/content/public/browser/tracing_controller.h b/content/public/browser/tracing_controller.h
index 68184a5..ae46199 100644
--- a/content/public/browser/tracing_controller.h
+++ b/content/public/browser/tracing_controller.h
@@ -6,9 +6,8 @@
#define CONTENT_PUBLIC_BROWSER_TRACING_CONTROLLER_H_
#include <set>
-#include <string>
-#include "base/callback.h"
+#include "base/debug/trace_event.h"
#include "content/common/content_export.h"
namespace base {
@@ -26,7 +25,6 @@ class TracingController;
class TracingController {
public:
enum Options {
- DEFAULT_OPTIONS = 0,
ENABLE_SYSTRACE = 1 << 0,
ENABLE_SAMPLING = 1 << 1,
RECORD_CONTINUOUSLY = 1 << 2, // For EnableRecording() only.
@@ -42,7 +40,7 @@ class TracingController {
// groups.
typedef base::Callback<void(const std::set<std::string>&)>
GetCategoriesDoneCallback;
- virtual bool GetCategories(
+ virtual void GetCategories(
const GetCategoriesDoneCallback& callback) = 0;
// Start recording on all processes.
@@ -53,8 +51,8 @@ class TracingController {
// Once all child processes have acked to the EnableRecording request,
// EnableRecordingDoneCallback will be called back.
//
- // |category_filter| is a filter to control what category groups should be
- // traced. A filter can have an optional '-' prefix to exclude category groups
+ // |filter| is a filter to control what category groups should be traced.
+ // A filter can have an optional '-' prefix to exclude category groups
// that contain a matching category. Having both included and excluded
// category patterns in the same list would not be supported.
//
@@ -65,7 +63,7 @@ class TracingController {
// |options| controls what kind of tracing is enabled.
typedef base::Callback<void()> EnableRecordingDoneCallback;
virtual bool EnableRecording(
- const std::string& category_filter,
+ const base::debug::CategoryFilter& filter,
TracingController::Options options,
const EnableRecordingDoneCallback& callback) = 0;
@@ -99,13 +97,11 @@ class TracingController {
// Once all child processes have acked to the EnableMonitoring request,
// EnableMonitoringDoneCallback will be called back.
//
- // |category_filter| is a filter to control what category groups should be
- // traced.
+ // |filter| is a filter to control what category groups should be traced.
//
// |options| controls what kind of tracing is enabled.
typedef base::Callback<void()> EnableMonitoringDoneCallback;
- virtual bool EnableMonitoring(
- const std::string& category_filter,
+ virtual bool EnableMonitoring(const base::debug::CategoryFilter& filter,
TracingController::Options options,
const EnableMonitoringDoneCallback& callback) = 0;
@@ -119,8 +115,8 @@ class TracingController {
// Get the current monitoring configuration.
virtual void GetMonitoringStatus(bool* out_enabled,
- std::string* out_category_filter,
- TracingController::Options* out_options) = 0;
+ base::debug::CategoryFilter* out_filter,
+ TracingController::Options* out_options) = 0;
// Get the current monitoring traced data.
//
@@ -139,7 +135,7 @@ class TracingController {
//
// If |result_file_path| is empty and |callback| is null, trace data won't be
// written to any file.
- virtual bool CaptureMonitoringSnapshot(
+ virtual void CaptureMonitoringSnapshot(
const base::FilePath& result_file_path,
const TracingFileResultCallback& callback) = 0;
@@ -150,17 +146,6 @@ class TracingController {
virtual bool GetTraceBufferPercentFull(
const GetTraceBufferPercentFullCallback& callback) = 0;
- // |callback| will will be called every time the given event occurs on any
- // process.
- typedef base::Callback<void()> WatchEventCallback;
- virtual bool SetWatchEvent(const std::string& category_name,
- const std::string& event_name,
- const WatchEventCallback& callback) = 0;
-
- // Cancel the watch event. If tracing is enabled, this may race with the
- // watch event callback.
- virtual bool CancelWatchEvent() = 0;
-
protected:
virtual ~TracingController() {}
};