Chromium Code Reviews| 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..a6af32134d1aeff0d1595a40fdc94c62b7cf542f 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,8 @@ void Document::initialize() { |
| if (view()) |
| view()->didAttachDocument(); |
| + |
| + m_networkStateObserver = new NetworkStateObserver(*this); |
|
sof
2017/02/27 07:54:33
Could you add a short explanatory comment why this
kinuko
2017/02/27 09:15:05
Done.
|
| } |
| void Document::shutdown() { |