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

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: Split config into separate headers and build fix. 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(
23 scoped_refptr<content::BackgroundTracingConfig>,
24 scoped_refptr<content::BackgroundTracingUploadSink>) override;
25 void WhenIdle(IdleCallback idle_callback) override;
26
27 void DidTriggerHappen(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 OnFinalizeComplete();
40 void BeginFinalizing(StartedFinalizingCallback);
41
42 std::string GetTriggerNameFromHandle(TriggerHandle handle) const;
43 bool IsTriggerHandleValid(TriggerHandle handle) const;
44
45 bool IsAbleToTriggerTracing(TriggerHandle handle) const;
46 bool IsSupportedConfig(scoped_refptr<BackgroundTracingConfig> config);
47
48 base::trace_event::CategoryFilter GetCategoryFilterForCategoryPreset(
49 BackgroundTracingConfig::CategoryPreset) const;
50
51 class TraceDataEndpointWrapper
52 : public content::TracingController::TraceDataEndpoint {
53 public:
54 TraceDataEndpointWrapper(base::Callback<void()> done_callback);
55
56 void ReceiveTraceFinalContents(const std::string& file_contents) override;
57 void SetUploadSink(
58 scoped_refptr<content::BackgroundTracingUploadSink> upload_sink);
59
60 private:
61 ~TraceDataEndpointWrapper() override;
62
63 scoped_refptr<content::BackgroundTracingUploadSink> upload_sink_;
64 base::Callback<void()> done_callback_;
65 };
66
67 scoped_refptr<content::BackgroundTracingConfig> config_;
68 scoped_refptr<TraceDataEndpointWrapper> data_endpoint_wrapper_;
69 std::map<TriggerHandle, std::string> trigger_handles_;
70
71 bool is_gathering_;
72 int trigger_handle_ids_;
73
74 IdleCallback idle_callback_;
75
76 friend struct base::DefaultLazyInstanceTraits<BackgroundTracingManagerImpl>;
77
78 DISALLOW_COPY_AND_ASSIGN(BackgroundTracingManagerImpl);
79 };
80
81 } // namespace content
82
83 #endif // CONTENT_BROWSER_TRACING_BACKGROUND_TRACING_MANAGER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698