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..f2496a5656a4b6dae1a2950c97a7b642cc67d90b |
--- /dev/null |
+++ b/content/browser/tracing/background_tracing_manager_impl.h |
@@ -0,0 +1,82 @@ |
+// 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_manager.h" |
+ |
+namespace content { |
+ |
+class BackgroundTracingManagerImpl : public content::BackgroundTracingManager { |
+ public: |
+ static BackgroundTracingManagerImpl* GetInstance(); |
+ |
+ bool SetActiveScenario( |
+ scoped_refptr<content::BackgroundTracingConfig>, |
+ scoped_refptr<content::BackgroundTracingUploadSink>) override; |
+ void WhenIdle(IdleCallback idle_callback) override; |
+ |
+ void DidTriggerHappen(TriggerHandle, StartedFinalizingCallback) override; |
+ TriggerHandle RegisterTriggerType(const char* trigger_name) override; |
+ void GetTriggerNameList(std::vector<std::string>& trigger_names) override; |
+ |
+ void InvalidateTriggerHandlesForTesting(); |
+ |
+ private: |
+ BackgroundTracingManagerImpl(); |
+ ~BackgroundTracingManagerImpl() override; |
+ |
+ void EnableRecording(base::trace_event::CategoryFilter); |
+ void EnableRecordingIfConfigNeedsIt(); |
+ void OnFinalizeComplete(); |
+ void BeginFinalizing(StartedFinalizingCallback); |
+ |
+ std::string GetTriggerNameFromHandle(TriggerHandle handle) const; |
+ bool IsTriggerHandleValid(TriggerHandle handle) const; |
+ |
+ bool IsAbleToTriggerTracing(TriggerHandle handle) const; |
+ bool IsSupportedConfig(scoped_refptr<BackgroundTracingConfig> config); |
+ |
+ base::trace_event::CategoryFilter GetCategoryFilterForCategoryPreset( |
+ BackgroundTracingConfig::CategoryPreset) const; |
+ |
+ class TraceDataEndpointWrapper |
+ : public content::TracingController::TraceDataEndpoint { |
+ public: |
+ TraceDataEndpointWrapper(base::Callback<void()> done_callback); |
+ |
+ void ReceiveTraceFinalContents(const std::string& file_contents) override; |
+ void SetUploadSink( |
+ scoped_refptr<content::BackgroundTracingUploadSink> upload_sink); |
+ |
+ private: |
+ ~TraceDataEndpointWrapper() override; |
+ |
+ scoped_refptr<content::BackgroundTracingUploadSink> upload_sink_; |
+ base::Callback<void()> done_callback_; |
+ }; |
+ |
+ scoped_refptr<content::BackgroundTracingConfig> config_; |
+ scoped_refptr<TraceDataEndpointWrapper> data_endpoint_wrapper_; |
+ std::map<TriggerHandle, std::string> trigger_handles_; |
+ |
+ bool is_gathering_; |
+ 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_ |