Commit 164ea1ce authored by haraken's avatar haraken Committed by Commit bot

Add ContextLifecycleObserver::frame()

I'm replacing DOMWindowProperty with ContextLifecycleObserver.
(ContextLifecycleObserver::contextDestroyed() is called already almost at the same
timing as DOMWindowProperty::frameDestroyed().)

To make the replacement easier, this CL introduces ContextLifecycleObserver::frame().
Also this CL moves ApplicationCache to ContextLifecycleObserver.

BUG=610176

Review-Url: https://codereview.chromium.org/2562303002
Cr-Commit-Position: refs/heads/master@{#437852}
parent a0d0931b
......@@ -42,6 +42,7 @@ blink_core_sources("dom") {
"ContextFeatures.h",
"ContextLifecycleNotifier.cpp",
"ContextLifecycleNotifier.h",
"ContextLifecycleObserver.cpp",
"ContextLifecycleObserver.h",
"DOMArrayBuffer.cpp",
"DOMArrayBuffer.h",
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "core/dom/ContextLifecycleObserver.h"
#include "core/dom/Document.h"
#include "core/frame/LocalFrame.h"
namespace blink {
LocalFrame* ContextLifecycleObserver::frame() const {
return getExecutionContext() && getExecutionContext()->isDocument()
? toDocument(getExecutionContext())->frame()
: nullptr;
}
}
......@@ -33,11 +33,18 @@
namespace blink {
class LocalFrame;
class CORE_EXPORT ContextLifecycleObserver
: public LifecycleObserver<ExecutionContext, ContextLifecycleObserver> {
public:
// Returns null after the observing context is detached.
ExecutionContext* getExecutionContext() const { return lifecycleContext(); }
// Returns null after the observing context is detached or if the context
// doesn't have a frame (i.e., if the context is not a Document).
LocalFrame* frame() const;
enum Type {
GenericType,
SuspendableObjectType,
......
......@@ -39,7 +39,7 @@
namespace blink {
ApplicationCache::ApplicationCache(LocalFrame* frame)
: DOMWindowProperty(frame) {
: ContextLifecycleObserver(frame->document()) {
ApplicationCacheHost* cacheHost = applicationCacheHost();
if (cacheHost)
cacheHost->setApplicationCache(this);
......@@ -47,13 +47,12 @@ ApplicationCache::ApplicationCache(LocalFrame* frame)
DEFINE_TRACE(ApplicationCache) {
EventTargetWithInlineData::trace(visitor);
DOMWindowProperty::trace(visitor);
ContextLifecycleObserver::trace(visitor);
}
void ApplicationCache::frameDestroyed() {
void ApplicationCache::contextDestroyed() {
if (ApplicationCacheHost* cacheHost = applicationCacheHost())
cacheHost->setApplicationCache(0);
DOMWindowProperty::frameDestroyed();
}
ApplicationCacheHost* ApplicationCache::applicationCacheHost() const {
......
......@@ -26,9 +26,8 @@
#ifndef ApplicationCache_h
#define ApplicationCache_h
#include "core/dom/ContextLifecycleObserver.h"
#include "core/events/EventTarget.h"
#include "core/frame/DOMWindowProperty.h"
#include "core/loader/appcache/ApplicationCacheHost.h"
#include "platform/heap/Handle.h"
#include "wtf/Forward.h"
......@@ -39,7 +38,7 @@ class ExceptionState;
class LocalFrame;
class ApplicationCache final : public EventTargetWithInlineData,
public DOMWindowProperty {
public ContextLifecycleObserver {
DEFINE_WRAPPERTYPEINFO();
USING_GARBAGE_COLLECTED_MIXIN(ApplicationCache);
......@@ -49,7 +48,7 @@ class ApplicationCache final : public EventTargetWithInlineData,
}
~ApplicationCache() override {}
void frameDestroyed() override;
void contextDestroyed() override;
unsigned short status() const;
void update(ExceptionState&);
......
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