Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
| 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All |
| 7 * rights reserved. | 7 * rights reserved. |
| 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
| 9 * (http://www.torchmobile.com/) | 9 * (http://www.torchmobile.com/) |
| 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. | 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 399 } | 399 } |
| 400 | 400 |
| 401 static void recordLoadReasonToHistogram(WouldLoadReason reason) { | 401 static void recordLoadReasonToHistogram(WouldLoadReason reason) { |
| 402 DEFINE_STATIC_LOCAL( | 402 DEFINE_STATIC_LOCAL( |
| 403 EnumerationHistogram, unseenFrameHistogram, | 403 EnumerationHistogram, unseenFrameHistogram, |
| 404 ("Navigation.DeferredDocumentLoading.StatesV3", WouldLoadReasonEnd)); | 404 ("Navigation.DeferredDocumentLoading.StatesV3", WouldLoadReasonEnd)); |
| 405 unseenFrameHistogram.count(reason); | 405 unseenFrameHistogram.count(reason); |
| 406 } | 406 } |
| 407 | 407 |
| 408 class Document::NetworkStateObserver final | 408 class Document::NetworkStateObserver final |
| 409 : public GarbageCollected<Document::NetworkStateObserver>, | 409 : public GarbageCollectedFinalized<Document::NetworkStateObserver>, |
| 410 public NetworkStateNotifier::NetworkStateObserver, | 410 public NetworkStateNotifier::NetworkStateObserver, |
| 411 public ContextLifecycleObserver { | 411 public ContextLifecycleObserver { |
| 412 USING_GARBAGE_COLLECTED_MIXIN(Document::NetworkStateObserver); | 412 USING_GARBAGE_COLLECTED_MIXIN(Document::NetworkStateObserver); |
| 413 | 413 |
| 414 public: | 414 public: |
| 415 explicit NetworkStateObserver(Document& document) | 415 explicit NetworkStateObserver(Document& document) |
| 416 : ContextLifecycleObserver(&document) { | 416 : ContextLifecycleObserver(&document) { |
| 417 networkStateNotifier().addOnLineObserver( | 417 networkStateNotifier().addOnLineObserver( |
| 418 this, | 418 this, |
| 419 TaskRunnerHelper::get(TaskType::Networking, getExecutionContext())); | 419 TaskRunnerHelper::get(TaskType::Networking, getExecutionContext())); |
| 420 } | 420 } |
| 421 | 421 |
| 422 ~NetworkStateObserver() { | |
| 423 if (getExecutionContext()) | |
|
sof
2017/02/24 14:21:59
It's safe to do this eagerly, but how about introd
kinuko
2017/02/24 14:43:16
Sounds good, done.
| |
| 424 contextDestroyed(getExecutionContext()); | |
| 425 } | |
| 426 | |
| 422 void onLineStateChange(bool onLine) override { | 427 void onLineStateChange(bool onLine) override { |
| 423 AtomicString eventName = | 428 AtomicString eventName = |
| 424 onLine ? EventTypeNames::online : EventTypeNames::offline; | 429 onLine ? EventTypeNames::online : EventTypeNames::offline; |
| 425 Document* document = toDocument(getExecutionContext()); | 430 Document* document = toDocument(getExecutionContext()); |
| 426 if (!document->domWindow()) | 431 if (!document->domWindow()) |
| 427 return; | 432 return; |
| 428 document->domWindow()->dispatchEvent(Event::create(eventName)); | 433 document->domWindow()->dispatchEvent(Event::create(eventName)); |
| 429 InspectorInstrumentation::networkStateChanged(document->frame(), onLine); | 434 InspectorInstrumentation::networkStateChanged(document->frame(), onLine); |
| 430 } | 435 } |
| 431 | 436 |
| 432 void contextDestroyed(ExecutionContext* context) override { | 437 void contextDestroyed(ExecutionContext* context) override { |
| 433 networkStateNotifier().removeOnLineObserver( | 438 networkStateNotifier().removeOnLineObserver( |
| 434 this, TaskRunnerHelper::get(TaskType::Networking, context)); | 439 this, TaskRunnerHelper::get(TaskType::Networking, context)); |
| 435 } | 440 } |
| 436 | 441 |
| 437 DEFINE_INLINE_VIRTUAL_TRACE() { ContextLifecycleObserver::trace(visitor); } | 442 DEFINE_INLINE_VIRTUAL_TRACE() { ContextLifecycleObserver::trace(visitor); } |
| 443 EAGERLY_FINALIZE(); | |
| 438 }; | 444 }; |
| 439 | 445 |
| 440 Document::Document(const DocumentInit& initializer, | 446 Document::Document(const DocumentInit& initializer, |
| 441 DocumentClassFlags documentClasses) | 447 DocumentClassFlags documentClasses) |
| 442 : ContainerNode(0, CreateDocument), | 448 : ContainerNode(0, CreateDocument), |
| 443 TreeScope(*this), | 449 TreeScope(*this), |
| 444 m_hasNodesWithPlaceholderStyle(false), | 450 m_hasNodesWithPlaceholderStyle(false), |
| 445 m_evaluateMediaQueriesOnStyleRecalc(false), | 451 m_evaluateMediaQueriesOnStyleRecalc(false), |
| 446 m_pendingSheetLayout(NoLayoutWithPendingSheets), | 452 m_pendingSheetLayout(NoLayoutWithPendingSheets), |
| 447 m_frame(initializer.frame()), | 453 m_frame(initializer.frame()), |
| (...skipping 6204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6652 } | 6658 } |
| 6653 | 6659 |
| 6654 void showLiveDocumentInstances() { | 6660 void showLiveDocumentInstances() { |
| 6655 WeakDocumentSet& set = liveDocumentSet(); | 6661 WeakDocumentSet& set = liveDocumentSet(); |
| 6656 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 6662 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
| 6657 for (blink::Document* document : set) | 6663 for (blink::Document* document : set) |
| 6658 fprintf(stderr, "- Document %p URL: %s\n", document, | 6664 fprintf(stderr, "- Document %p URL: %s\n", document, |
| 6659 document->url().getString().utf8().data()); | 6665 document->url().getString().utf8().data()); |
| 6660 } | 6666 } |
| 6661 #endif | 6667 #endif |
| OLD | NEW |