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 21 matching lines...) Expand all Loading... |
32 #include "core/events/EventListener.h" | 32 #include "core/events/EventListener.h" |
33 #include "core/frame/LocalFrame.h" | 33 #include "core/frame/LocalFrame.h" |
34 #include "core/loader/DocumentLoader.h" | 34 #include "core/loader/DocumentLoader.h" |
35 #include "core/loader/FrameLoader.h" | 35 #include "core/loader/FrameLoader.h" |
36 | 36 |
37 namespace blink { | 37 namespace blink { |
38 | 38 |
39 ApplicationCache::ApplicationCache(LocalFrame* frame) | 39 ApplicationCache::ApplicationCache(LocalFrame* frame) |
40 : DOMWindowProperty(frame) | 40 : DOMWindowProperty(frame) |
41 { | 41 { |
42 ApplicationCacheHost* cacheHost = applicationCacheHost(); | 42 if (ApplicationCacheHost* cacheHost = applicationCacheHost()) |
43 if (cacheHost) | |
44 cacheHost->setApplicationCache(this); | 43 cacheHost->setApplicationCache(this); |
45 } | 44 } |
46 | 45 |
47 DEFINE_TRACE(ApplicationCache) | 46 DEFINE_TRACE(ApplicationCache) |
48 { | 47 { |
49 EventTargetWithInlineData::trace(visitor); | 48 EventTargetWithInlineData::trace(visitor); |
50 DOMWindowProperty::trace(visitor); | 49 DOMWindowProperty::trace(visitor); |
51 } | 50 } |
52 | 51 |
53 void ApplicationCache::willDestroyGlobalObjectInFrame() | 52 void ApplicationCache::willDestroyGlobalObjectInFrame() |
54 { | 53 { |
55 if (ApplicationCacheHost* cacheHost = applicationCacheHost()) | 54 if (ApplicationCacheHost* cacheHost = applicationCacheHost()) |
56 cacheHost->setApplicationCache(0); | 55 cacheHost->setApplicationCache(0); |
57 DOMWindowProperty::willDestroyGlobalObjectInFrame(); | 56 DOMWindowProperty::willDestroyGlobalObjectInFrame(); |
58 } | 57 } |
59 | 58 |
60 ApplicationCacheHost* ApplicationCache::applicationCacheHost() const | 59 ApplicationCacheHost* ApplicationCache::applicationCacheHost() const |
61 { | 60 { |
62 if (!m_frame || !m_frame->loader().documentLoader()) | 61 if (!m_frame || !m_frame->loader().documentLoader()) |
63 return 0; | 62 return 0; |
64 return m_frame->loader().documentLoader()->applicationCacheHost(); | 63 return m_frame->loader().documentLoader()->applicationCacheHost(); |
65 } | 64 } |
66 | 65 |
67 unsigned short ApplicationCache::status() const | 66 unsigned short ApplicationCache::status() const |
68 { | 67 { |
69 ApplicationCacheHost* cacheHost = applicationCacheHost(); | 68 if (ApplicationCacheHost* cacheHost = applicationCacheHost()) |
70 if (!cacheHost) | 69 return cacheHost->status(); |
71 return ApplicationCacheHost::UNCACHED; | 70 return ApplicationCacheHost::UNCACHED; |
72 return cacheHost->status(); | |
73 } | 71 } |
74 | 72 |
75 void ApplicationCache::update(ExceptionState& exceptionState) | 73 void ApplicationCache::update(ExceptionState& exceptionState) |
76 { | 74 { |
77 ApplicationCacheHost* cacheHost = applicationCacheHost(); | 75 ApplicationCacheHost* cacheHost = applicationCacheHost(); |
78 if (!cacheHost || !cacheHost->update()) | 76 if (!cacheHost || !cacheHost->update()) |
79 exceptionState.throwDOMException(InvalidStateError, "there is no applica
tion cache to update."); | 77 exceptionState.throwDOMException(InvalidStateError, "there is no applica
tion cache to update."); |
80 } | 78 } |
81 | 79 |
82 void ApplicationCache::swapCache(ExceptionState& exceptionState) | 80 void ApplicationCache::swapCache(ExceptionState& exceptionState) |
83 { | 81 { |
84 ApplicationCacheHost* cacheHost = applicationCacheHost(); | 82 ApplicationCacheHost* cacheHost = applicationCacheHost(); |
85 if (!cacheHost || !cacheHost->swapCache()) | 83 if (!cacheHost || !cacheHost->swapCache()) |
86 exceptionState.throwDOMException(InvalidStateError, "there is no newer a
pplication cache to swap to."); | 84 exceptionState.throwDOMException(InvalidStateError, "there is no newer a
pplication cache to swap to."); |
87 } | 85 } |
88 | 86 |
89 void ApplicationCache::abort() | 87 void ApplicationCache::abort() |
90 { | 88 { |
91 ApplicationCacheHost* cacheHost = applicationCacheHost(); | 89 if (ApplicationCacheHost* cacheHost = applicationCacheHost()) |
92 if (cacheHost) | |
93 cacheHost->abort(); | 90 cacheHost->abort(); |
94 } | 91 } |
95 | 92 |
96 const AtomicString& ApplicationCache::interfaceName() const | 93 const AtomicString& ApplicationCache::interfaceName() const |
97 { | 94 { |
98 return EventTargetNames::ApplicationCache; | 95 return EventTargetNames::ApplicationCache; |
99 } | 96 } |
100 | 97 |
101 ExecutionContext* ApplicationCache::executionContext() const | 98 ExecutionContext* ApplicationCache::executionContext() const |
102 { | 99 { |
(...skipping 20 matching lines...) Expand all Loading... |
123 case ApplicationCacheHost::CACHED_EVENT: | 120 case ApplicationCacheHost::CACHED_EVENT: |
124 return EventTypeNames::cached; | 121 return EventTypeNames::cached; |
125 case ApplicationCacheHost::OBSOLETE_EVENT: | 122 case ApplicationCacheHost::OBSOLETE_EVENT: |
126 return EventTypeNames::obsolete; | 123 return EventTypeNames::obsolete; |
127 } | 124 } |
128 ASSERT_NOT_REACHED(); | 125 ASSERT_NOT_REACHED(); |
129 return EventTypeNames::error; | 126 return EventTypeNames::error; |
130 } | 127 } |
131 | 128 |
132 } // namespace blink | 129 } // namespace blink |
OLD | NEW |