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

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

Issue 133173003: The HTML parser should ignore incoming bytes when stopped, not just when detached. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 11 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
« 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 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 652
653 m_insertionPreloadScanner->appendToEnd(source); 653 m_insertionPreloadScanner->appendToEnd(source);
654 m_insertionPreloadScanner->scan(m_preloader.get(), document()->baseEleme ntURL()); 654 m_insertionPreloadScanner->scan(m_preloader.get(), document()->baseEleme ntURL());
655 } 655 }
656 656
657 endIfDelayed(); 657 endIfDelayed();
658 } 658 }
659 659
660 void HTMLDocumentParser::startBackgroundParser() 660 void HTMLDocumentParser::startBackgroundParser()
661 { 661 {
662 ASSERT(!isStopped());
662 ASSERT(shouldUseThreading()); 663 ASSERT(shouldUseThreading());
663 ASSERT(!m_haveBackgroundParser); 664 ASSERT(!m_haveBackgroundParser);
664 m_haveBackgroundParser = true; 665 m_haveBackgroundParser = true;
665 666
666 RefPtr<WeakReference<BackgroundHTMLParser> > reference = WeakReference<Backg roundHTMLParser>::createUnbound(); 667 RefPtr<WeakReference<BackgroundHTMLParser> > reference = WeakReference<Backg roundHTMLParser>::createUnbound();
667 m_backgroundParser = WeakPtr<BackgroundHTMLParser>(reference); 668 m_backgroundParser = WeakPtr<BackgroundHTMLParser>(reference);
668 669
669 OwnPtr<BackgroundHTMLParser::Configuration> config = adoptPtr(new Background HTMLParser::Configuration); 670 OwnPtr<BackgroundHTMLParser::Configuration> config = adoptPtr(new Background HTMLParser::Configuration);
670 config->options = m_options; 671 config->options = m_options;
671 config->parser = m_weakFactory.createWeakPtr(); 672 config->parser = m_weakFactory.createWeakPtr();
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 } 958 }
958 959
959 void HTMLDocumentParser::resumeScheduledTasks() 960 void HTMLDocumentParser::resumeScheduledTasks()
960 { 961 {
961 if (m_parserScheduler) 962 if (m_parserScheduler)
962 m_parserScheduler->resume(); 963 m_parserScheduler->resume();
963 } 964 }
964 965
965 void HTMLDocumentParser::appendBytes(const char* data, size_t length) 966 void HTMLDocumentParser::appendBytes(const char* data, size_t length)
966 { 967 {
967 if (!length || isDetached()) 968 if (!length || isStopped())
968 return; 969 return;
969 970
970 if (shouldUseThreading()) { 971 if (shouldUseThreading()) {
971 if (!m_haveBackgroundParser) 972 if (!m_haveBackgroundParser)
972 startBackgroundParser(); 973 startBackgroundParser();
973 974
974 OwnPtr<Vector<char> > buffer = adoptPtr(new Vector<char>(length)); 975 OwnPtr<Vector<char> > buffer = adoptPtr(new Vector<char>(length));
975 memcpy(buffer->data(), data, length); 976 memcpy(buffer->data(), data, length);
976 TRACE_EVENT1("net", "HTMLDocumentParser::appendBytes", "size", (unsigned )length); 977 TRACE_EVENT1("net", "HTMLDocumentParser::appendBytes", "size", (unsigned )length);
977 978
(...skipping 11 matching lines...) Expand all
989 return; 990 return;
990 991
991 if (m_haveBackgroundParser) 992 if (m_haveBackgroundParser)
992 HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::flush, m_backgroundParser)); 993 HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::flush, m_backgroundParser));
993 else 994 else
994 DecodedDataDocumentParser::flush(); 995 DecodedDataDocumentParser::flush();
995 } 996 }
996 997
997 void HTMLDocumentParser::setDecoder(PassOwnPtr<TextResourceDecoder> decoder) 998 void HTMLDocumentParser::setDecoder(PassOwnPtr<TextResourceDecoder> decoder)
998 { 999 {
1000 ASSERT(decoder);
999 DecodedDataDocumentParser::setDecoder(decoder); 1001 DecodedDataDocumentParser::setDecoder(decoder);
1000 1002
1001 if (m_haveBackgroundParser) 1003 if (m_haveBackgroundParser)
1002 HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::setDeco der, m_backgroundParser, takeDecoder())); 1004 HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::setDeco der, m_backgroundParser, takeDecoder()));
1003 } 1005 }
1004 1006
1005 } 1007 }
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