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

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

Issue 1583263002: Experimental CompressibleString UMA (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adopt lazy-initializing way 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, 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "core/page/ChromeClient.h" 43 #include "core/page/ChromeClient.h"
44 #include "core/page/ContextMenuController.h" 44 #include "core/page/ContextMenuController.h"
45 #include "core/page/DragController.h" 45 #include "core/page/DragController.h"
46 #include "core/page/FocusController.h" 46 #include "core/page/FocusController.h"
47 #include "core/page/PointerLockController.h" 47 #include "core/page/PointerLockController.h"
48 #include "core/page/ValidationMessageClient.h" 48 #include "core/page/ValidationMessageClient.h"
49 #include "core/page/scrolling/ScrollingCoordinator.h" 49 #include "core/page/scrolling/ScrollingCoordinator.h"
50 #include "core/paint/PaintLayer.h" 50 #include "core/paint/PaintLayer.h"
51 #include "platform/graphics/GraphicsLayer.h" 51 #include "platform/graphics/GraphicsLayer.h"
52 #include "platform/plugins/PluginData.h" 52 #include "platform/plugins/PluginData.h"
53 #include "platform/text/CompressibleString.h"
53 #include "public/platform/Platform.h" 54 #include "public/platform/Platform.h"
54 55
55 namespace blink { 56 namespace blink {
56 57
57 // Set of all live pages; includes internal Page objects that are 58 // Set of all live pages; includes internal Page objects that are
58 // not observable from scripts. 59 // not observable from scripts.
59 static Page::PageSet& allPages() 60 static Page::PageSet& allPages()
60 { 61 {
61 DEFINE_STATIC_LOCAL(Page::PageSet, allPages, ()); 62 DEFINE_STATIC_LOCAL(Page::PageSet, allPages, ());
62 return allPages; 63 return allPages;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 , m_openedByDOM(false) 130 , m_openedByDOM(false)
130 , m_tabKeyCyclesThroughElements(true) 131 , m_tabKeyCyclesThroughElements(true)
131 , m_defersLoading(false) 132 , m_defersLoading(false)
132 , m_deviceScaleFactor(1) 133 , m_deviceScaleFactor(1)
133 , m_visibilityState(PageVisibilityStateVisible) 134 , m_visibilityState(PageVisibilityStateVisible)
134 , m_isCursorVisible(true) 135 , m_isCursorVisible(true)
135 #if ENABLE(ASSERT) 136 #if ENABLE(ASSERT)
136 , m_isPainting(false) 137 , m_isPainting(false)
137 #endif 138 #endif
138 , m_frameHost(FrameHost::create(*this)) 139 , m_frameHost(FrameHost::create(*this))
140 , m_timerForCompressStrings(this, &Page::compressStrings)
139 { 141 {
140 ASSERT(m_editorClient); 142 ASSERT(m_editorClient);
141 143
142 ASSERT(!allPages().contains(this)); 144 ASSERT(!allPages().contains(this));
143 allPages().add(this); 145 allPages().add(this);
144 } 146 }
145 147
146 Page::~Page() 148 Page::~Page()
147 { 149 {
148 #if !ENABLE(OILPAN) 150 #if !ENABLE(OILPAN)
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 for (const Page* page : ordinaryPages()) { 358 for (const Page* page : ordinaryPages()) {
357 for (Frame* frame = page->m_mainFrame; frame; frame = frame->tree().trav erseNext()) { 359 for (Frame* frame = page->m_mainFrame; frame; frame = frame->tree().trav erseNext()) {
358 if (frame->isLocalFrame()) 360 if (frame->isLocalFrame())
359 toLocalFrame(frame)->document()->visitedLinkState().invalidateSt yleForLink(linkHash); 361 toLocalFrame(frame)->document()->visitedLinkState().invalidateSt yleForLink(linkHash);
360 } 362 }
361 } 363 }
362 } 364 }
363 365
364 void Page::setVisibilityState(PageVisibilityState visibilityState, bool isInitia lState) 366 void Page::setVisibilityState(PageVisibilityState visibilityState, bool isInitia lState)
365 { 367 {
368 static const double waitingTimeBeforeCompressingString = 10;
369
370 CompressibleStringImpl::setPageBackground(visibilityState == PageVisibilityS tateHidden);
366 if (m_visibilityState == visibilityState) 371 if (m_visibilityState == visibilityState)
367 return; 372 return;
368 m_visibilityState = visibilityState; 373 m_visibilityState = visibilityState;
369 374
370 if (!isInitialState) 375 if (!isInitialState)
371 notifyPageVisibilityChanged(); 376 notifyPageVisibilityChanged();
372 377
373 if (!isInitialState && m_mainFrame && m_mainFrame->isLocalFrame()) 378 if (!isInitialState && m_mainFrame && m_mainFrame->isLocalFrame())
374 deprecatedLocalMainFrame()->didChangeVisibilityState(); 379 deprecatedLocalMainFrame()->didChangeVisibilityState();
380
381 // Compress CompressibleStrings when 10 seconds have passed since the page
382 // went to background.
383 if (m_visibilityState == PageVisibilityStateHidden) {
384 if (!m_timerForCompressStrings.isActive())
385 m_timerForCompressStrings.startOneShot(waitingTimeBeforeCompressingS tring, BLINK_FROM_HERE);
386 } else if (m_timerForCompressStrings.isActive()) {
387 m_timerForCompressStrings.stop();
388 }
375 } 389 }
376 390
377 PageVisibilityState Page::visibilityState() const 391 PageVisibilityState Page::visibilityState() const
378 { 392 {
379 return m_visibilityState; 393 return m_visibilityState;
380 } 394 }
381 395
382 bool Page::isCursorVisible() const 396 bool Page::isCursorVisible() const
383 { 397 {
384 return m_isCursorVisible && settings().deviceSupportsMouse(); 398 return m_isCursorVisible && settings().deviceSupportsMouse();
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 m_scrollingCoordinator->willBeDestroyed(); 591 m_scrollingCoordinator->willBeDestroyed();
578 592
579 chromeClient().chromeDestroyed(); 593 chromeClient().chromeDestroyed();
580 if (m_validationMessageClient) 594 if (m_validationMessageClient)
581 m_validationMessageClient->willBeDestroyed(); 595 m_validationMessageClient->willBeDestroyed();
582 m_mainFrame = nullptr; 596 m_mainFrame = nullptr;
583 597
584 PageLifecycleNotifier::notifyContextDestroyed(); 598 PageLifecycleNotifier::notifyContextDestroyed();
585 } 599 }
586 600
601 void Page::compressStrings(Timer<Page>* timer)
602 {
603 ASSERT_UNUSED(timer, timer == &m_timerForCompressStrings);
604 if (m_visibilityState == PageVisibilityStateHidden)
605 CompressibleStringImpl::compressAll();
606 }
607
587 Page::PageClients::PageClients() 608 Page::PageClients::PageClients()
588 : chromeClient(nullptr) 609 : chromeClient(nullptr)
589 , contextMenuClient(nullptr) 610 , contextMenuClient(nullptr)
590 , editorClient(nullptr) 611 , editorClient(nullptr)
591 , dragClient(nullptr) 612 , dragClient(nullptr)
592 , spellCheckerClient(nullptr) 613 , spellCheckerClient(nullptr)
593 { 614 {
594 } 615 }
595 616
596 Page::PageClients::~PageClients() 617 Page::PageClients::~PageClients()
597 { 618 {
598 } 619 }
599 620
600 template class CORE_TEMPLATE_EXPORT WillBeHeapSupplement<Page>; 621 template class CORE_TEMPLATE_EXPORT WillBeHeapSupplement<Page>;
601 622
602 } // namespace blink 623 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/page/Page.h ('k') | third_party/WebKit/Source/platform/blink_platform.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698