summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/dom/ignore_opens_during_unload_count_incrementer.h
blob: 0863a139a316620be377c6a91cca0466949719bc (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
// Copyright 2018 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_DOM_IGNORE_OPENS_DURING_UNLOAD_COUNT_INCREMENTER_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_DOM_IGNORE_OPENS_DURING_UNLOAD_COUNT_INCREMENTER_H_

#include "base/macros.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/platform/wtf/allocator.h"

namespace blink {

class IgnoreOpensDuringUnloadCountIncrementer {
  STACK_ALLOCATED();

 public:
  explicit IgnoreOpensDuringUnloadCountIncrementer(Document* document)
      : count_(document ? &document->ignore_opens_during_unload_count_
                        : nullptr) {
    if (!count_)
      return;
    ++(*count_);
  }

  ~IgnoreOpensDuringUnloadCountIncrementer() {
    if (!count_)
      return;
    --(*count_);
  }

 private:
  unsigned* count_;
  DISALLOW_COPY_AND_ASSIGN(IgnoreOpensDuringUnloadCountIncrementer);
};

}  // namespace blink

#endif