| Index: third_party/WebKit/Source/core/dom/Document.cpp
|
| diff --git a/third_party/WebKit/Source/core/dom/Document.cpp b/third_party/WebKit/Source/core/dom/Document.cpp
|
| index d8fc1a43d6f1d65b869cedef6bcf79b60cd5eb2d..99d4e4828b7c6bf58fb35b3ea00796a49df14713 100644
|
| --- a/third_party/WebKit/Source/core/dom/Document.cpp
|
| +++ b/third_party/WebKit/Source/core/dom/Document.cpp
|
| @@ -410,7 +410,6 @@ class Document::NetworkStateObserver final
|
| public NetworkStateNotifier::NetworkStateObserver,
|
| public ContextLifecycleObserver {
|
| USING_GARBAGE_COLLECTED_MIXIN(Document::NetworkStateObserver);
|
| - EAGERLY_FINALIZE();
|
|
|
| public:
|
| explicit NetworkStateObserver(Document& document)
|
| @@ -420,9 +419,6 @@ class Document::NetworkStateObserver final
|
| TaskRunnerHelper::get(TaskType::Networking, getExecutionContext()));
|
| }
|
|
|
| - // We eagerly finalize, so it's safe to touch getExecutionContext() here.
|
| - ~NetworkStateObserver() { unregisterAsObserver(getExecutionContext()); }
|
| -
|
| void onLineStateChange(bool onLine) override {
|
| AtomicString eventName =
|
| onLine ? EventTypeNames::online : EventTypeNames::offline;
|
| @@ -438,8 +434,7 @@ class Document::NetworkStateObserver final
|
| }
|
|
|
| void unregisterAsObserver(ExecutionContext* context) {
|
| - if (!context)
|
| - return;
|
| + DCHECK(context);
|
| networkStateNotifier().removeOnLineObserver(
|
| this, TaskRunnerHelper::get(TaskType::Networking, context));
|
| }
|
| @@ -539,8 +534,7 @@ Document::Document(const DocumentInit& initializer,
|
| m_nodeCount(0),
|
| m_wouldLoadReason(Created),
|
| m_passwordCount(0),
|
| - m_engagementLevel(mojom::blink::EngagementLevel::NONE),
|
| - m_networkStateObserver(new NetworkStateObserver(*this)) {
|
| + m_engagementLevel(mojom::blink::EngagementLevel::NONE) {
|
| if (m_frame) {
|
| DCHECK(m_frame->page());
|
| provideContextFeaturesToDocumentFrom(*this, *m_frame->page());
|
| @@ -2450,6 +2444,11 @@ void Document::initialize() {
|
|
|
| if (view())
|
| view()->didAttachDocument();
|
| +
|
| + // Observer(s) should not be initialized until the document is initialized /
|
| + // attached to a frame. Otherwise ContextLifecycleObserver::contextDestroyed
|
| + // wouldn't be fired.
|
| + m_networkStateObserver = new NetworkStateObserver(*this);
|
| }
|
|
|
| void Document::shutdown() {
|
|
|