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

Side by Side Diff: Source/core/html/parser/HTMLDocumentParser.cpp

Issue 634983003: Yield HTMLDocumentParser for high priority tasks in blink scheduler. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 25 matching lines...) Expand all
36 #include "core/html/parser/BackgroundHTMLParser.h" 36 #include "core/html/parser/BackgroundHTMLParser.h"
37 #include "core/html/parser/HTMLParserScheduler.h" 37 #include "core/html/parser/HTMLParserScheduler.h"
38 #include "core/html/parser/HTMLParserThread.h" 38 #include "core/html/parser/HTMLParserThread.h"
39 #include "core/html/parser/HTMLScriptRunner.h" 39 #include "core/html/parser/HTMLScriptRunner.h"
40 #include "core/html/parser/HTMLTreeBuilder.h" 40 #include "core/html/parser/HTMLTreeBuilder.h"
41 #include "core/inspector/InspectorInstrumentation.h" 41 #include "core/inspector/InspectorInstrumentation.h"
42 #include "core/inspector/InspectorTraceEvents.h" 42 #include "core/inspector/InspectorTraceEvents.h"
43 #include "core/loader/DocumentLoader.h" 43 #include "core/loader/DocumentLoader.h"
44 #include "platform/SharedBuffer.h" 44 #include "platform/SharedBuffer.h"
45 #include "platform/TraceEvent.h" 45 #include "platform/TraceEvent.h"
46 #include "platform/scheduler/Scheduler.h"
46 #include "public/platform/WebThreadedDataReceiver.h" 47 #include "public/platform/WebThreadedDataReceiver.h"
47 #include "wtf/Functional.h" 48 #include "wtf/Functional.h"
48 49
49 namespace blink { 50 namespace blink {
50 51
51 using namespace HTMLNames; 52 using namespace HTMLNames;
52 53
53 // This is a direct transcription of step 4 from: 54 // This is a direct transcription of step 4 from:
54 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#frag ment-case 55 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#frag ment-case
55 static HTMLTokenizer::State tokenizerStateForContextElement(Element* contextElem ent, bool reportErrors, const HTMLParserOptions& options) 56 static HTMLTokenizer::State tokenizerStateForContextElement(Element* contextElem ent, bool reportErrors, const HTMLParserOptions& options)
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 530
530 double startTime = currentTime(); 531 double startTime = currentTime();
531 532
532 while (!m_speculations.isEmpty()) { 533 while (!m_speculations.isEmpty()) {
533 processParsedChunkFromBackgroundParser(m_speculations.takeFirst()); 534 processParsedChunkFromBackgroundParser(m_speculations.takeFirst());
534 535
535 // Always check isStopped first as m_document may be null. 536 // Always check isStopped first as m_document may be null.
536 if (isStopped() || isWaitingForScripts()) 537 if (isStopped() || isWaitingForScripts())
537 break; 538 break;
538 539
539 if (currentTime() - startTime > parserTimeLimit && !m_speculations.isEmp ty()) { 540 if ((Scheduler::shared()->shouldYieldForHighPriorityWork() || currentTim e() - startTime > parserTimeLimit) && !m_speculations.isEmpty()) {
540 m_parserScheduler->scheduleForResume(); 541 m_parserScheduler->scheduleForResume();
541 break; 542 break;
542 } 543 }
543 } 544 }
544 545
545 TRACE_EVENT_END1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "ParseHTML" , "endLine", lineNumber().zeroBasedInt()); 546 TRACE_EVENT_END1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "ParseHTML" , "endLine", lineNumber().zeroBasedInt());
546 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli ne migrates to tracing. 547 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli ne migrates to tracing.
547 InspectorInstrumentation::didWriteHTML(cookie, lineNumber().zeroBasedInt()); 548 InspectorInstrumentation::didWriteHTML(cookie, lineNumber().zeroBasedInt());
548 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update Counters", "data", InspectorUpdateCountersEvent::data()); 549 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update Counters", "data", InspectorUpdateCountersEvent::data());
549 } 550 }
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 void HTMLDocumentParser::setDecoder(PassOwnPtr<TextResourceDecoder> decoder) 1075 void HTMLDocumentParser::setDecoder(PassOwnPtr<TextResourceDecoder> decoder)
1075 { 1076 {
1076 ASSERT(decoder); 1077 ASSERT(decoder);
1077 DecodedDataDocumentParser::setDecoder(decoder); 1078 DecodedDataDocumentParser::setDecoder(decoder);
1078 1079
1079 if (m_haveBackgroundParser) 1080 if (m_haveBackgroundParser)
1080 HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::setDeco der, m_backgroundParser, takeDecoder())); 1081 HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::setDeco der, m_backgroundParser, takeDecoder()));
1081 } 1082 }
1082 1083
1083 } 1084 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698