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

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

Issue 2704083002: Remove Page dependency from NetworkStateNotifier (Closed)
Patch Set: nullcheck for tests Created 3 years, 9 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, 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 static Page::PageSet& allPages() { 65 static Page::PageSet& allPages() {
66 DEFINE_STATIC_LOCAL(Page::PageSet, pages, ()); 66 DEFINE_STATIC_LOCAL(Page::PageSet, pages, ());
67 return pages; 67 return pages;
68 } 68 }
69 69
70 Page::PageSet& Page::ordinaryPages() { 70 Page::PageSet& Page::ordinaryPages() {
71 DEFINE_STATIC_LOCAL(Page::PageSet, pages, ()); 71 DEFINE_STATIC_LOCAL(Page::PageSet, pages, ());
72 return pages; 72 return pages;
73 } 73 }
74 74
75 void Page::networkStateChanged(bool online) {
76 HeapVector<Member<LocalFrame>> frames;
77
78 // Get all the frames of all the pages in all the page groups
79 for (Page* page : allPages()) {
80 for (Frame* frame = page->mainFrame(); frame;
81 frame = frame->tree().traverseNext()) {
82 // FIXME: There is currently no way to dispatch events to out-of-process
83 // frames.
84 if (frame->isLocalFrame())
85 frames.push_back(toLocalFrame(frame));
86 }
87 }
88
89 AtomicString eventName =
90 online ? EventTypeNames::online : EventTypeNames::offline;
91 for (const auto& frame : frames) {
92 frame->domWindow()->dispatchEvent(Event::create(eventName));
93 InspectorInstrumentation::networkStateChanged(frame.get(), online);
94 }
95 }
96
97 float deviceScaleFactor(LocalFrame* frame) { 75 float deviceScaleFactor(LocalFrame* frame) {
98 if (!frame) 76 if (!frame)
99 return 1; 77 return 1;
100 Page* page = frame->page(); 78 Page* page = frame->page();
101 if (!page) 79 if (!page)
102 return 1; 80 return 1;
103 return page->deviceScaleFactor(); 81 return page->deviceScaleFactor();
104 } 82 }
105 83
106 Page* Page::createOrdinary(PageClients& pageClients) { 84 Page* Page::createOrdinary(PageClients& pageClients) {
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 : chromeClient(nullptr), 530 : chromeClient(nullptr),
553 contextMenuClient(nullptr), 531 contextMenuClient(nullptr),
554 editorClient(nullptr), 532 editorClient(nullptr),
555 spellCheckerClient(nullptr) {} 533 spellCheckerClient(nullptr) {}
556 534
557 Page::PageClients::~PageClients() {} 535 Page::PageClients::~PageClients() {}
558 536
559 template class CORE_TEMPLATE_EXPORT Supplement<Page>; 537 template class CORE_TEMPLATE_EXPORT Supplement<Page>;
560 538
561 } // namespace blink 539 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/page/Page.h ('k') | third_party/WebKit/Source/modules/netinfo/NetworkInformation.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698