OLD | NEW |
---|---|
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 Loading... | |
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 HeapVector<Member<Page>> pages; | |
dcheng
2016/08/15 21:57:27
I'm not sure if it's more standard for this to be
haraken
2016/08/15 22:01:47
HeapVector<Member<>> makes sense. We don't want to
| |
40 for (const auto& page : Page::ordinaryPages()) | 41 for (const auto& page : Page::ordinaryPages()) |
42 pages.append(page); | |
haraken
2016/08/15 22:01:47
Shall we add a comment and mention why we're copyi
dcheng
2016/08/15 22:34:28
Done.
| |
43 for (const auto& page : pages) | |
41 page->setDefersLoading(isDeferred); | 44 page->setDefersLoading(isDeferred); |
42 } | 45 } |
43 | 46 |
44 } // namespace | 47 } // namespace |
45 | 48 |
46 ScopedPageLoadDeferrer::ScopedPageLoadDeferrer() | 49 ScopedPageLoadDeferrer::ScopedPageLoadDeferrer() |
47 { | 50 { |
48 if (++s_deferralCount > 1) | 51 if (++s_deferralCount > 1) |
49 return; | 52 return; |
50 | 53 |
51 setDefersLoading(true); | 54 setDefersLoading(true); |
52 Platform::current()->currentThread()->scheduler()->suspendTimerQueue(); | 55 Platform::current()->currentThread()->scheduler()->suspendTimerQueue(); |
53 } | 56 } |
54 | 57 |
55 ScopedPageLoadDeferrer::~ScopedPageLoadDeferrer() | 58 ScopedPageLoadDeferrer::~ScopedPageLoadDeferrer() |
56 { | 59 { |
57 if (--s_deferralCount > 0) | 60 if (--s_deferralCount > 0) |
58 return; | 61 return; |
59 | 62 |
60 setDefersLoading(false); | 63 setDefersLoading(false); |
61 Platform::current()->currentThread()->scheduler()->resumeTimerQueue(); | 64 Platform::current()->currentThread()->scheduler()->resumeTimerQueue(); |
62 } | 65 } |
63 | 66 |
64 bool ScopedPageLoadDeferrer::isActive() | 67 bool ScopedPageLoadDeferrer::isActive() |
65 { | 68 { |
66 return s_deferralCount > 0; | 69 return s_deferralCount > 0; |
67 } | 70 } |
68 | 71 |
69 } // namespace blink | 72 } // namespace blink |
OLD | NEW |