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

Unified Diff: content/browser/tracing/background_tracing_manager_impl.h

Issue 1089253003: Re-land first pass BackgroundTracingManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Scoped_ptr Created 5 years, 7 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/tracing/background_tracing_manager_impl.h
diff --git a/content/browser/tracing/background_tracing_manager_impl.h b/content/browser/tracing/background_tracing_manager_impl.h
new file mode 100644
index 0000000000000000000000000000000000000000..fd1fd00ad9e4fe147d0861e37c1327448ab6b53b
--- /dev/null
+++ b/content/browser/tracing/background_tracing_manager_impl.h
@@ -0,0 +1,85 @@
+// Copyright 2015 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_BROWSER_TRACING_BACKGROUND_TRACING_MANAGER_IMPL_H_
+#define CONTENT_BROWSER_TRACING_BACKGROUND_TRACING_MANAGER_IMPL_H_
+
+#include "base/lazy_instance.h"
+#include "base/memory/ref_counted_memory.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "content/browser/tracing/tracing_controller_impl.h"
+#include "content/public/browser/background_tracing_config.h"
+#include "content/public/browser/background_tracing_manager.h"
+
+namespace content {
+
+class BackgroundTracingManagerImpl : public content::BackgroundTracingManager {
+ public:
+ static BackgroundTracingManagerImpl* GetInstance();
+
+ bool SetActiveScenario(scoped_ptr<BackgroundTracingConfig>,
+ const ReceiveCallback&,
+ bool) override;
+ void WhenIdle(IdleCallback idle_callback) override;
+
+ void TriggerNamedEvent(TriggerHandle, StartedFinalizingCallback) override;
+ TriggerHandle RegisterTriggerType(const char* trigger_name) override;
+ void GetTriggerNameList(std::vector<std::string>* trigger_names) override;
+
+ void InvalidateTriggerHandlesForTesting() override;
+
+ private:
+ BackgroundTracingManagerImpl();
+ ~BackgroundTracingManagerImpl() override;
+
+ void EnableRecording(base::trace_event::CategoryFilter);
+ void EnableRecordingIfConfigNeedsIt();
+ void OnFinalizeStarted(scoped_refptr<base::RefCountedString>);
+ void OnFinalizeComplete();
+ void BeginFinalizing(StartedFinalizingCallback);
+
+ std::string GetTriggerNameFromHandle(TriggerHandle handle) const;
+ bool IsTriggerHandleValid(TriggerHandle handle) const;
+
+ bool IsAbleToTriggerTracing(TriggerHandle handle) const;
+ bool IsSupportedConfig(BackgroundTracingConfig* config);
+
+ base::trace_event::CategoryFilter GetCategoryFilterForCategoryPreset(
+ BackgroundTracingConfig::CategoryPreset) const;
+
+ class TraceDataEndpointWrapper
+ : public content::TracingController::TraceDataEndpoint {
+ public:
+ TraceDataEndpointWrapper(base::Callback<
+ void(scoped_refptr<base::RefCountedString>)> done_callback);
+
+ void ReceiveTraceFinalContents(const std::string& file_contents) override;
+
+ private:
+ ~TraceDataEndpointWrapper() override;
+
+ base::Callback<void(scoped_refptr<base::RefCountedString>)> done_callback_;
+ };
+
+ scoped_ptr<content::BackgroundTracingConfig> config_;
+ scoped_refptr<TraceDataEndpointWrapper> data_endpoint_wrapper_;
+ std::map<TriggerHandle, std::string> trigger_handles_;
+ ReceiveCallback receive_callback_;
+
+ bool is_gathering_;
+ bool is_tracing_;
+ bool requires_anonymized_data_;
+ int trigger_handle_ids_;
+
+ IdleCallback idle_callback_;
+
+ friend struct base::DefaultLazyInstanceTraits<BackgroundTracingManagerImpl>;
+
+ DISALLOW_COPY_AND_ASSIGN(BackgroundTracingManagerImpl);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_TRACING_BACKGROUND_TRACING_MANAGER_IMPL_H_

Powered by Google App Engine
This is Rietveld 408576698