| OLD | NEW |
| 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 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 #include "core/css/CSSStyleSheet.h" | 28 #include "core/css/CSSStyleSheet.h" |
| 29 #include "core/css/StyleSheetContents.h" | 29 #include "core/css/StyleSheetContents.h" |
| 30 #include "core/dom/Document.h" | 30 #include "core/dom/Document.h" |
| 31 #include "core/dom/ExecutionContext.h" | 31 #include "core/dom/ExecutionContext.h" |
| 32 #include "core/frame/FrameConsole.h" | 32 #include "core/frame/FrameConsole.h" |
| 33 #include "core/frame/FrameHost.h" | 33 #include "core/frame/FrameHost.h" |
| 34 #include "core/frame/LocalFrame.h" | 34 #include "core/frame/LocalFrame.h" |
| 35 #include "core/inspector/ConsoleMessage.h" | 35 #include "core/inspector/ConsoleMessage.h" |
| 36 #include "core/workers/WorkerGlobalScope.h" | 36 #include "core/workers/WorkerGlobalScope.h" |
| 37 #include "public/platform/Platform.h" | 37 #include "platform/Histogram.h" |
| 38 | 38 |
| 39 namespace blink { | 39 namespace blink { |
| 40 | 40 |
| 41 static int totalPagesMeasuredCSSSampleId() { return 1; } | 41 static int totalPagesMeasuredCSSSampleId() { return 1; } |
| 42 | 42 |
| 43 int UseCounter::m_muteCount = 0; | 43 int UseCounter::m_muteCount = 0; |
| 44 | 44 |
| 45 // FIXME : This mapping should be autogenerated. This function should | 45 // FIXME : This mapping should be autogenerated. This function should |
| 46 // be moved to a separate file and a script run at build time | 46 // be moved to a separate file and a script run at build time |
| 47 // to detect new values in CSSPropertyID and add them to the | 47 // to detect new values in CSSPropertyID and add them to the |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 ASSERT_NOT_REACHED(); | 561 ASSERT_NOT_REACHED(); |
| 562 return 0; | 562 return 0; |
| 563 } | 563 } |
| 564 | 564 |
| 565 ASSERT_NOT_REACHED(); | 565 ASSERT_NOT_REACHED(); |
| 566 return 0; | 566 return 0; |
| 567 } | 567 } |
| 568 | 568 |
| 569 static int maximumCSSSampleId() { return 518; } | 569 static int maximumCSSSampleId() { return 518; } |
| 570 | 570 |
| 571 static EnumerationHistogram& featureObserverHistogram() |
| 572 { |
| 573 DEFINE_STATIC_LOCAL(EnumerationHistogram, histogram, ("WebCore.FeatureObserv
er", UseCounter::NumberOfFeatures)); |
| 574 return histogram; |
| 575 } |
| 576 |
| 571 void UseCounter::muteForInspector() | 577 void UseCounter::muteForInspector() |
| 572 { | 578 { |
| 573 UseCounter::m_muteCount++; | 579 UseCounter::m_muteCount++; |
| 574 } | 580 } |
| 575 | 581 |
| 576 void UseCounter::unmuteForInspector() | 582 void UseCounter::unmuteForInspector() |
| 577 { | 583 { |
| 578 UseCounter::m_muteCount--; | 584 UseCounter::m_muteCount--; |
| 579 } | 585 } |
| 580 | 586 |
| 581 UseCounter::UseCounter() | 587 UseCounter::UseCounter() |
| 582 { | 588 { |
| 583 m_CSSFeatureBits.ensureSize(lastUnresolvedCSSProperty + 1); | 589 m_CSSFeatureBits.ensureSize(lastUnresolvedCSSProperty + 1); |
| 584 m_CSSFeatureBits.clearAll(); | 590 m_CSSFeatureBits.clearAll(); |
| 585 } | 591 } |
| 586 | 592 |
| 587 UseCounter::~UseCounter() | 593 UseCounter::~UseCounter() |
| 588 { | 594 { |
| 589 // We always log PageDestruction so that we have a scale for the rest of the
features. | 595 // We always log PageDestruction so that we have a scale for the rest of the
features. |
| 590 Platform::current()->histogramEnumeration("WebCore.FeatureObserver", PageDes
truction, NumberOfFeatures); | 596 featureObserverHistogram().count(PageDestruction); |
| 591 | 597 |
| 592 updateMeasurements(); | 598 updateMeasurements(); |
| 593 } | 599 } |
| 594 | 600 |
| 595 void UseCounter::CountBits::updateMeasurements() | 601 void UseCounter::CountBits::updateMeasurements() |
| 596 { | 602 { |
| 603 EnumerationHistogram& featureHistogram = featureObserverHistogram(); |
| 597 for (unsigned i = 0; i < NumberOfFeatures; ++i) { | 604 for (unsigned i = 0; i < NumberOfFeatures; ++i) { |
| 598 if (m_bits.quickGet(i)) | 605 if (m_bits.quickGet(i)) |
| 599 Platform::current()->histogramEnumeration("WebCore.FeatureObserver",
i, NumberOfFeatures); | 606 featureHistogram.count(i); |
| 600 } | 607 } |
| 601 // Clearing count bits is timing sensitive. | 608 // Clearing count bits is timing sensitive. |
| 602 m_bits.clearAll(); | 609 m_bits.clearAll(); |
| 603 } | 610 } |
| 604 | 611 |
| 605 void UseCounter::updateMeasurements() | 612 void UseCounter::updateMeasurements() |
| 606 { | 613 { |
| 607 Platform::current()->histogramEnumeration("WebCore.FeatureObserver", PageVis
its, NumberOfFeatures); | 614 featureObserverHistogram().count(PageVisits); |
| 608 m_countBits.updateMeasurements(); | 615 m_countBits.updateMeasurements(); |
| 609 | 616 |
| 610 // FIXME: Sometimes this function is called more than once per page. The fol
lowing | 617 // FIXME: Sometimes this function is called more than once per page. The fol
lowing |
| 611 // bool guards against incrementing the page count when there are no
CSS | 618 // bool guards against incrementing the page count when there are no
CSS |
| 612 // bits set. https://crbug.com/236262. | 619 // bits set. https://crbug.com/236262. |
| 620 DEFINE_STATIC_LOCAL(EnumerationHistogram, cssPropertiesHistogram, ("WebCore.
FeatureObserver.CSSProperties", maximumCSSSampleId())); |
| 613 bool needsPagesMeasuredUpdate = false; | 621 bool needsPagesMeasuredUpdate = false; |
| 614 for (int i = firstCSSProperty; i <= lastUnresolvedCSSProperty; ++i) { | 622 for (int i = firstCSSProperty; i <= lastUnresolvedCSSProperty; ++i) { |
| 615 if (m_CSSFeatureBits.quickGet(i)) { | 623 if (m_CSSFeatureBits.quickGet(i)) { |
| 616 int cssSampleId = mapCSSPropertyIdToCSSSampleIdForHistogram(i); | 624 int cssSampleId = mapCSSPropertyIdToCSSSampleIdForHistogram(i); |
| 617 Platform::current()->histogramEnumeration("WebCore.FeatureObserver.C
SSProperties", cssSampleId, maximumCSSSampleId()); | 625 cssPropertiesHistogram.count(cssSampleId); |
| 618 needsPagesMeasuredUpdate = true; | 626 needsPagesMeasuredUpdate = true; |
| 619 } | 627 } |
| 620 } | 628 } |
| 621 | 629 |
| 622 if (needsPagesMeasuredUpdate) | 630 if (needsPagesMeasuredUpdate) |
| 623 Platform::current()->histogramEnumeration("WebCore.FeatureObserver.CSSPr
operties", totalPagesMeasuredCSSSampleId(), maximumCSSSampleId()); | 631 cssPropertiesHistogram.count(totalPagesMeasuredCSSSampleId()); |
| 624 | 632 |
| 625 m_CSSFeatureBits.clearAll(); | 633 m_CSSFeatureBits.clearAll(); |
| 626 } | 634 } |
| 627 | 635 |
| 628 void UseCounter::didCommitLoad() | 636 void UseCounter::didCommitLoad() |
| 629 { | 637 { |
| 630 updateMeasurements(); | 638 updateMeasurements(); |
| 631 } | 639 } |
| 632 | 640 |
| 633 void UseCounter::count(const Frame* frame, Feature feature) | 641 void UseCounter::count(const Frame* frame, Feature feature) |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1032 UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents) | 1040 UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents) |
| 1033 { | 1041 { |
| 1034 // FIXME: We may want to handle stylesheets that have multiple owners | 1042 // FIXME: We may want to handle stylesheets that have multiple owners |
| 1035 // https://crbug.com/242125 | 1043 // https://crbug.com/242125 |
| 1036 if (sheetContents && sheetContents->hasSingleOwnerNode()) | 1044 if (sheetContents && sheetContents->hasSingleOwnerNode()) |
| 1037 return getFrom(sheetContents->singleOwnerDocument()); | 1045 return getFrom(sheetContents->singleOwnerDocument()); |
| 1038 return 0; | 1046 return 0; |
| 1039 } | 1047 } |
| 1040 | 1048 |
| 1041 } // namespace blink | 1049 } // namespace blink |
| OLD | NEW |