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

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

Issue 2616513002: Make sure pages that are closing but not yet closed are still suspended. (Closed)
Patch Set: 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 /* 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 17 matching lines...) Expand all
28 #include "public/platform/WebScheduler.h" 28 #include "public/platform/WebScheduler.h"
29 #include "wtf/StdLibExtras.h" 29 #include "wtf/StdLibExtras.h"
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_suspensionCount = 0; 36 unsigned s_suspensionCount = 0;
37 37
38 void setSuspended(bool isSuspended) {
39 // Make a copy of the collection. Undeferring loads can cause script to run,
40 // which would mutate ordinaryPages() in the middle of iteration.
41 HeapVector<Member<Page>> pages;
42 copyToVector(Page::ordinaryPages(), pages);
43 for (const auto& page : pages)
44 page->setSuspended(isSuspended);
45 }
46
47 } // namespace 38 } // namespace
48 39
49 ScopedPageSuspender::ScopedPageSuspender() { 40 ScopedPageSuspender::ScopedPageSuspender() {
50 if (++s_suspensionCount > 1) 41 if (++s_suspensionCount > 1)
51 return; 42 return;
52 43
53 setSuspended(true); 44 setSuspended(true);
54 Platform::current()->currentThread()->scheduler()->suspendTimerQueue(); 45 Platform::current()->currentThread()->scheduler()->suspendTimerQueue();
55 } 46 }
56 47
57 ScopedPageSuspender::~ScopedPageSuspender() { 48 ScopedPageSuspender::~ScopedPageSuspender() {
58 if (--s_suspensionCount > 0) 49 if (--s_suspensionCount > 0)
59 return; 50 return;
60 51
61 setSuspended(false); 52 setSuspended(false);
62 Platform::current()->currentThread()->scheduler()->resumeTimerQueue(); 53 Platform::current()->currentThread()->scheduler()->resumeTimerQueue();
63 } 54 }
64 55
56 void ScopedPageSuspender::setSuspended(bool isSuspended) {
57 // Make a copy of the collection. Undeferring loads can cause script to run,
58 // which would mutate ordinaryPages() in the middle of iteration.
59 HeapVector<Member<Page>> pages;
60 copyToVector(Page::ordinaryPages(), pages);
61
62 for (const auto& page : pages)
63 page->setSuspended(isSuspended);
64 }
65
65 bool ScopedPageSuspender::isActive() { 66 bool ScopedPageSuspender::isActive() {
66 return s_suspensionCount > 0; 67 return s_suspensionCount > 0;
67 } 68 }
68 69
69 } // namespace blink 70 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/page/ScopedPageSuspender.h ('k') | third_party/WebKit/Source/web/ChromeClientImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698