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

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

Issue 1441073006: Move throttling of background timers into the renderer scheduler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Try again for MSVC Created 5 years, 1 month 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 R ights Reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All R ights Reserved.
3 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 3 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
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 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 , m_contextMenuController(ContextMenuController::create(this, pageClients.co ntextMenuClient)) 110 , m_contextMenuController(ContextMenuController::create(this, pageClients.co ntextMenuClient))
111 , m_pointerLockController(PointerLockController::create(this)) 111 , m_pointerLockController(PointerLockController::create(this))
112 , m_undoStack(UndoStack::create()) 112 , m_undoStack(UndoStack::create())
113 , m_mainFrame(nullptr) 113 , m_mainFrame(nullptr)
114 , m_editorClient(pageClients.editorClient) 114 , m_editorClient(pageClients.editorClient)
115 , m_spellCheckerClient(pageClients.spellCheckerClient) 115 , m_spellCheckerClient(pageClients.spellCheckerClient)
116 , m_openedByDOM(false) 116 , m_openedByDOM(false)
117 , m_tabKeyCyclesThroughElements(true) 117 , m_tabKeyCyclesThroughElements(true)
118 , m_defersLoading(false) 118 , m_defersLoading(false)
119 , m_deviceScaleFactor(1) 119 , m_deviceScaleFactor(1)
120 , m_timerAlignmentInterval(DOMTimer::visiblePageAlignmentInterval())
121 , m_visibilityState(PageVisibilityStateVisible) 120 , m_visibilityState(PageVisibilityStateVisible)
122 , m_isCursorVisible(true) 121 , m_isCursorVisible(true)
123 #if ENABLE(ASSERT) 122 #if ENABLE(ASSERT)
124 , m_isPainting(false) 123 , m_isPainting(false)
125 #endif 124 #endif
126 , m_frameHost(FrameHost::create(*this)) 125 , m_frameHost(FrameHost::create(*this))
127 { 126 {
128 ASSERT(m_editorClient); 127 ASSERT(m_editorClient);
129 128
130 ASSERT(!allPages().contains(this)); 129 ASSERT(!allPages().contains(this));
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 void Page::visitedStateChanged(LinkHash linkHash) 355 void Page::visitedStateChanged(LinkHash linkHash)
357 { 356 {
358 for (const Page* page : ordinaryPages()) { 357 for (const Page* page : ordinaryPages()) {
359 for (Frame* frame = page->m_mainFrame; frame; frame = frame->tree().trav erseNext()) { 358 for (Frame* frame = page->m_mainFrame; frame; frame = frame->tree().trav erseNext()) {
360 if (frame->isLocalFrame()) 359 if (frame->isLocalFrame())
361 toLocalFrame(frame)->document()->visitedLinkState().invalidateSt yleForLink(linkHash); 360 toLocalFrame(frame)->document()->visitedLinkState().invalidateSt yleForLink(linkHash);
362 } 361 }
363 } 362 }
364 } 363 }
365 364
366 void Page::setTimerAlignmentInterval(double interval)
367 {
368 if (interval == m_timerAlignmentInterval)
369 return;
370
371 m_timerAlignmentInterval = interval;
372 for (Frame* frame = mainFrame(); frame; frame = frame->tree().traverseNextWi thWrap(false)) {
373 if (!frame->isLocalFrame())
374 continue;
375
376 if (Document* document = toLocalFrame(frame)->document()) {
377 if (DOMTimerCoordinator* timers = document->timers()) {
378 timers->didChangeTimerAlignmentInterval();
379 }
380 }
381 }
382 }
383
384 double Page::timerAlignmentInterval() const
385 {
386 return m_timerAlignmentInterval;
387 }
388
389 void Page::setVisibilityState(PageVisibilityState visibilityState, bool isInitia lState) 365 void Page::setVisibilityState(PageVisibilityState visibilityState, bool isInitia lState)
390 { 366 {
391 if (m_visibilityState == visibilityState) 367 if (m_visibilityState == visibilityState)
392 return; 368 return;
393 m_visibilityState = visibilityState; 369 m_visibilityState = visibilityState;
394 370
395 // TODO(alexclarke): Move throttling of timers to chromium.
396 if (visibilityState == PageVisibilityStateVisible) { 371 if (visibilityState == PageVisibilityStateVisible) {
397 setTimerAlignmentInterval(DOMTimer::visiblePageAlignmentInterval());
398 m_memoryPurgeController->pageBecameActive(); 372 m_memoryPurgeController->pageBecameActive();
399 } else { 373 } else {
400 setTimerAlignmentInterval(DOMTimer::hiddenPageAlignmentInterval());
401 if (!isInitialState) 374 if (!isInitialState)
402 m_memoryPurgeController->pageBecameInactive(); 375 m_memoryPurgeController->pageBecameInactive();
403 } 376 }
404 377
405 if (!isInitialState) 378 if (!isInitialState)
406 notifyPageVisibilityChanged(); 379 notifyPageVisibilityChanged();
407 380
408 if (!isInitialState && m_mainFrame && m_mainFrame->isLocalFrame()) 381 if (!isInitialState && m_mainFrame && m_mainFrame->isLocalFrame())
409 deprecatedLocalMainFrame()->didChangeVisibilityState(); 382 deprecatedLocalMainFrame()->didChangeVisibilityState();
410 } 383 }
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 { 595 {
623 } 596 }
624 597
625 Page::PageClients::~PageClients() 598 Page::PageClients::~PageClients()
626 { 599 {
627 } 600 }
628 601
629 template class CORE_TEMPLATE_EXPORT WillBeHeapSupplement<Page>; 602 template class CORE_TEMPLATE_EXPORT WillBeHeapSupplement<Page>;
630 603
631 } // namespace blink 604 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698