| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ThrowOnDynamicMarkupInsertionCountIncrementer_h | 5 #ifndef ThrowOnDynamicMarkupInsertionCountIncrementer_h |
| 6 #define ThrowOnDynamicMarkupInsertionCountIncrementer_h | 6 #define ThrowOnDynamicMarkupInsertionCountIncrementer_h |
| 7 | 7 |
| 8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
| 9 #include "wtf/Allocator.h" | 9 #include "platform/wtf/Allocator.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 class ThrowOnDynamicMarkupInsertionCountIncrementer { | 13 class ThrowOnDynamicMarkupInsertionCountIncrementer { |
| 14 STACK_ALLOCATED(); | 14 STACK_ALLOCATED(); |
| 15 WTF_MAKE_NONCOPYABLE(ThrowOnDynamicMarkupInsertionCountIncrementer); | 15 WTF_MAKE_NONCOPYABLE(ThrowOnDynamicMarkupInsertionCountIncrementer); |
| 16 | 16 |
| 17 public: | 17 public: |
| 18 explicit ThrowOnDynamicMarkupInsertionCountIncrementer(Document* document) | 18 explicit ThrowOnDynamicMarkupInsertionCountIncrementer(Document* document) |
| 19 : count_(document ? &document->throw_on_dynamic_markup_insertion_count_ | 19 : count_(document ? &document->throw_on_dynamic_markup_insertion_count_ |
| 20 : 0) { | 20 : 0) { |
| 21 if (!count_) | 21 if (!count_) |
| 22 return; | 22 return; |
| 23 ++(*count_); | 23 ++(*count_); |
| 24 } | 24 } |
| 25 | 25 |
| 26 ~ThrowOnDynamicMarkupInsertionCountIncrementer() { | 26 ~ThrowOnDynamicMarkupInsertionCountIncrementer() { |
| 27 if (!count_) | 27 if (!count_) |
| 28 return; | 28 return; |
| 29 --(*count_); | 29 --(*count_); |
| 30 } | 30 } |
| 31 | 31 |
| 32 private: | 32 private: |
| 33 unsigned* count_; | 33 unsigned* count_; |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 } // namespace blink | 36 } // namespace blink |
| 37 | 37 |
| 38 #endif | 38 #endif |
| OLD | NEW |