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

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

Issue 2580703003: Make sure pages that are closing but not yet closed are still suspended. (Closed)
Patch Set: comments Created 4 years 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, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All
3 * Rights Reserved. 3 * Rights Reserved.
4 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. 4 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved.
5 * (http://www.torchmobile.com/) 5 * (http://www.torchmobile.com/)
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 #include "platform/WebFrameScheduler.h" 56 #include "platform/WebFrameScheduler.h"
57 #include "platform/graphics/GraphicsLayer.h" 57 #include "platform/graphics/GraphicsLayer.h"
58 #include "platform/plugins/PluginData.h" 58 #include "platform/plugins/PluginData.h"
59 #include "public/platform/Platform.h" 59 #include "public/platform/Platform.h"
60 60
61 namespace blink { 61 namespace blink {
62 62
63 // Set of all live pages; includes internal Page objects that are 63 // Set of all live pages; includes internal Page objects that are
64 // not observable from scripts. 64 // not observable from scripts.
65 static Page::PageSet& allPages() { 65 static Page::PageSet& allPages() {
66 DEFINE_STATIC_LOCAL(Page::PageSet, allPages, ()); 66 DEFINE_STATIC_LOCAL(Page::PageSet, pages, ());
67 return allPages; 67 return pages;
68 } 68 }
69 69
70 Page::PageSet& Page::ordinaryPages() { 70 Page::PageSet& Page::ordinaryPages() {
71 DEFINE_STATIC_LOCAL(Page::PageSet, ordinaryPages, ()); 71 DEFINE_STATIC_LOCAL(Page::PageSet, pages, ());
72 return ordinaryPages; 72 return pages;
73 } 73 }
74 74
75 void Page::networkStateChanged(bool online) { 75 void Page::networkStateChanged(bool online) {
76 HeapVector<Member<LocalFrame>> frames; 76 HeapVector<Member<LocalFrame>> frames;
77 77
78 // Get all the frames of all the pages in all the page groups 78 // Get all the frames of all the pages in all the page groups
79 for (Page* page : allPages()) { 79 for (Page* page : allPages()) {
80 for (Frame* frame = page->mainFrame(); frame; 80 for (Frame* frame = page->mainFrame(); frame;
81 frame = frame->tree().traverseNext()) { 81 frame = frame->tree().traverseNext()) {
82 // FIXME: There is currently no way to dispatch events to out-of-process 82 // FIXME: There is currently no way to dispatch events to out-of-process
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 143
144 ASSERT(!allPages().contains(this)); 144 ASSERT(!allPages().contains(this));
145 allPages().add(this); 145 allPages().add(this);
146 } 146 }
147 147
148 Page::~Page() { 148 Page::~Page() {
149 // willBeDestroyed() must be called before Page destruction. 149 // willBeDestroyed() must be called before Page destruction.
150 ASSERT(!m_mainFrame); 150 ASSERT(!m_mainFrame);
151 } 151 }
152 152
153 void Page::closeSoon() {
154 // Make sure this Page can no longer be found by JS.
155 m_isClosing = true;
156
157 // TODO(dcheng): Try to remove this in a followup, it's not obviously needed.
dcheng 2016/12/15 19:11:38 Originally I wanted to remove this as the fix (sin
158 if (m_mainFrame->isLocalFrame())
159 toLocalFrame(m_mainFrame)->loader().stopAllLoaders();
160
161 chromeClient().closeWindowSoon();
162 }
163
153 ViewportDescription Page::viewportDescription() const { 164 ViewportDescription Page::viewportDescription() const {
154 return mainFrame() && mainFrame()->isLocalFrame() && 165 return mainFrame() && mainFrame()->isLocalFrame() &&
155 deprecatedLocalMainFrame()->document() 166 deprecatedLocalMainFrame()->document()
156 ? deprecatedLocalMainFrame()->document()->viewportDescription() 167 ? deprecatedLocalMainFrame()->document()->viewportDescription()
157 : ViewportDescription(); 168 : ViewportDescription();
158 } 169 }
159 170
160 ScrollingCoordinator* Page::scrollingCoordinator() { 171 ScrollingCoordinator* Page::scrollingCoordinator() {
161 if (!m_scrollingCoordinator && m_settings->acceleratedCompositingEnabled()) 172 if (!m_scrollingCoordinator && m_settings->acceleratedCompositingEnabled())
162 m_scrollingCoordinator = ScrollingCoordinator::create(this); 173 m_scrollingCoordinator = ScrollingCoordinator::create(this);
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 void Page::layerTreeViewInitialized(WebLayerTreeView& layerTreeView) { 515 void Page::layerTreeViewInitialized(WebLayerTreeView& layerTreeView) {
505 if (scrollingCoordinator()) 516 if (scrollingCoordinator())
506 scrollingCoordinator()->layerTreeViewInitialized(layerTreeView); 517 scrollingCoordinator()->layerTreeViewInitialized(layerTreeView);
507 } 518 }
508 519
509 void Page::willCloseLayerTreeView(WebLayerTreeView& layerTreeView) { 520 void Page::willCloseLayerTreeView(WebLayerTreeView& layerTreeView) {
510 if (m_scrollingCoordinator) 521 if (m_scrollingCoordinator)
511 m_scrollingCoordinator->willCloseLayerTreeView(layerTreeView); 522 m_scrollingCoordinator->willCloseLayerTreeView(layerTreeView);
512 } 523 }
513 524
514 void Page::willBeClosed() {
515 ordinaryPages().remove(this);
516 }
517
518 void Page::willBeDestroyed() { 525 void Page::willBeDestroyed() {
519 Frame* mainFrame = m_mainFrame; 526 Frame* mainFrame = m_mainFrame;
520 527
521 mainFrame->detach(FrameDetachType::Remove); 528 mainFrame->detach(FrameDetachType::Remove);
522 529
523 ASSERT(allPages().contains(this)); 530 ASSERT(allPages().contains(this));
524 allPages().remove(this); 531 allPages().remove(this);
525 ordinaryPages().remove(this); 532 ordinaryPages().remove(this);
526 533
527 if (m_scrollingCoordinator) 534 if (m_scrollingCoordinator)
(...skipping 11 matching lines...) Expand all
539 : chromeClient(nullptr), 546 : chromeClient(nullptr),
540 contextMenuClient(nullptr), 547 contextMenuClient(nullptr),
541 editorClient(nullptr), 548 editorClient(nullptr),
542 spellCheckerClient(nullptr) {} 549 spellCheckerClient(nullptr) {}
543 550
544 Page::PageClients::~PageClients() {} 551 Page::PageClients::~PageClients() {}
545 552
546 template class CORE_TEMPLATE_EXPORT Supplement<Page>; 553 template class CORE_TEMPLATE_EXPORT Supplement<Page>;
547 554
548 } // namespace blink 555 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698