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

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

Issue 2212183004: Log to UMA when x-origin frames (1) are created and (2) become visible (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix histogram description Created 4 years, 3 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 r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 // This doesn't work with non-Document ExecutionContext. 376 // This doesn't work with non-Document ExecutionContext.
377 static void runAutofocusTask(ExecutionContext* context) 377 static void runAutofocusTask(ExecutionContext* context)
378 { 378 {
379 Document* document = toDocument(context); 379 Document* document = toDocument(context);
380 if (Element* element = document->autofocusElement()) { 380 if (Element* element = document->autofocusElement()) {
381 document->setAutofocusElement(0); 381 document->setAutofocusElement(0);
382 element->focus(); 382 element->focus();
383 } 383 }
384 } 384 }
385 385
386 // These are logged to UMA, so don't re-arrange them without creating a new hist ogram.
387 enum DocumentVisibilityForDeferredLoading {
388 Created,
389 WouldLoadBecauseVisible,
390 // TODO(dgrogan): Add WouldLoadBecauseTopOrLeft, WouldLoadBecauseDisplayNone , etc
391
392 DocumentVisibilityForDeferredLoadingEnd
393 };
394
395 static void RecordStateToHistogram(DocumentVisibilityForDeferredLoading state)
396 {
397 DEFINE_STATIC_LOCAL(EnumerationHistogram, unseenFrameHistogram, ("Navigation .DeferredDocumentLoading.StatesV1", DocumentVisibilityForDeferredLoadingEnd));
398 unseenFrameHistogram.count(state);
399 }
400
386 Document::Document(const DocumentInit& initializer, DocumentClassFlags documentC lasses) 401 Document::Document(const DocumentInit& initializer, DocumentClassFlags documentC lasses)
387 : ContainerNode(0, CreateDocument) 402 : ContainerNode(0, CreateDocument)
388 , TreeScope(*this) 403 , TreeScope(*this)
389 , m_hasNodesWithPlaceholderStyle(false) 404 , m_hasNodesWithPlaceholderStyle(false)
390 , m_evaluateMediaQueriesOnStyleRecalc(false) 405 , m_evaluateMediaQueriesOnStyleRecalc(false)
391 , m_pendingSheetLayout(NoLayoutWithPendingSheets) 406 , m_pendingSheetLayout(NoLayoutWithPendingSheets)
392 , m_frame(initializer.frame()) 407 , m_frame(initializer.frame())
393 , m_domWindow(m_frame ? m_frame->localDOMWindow() : 0) 408 , m_domWindow(m_frame ? m_frame->localDOMWindow() : 0)
394 , m_importsController(initializer.importsController()) 409 , m_importsController(initializer.importsController())
395 , m_contextFeatures(ContextFeatures::defaultSwitch()) 410 , m_contextFeatures(ContextFeatures::defaultSwitch())
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 , m_registrationContext(initializer.registrationContext(this)) 462 , m_registrationContext(initializer.registrationContext(this))
448 , m_elementDataCacheClearTimer(this, &Document::elementDataCacheClearTimerFi red) 463 , m_elementDataCacheClearTimer(this, &Document::elementDataCacheClearTimerFi red)
449 , m_timeline(DocumentTimeline::create(this)) 464 , m_timeline(DocumentTimeline::create(this))
450 , m_compositorPendingAnimations(new CompositorPendingAnimations()) 465 , m_compositorPendingAnimations(new CompositorPendingAnimations())
451 , m_templateDocumentHost(nullptr) 466 , m_templateDocumentHost(nullptr)
452 , m_didAssociateFormControlsTimer(this, &Document::didAssociateFormControlsT imerFired) 467 , m_didAssociateFormControlsTimer(this, &Document::didAssociateFormControlsT imerFired)
453 , m_timers(TaskRunnerHelper::get(TaskType::Timer, this)->clone()) 468 , m_timers(TaskRunnerHelper::get(TaskType::Timer, this)->clone())
454 , m_hasViewportUnits(false) 469 , m_hasViewportUnits(false)
455 , m_parserSyncPolicy(AllowAsynchronousParsing) 470 , m_parserSyncPolicy(AllowAsynchronousParsing)
456 , m_nodeCount(0) 471 , m_nodeCount(0)
472 , m_visibilityWasLogged(false)
457 { 473 {
458 if (m_frame) { 474 if (m_frame) {
459 DCHECK(m_frame->page()); 475 DCHECK(m_frame->page());
460 provideContextFeaturesToDocumentFrom(*this, *m_frame->page()); 476 provideContextFeaturesToDocumentFrom(*this, *m_frame->page());
461 477
462 m_fetcher = m_frame->loader().documentLoader()->fetcher(); 478 m_fetcher = m_frame->loader().documentLoader()->fetcher();
463 FrameFetchContext::provideDocumentToContext(m_fetcher->context(), this); 479 FrameFetchContext::provideDocumentToContext(m_fetcher->context(), this);
464 480
465 CustomElementRegistry* registry = m_frame->localDOMWindow() 481 CustomElementRegistry* registry = m_frame->localDOMWindow()
466 ? m_frame->localDOMWindow()->maybeCustomElements() 482 ? m_frame->localDOMWindow()->maybeCustomElements()
(...skipping 14 matching lines...) Expand all
481 497
482 // We depend on the url getting immediately set in subframes, but we 498 // We depend on the url getting immediately set in subframes, but we
483 // also depend on the url NOT getting immediately set in opened windows. 499 // also depend on the url NOT getting immediately set in opened windows.
484 // See fast/dom/early-frame-url.html 500 // See fast/dom/early-frame-url.html
485 // and fast/dom/location-new-window-no-crash.html, respectively. 501 // and fast/dom/location-new-window-no-crash.html, respectively.
486 // FIXME: Can/should we unify this behavior? 502 // FIXME: Can/should we unify this behavior?
487 if (initializer.shouldSetURL()) 503 if (initializer.shouldSetURL())
488 setURL(initializer.url()); 504 setURL(initializer.url());
489 505
490 initSecurityContext(initializer); 506 initSecurityContext(initializer);
507 DCHECK(getSecurityOrigin());
508 if (frame() && frame()->tree().top()->securityContext() && !getSecurityOrigi n()->canAccess(frame()->tree().top()->securityContext()->getSecurityOrigin()))
509 RecordStateToHistogram(Created);
510
491 initDNSPrefetch(); 511 initDNSPrefetch();
492 512
493 InstanceCounters::incrementCounter(InstanceCounters::DocumentCounter); 513 InstanceCounters::incrementCounter(InstanceCounters::DocumentCounter);
494 514
495 m_lifecycle.advanceTo(DocumentLifecycle::Inactive); 515 m_lifecycle.advanceTo(DocumentLifecycle::Inactive);
496 516
497 // Since CSSFontSelector requires Document::m_fetcher and StyleEngine owns 517 // Since CSSFontSelector requires Document::m_fetcher and StyleEngine owns
498 // CSSFontSelector, need to initialize m_styleEngine after initializing 518 // CSSFontSelector, need to initialize m_styleEngine after initializing
499 // m_fetcher. 519 // m_fetcher.
500 m_styleEngine = StyleEngine::create(*this); 520 m_styleEngine = StyleEngine::create(*this);
(...skipping 5510 matching lines...) Expand 10 before | Expand all | Expand 10 after
6011 visitor->trace(m_intersectionObserverData); 6031 visitor->trace(m_intersectionObserverData);
6012 visitor->trace(m_snapCoordinator); 6032 visitor->trace(m_snapCoordinator);
6013 visitor->trace(m_resizeObserverController); 6033 visitor->trace(m_resizeObserverController);
6014 Supplementable<Document>::trace(visitor); 6034 Supplementable<Document>::trace(visitor);
6015 TreeScope::trace(visitor); 6035 TreeScope::trace(visitor);
6016 ContainerNode::trace(visitor); 6036 ContainerNode::trace(visitor);
6017 ExecutionContext::trace(visitor); 6037 ExecutionContext::trace(visitor);
6018 SecurityContext::trace(visitor); 6038 SecurityContext::trace(visitor);
6019 } 6039 }
6020 6040
6041 void Document::onVisibilityMaybeChanged(bool visible)
6042 {
6043 DCHECK(frame());
6044 if (visible && !m_visibilityWasLogged && frame()->isCrossOriginSubframe()) {
6045 m_visibilityWasLogged = true;
6046 RecordStateToHistogram(WouldLoadBecauseVisible);
6047 }
6048 }
6049
6021 DEFINE_TRACE_WRAPPERS(Document) 6050 DEFINE_TRACE_WRAPPERS(Document)
6022 { 6051 {
6023 visitor->traceWrappers(m_importsController); 6052 visitor->traceWrappers(m_importsController);
6024 visitor->traceWrappers(m_implementation); 6053 visitor->traceWrappers(m_implementation);
6025 visitor->traceWrappers(m_styleSheetList); 6054 visitor->traceWrappers(m_styleSheetList);
6026 visitor->traceWrappers(m_styleEngine); 6055 visitor->traceWrappers(m_styleEngine);
6027 visitor->traceWrappers( 6056 visitor->traceWrappers(
6028 Supplementable<Document>::m_supplements.get( 6057 Supplementable<Document>::m_supplements.get(
6029 FontFaceSet::supplementName())); 6058 FontFaceSet::supplementName()));
6030 for (int i = 0; i < numNodeListInvalidationTypes; ++i) { 6059 for (int i = 0; i < numNodeListInvalidationTypes; ++i) {
(...skipping 18 matching lines...) Expand all
6049 } 6078 }
6050 6079
6051 void showLiveDocumentInstances() 6080 void showLiveDocumentInstances()
6052 { 6081 {
6053 WeakDocumentSet& set = liveDocumentSet(); 6082 WeakDocumentSet& set = liveDocumentSet();
6054 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6083 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6055 for (Document* document : set) 6084 for (Document* document : set)
6056 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data()); 6085 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data());
6057 } 6086 }
6058 #endif 6087 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.h ('k') | third_party/WebKit/Source/core/frame/FrameView.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698