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

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

Issue 2432933005: Revert "Log to UMA why we would load a third-party frame" (Closed)
Patch Set: Created 4 years, 1 month 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 static void recordLoadReasonToHistogram(WouldLoadReason reason) { 401 // These are logged to UMA, so don't re-arrange them without creating a new
402 DEFINE_STATIC_LOCAL( 402 // histogram.
403 EnumerationHistogram, unseenFrameHistogram, 403 enum DocumentVisibilityForDeferredLoading {
404 ("Navigation.DeferredDocumentLoading.StatesV2", WouldLoadReasonEnd)); 404 Created,
405 unseenFrameHistogram.count(reason); 405 WouldLoadBecauseVisible,
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);
406 } 417 }
407 418
408 Document::Document(const DocumentInit& initializer, 419 Document::Document(const DocumentInit& initializer,
409 DocumentClassFlags documentClasses) 420 DocumentClassFlags documentClasses)
410 : ContainerNode(0, CreateDocument), 421 : ContainerNode(0, CreateDocument),
411 TreeScope(*this), 422 TreeScope(*this),
412 m_hasNodesWithPlaceholderStyle(false), 423 m_hasNodesWithPlaceholderStyle(false),
413 m_evaluateMediaQueriesOnStyleRecalc(false), 424 m_evaluateMediaQueriesOnStyleRecalc(false),
414 m_pendingSheetLayout(NoLayoutWithPendingSheets), 425 m_pendingSheetLayout(NoLayoutWithPendingSheets),
415 m_frame(initializer.frame()), 426 m_frame(initializer.frame()),
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 m_timeline(DocumentTimeline::create(this)), 491 m_timeline(DocumentTimeline::create(this)),
481 m_compositorPendingAnimations(new CompositorPendingAnimations()), 492 m_compositorPendingAnimations(new CompositorPendingAnimations()),
482 m_templateDocumentHost(nullptr), 493 m_templateDocumentHost(nullptr),
483 m_didAssociateFormControlsTimer( 494 m_didAssociateFormControlsTimer(
484 this, 495 this,
485 &Document::didAssociateFormControlsTimerFired), 496 &Document::didAssociateFormControlsTimerFired),
486 m_timers(TaskRunnerHelper::get(TaskType::Timer, this)->clone()), 497 m_timers(TaskRunnerHelper::get(TaskType::Timer, this)->clone()),
487 m_hasViewportUnits(false), 498 m_hasViewportUnits(false),
488 m_parserSyncPolicy(AllowAsynchronousParsing), 499 m_parserSyncPolicy(AllowAsynchronousParsing),
489 m_nodeCount(0), 500 m_nodeCount(0),
490 m_wouldLoadReason(Created) { 501 m_visibilityWasLogged(false) {
491 if (m_frame) { 502 if (m_frame) {
492 DCHECK(m_frame->page()); 503 DCHECK(m_frame->page());
493 provideContextFeaturesToDocumentFrom(*this, *m_frame->page()); 504 provideContextFeaturesToDocumentFrom(*this, *m_frame->page());
494 505
495 m_fetcher = m_frame->loader().documentLoader()->fetcher(); 506 m_fetcher = m_frame->loader().documentLoader()->fetcher();
496 FrameFetchContext::provideDocumentToContext(m_fetcher->context(), this); 507 FrameFetchContext::provideDocumentToContext(m_fetcher->context(), this);
497 508
498 CustomElementRegistry* registry = 509 CustomElementRegistry* registry =
499 m_frame->localDOMWindow() 510 m_frame->localDOMWindow()
500 ? m_frame->localDOMWindow()->maybeCustomElements() 511 ? m_frame->localDOMWindow()->maybeCustomElements()
(...skipping 10 matching lines...) Expand all
511 522
512 // We depend on the url getting immediately set in subframes, but we 523 // We depend on the url getting immediately set in subframes, but we
513 // also depend on the url NOT getting immediately set in opened windows. 524 // also depend on the url NOT getting immediately set in opened windows.
514 // See fast/dom/early-frame-url.html 525 // See fast/dom/early-frame-url.html
515 // and fast/dom/location-new-window-no-crash.html, respectively. 526 // and fast/dom/location-new-window-no-crash.html, respectively.
516 // FIXME: Can/should we unify this behavior? 527 // FIXME: Can/should we unify this behavior?
517 if (initializer.shouldSetURL()) 528 if (initializer.shouldSetURL())
518 setURL(initializer.url()); 529 setURL(initializer.url());
519 530
520 initSecurityContext(initializer); 531 initSecurityContext(initializer);
532 DCHECK(getSecurityOrigin());
533 if (frame() && frame()->tree().top()->securityContext() &&
534 !getSecurityOrigin()->canAccess(
535 frame()->tree().top()->securityContext()->getSecurityOrigin()))
536 RecordStateToHistogram(Created);
521 537
522 initDNSPrefetch(); 538 initDNSPrefetch();
523 539
524 InstanceCounters::incrementCounter(InstanceCounters::DocumentCounter); 540 InstanceCounters::incrementCounter(InstanceCounters::DocumentCounter);
525 541
526 m_lifecycle.advanceTo(DocumentLifecycle::Inactive); 542 m_lifecycle.advanceTo(DocumentLifecycle::Inactive);
527 543
528 // Since CSSFontSelector requires Document::m_fetcher and StyleEngine owns 544 // Since CSSFontSelector requires Document::m_fetcher and StyleEngine owns
529 // CSSFontSelector, need to initialize m_styleEngine after initializing 545 // CSSFontSelector, need to initialize m_styleEngine after initializing
530 // m_fetcher. 546 // m_fetcher.
(...skipping 5817 matching lines...) Expand 10 before | Expand all | Expand 10 after
6348 visitor->trace(m_resizeObserverController); 6364 visitor->trace(m_resizeObserverController);
6349 visitor->trace(m_propertyRegistry); 6365 visitor->trace(m_propertyRegistry);
6350 visitor->trace(m_nonAttachedStyle); 6366 visitor->trace(m_nonAttachedStyle);
6351 Supplementable<Document>::trace(visitor); 6367 Supplementable<Document>::trace(visitor);
6352 TreeScope::trace(visitor); 6368 TreeScope::trace(visitor);
6353 ContainerNode::trace(visitor); 6369 ContainerNode::trace(visitor);
6354 ExecutionContext::trace(visitor); 6370 ExecutionContext::trace(visitor);
6355 SecurityContext::trace(visitor); 6371 SecurityContext::trace(visitor);
6356 } 6372 }
6357 6373
6358 void Document::maybeRecordLoadReason(WouldLoadReason reason) { 6374 void Document::onVisibilityMaybeChanged(bool visible) {
6359 DCHECK(m_wouldLoadReason == Created || reason != Created);
6360 DCHECK(frame()); 6375 DCHECK(frame());
6361 if (m_wouldLoadReason == Created && frame()->isCrossOriginSubframe() && 6376 if (visible && !m_visibilityWasLogged && frame()->isCrossOriginSubframe()) {
6362 frame()->loader().stateMachine()->committedFirstRealDocumentLoad()) { 6377 m_visibilityWasLogged = true;
6363 recordLoadReasonToHistogram(reason); 6378 RecordStateToHistogram(WouldLoadBecauseVisible);
6364 } 6379 }
6365 m_wouldLoadReason = reason;
6366 } 6380 }
6367 6381
6368 DEFINE_TRACE_WRAPPERS(Document) { 6382 DEFINE_TRACE_WRAPPERS(Document) {
6369 visitor->traceWrappers(m_importsController); 6383 visitor->traceWrappers(m_importsController);
6370 visitor->traceWrappers(m_implementation); 6384 visitor->traceWrappers(m_implementation);
6371 visitor->traceWrappers(m_styleSheetList); 6385 visitor->traceWrappers(m_styleSheetList);
6372 visitor->traceWrappers(m_styleEngine); 6386 visitor->traceWrappers(m_styleEngine);
6373 for (int i = 0; i < numNodeListInvalidationTypes; ++i) { 6387 for (int i = 0; i < numNodeListInvalidationTypes; ++i) {
6374 for (auto list : m_nodeLists[i]) { 6388 for (auto list : m_nodeLists[i]) {
6375 visitor->traceWrappers(list); 6389 visitor->traceWrappers(list);
(...skipping 19 matching lines...) Expand all
6395 } 6409 }
6396 6410
6397 void showLiveDocumentInstances() { 6411 void showLiveDocumentInstances() {
6398 WeakDocumentSet& set = liveDocumentSet(); 6412 WeakDocumentSet& set = liveDocumentSet();
6399 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6413 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6400 for (Document* document : set) 6414 for (Document* document : set)
6401 fprintf(stderr, "- Document %p URL: %s\n", document, 6415 fprintf(stderr, "- Document %p URL: %s\n", document,
6402 document->url().getString().utf8().data()); 6416 document->url().getString().utf8().data());
6403 } 6417 }
6404 #endif 6418 #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