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

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: move to Document 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, ("DeferredFr ameLoading.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 CustomElementsRegistry* registry = m_frame->localDOMWindow() 481 CustomElementsRegistry* registry = m_frame->localDOMWindow()
466 ? m_frame->localDOMWindow()->maybeCustomElements() 482 ? m_frame->localDOMWindow()->maybeCustomElements()
(...skipping 10 matching lines...) Expand all
477 493
478 // We depend on the url getting immediately set in subframes, but we 494 // We depend on the url getting immediately set in subframes, but we
479 // also depend on the url NOT getting immediately set in opened windows. 495 // also depend on the url NOT getting immediately set in opened windows.
480 // See fast/dom/early-frame-url.html 496 // See fast/dom/early-frame-url.html
481 // and fast/dom/location-new-window-no-crash.html, respectively. 497 // and fast/dom/location-new-window-no-crash.html, respectively.
482 // FIXME: Can/should we unify this behavior? 498 // FIXME: Can/should we unify this behavior?
483 if (initializer.shouldSetURL()) 499 if (initializer.shouldSetURL())
484 setURL(initializer.url()); 500 setURL(initializer.url());
485 501
486 initSecurityContext(initializer); 502 initSecurityContext(initializer);
503 if (frame() && getSecurityOrigin() && frame()->tree().top()->securityContext () && !getSecurityOrigin()->canAccess(frame()->tree().top()->securityContext()-> getSecurityOrigin()))
dcheng 2016/08/29 20:37:19 I don't think securityOrigin can be null here, unl
dgrogan 2016/08/31 19:52:41 Good to know, changed to DCHECK.
504 RecordStateToHistogram(Created);
505
487 initDNSPrefetch(); 506 initDNSPrefetch();
488 507
489 InstanceCounters::incrementCounter(InstanceCounters::DocumentCounter); 508 InstanceCounters::incrementCounter(InstanceCounters::DocumentCounter);
490 509
491 m_lifecycle.advanceTo(DocumentLifecycle::Inactive); 510 m_lifecycle.advanceTo(DocumentLifecycle::Inactive);
492 511
493 // Since CSSFontSelector requires Document::m_fetcher and StyleEngine owns 512 // Since CSSFontSelector requires Document::m_fetcher and StyleEngine owns
494 // CSSFontSelector, need to initialize m_styleEngine after initializing 513 // CSSFontSelector, need to initialize m_styleEngine after initializing
495 // m_fetcher. 514 // m_fetcher.
496 m_styleEngine = StyleEngine::create(*this); 515 m_styleEngine = StyleEngine::create(*this);
(...skipping 5503 matching lines...) Expand 10 before | Expand all | Expand 10 after
6000 visitor->trace(m_intersectionObserverData); 6019 visitor->trace(m_intersectionObserverData);
6001 visitor->trace(m_snapCoordinator); 6020 visitor->trace(m_snapCoordinator);
6002 visitor->trace(m_resizeObserverController); 6021 visitor->trace(m_resizeObserverController);
6003 Supplementable<Document>::trace(visitor); 6022 Supplementable<Document>::trace(visitor);
6004 TreeScope::trace(visitor); 6023 TreeScope::trace(visitor);
6005 ContainerNode::trace(visitor); 6024 ContainerNode::trace(visitor);
6006 ExecutionContext::trace(visitor); 6025 ExecutionContext::trace(visitor);
6007 SecurityContext::trace(visitor); 6026 SecurityContext::trace(visitor);
6008 } 6027 }
6009 6028
6029 void Document::onVisibilityMaybeChanged(bool visible)
6030 {
6031 if (visible && !m_visibilityWasLogged && frame() && frame()->isCrossOriginSu bframe()) {
dcheng 2016/08/29 20:37:19 Since frame()->document() points to this document(
dgrogan 2016/08/31 19:52:41 Done.
6032 m_visibilityWasLogged = true;
6033 RecordStateToHistogram(WouldLoadBecauseVisible);
6034 }
6035 }
6036
6010 DEFINE_TRACE_WRAPPERS(Document) 6037 DEFINE_TRACE_WRAPPERS(Document)
6011 { 6038 {
6012 visitor->traceWrappers(m_importsController); 6039 visitor->traceWrappers(m_importsController);
6013 visitor->traceWrappers(m_implementation); 6040 visitor->traceWrappers(m_implementation);
6014 visitor->traceWrappers(m_styleSheetList); 6041 visitor->traceWrappers(m_styleSheetList);
6015 visitor->traceWrappers(m_styleEngine); 6042 visitor->traceWrappers(m_styleEngine);
6016 visitor->traceWrappers( 6043 visitor->traceWrappers(
6017 Supplementable<Document>::m_supplements.get( 6044 Supplementable<Document>::m_supplements.get(
6018 FontFaceSet::supplementName())); 6045 FontFaceSet::supplementName()));
6019 for (int i = 0; i < numNodeListInvalidationTypes; ++i) { 6046 for (int i = 0; i < numNodeListInvalidationTypes; ++i) {
(...skipping 18 matching lines...) Expand all
6038 } 6065 }
6039 6066
6040 void showLiveDocumentInstances() 6067 void showLiveDocumentInstances()
6041 { 6068 {
6042 WeakDocumentSet& set = liveDocumentSet(); 6069 WeakDocumentSet& set = liveDocumentSet();
6043 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6070 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6044 for (Document* document : set) 6071 for (Document* document : set)
6045 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data()); 6072 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data());
6046 } 6073 }
6047 #endif 6074 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698