Commit 989dace1 authored by haraken's avatar haraken Committed by Commit bot

Make ApplicationCache a DOMWindowClient

ApplicationCache is a per-DOMWindow thing instead of a per-ExecutionContext thing.
It should use DOMWindowClient instead of ContextClient.

BUG=610176

Review-Url: https://codereview.chromium.org/2631653002
Cr-Commit-Position: refs/heads/master@{#443541}
parent 71db1d97
...@@ -38,8 +38,7 @@ ...@@ -38,8 +38,7 @@
namespace blink { namespace blink {
ApplicationCache::ApplicationCache(LocalFrame* frame) ApplicationCache::ApplicationCache(LocalFrame* frame) : DOMWindowClient(frame) {
: ContextLifecycleObserver(frame->document()) {
ApplicationCacheHost* cacheHost = applicationCacheHost(); ApplicationCacheHost* cacheHost = applicationCacheHost();
if (cacheHost) if (cacheHost)
cacheHost->setApplicationCache(this); cacheHost->setApplicationCache(this);
...@@ -47,12 +46,7 @@ ApplicationCache::ApplicationCache(LocalFrame* frame) ...@@ -47,12 +46,7 @@ ApplicationCache::ApplicationCache(LocalFrame* frame)
DEFINE_TRACE(ApplicationCache) { DEFINE_TRACE(ApplicationCache) {
EventTargetWithInlineData::trace(visitor); EventTargetWithInlineData::trace(visitor);
ContextLifecycleObserver::trace(visitor); DOMWindowClient::trace(visitor);
}
void ApplicationCache::contextDestroyed() {
if (ApplicationCacheHost* cacheHost = applicationCacheHost())
cacheHost->setApplicationCache(0);
} }
ApplicationCacheHost* ApplicationCache::applicationCacheHost() const { ApplicationCacheHost* ApplicationCache::applicationCacheHost() const {
...@@ -98,9 +92,7 @@ const AtomicString& ApplicationCache::interfaceName() const { ...@@ -98,9 +92,7 @@ const AtomicString& ApplicationCache::interfaceName() const {
} }
ExecutionContext* ApplicationCache::getExecutionContext() const { ExecutionContext* ApplicationCache::getExecutionContext() const {
if (frame()) return frame() ? frame()->document() : nullptr;
return frame()->document();
return 0;
} }
const AtomicString& ApplicationCache::toEventType( const AtomicString& ApplicationCache::toEventType(
......
...@@ -38,7 +38,7 @@ class ExceptionState; ...@@ -38,7 +38,7 @@ class ExceptionState;
class LocalFrame; class LocalFrame;
class ApplicationCache final : public EventTargetWithInlineData, class ApplicationCache final : public EventTargetWithInlineData,
public ContextLifecycleObserver { public DOMWindowClient {
DEFINE_WRAPPERTYPEINFO(); DEFINE_WRAPPERTYPEINFO();
USING_GARBAGE_COLLECTED_MIXIN(ApplicationCache); USING_GARBAGE_COLLECTED_MIXIN(ApplicationCache);
...@@ -48,8 +48,6 @@ class ApplicationCache final : public EventTargetWithInlineData, ...@@ -48,8 +48,6 @@ class ApplicationCache final : public EventTargetWithInlineData,
} }
~ApplicationCache() override {} ~ApplicationCache() override {}
void contextDestroyed() override;
unsigned short status() const; unsigned short status() const;
void update(ExceptionState&); void update(ExceptionState&);
void swapCache(ExceptionState&); void swapCache(ExceptionState&);
......
...@@ -260,11 +260,12 @@ void ApplicationCacheHost::dispatchDOMEvent( ...@@ -260,11 +260,12 @@ void ApplicationCacheHost::dispatchDOMEvent(
const String& errorURL, const String& errorURL,
int errorStatus, int errorStatus,
const String& errorMessage) { const String& errorMessage) {
if (!m_domApplicationCache) // Don't dispatch an event if the window is detached.
if (!m_domApplicationCache || !m_domApplicationCache->domWindow())
return; return;
const AtomicString& eventType = ApplicationCache::toEventType(id); const AtomicString& eventType = ApplicationCache::toEventType(id);
if (eventType.isEmpty() || !m_domApplicationCache->getExecutionContext()) if (eventType.isEmpty())
return; return;
Event* event = nullptr; Event* event = nullptr;
if (id == kProgressEvent) { if (id == kProgressEvent) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment