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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/page/Page.cpp
diff --git a/third_party/WebKit/Source/core/page/Page.cpp b/third_party/WebKit/Source/core/page/Page.cpp
index 6ed312c28645668efdf089e6a98768aae7dbaed9..c587b9c432764e6330589cf8235ef912fcdad5e3 100644
--- a/third_party/WebKit/Source/core/page/Page.cpp
+++ b/third_party/WebKit/Source/core/page/Page.cpp
@@ -50,6 +50,7 @@
#include "core/paint/PaintLayer.h"
#include "platform/graphics/GraphicsLayer.h"
#include "platform/plugins/PluginData.h"
+#include "platform/text/CompressibleString.h"
#include "public/platform/Platform.h"
namespace blink {
@@ -136,6 +137,7 @@ Page::Page(PageClients& pageClients)
, m_isPainting(false)
#endif
, m_frameHost(FrameHost::create(*this))
+ , m_timerForCompressStrings(this, &Page::compressStrings)
{
ASSERT(m_editorClient);
@@ -363,6 +365,9 @@ void Page::visitedStateChanged(LinkHash linkHash)
void Page::setVisibilityState(PageVisibilityState visibilityState, bool isInitialState)
{
+ static const double waitingTimeBeforeCompressingString = 10;
+
+ CompressibleStringImpl::setPageBackground(visibilityState == PageVisibilityStateHidden);
if (m_visibilityState == visibilityState)
return;
m_visibilityState = visibilityState;
@@ -372,6 +377,15 @@ void Page::setVisibilityState(PageVisibilityState visibilityState, bool isInitia
if (!isInitialState && m_mainFrame && m_mainFrame->isLocalFrame())
deprecatedLocalMainFrame()->didChangeVisibilityState();
+
+ // Compress CompressibleStrings when 10 seconds have passed since the page
+ // went to background.
+ if (m_visibilityState == PageVisibilityStateHidden) {
+ if (!m_timerForCompressStrings.isActive())
+ m_timerForCompressStrings.startOneShot(waitingTimeBeforeCompressingString, BLINK_FROM_HERE);
+ } else if (m_timerForCompressStrings.isActive()) {
+ m_timerForCompressStrings.stop();
+ }
}
PageVisibilityState Page::visibilityState() const
@@ -584,6 +598,13 @@ void Page::willBeDestroyed()
PageLifecycleNotifier::notifyContextDestroyed();
}
+void Page::compressStrings(Timer<Page>* timer)
+{
+ ASSERT_UNUSED(timer, timer == &m_timerForCompressStrings);
+ if (m_visibilityState == PageVisibilityStateHidden)
+ CompressibleStringImpl::compressAll();
+}
+
Page::PageClients::PageClients()
: chromeClient(nullptr)
, contextMenuClient(nullptr)
« 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