Mechanical rename of base::debug -> base::trace_event for /content
[chromium-blink-merge.git] / content / browser / devtools / protocol / tracing_handler.h
blob1afd6b39fcf71cfbed7c4c0bbda5bfddd1de0872
1 // Copyright 2014 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.
5 #ifndef CONTENT_BROWSER_DEVTOOLS_PROTOCOL_TRACING_HANDLER_H_
6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_TRACING_HANDLER_H_
8 #include <set>
9 #include <string>
11 #include "base/memory/weak_ptr.h"
12 #include "base/trace_event/trace_event.h"
13 #include "content/browser/devtools/protocol/devtools_protocol_handler.h"
14 #include "content/public/browser/tracing_controller.h"
16 namespace base {
17 class RefCountedString;
18 class Timer;
21 namespace content {
22 namespace devtools {
23 namespace tracing {
25 class TracingHandler {
26 public:
27 typedef DevToolsProtocolClient::Response Response;
29 enum Target { Browser, Renderer };
30 explicit TracingHandler(Target target);
31 virtual ~TracingHandler();
33 void SetClient(scoped_ptr<Client> client);
34 void Detached();
36 void OnTraceDataCollected(const std::string& trace_fragment);
37 void OnTraceComplete();
39 Response Start(DevToolsCommandId command_id,
40 const std::string* categories,
41 const std::string* options,
42 const double* buffer_usage_reporting_interval);
43 Response End(DevToolsCommandId command_id);
44 Response GetCategories(DevToolsCommandId command);
46 private:
47 void OnRecordingEnabled(DevToolsCommandId command_id);
48 void OnBufferUsage(float percent_full, size_t approximate_event_count);
50 void OnCategoriesReceived(DevToolsCommandId command_id,
51 const std::set<std::string>& category_set);
53 base::trace_event::TraceOptions TraceOptionsFromString(
54 const std::string* options);
56 void SetupTimer(double usage_reporting_interval);
58 void DisableRecording(bool abort);
60 scoped_ptr<base::Timer> buffer_usage_poll_timer_;
61 Target target_;
62 bool is_recording_;
64 scoped_ptr<Client> client_;
65 base::WeakPtrFactory<TracingHandler> weak_factory_;
67 DISALLOW_COPY_AND_ASSIGN(TracingHandler);
70 } // namespace tracing
71 } // namespace devtools
72 } // namespace content
74 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_TRACING_HANDLER_H_