Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Side by Side Diff: third_party/WebKit/Source/core/dom/IncrementLoadEventDelayCount.h

Issue 2605383002: Introduce IncrementLoadEventDelayCount::clearAndCheckLoadEvent() (Closed)
Patch Set: Rebase Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 IncrementLoadEventDelayCount_h 5 #ifndef IncrementLoadEventDelayCount_h
6 #define IncrementLoadEventDelayCount_h 6 #define IncrementLoadEventDelayCount_h
7 7
8 #include "platform/heap/Handle.h" 8 #include "platform/heap/Handle.h"
9 #include "wtf/Allocator.h" 9 #include "wtf/Allocator.h"
10 #include "wtf/Noncopyable.h" 10 #include "wtf/Noncopyable.h"
11 #include <memory> 11 #include <memory>
12 12
13 namespace blink { 13 namespace blink {
14 14
15 class Document; 15 class Document;
16 16
17 // A helper class that will increment a document's loadEventDelayCount on 17 // A helper class that will increment a document's loadEventDelayCount on
18 // contruction and decrement it on destruction (semantics similar to RefPtr). 18 // contruction and decrement it on destruction (semantics similar to RefPtr).
19 class IncrementLoadEventDelayCount { 19 class IncrementLoadEventDelayCount {
20 USING_FAST_MALLOC(IncrementLoadEventDelayCount); 20 USING_FAST_MALLOC(IncrementLoadEventDelayCount);
21 WTF_MAKE_NONCOPYABLE(IncrementLoadEventDelayCount); 21 WTF_MAKE_NONCOPYABLE(IncrementLoadEventDelayCount);
22 22
23 public: 23 public:
24 static std::unique_ptr<IncrementLoadEventDelayCount> create(Document&); 24 static std::unique_ptr<IncrementLoadEventDelayCount> create(Document&);
25 ~IncrementLoadEventDelayCount(); 25 ~IncrementLoadEventDelayCount();
26 26
27 // Decrements the loadEventDelayCount and checks load event synchronously,
28 // and thus can cause synchronous Document load event/JavaScript execution.
29 // Call this only when it is safe, e.g. at the top of an async task.
30 // After calling this, |this| no longer blocks document's load event and
31 // will not decrement loadEventDelayCount at destruction.
32 void clearAndCheckLoadEvent();
33
27 // Increments the new document's count and decrements the old count. 34 // Increments the new document's count and decrements the old count.
28 void documentChanged(Document& newDocument); 35 void documentChanged(Document& newDocument);
29 36
30 private: 37 private:
31 IncrementLoadEventDelayCount(Document&); 38 IncrementLoadEventDelayCount(Document&);
32 Persistent<Document> m_document; 39 Persistent<Document> m_document;
33 }; 40 };
34 } // namespace blink 41 } // namespace blink
35 42
36 #endif 43 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.cpp ('k') | third_party/WebKit/Source/core/dom/IncrementLoadEventDelayCount.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698