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

Side by Side Diff: third_party/WebKit/Source/core/page/ScopedPageLoadDeferrer.cpp

Issue 2242923002: Copy Page::ordinaryPages() before undeferring loads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comment Created 4 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 19 matching lines...) Expand all
30 #include "wtf/Vector.h" 30 #include "wtf/Vector.h"
31 31
32 namespace blink { 32 namespace blink {
33 33
34 namespace { 34 namespace {
35 35
36 unsigned s_deferralCount = 0; 36 unsigned s_deferralCount = 0;
37 37
38 void setDefersLoading(bool isDeferred) 38 void setDefersLoading(bool isDeferred)
39 { 39 {
40 // Make a copy of the collection. Undeferring loads can cause script to run,
41 // which would mutate ordinaryPages() in the middle of iteration.
42 HeapVector<Member<Page>> pages;
40 for (const auto& page : Page::ordinaryPages()) 43 for (const auto& page : Page::ordinaryPages())
44 pages.append(page);
esprehn 2016/08/16 02:31:42 copyToVector(pages, Page::ordinaryPages())
45 for (const auto& page : pages)
41 page->setDefersLoading(isDeferred); 46 page->setDefersLoading(isDeferred);
42 } 47 }
43 48
44 } // namespace 49 } // namespace
45 50
46 ScopedPageLoadDeferrer::ScopedPageLoadDeferrer() 51 ScopedPageLoadDeferrer::ScopedPageLoadDeferrer()
47 { 52 {
48 if (++s_deferralCount > 1) 53 if (++s_deferralCount > 1)
49 return; 54 return;
50 55
51 setDefersLoading(true); 56 setDefersLoading(true);
52 Platform::current()->currentThread()->scheduler()->suspendTimerQueue(); 57 Platform::current()->currentThread()->scheduler()->suspendTimerQueue();
53 } 58 }
54 59
55 ScopedPageLoadDeferrer::~ScopedPageLoadDeferrer() 60 ScopedPageLoadDeferrer::~ScopedPageLoadDeferrer()
56 { 61 {
57 if (--s_deferralCount > 0) 62 if (--s_deferralCount > 0)
58 return; 63 return;
59 64
60 setDefersLoading(false); 65 setDefersLoading(false);
61 Platform::current()->currentThread()->scheduler()->resumeTimerQueue(); 66 Platform::current()->currentThread()->scheduler()->resumeTimerQueue();
62 } 67 }
63 68
64 bool ScopedPageLoadDeferrer::isActive() 69 bool ScopedPageLoadDeferrer::isActive()
65 { 70 {
66 return s_deferralCount > 0; 71 return s_deferralCount > 0;
67 } 72 }
68 73
69 } // namespace blink 74 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698