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

Side by Side Diff: third_party/WebKit/Source/platform/text/CompressibleString.cpp

Issue 1646443002: Remove CompressibleStringImpl::s_isPageBackground (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/text/CompressibleString.h" 5 #include "platform/text/CompressibleString.h"
6 6
7 #include "public/platform/Platform.h" 7 #include "public/platform/Platform.h"
8 #include "wtf/Assertions.h" 8 #include "wtf/Assertions.h"
9 #include "wtf/WTFThreadData.h" 9 #include "wtf/WTFThreadData.h"
10 #include "wtf/text/WTFString.h" 10 #include "wtf/text/WTFString.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 { 63 {
64 WTFThreadData& data = wtfThreadData(); 64 WTFThreadData& data = wtfThreadData();
65 CompressibleStringTable* table = data.compressibleStringTable(); 65 CompressibleStringTable* table = data.compressibleStringTable();
66 if (UNLIKELY(!table)) 66 if (UNLIKELY(!table))
67 table = CompressibleStringTable::create(data); 67 table = CompressibleStringTable::create(data);
68 return *table; 68 return *table;
69 } 69 }
70 70
71 static const unsigned CompressibleStringImplSizeThrehold = 100000; 71 static const unsigned CompressibleStringImplSizeThrehold = 100000;
72 72
73 bool CompressibleStringImpl::s_isPageBackground = false;
74
75 void CompressibleStringImpl::compressAll() 73 void CompressibleStringImpl::compressAll()
76 { 74 {
77 compressibleStringTable().compressAll(); 75 compressibleStringTable().compressAll();
78 } 76 }
79 77
80 void CompressibleStringImpl::setPageBackground(bool isPageBackground)
81 {
82 s_isPageBackground = isPageBackground;
83 }
84
85 CompressibleStringImpl::CompressibleStringImpl(PassRefPtr<StringImpl> impl) 78 CompressibleStringImpl::CompressibleStringImpl(PassRefPtr<StringImpl> impl)
86 : m_string(impl) 79 : m_string(impl)
87 , m_isCompressed(false) 80 , m_isCompressed(false)
88 { 81 {
89 if (originalContentSizeInBytes() > CompressibleStringImplSizeThrehold) 82 if (originalContentSizeInBytes() > CompressibleStringImplSizeThrehold)
90 compressibleStringTable().add(this); 83 compressibleStringTable().add(this);
91 } 84 }
92 85
93 CompressibleStringImpl::~CompressibleStringImpl() 86 CompressibleStringImpl::~CompressibleStringImpl()
94 { 87 {
95 if (originalContentSizeInBytes() > CompressibleStringImplSizeThrehold) 88 if (originalContentSizeInBytes() > CompressibleStringImplSizeThrehold)
96 compressibleStringTable().remove(this); 89 compressibleStringTable().remove(this);
97 } 90 }
98 91
99 enum CompressibleStringCountType { 92 enum CompressibleStringCountType {
100 StringWasCompressedInBackgroundTab, 93 StringWasCompressedInBackgroundTab,
101 StringWasDecompressedInBackgroundTab, 94 StringWasDecompressed,
102 StringWasDecompressedInForegroundTab, 95 CompressibleStringCountTypeMax = StringWasDecompressed,
103 CompressibleStringCountTypeMax = StringWasDecompressedInForegroundTab,
104 }; 96 };
105 97
106 static void recordCompressibleStringCount(CompressibleStringCountType type) 98 static void recordCompressibleStringCount(CompressibleStringCountType type)
107 { 99 {
108 Platform::current()->histogramEnumeration("Memory.CompressibleStringCount", type, CompressibleStringCountTypeMax + 1); 100 Platform::current()->histogramEnumeration("Memory.CompressibleStringCount", type, CompressibleStringCountTypeMax + 1);
109 } 101 }
110 102
111 // compressString does nothing but collect UMA so far. 103 // compressString does nothing but collect UMA so far.
112 // TODO(hajimehoshi): Implement this. 104 // TODO(hajimehoshi): Implement this.
113 void CompressibleStringImpl::compressString() 105 void CompressibleStringImpl::compressString()
114 { 106 {
115 ASSERT(s_isPageBackground);
116 recordCompressibleStringCount(StringWasCompressedInBackgroundTab); 107 recordCompressibleStringCount(StringWasCompressedInBackgroundTab);
117 ASSERT(!isCompressed()); 108 ASSERT(!isCompressed());
118 m_isCompressed = true; 109 m_isCompressed = true;
119 } 110 }
120 111
121 // decompressString does nothing but collect UMA so far. 112 // decompressString does nothing but collect UMA so far.
122 // TODO(hajimehoshi): Implement this. 113 // TODO(hajimehoshi): Implement this.
123 void CompressibleStringImpl::decompressString() 114 void CompressibleStringImpl::decompressString()
124 { 115 {
125 if (s_isPageBackground) 116 // TODO(hajimehoshi): We wanted to tell whether decompressing in a
126 recordCompressibleStringCount(StringWasDecompressedInBackgroundTab); 117 // background tab or a foreground tab, but this was impossible. For example,
127 else 118 // one renderer process of a new tab page is used for multiple tabs.
128 recordCompressibleStringCount(StringWasDecompressedInForegroundTab); 119 // Another example is that reloading a page will re-use the process with a
129 120 // new Page object and updating a static variable along with reloading will
121 // be complex. See also crbug/581266. We will revisit when the situation
122 // changes.
123 recordCompressibleStringCount(StringWasDecompressed);
130 ASSERT(isCompressed()); 124 ASSERT(isCompressed());
131 m_isCompressed = false; 125 m_isCompressed = false;
132 } 126 }
133 127
134 } // namespace blink 128 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698