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

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

Issue 1441073006: Move throttling of background timers into the renderer scheduler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed various dchecks Created 5 years 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 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 , m_pluginLoadingTimer(this, &Document::pluginLoadingTimerFired) 435 , m_pluginLoadingTimer(this, &Document::pluginLoadingTimerFired)
436 , m_documentTiming(*this) 436 , m_documentTiming(*this)
437 , m_writeRecursionIsTooDeep(false) 437 , m_writeRecursionIsTooDeep(false)
438 , m_writeRecursionDepth(0) 438 , m_writeRecursionDepth(0)
439 , m_taskRunner(MainThreadTaskRunner::create(this)) 439 , m_taskRunner(MainThreadTaskRunner::create(this))
440 , m_registrationContext(initializer.registrationContext(this)) 440 , m_registrationContext(initializer.registrationContext(this))
441 , m_elementDataCacheClearTimer(this, &Document::elementDataCacheClearTimerFi red) 441 , m_elementDataCacheClearTimer(this, &Document::elementDataCacheClearTimerFi red)
442 , m_timeline(AnimationTimeline::create(this)) 442 , m_timeline(AnimationTimeline::create(this))
443 , m_templateDocumentHost(nullptr) 443 , m_templateDocumentHost(nullptr)
444 , m_didAssociateFormControlsTimer(this, &Document::didAssociateFormControlsT imerFired) 444 , m_didAssociateFormControlsTimer(this, &Document::didAssociateFormControlsT imerFired)
445 , m_timers(Platform::current()->currentThread()->scheduler()->timerTaskRunne r()->adoptClone()) 445 , m_timers(timerTaskRunner()->adoptClone())
446 , m_hasViewportUnits(false) 446 , m_hasViewportUnits(false)
447 , m_styleRecalcElementCounter(0) 447 , m_styleRecalcElementCounter(0)
448 , m_parserSyncPolicy(AllowAsynchronousParsing) 448 , m_parserSyncPolicy(AllowAsynchronousParsing)
449 , m_nodeCount(0) 449 , m_nodeCount(0)
450 { 450 {
451 if (m_frame) { 451 if (m_frame) {
452 ASSERT(m_frame->page()); 452 ASSERT(m_frame->page());
453 provideContextFeaturesToDocumentFrom(*this, *m_frame->page()); 453 provideContextFeaturesToDocumentFrom(*this, *m_frame->page());
454 454
455 m_fetcher = m_frame->loader().documentLoader()->fetcher(); 455 m_fetcher = m_frame->loader().documentLoader()->fetcher();
456 m_timers.setTimerTaskRunner(m_frame->frameScheduler()->timerTaskRunner() ->adoptClone());
457 FrameFetchContext::provideDocumentToContext(m_fetcher->context(), this); 456 FrameFetchContext::provideDocumentToContext(m_fetcher->context(), this);
458 } else if (m_importsController) { 457 } else if (m_importsController) {
459 m_fetcher = FrameFetchContext::createContextAndFetcher(nullptr); 458 m_fetcher = FrameFetchContext::createContextAndFetcher(nullptr);
460 FrameFetchContext::provideDocumentToContext(m_fetcher->context(), this); 459 FrameFetchContext::provideDocumentToContext(m_fetcher->context(), this);
461 } else { 460 } else {
462 m_fetcher = ResourceFetcher::create(nullptr); 461 m_fetcher = ResourceFetcher::create(nullptr);
463 } 462 }
464 463
465 // We depend on the url getting immediately set in subframes, but we 464 // We depend on the url getting immediately set in subframes, but we
466 // also depend on the url NOT getting immediately set in opened windows. 465 // also depend on the url NOT getting immediately set in opened windows.
(...skipping 2421 matching lines...) Expand 10 before | Expand all | Expand 10 after
2888 const KURL& Document::virtualURL() const 2887 const KURL& Document::virtualURL() const
2889 { 2888 {
2890 return m_url; 2889 return m_url;
2891 } 2890 }
2892 2891
2893 KURL Document::virtualCompleteURL(const String& url) const 2892 KURL Document::virtualCompleteURL(const String& url) const
2894 { 2893 {
2895 return completeURL(url); 2894 return completeURL(url);
2896 } 2895 }
2897 2896
2898 double Document::timerAlignmentInterval() const
2899 {
2900 Page* p = page();
2901 if (!p)
2902 return DOMTimer::visiblePageAlignmentInterval();
2903 return p->timerAlignmentInterval();
2904 }
2905
2906 DOMTimerCoordinator* Document::timers() 2897 DOMTimerCoordinator* Document::timers()
2907 { 2898 {
2908 return &m_timers; 2899 return &m_timers;
2909 } 2900 }
2910 2901
2911 EventTarget* Document::errorEventTarget() 2902 EventTarget* Document::errorEventTarget()
2912 { 2903 {
2913 return domWindow(); 2904 return domWindow();
2914 } 2905 }
2915 2906
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
3036 // Only imports on master documents can trigger rendering. 3027 // Only imports on master documents can trigger rendering.
3037 if (HTMLImportLoader* import = importLoader()) 3028 if (HTMLImportLoader* import = importLoader())
3038 import->didRemoveAllPendingStylesheet(); 3029 import->didRemoveAllPendingStylesheet();
3039 if (!haveImportsLoaded()) 3030 if (!haveImportsLoaded())
3040 return; 3031 return;
3041 didLoadAllScriptBlockingResources(); 3032 didLoadAllScriptBlockingResources();
3042 } 3033 }
3043 3034
3044 void Document::didLoadAllScriptBlockingResources() 3035 void Document::didLoadAllScriptBlockingResources()
3045 { 3036 {
3046 Platform::current()->currentThread()->scheduler()->loadingTaskRunner()->post Task( 3037 loadingTaskRunner()->postTask(BLINK_FROM_HERE, m_executeScriptsWaitingForRes ourcesTask->cancelAndCreate());
3047 BLINK_FROM_HERE, m_executeScriptsWaitingForResourcesTask->cancelAndCreat e());
3048 3038
3049 if (frame()) 3039 if (frame())
3050 frame()->loader().client()->didRemoveAllPendingStylesheet(); 3040 frame()->loader().client()->didRemoveAllPendingStylesheet();
3051 3041
3052 if (m_gotoAnchorNeededAfterStylesheetsLoad && view()) 3042 if (m_gotoAnchorNeededAfterStylesheetsLoad && view())
3053 view()->processUrlFragment(m_url); 3043 view()->processUrlFragment(m_url);
3054 } 3044 }
3055 3045
3056 void Document::executeScriptsWaitingForResources() 3046 void Document::executeScriptsWaitingForResources()
3057 { 3047 {
(...skipping 2708 matching lines...) Expand 10 before | Expand all | Expand 10 after
5766 5756
5767 WebTaskRunner* Document::loadingTaskRunner() const 5757 WebTaskRunner* Document::loadingTaskRunner() const
5768 { 5758 {
5769 if (frame()) 5759 if (frame())
5770 return frame()->frameScheduler()->loadingTaskRunner(); 5760 return frame()->frameScheduler()->loadingTaskRunner();
5771 return Platform::current()->currentThread()->scheduler()->loadingTaskRunner( ); 5761 return Platform::current()->currentThread()->scheduler()->loadingTaskRunner( );
5772 } 5762 }
5773 5763
5774 WebTaskRunner* Document::timerTaskRunner() const 5764 WebTaskRunner* Document::timerTaskRunner() const
5775 { 5765 {
5776 return m_timers.timerTaskRunner(); 5766 if (frame())
5767 return m_frame->frameScheduler()->timerTaskRunner();
5768 return Platform::current()->currentThread()->scheduler()->timerTaskRunner();
5777 } 5769 }
5778 5770
5779 DEFINE_TRACE(Document) 5771 DEFINE_TRACE(Document)
5780 { 5772 {
5781 #if ENABLE(OILPAN) 5773 #if ENABLE(OILPAN)
5782 visitor->trace(m_importsController); 5774 visitor->trace(m_importsController);
5783 visitor->trace(m_docType); 5775 visitor->trace(m_docType);
5784 visitor->trace(m_implementation); 5776 visitor->trace(m_implementation);
5785 visitor->trace(m_autofocusElement); 5777 visitor->trace(m_autofocusElement);
5786 visitor->trace(m_focusedElement); 5778 visitor->trace(m_focusedElement);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
5847 #ifndef NDEBUG 5839 #ifndef NDEBUG
5848 using namespace blink; 5840 using namespace blink;
5849 void showLiveDocumentInstances() 5841 void showLiveDocumentInstances()
5850 { 5842 {
5851 Document::WeakDocumentSet& set = Document::liveDocumentSet(); 5843 Document::WeakDocumentSet& set = Document::liveDocumentSet();
5852 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 5844 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
5853 for (Document* document : set) 5845 for (Document* document : set)
5854 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data()); 5846 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data());
5855 } 5847 }
5856 #endif 5848 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698