summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/inspector/inspector_log_agent.h
blob: 6e0f99d317362fc590ace52c63ea8a9803a31646 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright 2016 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 THIRD_PARTY_BLINK_RENDERER_CORE_INSPECTOR_INSPECTOR_LOG_AGENT_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_INSPECTOR_INSPECTOR_LOG_AGENT_H_

#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/frame/performance_monitor.h"
#include "third_party/blink/renderer/core/inspector/inspector_base_agent.h"
#include "third_party/blink/renderer/core/inspector/protocol/Log.h"

namespace v8_inspector {
class V8InspectorSession;
}

namespace blink {

class ConsoleMessage;
class ConsoleMessageStorage;

class CORE_EXPORT InspectorLogAgent
    : public InspectorBaseAgent<protocol::Log::Metainfo>,
      public PerformanceMonitor::Client {
 public:
  InspectorLogAgent(ConsoleMessageStorage*,
                    PerformanceMonitor*,
                    v8_inspector::V8InspectorSession*);
  InspectorLogAgent(const InspectorLogAgent&) = delete;
  InspectorLogAgent& operator=(const InspectorLogAgent&) = delete;
  ~InspectorLogAgent() override;
  void Trace(Visitor*) const override;

  void Restore() override;

  // Called from InspectorInstrumentation.
  void ConsoleMessageAdded(ConsoleMessage*);

  // Protocol methods.
  protocol::Response enable() override;
  protocol::Response disable() override;
  protocol::Response clear() override;
  protocol::Response startViolationsReport(
      std::unique_ptr<protocol::Array<protocol::Log::ViolationSetting>>)
      override;
  protocol::Response stopViolationsReport() override;

 private:
  // PerformanceMonitor::Client implementation.
  void ReportLongLayout(base::TimeDelta duration) override;
  void ReportGenericViolation(PerformanceMonitor::Violation,
                              const String& text,
                              base::TimeDelta time,
                              SourceLocation*) override;
  void InnerEnable();

  Member<ConsoleMessageStorage> storage_;
  Member<PerformanceMonitor> performance_monitor_;
  v8_inspector::V8InspectorSession* v8_session_;
  InspectorAgentState::Boolean enabled_;
  InspectorAgentState::DoubleMap violation_thresholds_;
};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_CORE_INSPECTOR_INSPECTOR_LOG_AGENT_H_