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

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

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