| 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 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 | 562 |
| 563 UseCounter::UseCounter() | 563 UseCounter::UseCounter() |
| 564 { | 564 { |
| 565 m_CSSFeatureBits.ensureSize(lastUnresolvedCSSProperty + 1); | 565 m_CSSFeatureBits.ensureSize(lastUnresolvedCSSProperty + 1); |
| 566 m_CSSFeatureBits.clearAll(); | 566 m_CSSFeatureBits.clearAll(); |
| 567 } | 567 } |
| 568 | 568 |
| 569 UseCounter::~UseCounter() | 569 UseCounter::~UseCounter() |
| 570 { | 570 { |
| 571 // 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. |
| 572 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObserver",
PageDestruction, NumberOfFeatures); | 572 Platform::current()->histogramEnumeration("WebCore.FeatureObserver", PageDes
truction, NumberOfFeatures); |
| 573 | 573 |
| 574 updateMeasurements(); | 574 updateMeasurements(); |
| 575 } | 575 } |
| 576 | 576 |
| 577 void UseCounter::CountBits::updateMeasurements() | 577 void UseCounter::CountBits::updateMeasurements() |
| 578 { | 578 { |
| 579 for (unsigned i = 0; i < NumberOfFeatures; ++i) { | 579 for (unsigned i = 0; i < NumberOfFeatures; ++i) { |
| 580 if (m_bits.quickGet(i)) | 580 if (m_bits.quickGet(i)) |
| 581 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObs
erver", i, NumberOfFeatures); | 581 Platform::current()->histogramEnumeration("WebCore.FeatureObserver",
i, NumberOfFeatures); |
| 582 } | 582 } |
| 583 // Clearing count bits is timing sensitive. | 583 // Clearing count bits is timing sensitive. |
| 584 m_bits.clearAll(); | 584 m_bits.clearAll(); |
| 585 } | 585 } |
| 586 | 586 |
| 587 void UseCounter::updateMeasurements() | 587 void UseCounter::updateMeasurements() |
| 588 { | 588 { |
| 589 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObserver",
PageVisits, NumberOfFeatures); | 589 Platform::current()->histogramEnumeration("WebCore.FeatureObserver", PageVis
its, NumberOfFeatures); |
| 590 m_countBits.updateMeasurements(); | 590 m_countBits.updateMeasurements(); |
| 591 | 591 |
| 592 // 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 |
| 593 // 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 |
| 594 // bits set. http://crbug.com/236262. | 594 // bits set. http://crbug.com/236262. |
| 595 bool needsPagesMeasuredUpdate = false; | 595 bool needsPagesMeasuredUpdate = false; |
| 596 for (int i = firstCSSProperty; i <= lastUnresolvedCSSProperty; ++i) { | 596 for (int i = firstCSSProperty; i <= lastUnresolvedCSSProperty; ++i) { |
| 597 if (m_CSSFeatureBits.quickGet(i)) { | 597 if (m_CSSFeatureBits.quickGet(i)) { |
| 598 int cssSampleId = mapCSSPropertyIdToCSSSampleIdForHistogram(i); | 598 int cssSampleId = mapCSSPropertyIdToCSSSampleIdForHistogram(i); |
| 599 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObs
erver.CSSProperties", cssSampleId, maximumCSSSampleId()); | 599 Platform::current()->histogramEnumeration("WebCore.FeatureObserver.C
SSProperties", cssSampleId, maximumCSSSampleId()); |
| 600 needsPagesMeasuredUpdate = true; | 600 needsPagesMeasuredUpdate = true; |
| 601 } | 601 } |
| 602 } | 602 } |
| 603 | 603 |
| 604 if (needsPagesMeasuredUpdate) | 604 if (needsPagesMeasuredUpdate) |
| 605 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObserve
r.CSSProperties", totalPagesMeasuredCSSSampleId(), maximumCSSSampleId()); | 605 Platform::current()->histogramEnumeration("WebCore.FeatureObserver.CSSPr
operties", totalPagesMeasuredCSSSampleId(), maximumCSSSampleId()); |
| 606 | 606 |
| 607 m_CSSFeatureBits.clearAll(); | 607 m_CSSFeatureBits.clearAll(); |
| 608 } | 608 } |
| 609 | 609 |
| 610 void UseCounter::didCommitLoad() | 610 void UseCounter::didCommitLoad() |
| 611 { | 611 { |
| 612 updateMeasurements(); | 612 updateMeasurements(); |
| 613 } | 613 } |
| 614 | 614 |
| 615 void UseCounter::count(const Frame* frame, Feature feature) | 615 void UseCounter::count(const Frame* frame, Feature feature) |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 939 UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents) | 939 UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents) |
| 940 { | 940 { |
| 941 // FIXME: We may want to handle stylesheets that have multiple owners | 941 // FIXME: We may want to handle stylesheets that have multiple owners |
| 942 // http://crbug.com/242125 | 942 // http://crbug.com/242125 |
| 943 if (sheetContents && sheetContents->hasSingleOwnerNode()) | 943 if (sheetContents && sheetContents->hasSingleOwnerNode()) |
| 944 return getFrom(sheetContents->singleOwnerDocument()); | 944 return getFrom(sheetContents->singleOwnerDocument()); |
| 945 return 0; | 945 return 0; |
| 946 } | 946 } |
| 947 | 947 |
| 948 } // namespace blink | 948 } // namespace blink |
| OLD | NEW |