Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 #include "core/page/ChromeClient.h" | 44 #include "core/page/ChromeClient.h" |
| 45 #include "core/page/ContextMenuController.h" | 45 #include "core/page/ContextMenuController.h" |
| 46 #include "core/page/DragController.h" | 46 #include "core/page/DragController.h" |
| 47 #include "core/page/FocusController.h" | 47 #include "core/page/FocusController.h" |
| 48 #include "core/page/PointerLockController.h" | 48 #include "core/page/PointerLockController.h" |
| 49 #include "core/page/ValidationMessageClient.h" | 49 #include "core/page/ValidationMessageClient.h" |
| 50 #include "core/page/scrolling/ScrollingCoordinator.h" | 50 #include "core/page/scrolling/ScrollingCoordinator.h" |
| 51 #include "core/paint/PaintLayer.h" | 51 #include "core/paint/PaintLayer.h" |
| 52 #include "platform/graphics/GraphicsLayer.h" | 52 #include "platform/graphics/GraphicsLayer.h" |
| 53 #include "platform/plugins/PluginData.h" | 53 #include "platform/plugins/PluginData.h" |
| 54 #include "platform/text/CompressibleString.h" | |
| 55 #include "public/platform/Platform.h" | 54 #include "public/platform/Platform.h" |
| 56 | 55 |
| 57 namespace blink { | 56 namespace blink { |
| 58 | 57 |
| 59 // Set of all live pages; includes internal Page objects that are | 58 // Set of all live pages; includes internal Page objects that are |
| 60 // not observable from scripts. | 59 // not observable from scripts. |
| 61 static Page::PageSet& allPages() | 60 static Page::PageSet& allPages() |
| 62 { | 61 { |
| 63 DEFINE_STATIC_LOCAL(Page::PageSet, allPages, ()); | 62 DEFINE_STATIC_LOCAL(Page::PageSet, allPages, ()); |
| 64 return allPages; | 63 return allPages; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 , m_openedByDOM(false) | 122 , m_openedByDOM(false) |
| 124 , m_tabKeyCyclesThroughElements(true) | 123 , m_tabKeyCyclesThroughElements(true) |
| 125 , m_defersLoading(false) | 124 , m_defersLoading(false) |
| 126 , m_deviceScaleFactor(1) | 125 , m_deviceScaleFactor(1) |
| 127 , m_visibilityState(PageVisibilityStateVisible) | 126 , m_visibilityState(PageVisibilityStateVisible) |
| 128 , m_isCursorVisible(true) | 127 , m_isCursorVisible(true) |
| 129 #if ENABLE(ASSERT) | 128 #if ENABLE(ASSERT) |
| 130 , m_isPainting(false) | 129 , m_isPainting(false) |
| 131 #endif | 130 #endif |
| 132 , m_frameHost(FrameHost::create(*this)) | 131 , m_frameHost(FrameHost::create(*this)) |
| 133 , m_timerForCompressStrings(this, &Page::compressStrings) | |
| 134 { | 132 { |
| 135 ASSERT(m_editorClient); | 133 ASSERT(m_editorClient); |
| 136 | 134 |
| 137 ASSERT(!allPages().contains(this)); | 135 ASSERT(!allPages().contains(this)); |
| 138 allPages().add(this); | 136 allPages().add(this); |
| 139 } | 137 } |
| 140 | 138 |
| 141 Page::~Page() | 139 Page::~Page() |
| 142 { | 140 { |
| 143 // willBeDestroyed() must be called before Page destruction. | 141 // willBeDestroyed() must be called before Page destruction. |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 310 for (const Page* page : ordinaryPages()) { | 308 for (const Page* page : ordinaryPages()) { |
| 311 for (Frame* frame = page->m_mainFrame; frame; frame = frame->tree().trav erseNext()) { | 309 for (Frame* frame = page->m_mainFrame; frame; frame = frame->tree().trav erseNext()) { |
| 312 if (frame->isLocalFrame()) | 310 if (frame->isLocalFrame()) |
| 313 toLocalFrame(frame)->document()->visitedLinkState().invalidateSt yleForLink(linkHash); | 311 toLocalFrame(frame)->document()->visitedLinkState().invalidateSt yleForLink(linkHash); |
| 314 } | 312 } |
| 315 } | 313 } |
| 316 } | 314 } |
| 317 | 315 |
| 318 void Page::setVisibilityState(PageVisibilityState visibilityState, bool isInitia lState) | 316 void Page::setVisibilityState(PageVisibilityState visibilityState, bool isInitia lState) |
| 319 { | 317 { |
| 320 static const double waitingTimeBeforeCompressingString = 10; | |
| 321 | |
| 322 if (m_visibilityState == visibilityState) | 318 if (m_visibilityState == visibilityState) |
| 323 return; | 319 return; |
| 324 m_visibilityState = visibilityState; | 320 m_visibilityState = visibilityState; |
| 325 | 321 |
| 326 if (!isInitialState) | 322 if (!isInitialState) |
| 327 notifyPageVisibilityChanged(); | 323 notifyPageVisibilityChanged(); |
| 328 | 324 |
| 329 if (!isInitialState && m_mainFrame) | 325 if (!isInitialState && m_mainFrame) |
| 330 m_mainFrame->didChangeVisibilityState(); | 326 m_mainFrame->didChangeVisibilityState(); |
| 331 | |
| 332 // Compress CompressibleStrings when 10 seconds have passed since the page | |
| 333 // went to background. | |
| 334 if (m_visibilityState == PageVisibilityStateHidden) { | |
|
esprehn
2016/08/05 23:00:58
is this actually enabled today?
tasak
2016/08/08 04:47:36
No, not enabled. I manually applied compressibleSt
| |
| 335 if (!m_timerForCompressStrings.isActive()) | |
| 336 m_timerForCompressStrings.startOneShot(waitingTimeBeforeCompressingS tring, BLINK_FROM_HERE); | |
| 337 } else if (m_timerForCompressStrings.isActive()) { | |
| 338 m_timerForCompressStrings.stop(); | |
| 339 } | |
| 340 } | 327 } |
| 341 | 328 |
| 342 PageVisibilityState Page::visibilityState() const | 329 PageVisibilityState Page::visibilityState() const |
| 343 { | 330 { |
| 344 return m_visibilityState; | 331 return m_visibilityState; |
| 345 } | 332 } |
| 346 | 333 |
| 347 bool Page::isPageVisible() const | 334 bool Page::isPageVisible() const |
| 348 { | 335 { |
| 349 return visibilityState() == PageVisibilityStateVisible; | 336 return visibilityState() == PageVisibilityStateVisible; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 470 // an event so we keep the frames alive until we are done. | 457 // an event so we keep the frames alive until we are done. |
| 471 for (Frame* frame = mainFrame(); frame; frame = frame->tree().traverseNext() ) { | 458 for (Frame* frame = mainFrame(); frame; frame = frame->tree().traverseNext() ) { |
| 472 if (frame->isLocalFrame()) | 459 if (frame->isLocalFrame()) |
| 473 frames.append(toLocalFrame(frame)); | 460 frames.append(toLocalFrame(frame)); |
| 474 } | 461 } |
| 475 | 462 |
| 476 for (unsigned i = 0; i < frames.size(); ++i) | 463 for (unsigned i = 0; i < frames.size(); ++i) |
| 477 frames[i]->localDOMWindow()->acceptLanguagesChanged(); | 464 frames[i]->localDOMWindow()->acceptLanguagesChanged(); |
| 478 } | 465 } |
| 479 | 466 |
| 467 void Page::purgeMemory() | |
| 468 { | |
| 469 // Ask each frame to purge memory. | |
| 470 for (Frame* frame = mainFrame(); frame; frame = frame->tree().traverseNext() ) { | |
| 471 if (frame->isLocalFrame()) | |
| 472 toLocalFrame(frame)->purgeMemory(); | |
| 473 } | |
| 474 } | |
| 475 | |
| 476 void Page::onMemoryPressure() | |
| 477 { | |
| 478 for (Page* page : allPages()) | |
| 479 page->purgeMemory(); | |
| 480 } | |
| 481 | |
| 480 DEFINE_TRACE(Page) | 482 DEFINE_TRACE(Page) |
| 481 { | 483 { |
| 482 visitor->trace(m_animator); | 484 visitor->trace(m_animator); |
| 483 visitor->trace(m_autoscrollController); | 485 visitor->trace(m_autoscrollController); |
| 484 visitor->trace(m_chromeClient); | 486 visitor->trace(m_chromeClient); |
| 485 visitor->trace(m_dragCaretController); | 487 visitor->trace(m_dragCaretController); |
| 486 visitor->trace(m_dragController); | 488 visitor->trace(m_dragController); |
| 487 visitor->trace(m_focusController); | 489 visitor->trace(m_focusController); |
| 488 visitor->trace(m_contextMenuController); | 490 visitor->trace(m_contextMenuController); |
| 489 visitor->trace(m_pointerLockController); | 491 visitor->trace(m_pointerLockController); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 526 m_scrollingCoordinator->willBeDestroyed(); | 528 m_scrollingCoordinator->willBeDestroyed(); |
| 527 | 529 |
| 528 chromeClient().chromeDestroyed(); | 530 chromeClient().chromeDestroyed(); |
| 529 if (m_validationMessageClient) | 531 if (m_validationMessageClient) |
| 530 m_validationMessageClient->willBeDestroyed(); | 532 m_validationMessageClient->willBeDestroyed(); |
| 531 m_mainFrame = nullptr; | 533 m_mainFrame = nullptr; |
| 532 | 534 |
| 533 PageVisibilityNotifier::notifyContextDestroyed(); | 535 PageVisibilityNotifier::notifyContextDestroyed(); |
| 534 } | 536 } |
| 535 | 537 |
| 536 void Page::compressStrings(Timer<Page>* timer) | |
| 537 { | |
| 538 ASSERT_UNUSED(timer, timer == &m_timerForCompressStrings); | |
| 539 if (m_visibilityState == PageVisibilityStateHidden) | |
| 540 CompressibleStringImpl::compressAll(); | |
| 541 } | |
| 542 | |
| 543 Page::PageClients::PageClients() | 538 Page::PageClients::PageClients() |
| 544 : chromeClient(nullptr) | 539 : chromeClient(nullptr) |
| 545 , contextMenuClient(nullptr) | 540 , contextMenuClient(nullptr) |
| 546 , editorClient(nullptr) | 541 , editorClient(nullptr) |
| 547 , spellCheckerClient(nullptr) | 542 , spellCheckerClient(nullptr) |
| 548 { | 543 { |
| 549 } | 544 } |
| 550 | 545 |
| 551 Page::PageClients::~PageClients() | 546 Page::PageClients::~PageClients() |
| 552 { | 547 { |
| 553 } | 548 } |
| 554 | 549 |
| 555 template class CORE_TEMPLATE_EXPORT Supplement<Page>; | 550 template class CORE_TEMPLATE_EXPORT Supplement<Page>; |
| 556 | 551 |
| 557 } // namespace blink | 552 } // namespace blink |
| OLD | NEW |