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

Side by Side Diff: third_party/WebKit/Source/platform/blob/BlobRegistry.cpp

Issue 2654663004: [Not for review] record detailed time breakdown of SW related requests.
Patch Set: add stream uma Created 3 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 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 12 matching lines...) Expand all
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "platform/blob/BlobRegistry.h" 31 #include "platform/blob/BlobRegistry.h"
32 32
33 #include <memory>
33 #include "platform/CrossThreadFunctional.h" 34 #include "platform/CrossThreadFunctional.h"
35 #include "platform/Histogram.h"
34 #include "platform/WebTaskRunner.h" 36 #include "platform/WebTaskRunner.h"
35 #include "platform/blob/BlobData.h" 37 #include "platform/blob/BlobData.h"
36 #include "platform/blob/BlobURL.h" 38 #include "platform/blob/BlobURL.h"
37 #include "platform/weborigin/SecurityOrigin.h" 39 #include "platform/weborigin/SecurityOrigin.h"
38 #include "platform/weborigin/URLSecurityOriginMap.h" 40 #include "platform/weborigin/URLSecurityOriginMap.h"
39 #include "public/platform/Platform.h" 41 #include "public/platform/Platform.h"
40 #include "public/platform/WebBlobData.h" 42 #include "public/platform/WebBlobData.h"
41 #include "public/platform/WebBlobRegistry.h" 43 #include "public/platform/WebBlobRegistry.h"
42 #include "public/platform/WebString.h" 44 #include "public/platform/WebString.h"
43 #include "public/platform/WebTraceLocation.h" 45 #include "public/platform/WebTraceLocation.h"
44 #include "wtf/Assertions.h" 46 #include "wtf/Assertions.h"
47 #include "wtf/CurrentTime.h"
45 #include "wtf/HashMap.h" 48 #include "wtf/HashMap.h"
46 #include "wtf/RefPtr.h" 49 #include "wtf/RefPtr.h"
47 #include "wtf/ThreadSpecific.h" 50 #include "wtf/ThreadSpecific.h"
48 #include "wtf/Threading.h" 51 #include "wtf/Threading.h"
49 #include "wtf/text/StringHash.h" 52 #include "wtf/text/StringHash.h"
50 #include "wtf/text/WTFString.h" 53 #include "wtf/text/WTFString.h"
51 #include <memory>
52 54
53 namespace blink { 55 namespace blink {
54 56
55 class BlobOriginMap : public URLSecurityOriginMap { 57 class BlobOriginMap : public URLSecurityOriginMap {
56 public: 58 public:
57 BlobOriginMap(); 59 BlobOriginMap();
58 SecurityOrigin* getOrigin(const KURL&) override; 60 SecurityOrigin* getOrigin(const KURL&) override;
59 }; 61 };
60 62
61 static WebBlobRegistry* getBlobRegistry() { 63 static WebBlobRegistry* getBlobRegistry() {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 PassRefPtr<BlobDataHandle> handle) { 109 PassRefPtr<BlobDataHandle> handle) {
108 saveToOriginMap(origin, url); 110 saveToOriginMap(origin, url);
109 getBlobRegistry()->registerPublicBlobURL(url, handle->uuid()); 111 getBlobRegistry()->registerPublicBlobURL(url, handle->uuid());
110 } 112 }
111 113
112 void BlobRegistry::revokePublicBlobURL(const KURL& url) { 114 void BlobRegistry::revokePublicBlobURL(const KURL& url) {
113 removeFromOriginMap(url); 115 removeFromOriginMap(url);
114 getBlobRegistry()->revokePublicBlobURL(url); 116 getBlobRegistry()->revokePublicBlobURL(url);
115 } 117 }
116 118
117 static void registerStreamURLTask(const KURL& url, const String& type) { 119 static void registerStreamURLTask(const KURL& url,
120 const String& type,
121 double postTaskTime) {
122 int value =
123 static_cast<int>((monotonicallyIncreasingTime() - postTaskTime) * 1000);
124 DEFINE_STATIC_LOCAL(CustomCountHistogram, hist,
125 ("SWF.E1.Stream.RegisterStreamURLTask", 0, 10000000, 50));
126 if (postTaskTime != 0)
127 hist.count(value);
118 if (WebBlobRegistry* registry = getBlobRegistry()) 128 if (WebBlobRegistry* registry = getBlobRegistry())
119 registry->registerStreamURL(url, type); 129 registry->registerStreamURL(url, type);
120 } 130 }
121 131
122 void BlobRegistry::registerStreamURL(const KURL& url, const String& type) { 132 void BlobRegistry::registerStreamURL(const KURL& url, const String& type) {
123 if (isMainThread()) 133 if (isMainThread())
124 registerStreamURLTask(url, type); 134 registerStreamURLTask(url, type, 0);
125 else 135 else
126 Platform::current()->mainThread()->getWebTaskRunner()->postTask( 136 Platform::current()->mainThread()->getWebTaskRunner()->postTask(
127 BLINK_FROM_HERE, crossThreadBind(&registerStreamURLTask, url, type)); 137 BLINK_FROM_HERE, crossThreadBind(&registerStreamURLTask, url, type,
138 monotonicallyIncreasingTime()));
128 } 139 }
129 140
130 static void registerStreamURLFromTask(const KURL& url, const KURL& srcURL) { 141 static void registerStreamURLFromTask(const KURL& url,
142 const KURL& srcURL,
143 double postTaskTime) {
144 int value =
145 static_cast<int>((monotonicallyIncreasingTime() - postTaskTime) * 1000);
146 DEFINE_STATIC_LOCAL(
147 CustomCountHistogram, hist,
148 ("SWF.E1.Stream.registerStreamURLFromTask", 0, 10000000, 50));
149 if (postTaskTime != 0)
150 hist.count(value);
131 if (WebBlobRegistry* registry = getBlobRegistry()) 151 if (WebBlobRegistry* registry = getBlobRegistry())
132 registry->registerStreamURL(url, srcURL); 152 registry->registerStreamURL(url, srcURL);
133 } 153 }
134 154
135 void BlobRegistry::registerStreamURL(SecurityOrigin* origin, 155 void BlobRegistry::registerStreamURL(SecurityOrigin* origin,
136 const KURL& url, 156 const KURL& url,
137 const KURL& srcURL) { 157 const KURL& srcURL) {
138 saveToOriginMap(origin, url); 158 saveToOriginMap(origin, url);
139 159
140 if (isMainThread()) 160 if (isMainThread())
141 registerStreamURLFromTask(url, srcURL); 161 registerStreamURLFromTask(url, srcURL, 0);
142 else 162 else
143 Platform::current()->mainThread()->getWebTaskRunner()->postTask( 163 Platform::current()->mainThread()->getWebTaskRunner()->postTask(
144 BLINK_FROM_HERE, 164 BLINK_FROM_HERE,
145 crossThreadBind(&registerStreamURLFromTask, url, srcURL)); 165 crossThreadBind(&registerStreamURLFromTask, url, srcURL,
166 monotonicallyIncreasingTime()));
146 } 167 }
147 168
148 static void addDataToStreamTask(const KURL& url, 169 static void addDataToStreamTask(const KURL& url,
149 PassRefPtr<RawData> streamData) { 170 PassRefPtr<RawData> streamData,
171 double postTaskTime) {
172 int value =
173 static_cast<int>((monotonicallyIncreasingTime() - postTaskTime) * 1000);
174 DEFINE_STATIC_LOCAL(CustomCountHistogram, hist,
175 ("SWF.E2.Stream.AddDataToStreamTask", 0, 10000000, 50));
176 if (postTaskTime != 0)
177 hist.count(value);
178
150 if (WebBlobRegistry* registry = getBlobRegistry()) 179 if (WebBlobRegistry* registry = getBlobRegistry())
151 registry->addDataToStream(url, streamData->data(), streamData->length()); 180 registry->addDataToStream(url, streamData->data(), streamData->length());
152 } 181 }
153 182
154 void BlobRegistry::addDataToStream(const KURL& url, 183 void BlobRegistry::addDataToStream(const KURL& url,
155 PassRefPtr<RawData> streamData) { 184 PassRefPtr<RawData> streamData) {
156 if (isMainThread()) 185 if (isMainThread())
157 addDataToStreamTask(url, std::move(streamData)); 186 addDataToStreamTask(url, std::move(streamData), 0);
158 else 187 else
159 Platform::current()->mainThread()->getWebTaskRunner()->postTask( 188 Platform::current()->mainThread()->getWebTaskRunner()->postTask(
160 BLINK_FROM_HERE, 189 BLINK_FROM_HERE,
161 crossThreadBind(&addDataToStreamTask, url, std::move(streamData))); 190 crossThreadBind(&addDataToStreamTask, url, std::move(streamData),
191 monotonicallyIncreasingTime()));
162 } 192 }
163 193
164 static void flushStreamTask(const KURL& url) { 194 static void flushStreamTask(const KURL& url, double postTaskTime) {
195 int value =
196 static_cast<int>((monotonicallyIncreasingTime() - postTaskTime) * 1000);
197 DEFINE_STATIC_LOCAL(CustomCountHistogram, hist,
198 ("SWF.E3.Stream.FlushStreamTask", 0, 10000000, 50));
199 if (postTaskTime != 0)
200 hist.count(value);
201
165 if (WebBlobRegistry* registry = getBlobRegistry()) 202 if (WebBlobRegistry* registry = getBlobRegistry())
166 registry->flushStream(url); 203 registry->flushStream(url);
167 } 204 }
168 205
169 void BlobRegistry::flushStream(const KURL& url) { 206 void BlobRegistry::flushStream(const KURL& url) {
170 if (isMainThread()) 207 if (isMainThread())
171 flushStreamTask(url); 208 flushStreamTask(url, 0);
172 else 209 else
173 Platform::current()->mainThread()->getWebTaskRunner()->postTask( 210 Platform::current()->mainThread()->getWebTaskRunner()->postTask(
174 BLINK_FROM_HERE, crossThreadBind(&flushStreamTask, url)); 211 BLINK_FROM_HERE,
212 crossThreadBind(&flushStreamTask, url, monotonicallyIncreasingTime()));
175 } 213 }
176 214
177 static void finalizeStreamTask(const KURL& url) { 215 static void finalizeStreamTask(const KURL& url, double postTaskTime) {
216 int value =
217 static_cast<int>((monotonicallyIncreasingTime() - postTaskTime) * 1000);
218 DEFINE_STATIC_LOCAL(CustomCountHistogram, hist,
219 ("SWF.E4.Stream.FinalizeStreamTask", 0, 10000000, 50));
220 if (postTaskTime != 0)
221 hist.count(value);
178 if (WebBlobRegistry* registry = getBlobRegistry()) 222 if (WebBlobRegistry* registry = getBlobRegistry())
179 registry->finalizeStream(url); 223 registry->finalizeStream(url);
180 } 224 }
181 225
182 void BlobRegistry::finalizeStream(const KURL& url) { 226 void BlobRegistry::finalizeStream(const KURL& url) {
183 if (isMainThread()) 227 if (isMainThread())
184 finalizeStreamTask(url); 228 finalizeStreamTask(url, 0);
185 else 229 else
186 Platform::current()->mainThread()->getWebTaskRunner()->postTask( 230 Platform::current()->mainThread()->getWebTaskRunner()->postTask(
187 BLINK_FROM_HERE, crossThreadBind(&finalizeStreamTask, url)); 231 BLINK_FROM_HERE, crossThreadBind(&finalizeStreamTask, url,
232 monotonicallyIncreasingTime()));
188 } 233 }
189 234
190 static void abortStreamTask(const KURL& url) { 235 static void abortStreamTask(const KURL& url, double postTaskTime) {
236 int value =
237 static_cast<int>((monotonicallyIncreasingTime() - postTaskTime) * 1000);
238 DEFINE_STATIC_LOCAL(CustomCountHistogram, hist,
239 ("SWF.E5.Stream.AbortStreamTask", 0, 10000000, 50));
240 if (postTaskTime != 0)
241 hist.count(value);
191 if (WebBlobRegistry* registry = getBlobRegistry()) 242 if (WebBlobRegistry* registry = getBlobRegistry())
192 registry->abortStream(url); 243 registry->abortStream(url);
193 } 244 }
194 245
195 void BlobRegistry::abortStream(const KURL& url) { 246 void BlobRegistry::abortStream(const KURL& url) {
196 if (isMainThread()) 247 if (isMainThread())
197 abortStreamTask(url); 248 abortStreamTask(url, 0);
198 else 249 else
199 Platform::current()->mainThread()->getWebTaskRunner()->postTask( 250 Platform::current()->mainThread()->getWebTaskRunner()->postTask(
200 BLINK_FROM_HERE, crossThreadBind(&abortStreamTask, url)); 251 BLINK_FROM_HERE,
252 crossThreadBind(&abortStreamTask, url, monotonicallyIncreasingTime()));
201 } 253 }
202 254
203 static void unregisterStreamURLTask(const KURL& url) { 255 static void unregisterStreamURLTask(const KURL& url, double postTaskTime) {
256 int value =
257 static_cast<int>((monotonicallyIncreasingTime() - postTaskTime) * 1000);
258 DEFINE_STATIC_LOCAL(
259 CustomCountHistogram, hist,
260 ("SWF.E6.Stream.UnregisterStreamURLTask", 0, 10000000, 50));
261 if (postTaskTime != 0)
262 hist.count(value);
204 if (WebBlobRegistry* registry = getBlobRegistry()) 263 if (WebBlobRegistry* registry = getBlobRegistry())
205 registry->unregisterStreamURL(url); 264 registry->unregisterStreamURL(url);
206 } 265 }
207 266
208 void BlobRegistry::unregisterStreamURL(const KURL& url) { 267 void BlobRegistry::unregisterStreamURL(const KURL& url) {
209 removeFromOriginMap(url); 268 removeFromOriginMap(url);
210 269
211 if (isMainThread()) 270 if (isMainThread())
212 unregisterStreamURLTask(url); 271 unregisterStreamURLTask(url, 0);
213 else 272 else
214 Platform::current()->mainThread()->getWebTaskRunner()->postTask( 273 Platform::current()->mainThread()->getWebTaskRunner()->postTask(
215 BLINK_FROM_HERE, crossThreadBind(&unregisterStreamURLTask, url)); 274 BLINK_FROM_HERE, crossThreadBind(&unregisterStreamURLTask, url,
275 monotonicallyIncreasingTime()));
216 } 276 }
217 277
218 BlobOriginMap::BlobOriginMap() { 278 BlobOriginMap::BlobOriginMap() {
219 SecurityOrigin::setMap(this); 279 SecurityOrigin::setMap(this);
220 } 280 }
221 281
222 SecurityOrigin* BlobOriginMap::getOrigin(const KURL& url) { 282 SecurityOrigin* BlobOriginMap::getOrigin(const KURL& url) {
223 if (url.protocolIs("blob")) 283 if (url.protocolIs("blob"))
224 return originMap()->get(url.getString()); 284 return originMap()->get(url.getString());
225 return 0; 285 return 0;
226 } 286 }
227 287
228 } // namespace blink 288 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698