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

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

Issue 1507633003: Clarify ordinary page handling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: whitespace Created 4 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 14 matching lines...) Expand all
25 #include "core/loader/FrameLoader.h" 25 #include "core/loader/FrameLoader.h"
26 #include "core/page/Page.h" 26 #include "core/page/Page.h"
27 #include "public/platform/Platform.h" 27 #include "public/platform/Platform.h"
28 #include "public/platform/WebScheduler.h" 28 #include "public/platform/WebScheduler.h"
29 #include "wtf/HashSet.h" 29 #include "wtf/HashSet.h"
30 30
31 namespace blink { 31 namespace blink {
32 32
33 ScopedPageLoadDeferrer::ScopedPageLoadDeferrer(Page* exclusion) 33 ScopedPageLoadDeferrer::ScopedPageLoadDeferrer(Page* exclusion)
34 { 34 {
35 const WillBePersistentHeapHashSet<RawPtrWillBeWeakMember<Page>>& pages = Pag e::ordinaryPages(); 35 for (const Page* page : Page::ordinaryPages()) {
36 for (const Page* page : pages) {
37 if (page == exclusion || page->defersLoading()) 36 if (page == exclusion || page->defersLoading())
38 continue; 37 continue;
39 38
40 if (page->mainFrame()->isLocalFrame()) { 39 if (!page->mainFrame()->isLocalFrame())
41 m_deferredFrames.append(page->deprecatedLocalMainFrame()); 40 continue;
42 41
43 // Ensure that we notify the client if the initial empty document is accessed before 42 m_deferredFrames.append(page->deprecatedLocalMainFrame());
44 // showing anything modal, to prevent spoofs while the modal window or sheet is visible. 43
45 page->deprecatedLocalMainFrame()->loader().notifyIfInitialDocumentAc cessed(); 44 // Ensure that we notify the client if the initial empty document is acc essed before
46 } 45 // showing anything modal, to prevent spoofs while the modal window or s heet is visible.
46 page->deprecatedLocalMainFrame()->loader().notifyIfInitialDocumentAccess ed();
47 } 47 }
48 48
49 size_t count = m_deferredFrames.size(); 49 setDefersLoading(true);
50 for (size_t i = 0; i < count; ++i) {
51 if (Page* page = m_deferredFrames[i]->page())
52 page->setDefersLoading(true);
53 }
54 Platform::current()->currentThread()->scheduler()->suspendTimerQueue(); 50 Platform::current()->currentThread()->scheduler()->suspendTimerQueue();
55 } 51 }
56 52
57 void ScopedPageLoadDeferrer::detach()
58 {
59 for (size_t i = 0; i < m_deferredFrames.size(); ++i) {
60 if (Page* page = m_deferredFrames[i]->page())
61 page->setDefersLoading(false);
62 }
63
64 Platform::current()->currentThread()->scheduler()->resumeTimerQueue();
65 }
66
67 ScopedPageLoadDeferrer::~ScopedPageLoadDeferrer() 53 ScopedPageLoadDeferrer::~ScopedPageLoadDeferrer()
68 { 54 {
69 detach(); 55 setDefersLoading(false);
56 Platform::current()->currentThread()->scheduler()->resumeTimerQueue();
57 }
58
59 void ScopedPageLoadDeferrer::setDefersLoading(bool isDeferred)
60 {
61 for (const auto& frame : m_deferredFrames) {
62 if (Page* page = frame->page())
63 page->setDefersLoading(isDeferred);
64 }
70 } 65 }
71 66
72 } // namespace blink 67 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698