summaryrefslogtreecommitdiffstats
path: root/content/shell/renderer/layout_test/leak_detector.h
blob: 08f9a318d9b350c22b4fcc949873f9971fe55b7f (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
// Copyright 2014 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_SHELL_RENDERER_LAYOUT_TEST_LEAK_DETECTOR_H_
#define CONTENT_SHELL_RENDERER_LAYOUT_TEST_LEAK_DETECTOR_H_

#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "content/shell/common/leak_detection_result.h"
#include "third_party/WebKit/public/web/WebLeakDetector.h"

namespace blink {
class WebFrame;
}  // namespace blink

namespace content {

class BlinkTestRunner;

// LeakDetector counts DOM objects and compare them between two pages.
class LeakDetector : public blink::WebLeakDetectorClient {
 public:
  explicit LeakDetector(BlinkTestRunner* test_runner);
  virtual ~LeakDetector();

  // Counts DOM objects, compare the previous status and returns the result of
  // leak detection. It is assumed that this method is always called when a
  // specific page, like about:blank is loaded to compare the previous
  // circumstance of DOM objects. If the number of objects increses, there
  // should be a leak.
  void TryLeakDetection(blink::WebFrame* frame);

  // WebLeakDetectorClient:
  void onLeakDetectionComplete(const Result& result) override;

 private:
  BlinkTestRunner* test_runner_;
  scoped_ptr<blink::WebLeakDetector> web_leak_detector_;
  blink::WebLeakDetectorClient::Result previous_result_;

  DISALLOW_COPY_AND_ASSIGN(LeakDetector);
};

}  // namespace content

#endif  // CONTENT_SHELL_RENDERER_LAYOUT_TEST_LEAK_DETECTOR_H_