Add long running gmail memory benchmark for background tab.
[chromium-blink-merge.git] / content / browser / devtools / protocol / tracing_handler.h
blob4a80351a0e700eb53df113b72f64463e8590a295
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_dispatcher.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);
45 Response RequestMemoryDump(DevToolsCommandId command_id);
46 bool did_initiate_recording() { return did_initiate_recording_; }
48 private:
49 void OnRecordingEnabled(DevToolsCommandId command_id);
50 void OnBufferUsage(float percent_full, size_t approximate_event_count);
52 void OnCategoriesReceived(DevToolsCommandId command_id,
53 const std::set<std::string>& category_set);
54 void OnMemoryDumpFinished(DevToolsCommandId command_id,
55 uint64 dump_guid,
56 bool success);
58 void SetupTimer(double usage_reporting_interval);
60 void DisableRecording(bool abort);
62 bool IsRecording() const;
64 scoped_ptr<base::Timer> buffer_usage_poll_timer_;
65 Target target_;
67 scoped_ptr<Client> client_;
68 bool did_initiate_recording_;
69 base::WeakPtrFactory<TracingHandler> weak_factory_;
71 DISALLOW_COPY_AND_ASSIGN(TracingHandler);
74 } // namespace tracing
75 } // namespace devtools
76 } // namespace content
78 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_TRACING_HANDLER_H_