Chromium Code Reviews| 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 #ifndef FeatureObserver_h | 26 #ifndef UseCounter_h |
| 27 #define FeatureObserver_h | 27 #define UseCounter_h |
| 28 | 28 |
| 29 #include <wtf/BitVector.h> | 29 #include <wtf/BitVector.h> |
| 30 #include <wtf/Noncopyable.h> | 30 #include <wtf/Noncopyable.h> |
| 31 #include <wtf/OwnPtr.h> | 31 #include <wtf/OwnPtr.h> |
| 32 #include <wtf/PassOwnPtr.h> | 32 #include <wtf/PassOwnPtr.h> |
| 33 | 33 |
| 34 namespace WebCore { | 34 namespace WebCore { |
| 35 | 35 |
| 36 class DOMWindow; | 36 class DOMWindow; |
| 37 class Document; | 37 class Document; |
| 38 | 38 |
| 39 class FeatureObserver { | 39 // UseCounter is used for counting the number of times features of |
| 40 WTF_MAKE_NONCOPYABLE(FeatureObserver); | 40 // Blink are used on real web pages. The counts are submitted |
|
darin (slow to review)
2013/04/16 21:28:51
nit: You might consider revisions to this wording
| |
| 41 // anonymously through the Histogram recording system in Chrome | |
| 42 // for users who opt-in to "Usage Statistics" submission | |
| 43 // during their install of Google Chrome: | |
| 44 // http://www.google.com/chrome/intl/en/privacy.html | |
| 45 // These numbers are used to help us know how commonly features of | |
| 46 // Blink are used, and thus when it's safe to remove or change them. | |
| 47 class UseCounter { | |
| 48 WTF_MAKE_NONCOPYABLE(UseCounter); | |
| 41 public: | 49 public: |
| 42 FeatureObserver(); | 50 UseCounter(); |
| 43 ~FeatureObserver(); | 51 ~UseCounter(); |
| 44 | 52 |
| 45 enum Feature { | 53 enum Feature { |
| 46 PageDestruction, | 54 PageDestruction, |
| 47 LegacyNotifications, | 55 LegacyNotifications, |
| 48 MultipartMainResource, | 56 MultipartMainResource, |
| 49 PrefixedIndexedDB, | 57 PrefixedIndexedDB, |
| 50 WorkerStart, | 58 WorkerStart, |
| 51 SharedWorkerStart, | 59 SharedWorkerStart, |
| 52 LegacyWebAudio, | 60 LegacyWebAudio, |
| 53 WebAudioStart, | 61 WebAudioStart, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 XFrameOptions, | 112 XFrameOptions, |
| 105 XFrameOptionsSameOrigin, | 113 XFrameOptionsSameOrigin, |
| 106 XFrameOptionsSameOriginWithBadAncestorChain, | 114 XFrameOptionsSameOriginWithBadAncestorChain, |
| 107 DeprecatedFlexboxWebContent, | 115 DeprecatedFlexboxWebContent, |
| 108 DeprecatedFlexboxChrome, | 116 DeprecatedFlexboxChrome, |
| 109 DeprecatedFlexboxChromeExtension, | 117 DeprecatedFlexboxChromeExtension, |
| 110 // Add new features above this line. Don't change assigned numbers of ea ch items. | 118 // Add new features above this line. Don't change assigned numbers of ea ch items. |
| 111 NumberOfFeatures, // This enum value must be last. | 119 NumberOfFeatures, // This enum value must be last. |
| 112 }; | 120 }; |
| 113 | 121 |
| 122 // "observe" sets the bit for this feature to 1. Repeated calls are ignored. | |
| 114 static void observe(Document*, Feature); | 123 static void observe(Document*, Feature); |
| 115 static void observe(DOMWindow*, Feature); | 124 static void observe(DOMWindow*, Feature); |
| 116 void didCommitLoad(); | 125 void didCommitLoad(); |
| 117 | 126 |
| 118 const BitVector* accumulatedFeatureBits() const { return m_featureBits.get() ; } | |
| 119 | |
| 120 private: | 127 private: |
| 121 void didObserve(Feature feature) | 128 void didObserve(Feature feature) |
| 122 { | 129 { |
| 123 ASSERT(feature != PageDestruction); // PageDestruction is reserved as a scaling factor. | 130 ASSERT(feature != PageDestruction); // PageDestruction is reserved as a scaling factor. |
| 124 ASSERT(feature < NumberOfFeatures); | 131 ASSERT(feature < NumberOfFeatures); |
| 125 if (!m_featureBits) { | 132 if (!m_countBits) { |
| 126 m_featureBits = adoptPtr(new BitVector(NumberOfFeatures)); | 133 m_countBits = adoptPtr(new BitVector(NumberOfFeatures)); |
| 127 m_featureBits->clearAll(); | 134 m_countBits->clearAll(); |
| 128 } | 135 } |
| 129 m_featureBits->quickSet(feature); | 136 m_countBits->quickSet(feature); |
| 130 } | 137 } |
| 131 | 138 |
| 132 void updateMeasurements(); | 139 void updateMeasurements(); |
| 133 | 140 |
| 134 OwnPtr<BitVector> m_featureBits; | 141 OwnPtr<BitVector> m_countBits; |
| 135 }; | 142 }; |
| 136 | 143 |
| 137 } // namespace WebCore | 144 } // namespace WebCore |
| 138 | 145 |
| 139 #endif // FeatureObserver_h | 146 #endif // UseCounter_h |
| OLD | NEW |