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

Side by Side Diff: Source/core/frame/UseCounter.cpp

Issue 1096963002: Make UseCounters work on aliased properties (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 8 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 | « Source/core/css/parser/CSSPropertyParser.cpp ('k') | no next file » | 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) 2012 Google, Inc. All rights reserved. 2 * Copyright (C) 2012 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 int UseCounter::m_muteCount = 0; 44 int UseCounter::m_muteCount = 0;
45 45
46 // FIXME : This mapping should be autogenerated. This function should 46 // FIXME : This mapping should be autogenerated. This function should
47 // be moved to a separate file and a script run at build time 47 // be moved to a separate file and a script run at build time
48 // to detect new values in CSSPropertyID and add them to the 48 // to detect new values in CSSPropertyID and add them to the
49 // end of this function. This file would be checked in. 49 // end of this function. This file would be checked in.
50 // https://code.google.com/p/chromium/issues/detail?id=234940 50 // https://code.google.com/p/chromium/issues/detail?id=234940
51 int UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(int id) 51 int UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(int id)
52 { 52 {
53 CSSPropertyID cssPropertyID = convertToCSSPropertyID(id); 53 CSSPropertyID cssPropertyID = static_cast<CSSPropertyID>(id);
54 54
55 switch (cssPropertyID) { 55 switch (cssPropertyID) {
56 // Begin at 2, because 1 is reserved for totalPagesMeasuredCSSSampleId. 56 // Begin at 2, because 1 is reserved for totalPagesMeasuredCSSSampleId.
57 case CSSPropertyColor: return 2; 57 case CSSPropertyColor: return 2;
58 case CSSPropertyDirection: return 3; 58 case CSSPropertyDirection: return 3;
59 case CSSPropertyDisplay: return 4; 59 case CSSPropertyDisplay: return 4;
60 case CSSPropertyFont: return 5; 60 case CSSPropertyFont: return 5;
61 case CSSPropertyFontFamily: return 6; 61 case CSSPropertyFontFamily: return 6;
62 case CSSPropertyFontSize: return 7; 62 case CSSPropertyFontSize: return 7;
63 case CSSPropertyFontStyle: return 8; 63 case CSSPropertyFontStyle: return 8;
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 case CSSPropertyMotionRotation: return 459; 495 case CSSPropertyMotionRotation: return 459;
496 case CSSPropertyMotion: return 460; 496 case CSSPropertyMotion: return 460;
497 case CSSPropertyX: return 461; 497 case CSSPropertyX: return 461;
498 case CSSPropertyY: return 462; 498 case CSSPropertyY: return 462;
499 case CSSPropertyRx: return 463; 499 case CSSPropertyRx: return 463;
500 case CSSPropertyRy: return 464; 500 case CSSPropertyRy: return 464;
501 case CSSPropertyFontSizeAdjust: return 465; 501 case CSSPropertyFontSizeAdjust: return 465;
502 case CSSPropertyCx: return 466; 502 case CSSPropertyCx: return 466;
503 case CSSPropertyCy: return 467; 503 case CSSPropertyCy: return 467;
504 case CSSPropertyR: return 468; 504 case CSSPropertyR: return 468;
505 case CSSPropertyAliasEpubCaptionSide: return 469;
506 case CSSPropertyAliasEpubTextCombine: return 470;
507 case CSSPropertyAliasEpubTextEmphasis: return 471;
508 case CSSPropertyAliasEpubTextEmphasisColor: return 472;
509 case CSSPropertyAliasEpubTextEmphasisStyle: return 473;
510 case CSSPropertyAliasEpubTextOrientation: return 474;
511 case CSSPropertyAliasEpubTextTransform: return 475;
512 case CSSPropertyAliasEpubWordBreak: return 476;
513 case CSSPropertyAliasEpubWritingMode: return 477;
514 case CSSPropertyAliasWebkitAlignContent: return 478;
515 case CSSPropertyAliasWebkitAlignItems: return 479;
516 case CSSPropertyAliasWebkitAlignSelf: return 480;
517 case CSSPropertyAliasWebkitBorderBottomLeftRadius: return 481;
518 case CSSPropertyAliasWebkitBorderBottomRightRadius: return 482;
519 case CSSPropertyAliasWebkitBorderTopLeftRadius: return 483;
520 case CSSPropertyAliasWebkitBorderTopRightRadius: return 484;
521 case CSSPropertyAliasWebkitBoxSizing: return 485;
522 case CSSPropertyAliasWebkitFlex: return 486;
523 case CSSPropertyAliasWebkitFlexBasis: return 487;
524 case CSSPropertyAliasWebkitFlexDirection: return 488;
525 case CSSPropertyAliasWebkitFlexFlow: return 489;
526 case CSSPropertyAliasWebkitFlexGrow: return 490;
527 case CSSPropertyAliasWebkitFlexShrink: return 491;
528 case CSSPropertyAliasWebkitFlexWrap: return 492;
529 case CSSPropertyAliasWebkitJustifyContent: return 493;
530 case CSSPropertyAliasWebkitOpacity: return 494;
531 case CSSPropertyAliasWebkitOrder: return 495;
532 case CSSPropertyAliasWebkitShapeImageThreshold: return 496;
533 case CSSPropertyAliasWebkitShapeMargin: return 497;
534 case CSSPropertyAliasWebkitShapeOutside: return 498;
505 535
506 // 1. Add new features above this line (don't change the assigned numbers of the existing 536 // 1. Add new features above this line (don't change the assigned numbers of the existing
507 // items). 537 // items).
508 // 2. Update maximumCSSSampleId() with the new maximum value. 538 // 2. Update maximumCSSSampleId() with the new maximum value.
509 // 3. Run the update_use_counter_css.py script in 539 // 3. Run the update_use_counter_css.py script in
510 // chromium/src/tools/metrics/histograms to update the UMA histogram names. 540 // chromium/src/tools/metrics/histograms to update the UMA histogram names.
511 541
512 case CSSPropertyInvalid: 542 case CSSPropertyInvalid:
513 ASSERT_NOT_REACHED(); 543 ASSERT_NOT_REACHED();
514 return 0; 544 return 0;
515 } 545 }
516 546
517 ASSERT_NOT_REACHED(); 547 ASSERT_NOT_REACHED();
518 return 0; 548 return 0;
519 } 549 }
520 550
521 static int maximumCSSSampleId() { return 468; } 551 static int maximumCSSSampleId() { return 498; }
522 552
523 void UseCounter::muteForInspector() 553 void UseCounter::muteForInspector()
524 { 554 {
525 UseCounter::m_muteCount++; 555 UseCounter::m_muteCount++;
526 } 556 }
527 557
528 void UseCounter::unmuteForInspector() 558 void UseCounter::unmuteForInspector()
529 { 559 {
530 UseCounter::m_muteCount--; 560 UseCounter::m_muteCount--;
531 } 561 }
532 562
533 UseCounter::UseCounter() 563 UseCounter::UseCounter()
534 { 564 {
535 m_CSSFeatureBits.ensureSize(lastCSSProperty + 1); 565 m_CSSFeatureBits.ensureSize(lastUnresolvedCSSProperty + 1);
536 m_CSSFeatureBits.clearAll(); 566 m_CSSFeatureBits.clearAll();
537 } 567 }
538 568
539 UseCounter::~UseCounter() 569 UseCounter::~UseCounter()
540 { 570 {
541 // We always log PageDestruction so that we have a scale for the rest of the features. 571 // We always log PageDestruction so that we have a scale for the rest of the features.
542 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObserver", PageDestruction, NumberOfFeatures); 572 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObserver", PageDestruction, NumberOfFeatures);
543 573
544 updateMeasurements(); 574 updateMeasurements();
545 } 575 }
(...skipping 10 matching lines...) Expand all
556 586
557 void UseCounter::updateMeasurements() 587 void UseCounter::updateMeasurements()
558 { 588 {
559 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObserver", PageVisits, NumberOfFeatures); 589 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObserver", PageVisits, NumberOfFeatures);
560 m_countBits.updateMeasurements(); 590 m_countBits.updateMeasurements();
561 591
562 // FIXME: Sometimes this function is called more than once per page. The fol lowing 592 // FIXME: Sometimes this function is called more than once per page. The fol lowing
563 // bool guards against incrementing the page count when there are no CSS 593 // bool guards against incrementing the page count when there are no CSS
564 // bits set. http://crbug.com/236262. 594 // bits set. http://crbug.com/236262.
565 bool needsPagesMeasuredUpdate = false; 595 bool needsPagesMeasuredUpdate = false;
566 for (int i = firstCSSProperty; i <= lastCSSProperty; ++i) { 596 for (int i = firstCSSProperty; i <= lastUnresolvedCSSProperty; ++i) {
567 if (m_CSSFeatureBits.quickGet(i)) { 597 if (m_CSSFeatureBits.quickGet(i)) {
568 int cssSampleId = mapCSSPropertyIdToCSSSampleIdForHistogram(i); 598 int cssSampleId = mapCSSPropertyIdToCSSSampleIdForHistogram(i);
569 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObs erver.CSSProperties", cssSampleId, maximumCSSSampleId()); 599 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObs erver.CSSProperties", cssSampleId, maximumCSSSampleId());
570 needsPagesMeasuredUpdate = true; 600 needsPagesMeasuredUpdate = true;
571 } 601 }
572 } 602 }
573 603
574 if (needsPagesMeasuredUpdate) 604 if (needsPagesMeasuredUpdate)
575 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObserve r.CSSProperties", totalPagesMeasuredCSSSampleId(), maximumCSSSampleId()); 605 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObserve r.CSSProperties", totalPagesMeasuredCSSSampleId(), maximumCSSSampleId());
576 606
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 901
872 // Features that aren't deprecated don't have a deprecation message. 902 // Features that aren't deprecated don't have a deprecation message.
873 default: 903 default:
874 return String(); 904 return String();
875 } 905 }
876 } 906 }
877 907
878 void UseCounter::count(CSSParserContext context, CSSPropertyID feature) 908 void UseCounter::count(CSSParserContext context, CSSPropertyID feature)
879 { 909 {
880 ASSERT(feature >= firstCSSProperty); 910 ASSERT(feature >= firstCSSProperty);
881 ASSERT(feature <= lastCSSProperty); 911 ASSERT(feature <= lastUnresolvedCSSProperty);
882 912
883 if (!isUseCounterEnabledForMode(context.mode())) 913 if (!isUseCounterEnabledForMode(context.mode()))
884 return; 914 return;
885 915
886 m_CSSFeatureBits.quickSet(feature); 916 m_CSSFeatureBits.quickSet(feature);
887 } 917 }
888 918
889 void UseCounter::count(Feature feature) 919 void UseCounter::count(Feature feature)
890 { 920 {
891 ASSERT(deprecationMessage(feature).isEmpty()); 921 ASSERT(deprecationMessage(feature).isEmpty());
(...skipping 17 matching lines...) Expand all
909 UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents) 939 UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents)
910 { 940 {
911 // FIXME: We may want to handle stylesheets that have multiple owners 941 // FIXME: We may want to handle stylesheets that have multiple owners
912 // http://crbug.com/242125 942 // http://crbug.com/242125
913 if (sheetContents && sheetContents->hasSingleOwnerNode()) 943 if (sheetContents && sheetContents->hasSingleOwnerNode())
914 return getFrom(sheetContents->singleOwnerDocument()); 944 return getFrom(sheetContents->singleOwnerDocument());
915 return 0; 945 return 0;
916 } 946 }
917 947
918 } // namespace blink 948 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/parser/CSSPropertyParser.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698