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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 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_BROWSER_TRACING_BACKGROUND_TRACING_MANAGER_IMPL_H_
6 #define CONTENT_BROWSER_TRACING_BACKGROUND_TRACING_MANAGER_IMPL_H_
7
8 #include "base/lazy_instance.h"
9 #include "base/memory/ref_counted_memory.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "content/browser/tracing/tracing_controller_impl.h"
13 #include "content/public/browser/background_tracing_config.h"
14 #include "content/public/browser/background_tracing_manager.h"
15
16 namespace content {
17
18 class BackgroundTracingManagerImpl : public content::BackgroundTracingManager {
19 public:
20 static BackgroundTracingManagerImpl* GetInstance();
21
22 bool SetActiveScenario(scoped_ptr<BackgroundTracingConfig>,
23 const ReceiveCallback&,
24 bool) override;
25 void WhenIdle(IdleCallback idle_callback) override;
26
27 void TriggerNamedEvent(TriggerHandle, StartedFinalizingCallback) override;
28 TriggerHandle RegisterTriggerType(const char* trigger_name) override;
29 void GetTriggerNameList(std::vector<std::string>* trigger_names) override;
30
31 void InvalidateTriggerHandlesForTesting() override;
32
33 private:
34 BackgroundTracingManagerImpl();
35 ~BackgroundTracingManagerImpl() override;
36
37 void EnableRecording(base::trace_event::CategoryFilter);
38 void EnableRecordingIfConfigNeedsIt();
39 void OnFinalizeStarted(scoped_refptr<base::RefCountedString>);
40 void OnFinalizeComplete();
41 void BeginFinalizing(StartedFinalizingCallback);
42
43 std::string GetTriggerNameFromHandle(TriggerHandle handle) const;
44 bool IsTriggerHandleValid(TriggerHandle handle) const;
45
46 bool IsAbleToTriggerTracing(TriggerHandle handle) const;
47 bool IsSupportedConfig(BackgroundTracingConfig* config);
48
49 base::trace_event::CategoryFilter GetCategoryFilterForCategoryPreset(
50 BackgroundTracingConfig::CategoryPreset) const;
51
52 class TraceDataEndpointWrapper
53 : public content::TracingController::TraceDataEndpoint {
54 public:
55 TraceDataEndpointWrapper(base::Callback<
56 void(scoped_refptr<base::RefCountedString>)> done_callback);
57
58 void ReceiveTraceFinalContents(const std::string& file_contents) override;
59
60 private:
61 ~TraceDataEndpointWrapper() override;
62
63 base::Callback<void(scoped_refptr<base::RefCountedString>)> done_callback_;
64 };
65
66 scoped_ptr<content::BackgroundTracingConfig> config_;
67 scoped_refptr<TraceDataEndpointWrapper> data_endpoint_wrapper_;
68 std::map<TriggerHandle, std::string> trigger_handles_;
69 ReceiveCallback receive_callback_;
70
71 bool is_gathering_;
72 bool is_tracing_;
73 bool requires_anonymized_data_;
74 int trigger_handle_ids_;
75
76 IdleCallback idle_callback_;
77
78 friend struct base::DefaultLazyInstanceTraits<BackgroundTracingManagerImpl>;
79
80 DISALLOW_COPY_AND_ASSIGN(BackgroundTracingManagerImpl);
81 };
82
83 } // namespace content
84
85 #endif // CONTENT_BROWSER_TRACING_BACKGROUND_TRACING_MANAGER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698