OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008, 2009 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008, 2009 Apple 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 11 matching lines...) Expand all Loading... |
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 "core/loader/appcache/ApplicationCache.h" | 26 #include "core/loader/appcache/ApplicationCache.h" |
27 | 27 |
28 #include "bindings/core/v8/ExceptionState.h" | 28 #include "bindings/core/v8/ExceptionState.h" |
29 #include "core/dom/Document.h" | 29 #include "core/dom/Document.h" |
30 #include "core/dom/ExceptionCode.h" | 30 #include "core/dom/ExceptionCode.h" |
31 #include "core/events/EventListener.h" | 31 #include "core/events/EventListener.h" |
| 32 #include "core/frame/Deprecation.h" |
32 #include "core/frame/LocalFrame.h" | 33 #include "core/frame/LocalFrame.h" |
| 34 #include "core/frame/OriginsUsingFeatures.h" |
| 35 #include "core/frame/UseCounter.h" |
33 #include "core/loader/DocumentLoader.h" | 36 #include "core/loader/DocumentLoader.h" |
34 #include "core/loader/FrameLoader.h" | 37 #include "core/loader/FrameLoader.h" |
35 | 38 |
36 namespace blink { | 39 namespace blink { |
37 | 40 |
38 ApplicationCache::ApplicationCache(LocalFrame* frame) | 41 ApplicationCache::ApplicationCache(LocalFrame* frame) |
39 : DOMWindowProperty(frame) | 42 : DOMWindowProperty(frame) |
40 { | 43 { |
41 ApplicationCacheHost* cacheHost = applicationCacheHost(); | 44 ApplicationCacheHost* cacheHost = applicationCacheHost(); |
42 if (cacheHost) | 45 if (cacheHost) |
(...skipping 15 matching lines...) Expand all Loading... |
58 | 61 |
59 ApplicationCacheHost* ApplicationCache::applicationCacheHost() const | 62 ApplicationCacheHost* ApplicationCache::applicationCacheHost() const |
60 { | 63 { |
61 if (!m_frame || !m_frame->loader().documentLoader()) | 64 if (!m_frame || !m_frame->loader().documentLoader()) |
62 return 0; | 65 return 0; |
63 return m_frame->loader().documentLoader()->applicationCacheHost(); | 66 return m_frame->loader().documentLoader()->applicationCacheHost(); |
64 } | 67 } |
65 | 68 |
66 unsigned short ApplicationCache::status() const | 69 unsigned short ApplicationCache::status() const |
67 { | 70 { |
| 71 recordAPIUseType(); |
68 ApplicationCacheHost* cacheHost = applicationCacheHost(); | 72 ApplicationCacheHost* cacheHost = applicationCacheHost(); |
69 if (!cacheHost) | 73 if (!cacheHost) |
70 return ApplicationCacheHost::UNCACHED; | 74 return ApplicationCacheHost::UNCACHED; |
71 return cacheHost->status(); | 75 return cacheHost->status(); |
72 } | 76 } |
73 | 77 |
74 void ApplicationCache::update(ExceptionState& exceptionState) | 78 void ApplicationCache::update(ExceptionState& exceptionState) |
75 { | 79 { |
| 80 recordAPIUseType(); |
76 ApplicationCacheHost* cacheHost = applicationCacheHost(); | 81 ApplicationCacheHost* cacheHost = applicationCacheHost(); |
77 if (!cacheHost || !cacheHost->update()) | 82 if (!cacheHost || !cacheHost->update()) |
78 exceptionState.throwDOMException(InvalidStateError, "there is no applica
tion cache to update."); | 83 exceptionState.throwDOMException(InvalidStateError, "there is no applica
tion cache to update."); |
79 } | 84 } |
80 | 85 |
81 void ApplicationCache::swapCache(ExceptionState& exceptionState) | 86 void ApplicationCache::swapCache(ExceptionState& exceptionState) |
82 { | 87 { |
| 88 recordAPIUseType(); |
83 ApplicationCacheHost* cacheHost = applicationCacheHost(); | 89 ApplicationCacheHost* cacheHost = applicationCacheHost(); |
84 if (!cacheHost || !cacheHost->swapCache()) | 90 if (!cacheHost || !cacheHost->swapCache()) |
85 exceptionState.throwDOMException(InvalidStateError, "there is no newer a
pplication cache to swap to."); | 91 exceptionState.throwDOMException(InvalidStateError, "there is no newer a
pplication cache to swap to."); |
86 } | 92 } |
87 | 93 |
88 void ApplicationCache::abort() | 94 void ApplicationCache::abort() |
89 { | 95 { |
90 ApplicationCacheHost* cacheHost = applicationCacheHost(); | 96 ApplicationCacheHost* cacheHost = applicationCacheHost(); |
91 if (cacheHost) | 97 if (cacheHost) |
92 cacheHost->abort(); | 98 cacheHost->abort(); |
(...skipping 28 matching lines...) Expand all Loading... |
121 return EventTypeNames::updateready; | 127 return EventTypeNames::updateready; |
122 case ApplicationCacheHost::CACHED_EVENT: | 128 case ApplicationCacheHost::CACHED_EVENT: |
123 return EventTypeNames::cached; | 129 return EventTypeNames::cached; |
124 case ApplicationCacheHost::OBSOLETE_EVENT: | 130 case ApplicationCacheHost::OBSOLETE_EVENT: |
125 return EventTypeNames::obsolete; | 131 return EventTypeNames::obsolete; |
126 } | 132 } |
127 ASSERT_NOT_REACHED(); | 133 ASSERT_NOT_REACHED(); |
128 return EventTypeNames::error; | 134 return EventTypeNames::error; |
129 } | 135 } |
130 | 136 |
| 137 void ApplicationCache::recordAPIUseType() const |
| 138 { |
| 139 if (!m_frame) |
| 140 return; |
| 141 |
| 142 Document* document = m_frame->document(); |
| 143 |
| 144 if (!document) |
| 145 return; |
| 146 |
| 147 if (document->isSecureContext()) { |
| 148 UseCounter::count(document, UseCounter::ApplicationCacheAPISecureOrigin)
; |
| 149 UseCounter::countCrossOriginIframe(*document, UseCounter::ApplicationCac
heAPISecureOrigin); |
| 150 } else { |
| 151 Deprecation::countDeprecation(document, UseCounter::ApplicationCacheAPII
nsecureOrigin); |
| 152 UseCounter::countCrossOriginIframe(*document, UseCounter::ApplicationCac
heAPIInsecureOrigin); |
| 153 OriginsUsingFeatures::countAnyWorld(*document, OriginsUsingFeatures::Fea
ture::ApplicationCacheAPIInsecureOrigin); |
| 154 } |
| 155 } |
| 156 |
131 } // namespace blink | 157 } // namespace blink |
OLD | NEW |