summaryrefslogtreecommitdiffstats
path: root/content/browser/devtools/devtools_tracing_handler.h
blob: 64f1af729ee70bb90ab237bdc0aefe805d941893 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright (c) 2012 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_DEVTOOLS_DEVTOOLS_TRACING_HANDLER_H_
#define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_TRACING_HANDLER_H_

#include "base/debug/trace_event.h"
#include "content/browser/devtools/devtools_protocol.h"
#include "content/public/browser/trace_subscriber.h"

namespace content {

// This class bridges DevTools remote debugging server with the trace
// infrastructure.
class DevToolsTracingHandler
    : public TraceSubscriber,
      public DevToolsProtocol::Handler {
 public:
  static const char kDomain[];

  DevToolsTracingHandler();
  virtual ~DevToolsTracingHandler();

  // TraceSubscriber:
  virtual void OnEndTracingComplete() OVERRIDE;;
  virtual void OnTraceDataCollected(
      const scoped_refptr<base::RefCountedString>& trace_fragment) OVERRIDE;

 private:
  scoped_ptr<DevToolsProtocol::Response> OnStart(
      DevToolsProtocol::Command* command);
  scoped_ptr<DevToolsProtocol::Response> OnEnd(
      DevToolsProtocol::Command* command);

  base::debug::TraceLog::Options TraceOptionsFromString(
      const std::string& options);

  bool is_running_;

  DISALLOW_COPY_AND_ASSIGN(DevToolsTracingHandler);
};

}  // namespace content

#endif  // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_TRACING_HANDLER_H_