Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 2389023002: Deferred frame loading stats v2 (Closed)
Patch Set: address comments Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 391
392 // This doesn't work with non-Document ExecutionContext. 392 // This doesn't work with non-Document ExecutionContext.
393 static void runAutofocusTask(ExecutionContext* context) { 393 static void runAutofocusTask(ExecutionContext* context) {
394 Document* document = toDocument(context); 394 Document* document = toDocument(context);
395 if (Element* element = document->autofocusElement()) { 395 if (Element* element = document->autofocusElement()) {
396 document->setAutofocusElement(0); 396 document->setAutofocusElement(0);
397 element->focus(); 397 element->focus();
398 } 398 }
399 } 399 }
400 400
401 // These are logged to UMA, so don't re-arrange them without creating a new 401 static void recordLoadReasonToHistogram(WouldLoadReason reason) {
402 // histogram. 402 DEFINE_STATIC_LOCAL(
403 enum DocumentVisibilityForDeferredLoading { 403 EnumerationHistogram, unseenFrameHistogram,
404 Created, 404 ("Navigation.DeferredDocumentLoading.StatesV2", WouldLoadReasonEnd));
405 WouldLoadBecauseVisible, 405 unseenFrameHistogram.count(reason);
406 // TODO(dgrogan): Add WouldLoadBecauseTopOrLeft, WouldLoadBecauseDisplayNone,
407 // etc
408
409 DocumentVisibilityForDeferredLoadingEnd
410 };
411
412 static void RecordStateToHistogram(DocumentVisibilityForDeferredLoading state) {
413 DEFINE_STATIC_LOCAL(EnumerationHistogram, unseenFrameHistogram,
414 ("Navigation.DeferredDocumentLoading.StatesV1",
415 DocumentVisibilityForDeferredLoadingEnd));
416 unseenFrameHistogram.count(state);
417 } 406 }
418 407
419 Document::Document(const DocumentInit& initializer, 408 Document::Document(const DocumentInit& initializer,
420 DocumentClassFlags documentClasses) 409 DocumentClassFlags documentClasses)
421 : ContainerNode(0, CreateDocument), 410 : ContainerNode(0, CreateDocument),
422 TreeScope(*this), 411 TreeScope(*this),
423 m_hasNodesWithPlaceholderStyle(false), 412 m_hasNodesWithPlaceholderStyle(false),
424 m_evaluateMediaQueriesOnStyleRecalc(false), 413 m_evaluateMediaQueriesOnStyleRecalc(false),
425 m_pendingSheetLayout(NoLayoutWithPendingSheets), 414 m_pendingSheetLayout(NoLayoutWithPendingSheets),
426 m_frame(initializer.frame()), 415 m_frame(initializer.frame()),
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 m_timeline(DocumentTimeline::create(this)), 478 m_timeline(DocumentTimeline::create(this)),
490 m_compositorPendingAnimations(new CompositorPendingAnimations()), 479 m_compositorPendingAnimations(new CompositorPendingAnimations()),
491 m_templateDocumentHost(nullptr), 480 m_templateDocumentHost(nullptr),
492 m_didAssociateFormControlsTimer( 481 m_didAssociateFormControlsTimer(
493 this, 482 this,
494 &Document::didAssociateFormControlsTimerFired), 483 &Document::didAssociateFormControlsTimerFired),
495 m_timers(TaskRunnerHelper::get(TaskType::Timer, this)->clone()), 484 m_timers(TaskRunnerHelper::get(TaskType::Timer, this)->clone()),
496 m_hasViewportUnits(false), 485 m_hasViewportUnits(false),
497 m_parserSyncPolicy(AllowAsynchronousParsing), 486 m_parserSyncPolicy(AllowAsynchronousParsing),
498 m_nodeCount(0), 487 m_nodeCount(0),
499 m_visibilityWasLogged(false) { 488 m_wouldLoadReason(Created) {
500 if (m_frame) { 489 if (m_frame) {
501 DCHECK(m_frame->page()); 490 DCHECK(m_frame->page());
502 provideContextFeaturesToDocumentFrom(*this, *m_frame->page()); 491 provideContextFeaturesToDocumentFrom(*this, *m_frame->page());
503 492
504 m_fetcher = m_frame->loader().documentLoader()->fetcher(); 493 m_fetcher = m_frame->loader().documentLoader()->fetcher();
505 FrameFetchContext::provideDocumentToContext(m_fetcher->context(), this); 494 FrameFetchContext::provideDocumentToContext(m_fetcher->context(), this);
506 495
507 CustomElementRegistry* registry = 496 CustomElementRegistry* registry =
508 m_frame->localDOMWindow() 497 m_frame->localDOMWindow()
509 ? m_frame->localDOMWindow()->maybeCustomElements() 498 ? m_frame->localDOMWindow()->maybeCustomElements()
(...skipping 13 matching lines...) Expand all
523 // See fast/dom/early-frame-url.html 512 // See fast/dom/early-frame-url.html
524 // and fast/dom/location-new-window-no-crash.html, respectively. 513 // and fast/dom/location-new-window-no-crash.html, respectively.
525 // FIXME: Can/should we unify this behavior? 514 // FIXME: Can/should we unify this behavior?
526 if (initializer.shouldSetURL()) 515 if (initializer.shouldSetURL())
527 setURL(initializer.url()); 516 setURL(initializer.url());
528 517
529 initSecurityContext(initializer); 518 initSecurityContext(initializer);
530 DCHECK(getSecurityOrigin()); 519 DCHECK(getSecurityOrigin());
531 if (frame() && frame()->tree().top()->securityContext() && 520 if (frame() && frame()->tree().top()->securityContext() &&
532 !getSecurityOrigin()->canAccess( 521 !getSecurityOrigin()->canAccess(
533 frame()->tree().top()->securityContext()->getSecurityOrigin())) 522 frame()->tree().top()->securityContext()->getSecurityOrigin()) &&
534 RecordStateToHistogram(Created); 523 frame()->loader().stateMachine()->committedFirstRealDocumentLoad()) {
524 recordLoadReasonToHistogram(Created);
525 }
535 526
536 initDNSPrefetch(); 527 initDNSPrefetch();
537 528
538 InstanceCounters::incrementCounter(InstanceCounters::DocumentCounter); 529 InstanceCounters::incrementCounter(InstanceCounters::DocumentCounter);
539 530
540 m_lifecycle.advanceTo(DocumentLifecycle::Inactive); 531 m_lifecycle.advanceTo(DocumentLifecycle::Inactive);
541 532
542 // Since CSSFontSelector requires Document::m_fetcher and StyleEngine owns 533 // Since CSSFontSelector requires Document::m_fetcher and StyleEngine owns
543 // CSSFontSelector, need to initialize m_styleEngine after initializing 534 // CSSFontSelector, need to initialize m_styleEngine after initializing
544 // m_fetcher. 535 // m_fetcher.
(...skipping 5813 matching lines...) Expand 10 before | Expand all | Expand 10 after
6358 visitor->trace(m_resizeObserverController); 6349 visitor->trace(m_resizeObserverController);
6359 visitor->trace(m_propertyRegistry); 6350 visitor->trace(m_propertyRegistry);
6360 visitor->trace(m_nonAttachedStyle); 6351 visitor->trace(m_nonAttachedStyle);
6361 Supplementable<Document>::trace(visitor); 6352 Supplementable<Document>::trace(visitor);
6362 TreeScope::trace(visitor); 6353 TreeScope::trace(visitor);
6363 ContainerNode::trace(visitor); 6354 ContainerNode::trace(visitor);
6364 ExecutionContext::trace(visitor); 6355 ExecutionContext::trace(visitor);
6365 SecurityContext::trace(visitor); 6356 SecurityContext::trace(visitor);
6366 } 6357 }
6367 6358
6368 void Document::onVisibilityMaybeChanged(bool visible) { 6359 void Document::wouldLoadBecause(WouldLoadReason reason) {
6360 DCHECK(reason != Created);
6369 DCHECK(frame()); 6361 DCHECK(frame());
6370 if (visible && !m_visibilityWasLogged && frame()->isCrossOriginSubframe()) { 6362 if (m_wouldLoadReason == Created && frame()->isCrossOriginSubframe() &&
6371 m_visibilityWasLogged = true; 6363 frame()->loader().stateMachine()->committedFirstRealDocumentLoad()) {
6372 RecordStateToHistogram(WouldLoadBecauseVisible); 6364 recordLoadReasonToHistogram(reason);
6373 } 6365 }
6366 m_wouldLoadReason = reason;
6374 } 6367 }
6375 6368
6376 DEFINE_TRACE_WRAPPERS(Document) { 6369 DEFINE_TRACE_WRAPPERS(Document) {
6377 visitor->traceWrappers(m_importsController); 6370 visitor->traceWrappers(m_importsController);
6378 visitor->traceWrappers(m_implementation); 6371 visitor->traceWrappers(m_implementation);
6379 visitor->traceWrappers(m_styleSheetList); 6372 visitor->traceWrappers(m_styleSheetList);
6380 visitor->traceWrappers(m_styleEngine); 6373 visitor->traceWrappers(m_styleEngine);
6381 visitor->traceWrappers(Supplementable<Document>::m_supplements.get( 6374 visitor->traceWrappers(Supplementable<Document>::m_supplements.get(
6382 FontFaceSet::supplementName())); 6375 FontFaceSet::supplementName()));
6383 for (int i = 0; i < numNodeListInvalidationTypes; ++i) { 6376 for (int i = 0; i < numNodeListInvalidationTypes; ++i) {
(...skipping 17 matching lines...) Expand all
6401 } 6394 }
6402 6395
6403 void showLiveDocumentInstances() { 6396 void showLiveDocumentInstances() {
6404 WeakDocumentSet& set = liveDocumentSet(); 6397 WeakDocumentSet& set = liveDocumentSet();
6405 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6398 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6406 for (Document* document : set) 6399 for (Document* document : set)
6407 fprintf(stderr, "- Document %p URL: %s\n", document, 6400 fprintf(stderr, "- Document %p URL: %s\n", document,
6408 document->url().getString().utf8().data()); 6401 document->url().getString().utf8().data());
6409 } 6402 }
6410 #endif 6403 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698