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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 198 #include "core/loader/FrameLoader.h" | 198 #include "core/loader/FrameLoader.h" |
| 199 #include "core/loader/FrameLoaderClient.h" | 199 #include "core/loader/FrameLoaderClient.h" |
| 200 #include "core/loader/ImageLoader.h" | 200 #include "core/loader/ImageLoader.h" |
| 201 #include "core/loader/NavigationScheduler.h" | 201 #include "core/loader/NavigationScheduler.h" |
| 202 #include "core/loader/PrerendererClient.h" | 202 #include "core/loader/PrerendererClient.h" |
| 203 #include "core/loader/appcache/ApplicationCacheHost.h" | 203 #include "core/loader/appcache/ApplicationCacheHost.h" |
| 204 #include "core/page/ChromeClient.h" | 204 #include "core/page/ChromeClient.h" |
| 205 #include "core/page/EventWithHitTestResults.h" | 205 #include "core/page/EventWithHitTestResults.h" |
| 206 #include "core/page/FocusController.h" | 206 #include "core/page/FocusController.h" |
| 207 #include "core/page/FrameTree.h" | 207 #include "core/page/FrameTree.h" |
| 208 #include "core/page/NetworkStateNotifier.h" | |
| 208 #include "core/page/Page.h" | 209 #include "core/page/Page.h" |
| 209 #include "core/page/PointerLockController.h" | 210 #include "core/page/PointerLockController.h" |
| 210 #include "core/page/scrolling/RootScrollerController.h" | 211 #include "core/page/scrolling/RootScrollerController.h" |
| 211 #include "core/page/scrolling/ScrollStateCallback.h" | 212 #include "core/page/scrolling/ScrollStateCallback.h" |
| 212 #include "core/page/scrolling/ScrollingCoordinator.h" | 213 #include "core/page/scrolling/ScrollingCoordinator.h" |
| 213 #include "core/page/scrolling/SnapCoordinator.h" | 214 #include "core/page/scrolling/SnapCoordinator.h" |
| 214 #include "core/page/scrolling/TopDocumentRootScrollerController.h" | 215 #include "core/page/scrolling/TopDocumentRootScrollerController.h" |
| 215 #include "core/svg/SVGDocumentExtensions.h" | 216 #include "core/svg/SVGDocumentExtensions.h" |
| 216 #include "core/svg/SVGScriptElement.h" | 217 #include "core/svg/SVGScriptElement.h" |
| 217 #include "core/svg/SVGTitleElement.h" | 218 #include "core/svg/SVGTitleElement.h" |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 397 } | 398 } |
| 398 } | 399 } |
| 399 | 400 |
| 400 static void recordLoadReasonToHistogram(WouldLoadReason reason) { | 401 static void recordLoadReasonToHistogram(WouldLoadReason reason) { |
| 401 DEFINE_STATIC_LOCAL( | 402 DEFINE_STATIC_LOCAL( |
| 402 EnumerationHistogram, unseenFrameHistogram, | 403 EnumerationHistogram, unseenFrameHistogram, |
| 403 ("Navigation.DeferredDocumentLoading.StatesV3", WouldLoadReasonEnd)); | 404 ("Navigation.DeferredDocumentLoading.StatesV3", WouldLoadReasonEnd)); |
| 404 unseenFrameHistogram.count(reason); | 405 unseenFrameHistogram.count(reason); |
| 405 } | 406 } |
| 406 | 407 |
| 408 class Document::NetworkStateObserver final | |
| 409 : public GarbageCollected<Document::NetworkStateObserver>, | |
| 410 public NetworkStateNotifier::NetworkStateObserver, | |
| 411 public ContextLifecycleObserver { | |
| 412 USING_GARBAGE_COLLECTED_MIXIN(Document::NetworkStateObserver); | |
| 413 | |
| 414 public: | |
| 415 NetworkStateObserver(Document& document) | |
|
dcheng
2017/02/22 09:23:15
Nit: explicit
kinuko
2017/02/22 13:17:27
Done.
| |
| 416 : ContextLifecycleObserver(document), m_document(&document) { | |
| 417 networkStateNotifier().addOnLineObserver( | |
| 418 this, TaskRunnerHelper::get(TaskType::Networking, m_document).get()); | |
|
dcheng
2017/02/22 09:23:15
Is it safe to pass (and store) the WebTaskRunner a
kinuko
2017/02/22 13:17:27
Hmm, there was an assumption that the task runner
| |
| 419 } | |
| 420 | |
| 421 void onLineStateChange(bool onLine) override { | |
| 422 AtomicString eventName = | |
| 423 onLine ? EventTypeNames::online : EventTypeNames::offline; | |
| 424 m_document->domWindow()->dispatchEvent(Event::create(eventName)); | |
| 425 InspectorInstrumentation::networkStateChanged(m_document->frame(), onLine); | |
| 426 } | |
| 427 | |
| 428 void contextDestroyed(ExecutionContext* context) override { | |
| 429 networkStateNotifier().removeOnLineObserver( | |
| 430 this, TaskRunnerHelper::get(TaskType::Networking, context).get()); | |
| 431 } | |
| 432 | |
| 433 DEFINE_INLINE_VIRTUAL_TRACE() { | |
| 434 visitor->trace(m_document); | |
| 435 ContextLifecycleObserver::trace(visitor); | |
| 436 } | |
| 437 | |
| 438 private: | |
| 439 Member<Document> m_document; | |
| 440 }; | |
| 441 | |
| 407 Document::Document(const DocumentInit& initializer, | 442 Document::Document(const DocumentInit& initializer, |
| 408 DocumentClassFlags documentClasses) | 443 DocumentClassFlags documentClasses) |
| 409 : ContainerNode(0, CreateDocument), | 444 : ContainerNode(0, CreateDocument), |
| 410 TreeScope(*this), | 445 TreeScope(*this), |
| 411 m_hasNodesWithPlaceholderStyle(false), | 446 m_hasNodesWithPlaceholderStyle(false), |
| 412 m_evaluateMediaQueriesOnStyleRecalc(false), | 447 m_evaluateMediaQueriesOnStyleRecalc(false), |
| 413 m_pendingSheetLayout(NoLayoutWithPendingSheets), | 448 m_pendingSheetLayout(NoLayoutWithPendingSheets), |
| 414 m_frame(initializer.frame()), | 449 m_frame(initializer.frame()), |
| 415 // TODO(dcheng): Why does this need both a LocalFrame and LocalDOMWindow | 450 // TODO(dcheng): Why does this need both a LocalFrame and LocalDOMWindow |
| 416 // pointer? | 451 // pointer? |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 489 m_didAssociateFormControlsTimer( | 524 m_didAssociateFormControlsTimer( |
| 490 TaskRunnerHelper::get(TaskType::UnspecedLoading, this), | 525 TaskRunnerHelper::get(TaskType::UnspecedLoading, this), |
| 491 this, | 526 this, |
| 492 &Document::didAssociateFormControlsTimerFired), | 527 &Document::didAssociateFormControlsTimerFired), |
| 493 m_timers(TaskRunnerHelper::get(TaskType::Timer, this)), | 528 m_timers(TaskRunnerHelper::get(TaskType::Timer, this)), |
| 494 m_hasViewportUnits(false), | 529 m_hasViewportUnits(false), |
| 495 m_parserSyncPolicy(AllowAsynchronousParsing), | 530 m_parserSyncPolicy(AllowAsynchronousParsing), |
| 496 m_nodeCount(0), | 531 m_nodeCount(0), |
| 497 m_wouldLoadReason(Created), | 532 m_wouldLoadReason(Created), |
| 498 m_passwordCount(0), | 533 m_passwordCount(0), |
| 499 m_engagementLevel(mojom::blink::EngagementLevel::NONE) { | 534 m_engagementLevel(mojom::blink::EngagementLevel::NONE), |
| 535 m_networkStateObserver(new NetworkStateObserver(*this)) { | |
| 500 if (m_frame) { | 536 if (m_frame) { |
| 501 DCHECK(m_frame->page()); | 537 DCHECK(m_frame->page()); |
| 502 provideContextFeaturesToDocumentFrom(*this, *m_frame->page()); | 538 provideContextFeaturesToDocumentFrom(*this, *m_frame->page()); |
| 503 | 539 |
| 504 m_fetcher = m_frame->loader().documentLoader()->fetcher(); | 540 m_fetcher = m_frame->loader().documentLoader()->fetcher(); |
| 505 FrameFetchContext::provideDocumentToContext(m_fetcher->context(), this); | 541 FrameFetchContext::provideDocumentToContext(m_fetcher->context(), this); |
| 506 | 542 |
| 507 // TODO(dcheng): Why does this need to check that DOMWindow is non-null? | 543 // TODO(dcheng): Why does this need to check that DOMWindow is non-null? |
| 508 CustomElementRegistry* registry = | 544 CustomElementRegistry* registry = |
| 509 m_frame->domWindow() ? m_frame->domWindow()->maybeCustomElements() | 545 m_frame->domWindow() ? m_frame->domWindow()->maybeCustomElements() |
| (...skipping 6033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6543 visitor->trace(m_svgExtensions); | 6579 visitor->trace(m_svgExtensions); |
| 6544 visitor->trace(m_timeline); | 6580 visitor->trace(m_timeline); |
| 6545 visitor->trace(m_compositorPendingAnimations); | 6581 visitor->trace(m_compositorPendingAnimations); |
| 6546 visitor->trace(m_contextDocument); | 6582 visitor->trace(m_contextDocument); |
| 6547 visitor->trace(m_canvasFontCache); | 6583 visitor->trace(m_canvasFontCache); |
| 6548 visitor->trace(m_intersectionObserverController); | 6584 visitor->trace(m_intersectionObserverController); |
| 6549 visitor->trace(m_snapCoordinator); | 6585 visitor->trace(m_snapCoordinator); |
| 6550 visitor->trace(m_resizeObserverController); | 6586 visitor->trace(m_resizeObserverController); |
| 6551 visitor->trace(m_propertyRegistry); | 6587 visitor->trace(m_propertyRegistry); |
| 6552 visitor->trace(m_styleReattachDataMap); | 6588 visitor->trace(m_styleReattachDataMap); |
| 6589 visitor->trace(m_networkStateObserver); | |
| 6553 Supplementable<Document>::trace(visitor); | 6590 Supplementable<Document>::trace(visitor); |
| 6554 TreeScope::trace(visitor); | 6591 TreeScope::trace(visitor); |
| 6555 ContainerNode::trace(visitor); | 6592 ContainerNode::trace(visitor); |
| 6556 ExecutionContext::trace(visitor); | 6593 ExecutionContext::trace(visitor); |
| 6557 SecurityContext::trace(visitor); | 6594 SecurityContext::trace(visitor); |
| 6558 SynchronousMutationNotifier::trace(visitor); | 6595 SynchronousMutationNotifier::trace(visitor); |
| 6559 } | 6596 } |
| 6560 | 6597 |
| 6561 void Document::maybeRecordLoadReason(WouldLoadReason reason) { | 6598 void Document::maybeRecordLoadReason(WouldLoadReason reason) { |
| 6562 DCHECK(m_wouldLoadReason == Created || reason != Created); | 6599 DCHECK(m_wouldLoadReason == Created || reason != Created); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6603 } | 6640 } |
| 6604 | 6641 |
| 6605 void showLiveDocumentInstances() { | 6642 void showLiveDocumentInstances() { |
| 6606 WeakDocumentSet& set = liveDocumentSet(); | 6643 WeakDocumentSet& set = liveDocumentSet(); |
| 6607 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 6644 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
| 6608 for (blink::Document* document : set) | 6645 for (blink::Document* document : set) |
| 6609 fprintf(stderr, "- Document %p URL: %s\n", document, | 6646 fprintf(stderr, "- Document %p URL: %s\n", document, |
| 6610 document->url().getString().utf8().data()); | 6647 document->url().getString().utf8().data()); |
| 6611 } | 6648 } |
| 6612 #endif | 6649 #endif |
| OLD | NEW |