| 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 |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 #include "FeatureObserver.h" | 27 #include "UseCounter.h" |
| 28 | 28 |
| 29 #include "DOMWindow.h" | 29 #include "DOMWindow.h" |
| 30 #include "Document.h" | 30 #include "Document.h" |
| 31 #include "HistogramSupport.h" | 31 #include "HistogramSupport.h" |
| 32 #include "Page.h" | 32 #include "Page.h" |
| 33 | 33 |
| 34 namespace WebCore { | 34 namespace WebCore { |
| 35 | 35 |
| 36 FeatureObserver::FeatureObserver() | 36 UseCounter::UseCounter() |
| 37 { | 37 { |
| 38 } | 38 } |
| 39 | 39 |
| 40 FeatureObserver::~FeatureObserver() | 40 UseCounter::~UseCounter() |
| 41 { | 41 { |
| 42 // We always log PageDestruction so that we have a scale for the rest of the
features. | 42 // We always log PageDestruction so that we have a scale for the rest of the
features. |
| 43 HistogramSupport::histogramEnumeration("WebCore.FeatureObserver", PageDestru
ction, NumberOfFeatures); | 43 HistogramSupport::histogramEnumeration("WebCore.FeatureObserver", PageDestru
ction, NumberOfFeatures); |
| 44 | 44 |
| 45 updateMeasurements(); | 45 updateMeasurements(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 void FeatureObserver::updateMeasurements() | 48 void UseCounter::updateMeasurements() |
| 49 { | 49 { |
| 50 HistogramSupport::histogramEnumeration("WebCore.FeatureObserver", PageVisits
, NumberOfFeatures); | 50 HistogramSupport::histogramEnumeration("WebCore.FeatureObserver", PageVisits
, NumberOfFeatures); |
| 51 | 51 |
| 52 if (!m_featureBits) | 52 if (!m_countBits) |
| 53 return; | 53 return; |
| 54 | 54 |
| 55 for (unsigned i = 0; i < NumberOfFeatures; ++i) { | 55 for (unsigned i = 0; i < NumberOfFeatures; ++i) { |
| 56 if (m_featureBits->quickGet(i)) | 56 if (m_countBits->quickGet(i)) |
| 57 HistogramSupport::histogramEnumeration("WebCore.FeatureObserver", i,
NumberOfFeatures); | 57 HistogramSupport::histogramEnumeration("WebCore.FeatureObserver", i,
NumberOfFeatures); |
| 58 } | 58 } |
| 59 | 59 |
| 60 // Clearing feature bits is timing sensitive. Ports other than chromium do n
ot use HistogramSupport, | 60 // Clearing count bits is timing sensitive. |
| 61 // and pull the results on certain navigation events instead. | 61 m_countBits->clearAll(); |
| 62 m_featureBits->clearAll(); | |
| 63 } | 62 } |
| 64 | 63 |
| 65 void FeatureObserver::didCommitLoad() | 64 void UseCounter::didCommitLoad() |
| 66 { | 65 { |
| 67 updateMeasurements(); | 66 updateMeasurements(); |
| 68 } | 67 } |
| 69 | 68 |
| 70 void FeatureObserver::observe(Document* document, Feature feature) | 69 void UseCounter::observe(Document* document, Feature feature) |
| 71 { | 70 { |
| 72 if (!document) | 71 if (!document) |
| 73 return; | 72 return; |
| 74 | 73 |
| 75 Page* page = document->page(); | 74 Page* page = document->page(); |
| 76 if (!page) | 75 if (!page) |
| 77 return; | 76 return; |
| 78 | 77 |
| 79 page->featureObserver()->didObserve(feature); | 78 page->useCounter()->didObserve(feature); |
| 80 } | 79 } |
| 81 | 80 |
| 82 void FeatureObserver::observe(DOMWindow* domWindow, Feature feature) | 81 void UseCounter::observe(DOMWindow* domWindow, Feature feature) |
| 83 { | 82 { |
| 84 ASSERT(domWindow); | 83 ASSERT(domWindow); |
| 85 observe(domWindow->document(), feature); | 84 observe(domWindow->document(), feature); |
| 86 } | 85 } |
| 87 | 86 |
| 88 } // namespace WebCore | 87 } // namespace WebCore |
| OLD | NEW |