| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright (C) 2012 Google, Inc. All rights reserved. | 3 * Copyright (C) 2012 Google, Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 } | 530 } |
| 531 | 531 |
| 532 UseCounter::~UseCounter() | 532 UseCounter::~UseCounter() |
| 533 { | 533 { |
| 534 // We always log PageDestruction so that we have a scale for the rest of the
features. | 534 // We always log PageDestruction so that we have a scale for the rest of the
features. |
| 535 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObserver",
PageDestruction, NumberOfFeatures); | 535 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObserver",
PageDestruction, NumberOfFeatures); |
| 536 | 536 |
| 537 updateMeasurements(); | 537 updateMeasurements(); |
| 538 } | 538 } |
| 539 | 539 |
| 540 void UseCounter::CountBits::updateMeasurements() |
| 541 { |
| 542 if (m_bits) { |
| 543 for (unsigned i = 0; i < NumberOfFeatures; ++i) { |
| 544 if (m_bits->quickGet(i)) |
| 545 blink::Platform::current()->histogramEnumeration("WebCore.Featur
eObserver", i, NumberOfFeatures); |
| 546 } |
| 547 // Clearing count bits is timing sensitive. |
| 548 m_bits->clearAll(); |
| 549 } |
| 550 } |
| 551 |
| 540 void UseCounter::updateMeasurements() | 552 void UseCounter::updateMeasurements() |
| 541 { | 553 { |
| 542 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObserver",
PageVisits, NumberOfFeatures); | 554 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObserver",
PageVisits, NumberOfFeatures); |
| 543 | 555 m_countBits.updateMeasurements(); |
| 544 if (m_countBits) { | |
| 545 for (unsigned i = 0; i < NumberOfFeatures; ++i) { | |
| 546 if (m_countBits->quickGet(i)) | |
| 547 blink::Platform::current()->histogramEnumeration("WebCore.Featur
eObserver", i, NumberOfFeatures); | |
| 548 } | |
| 549 // Clearing count bits is timing sensitive. | |
| 550 m_countBits->clearAll(); | |
| 551 } | |
| 552 | 556 |
| 553 // FIXME: Sometimes this function is called more than once per page. The fol
lowing | 557 // FIXME: Sometimes this function is called more than once per page. The fol
lowing |
| 554 // bool guards against incrementing the page count when there are no
CSS | 558 // bool guards against incrementing the page count when there are no
CSS |
| 555 // bits set. http://crbug.com/236262. | 559 // bits set. http://crbug.com/236262. |
| 556 bool needsPagesMeasuredUpdate = false; | 560 bool needsPagesMeasuredUpdate = false; |
| 557 for (int i = firstCSSProperty; i <= lastCSSProperty; ++i) { | 561 for (int i = firstCSSProperty; i <= lastCSSProperty; ++i) { |
| 558 if (m_CSSFeatureBits.quickGet(i)) { | 562 if (m_CSSFeatureBits.quickGet(i)) { |
| 559 int cssSampleId = mapCSSPropertyIdToCSSSampleIdForHistogram(i); | 563 int cssSampleId = mapCSSPropertyIdToCSSSampleIdForHistogram(i); |
| 560 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObs
erver.CSSProperties", cssSampleId, maximumCSSSampleId()); | 564 blink::Platform::current()->histogramEnumeration("WebCore.FeatureObs
erver.CSSProperties", cssSampleId, maximumCSSSampleId()); |
| 561 needsPagesMeasuredUpdate = true; | 565 needsPagesMeasuredUpdate = true; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 574 } | 578 } |
| 575 | 579 |
| 576 void UseCounter::count(const Frame* frame, Feature feature) | 580 void UseCounter::count(const Frame* frame, Feature feature) |
| 577 { | 581 { |
| 578 if (!frame) | 582 if (!frame) |
| 579 return; | 583 return; |
| 580 FrameHost* host = frame->host(); | 584 FrameHost* host = frame->host(); |
| 581 if (!host) | 585 if (!host) |
| 582 return; | 586 return; |
| 583 | 587 |
| 584 ASSERT(host->useCounter().deprecationMessage(feature).isEmpty()); | 588 ASSERT(deprecationMessage(feature).isEmpty()); |
| 585 host->useCounter().recordMeasurement(feature); | 589 host->useCounter().recordMeasurement(feature); |
| 586 } | 590 } |
| 587 | 591 |
| 588 void UseCounter::count(const Document& document, Feature feature) | 592 void UseCounter::count(const Document& document, Feature feature) |
| 589 { | 593 { |
| 590 count(document.frame(), feature); | 594 count(document.frame(), feature); |
| 591 } | 595 } |
| 592 | 596 |
| 593 void UseCounter::count(const ExecutionContext* context, Feature feature) | 597 void UseCounter::count(const ExecutionContext* context, Feature feature) |
| 594 { | 598 { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 625 | 629 |
| 626 void UseCounter::countDeprecation(const LocalFrame* frame, Feature feature) | 630 void UseCounter::countDeprecation(const LocalFrame* frame, Feature feature) |
| 627 { | 631 { |
| 628 if (!frame) | 632 if (!frame) |
| 629 return; | 633 return; |
| 630 FrameHost* host = frame->host(); | 634 FrameHost* host = frame->host(); |
| 631 if (!host) | 635 if (!host) |
| 632 return; | 636 return; |
| 633 | 637 |
| 634 if (host->useCounter().recordMeasurement(feature)) { | 638 if (host->useCounter().recordMeasurement(feature)) { |
| 635 ASSERT(!host->useCounter().deprecationMessage(feature).isEmpty()); | 639 ASSERT(!deprecationMessage(feature).isEmpty()); |
| 636 frame->console().addMessage(ConsoleMessage::create(DeprecationMessageSou
rce, WarningMessageLevel, host->useCounter().deprecationMessage(feature))); | 640 frame->console().addMessage(ConsoleMessage::create(DeprecationMessageSou
rce, WarningMessageLevel, deprecationMessage(feature))); |
| 637 } | 641 } |
| 638 } | 642 } |
| 639 | 643 |
| 640 void UseCounter::countDeprecation(ExecutionContext* context, Feature feature) | 644 void UseCounter::countDeprecation(ExecutionContext* context, Feature feature) |
| 641 { | 645 { |
| 642 if (!context) | 646 if (!context) |
| 643 return; | 647 return; |
| 644 if (context->isDocument()) { | 648 if (context->isDocument()) { |
| 645 UseCounter::countDeprecation(*toDocument(context), feature); | 649 UseCounter::countDeprecation(*toDocument(context), feature); |
| 646 return; | 650 return; |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 881 UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents) | 885 UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents) |
| 882 { | 886 { |
| 883 // FIXME: We may want to handle stylesheets that have multiple owners | 887 // FIXME: We may want to handle stylesheets that have multiple owners |
| 884 // http://crbug.com/242125 | 888 // http://crbug.com/242125 |
| 885 if (sheetContents && sheetContents->hasSingleOwnerNode()) | 889 if (sheetContents && sheetContents->hasSingleOwnerNode()) |
| 886 return getFrom(sheetContents->singleOwnerDocument()); | 890 return getFrom(sheetContents->singleOwnerDocument()); |
| 887 return 0; | 891 return 0; |
| 888 } | 892 } |
| 889 | 893 |
| 890 } // namespace blink | 894 } // namespace blink |
| OLD | NEW |