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

Side by Side Diff: third_party/WebKit/Source/core/html/parser/CSSPreloadScanner.cpp

Issue 2283803002: Add histogram to track overhead for scanning external css (Closed)
Patch Set: properly set upstream Created 4 years, 3 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
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008, 2010 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008, 2010 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2009 Torch Mobile, Inc. http://www.torchmobile.com/ 3 * Copyright (C) 2009 Torch Mobile, Inc. http://www.torchmobile.com/
4 * Copyright (C) 2010 Google Inc. All Rights Reserved. 4 * Copyright (C) 2010 Google Inc. All Rights Reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 } 266 }
267 267
268 void CSSPreloaderResourceClient::scanCSS(const CSSStyleSheetResource* resource) 268 void CSSPreloaderResourceClient::scanCSS(const CSSStyleSheetResource* resource)
269 { 269 {
270 DCHECK(m_preloader); 270 DCHECK(m_preloader);
271 // Passing an empty SegmentedString here results in PreloadRequest with no 271 // Passing an empty SegmentedString here results in PreloadRequest with no
272 // file/line information. 272 // file/line information.
273 // TODO(csharrison): If this becomes an issue the CSSPreloadScanner may be 273 // TODO(csharrison): If this becomes an issue the CSSPreloadScanner may be
274 // augmented to take care of this case without performing an additional 274 // augmented to take care of this case without performing an additional
275 // copy. 275 // copy.
276 double startTime = monotonicallyIncreasingTimeMS();
276 const String& chunk = resource->decodedText(); 277 const String& chunk = resource->decodedText();
277 if (chunk.isNull()) 278 if (chunk.isNull())
278 return; 279 return;
279 CSSPreloadScanner cssPreloadScanner; 280 CSSPreloadScanner cssPreloadScanner;
280 PreloadRequestStream preloads; 281 PreloadRequestStream preloads;
281 cssPreloadScanner.scan(chunk, SegmentedString(), preloads, resource->respons e().url()); 282 cssPreloadScanner.scan(chunk, SegmentedString(), preloads, resource->respons e().url());
283 DEFINE_STATIC_LOCAL(CustomCountHistogram, cssScanTimeHistogram, ("PreloadSca nner.ExternalCSS.ScanTime", 1, 1000000, 50));
284 cssScanTimeHistogram.count((monotonicallyIncreasingTimeMS() - startTime) * 1 000);
282 fetchPreloads(preloads); 285 fetchPreloads(preloads);
283 } 286 }
284 287
285 void CSSPreloaderResourceClient::fetchPreloads(PreloadRequestStream& preloads) 288 void CSSPreloaderResourceClient::fetchPreloads(PreloadRequestStream& preloads)
286 { 289 {
287 if (preloads.size()) { 290 if (preloads.size()) {
288 m_preloader->document()->loader()->didObserveLoadingBehavior(WebLoadingB ehaviorFlag::WebLoadingBehaviorCSSPreloadFound); 291 m_preloader->document()->loader()->didObserveLoadingBehavior(WebLoadingB ehaviorFlag::WebLoadingBehaviorCSSPreloadFound);
289 } 292 }
290 293
291 Settings* settings = m_preloader->document()->settings(); 294 Settings* settings = m_preloader->document()->settings();
292 DCHECK(settings); 295 DCHECK(settings);
293 if (settings->cssExternalScannerPreload()) { 296 if (settings->cssExternalScannerPreload()) {
294 int currentPreloadCount = m_preloader->countPreloads(); 297 int currentPreloadCount = m_preloader->countPreloads();
295 m_preloader->takeAndPreload(preloads); 298 m_preloader->takeAndPreload(preloads);
296 DEFINE_STATIC_LOCAL(CustomCountHistogram, cssImportHistogram, ("PreloadS canner.ExternalCSS.PreloadCount", 1, 100, 50)); 299 DEFINE_STATIC_LOCAL(CustomCountHistogram, cssImportHistogram, ("PreloadS canner.ExternalCSS.PreloadCount", 1, 100, 50));
297 cssImportHistogram.count(m_preloader->countPreloads() - currentPreloadCo unt); 300 cssImportHistogram.count(m_preloader->countPreloads() - currentPreloadCo unt);
298 } 301 }
299 } 302 }
300 303
301 DEFINE_TRACE(CSSPreloaderResourceClient) 304 DEFINE_TRACE(CSSPreloaderResourceClient)
302 { 305 {
303 visitor->trace(m_preloader); 306 visitor->trace(m_preloader);
304 ResourceOwner<CSSStyleSheetResource>::trace(visitor); 307 ResourceOwner<CSSStyleSheetResource>::trace(visitor);
305 } 308 }
306 309
307 } // namespace blink 310 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698