OLD | NEW |
---|---|
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 || (contextTag.matches(noscriptTag) && options.scriptEnabled) | 68 || (contextTag.matches(noscriptTag) && options.scriptEnabled) |
69 || contextTag.matches(noframesTag)) | 69 || contextTag.matches(noframesTag)) |
70 return reportErrors ? HTMLTokenizer::RAWTEXTState : HTMLTokenizer::PLAIN TEXTState; | 70 return reportErrors ? HTMLTokenizer::RAWTEXTState : HTMLTokenizer::PLAIN TEXTState; |
71 if (contextTag.matches(scriptTag)) | 71 if (contextTag.matches(scriptTag)) |
72 return reportErrors ? HTMLTokenizer::ScriptDataState : HTMLTokenizer::PL AINTEXTState; | 72 return reportErrors ? HTMLTokenizer::ScriptDataState : HTMLTokenizer::PL AINTEXTState; |
73 if (contextTag.matches(plaintextTag)) | 73 if (contextTag.matches(plaintextTag)) |
74 return HTMLTokenizer::PLAINTEXTState; | 74 return HTMLTokenizer::PLAINTEXTState; |
75 return HTMLTokenizer::DataState; | 75 return HTMLTokenizer::DataState; |
76 } | 76 } |
77 | 77 |
78 class ParserDataReceiver : public blink::WebThreadedDataReceiver { | 78 class ParserDataReceiver : public WebThreadedDataReceiver { |
79 public: | 79 public: |
80 explicit ParserDataReceiver(WeakPtr<BackgroundHTMLParser> backgroundParser) | 80 explicit ParserDataReceiver(WeakPtr<BackgroundHTMLParser> backgroundParser, WeakPtrWillBeRawPtr<Document> document) |
81 : m_backgroundParser(backgroundParser) | 81 : m_backgroundParser(backgroundParser) |
82 , m_document(document) | |
82 { | 83 { |
83 } | 84 } |
84 | 85 |
85 // WebThreadedDataReceiver | 86 // WebThreadedDataReceiver |
86 virtual void acceptData(const char* data, int dataLength) override final | 87 virtual void acceptData(const char* data, int dataLength) override final |
87 { | 88 { |
88 ASSERT(backgroundThread() && backgroundThread()->isCurrentThread()); | 89 ASSERT(backgroundThread() && backgroundThread()->isCurrentThread()); |
89 if (m_backgroundParser.get()) | 90 if (m_backgroundParser.get()) |
90 m_backgroundParser.get()->appendRawBytesFromParserThread(data, dataL ength); | 91 m_backgroundParser.get()->appendRawBytesFromParserThread(data, dataL ength); |
91 } | 92 } |
92 | 93 |
93 virtual blink::WebThread* backgroundThread() override final | 94 virtual blink::WebThread* backgroundThread() override final |
94 { | 95 { |
95 if (HTMLParserThread::shared()) | 96 if (HTMLParserThread::shared()) |
96 return &HTMLParserThread::shared()->platformThread(); | 97 return &HTMLParserThread::shared()->platformThread(); |
97 | 98 |
98 return nullptr; | 99 return nullptr; |
99 } | 100 } |
100 | 101 |
102 virtual bool needsMainthreadDataCopy() override final { return InspectorInst rumentation::hasFrontends(); } | |
103 virtual void acceptMainthreadDataNotification(const char* data, int dataLeng th, int encodedDataLength) override final | |
104 { | |
kouhei (in TOK)
2014/11/18 04:49:55
please add ASSERT(isMainThread());
| |
105 ASSERT(!data || m_needMainthreadDataCopy); | |
106 if (m_document.get()) | |
107 m_document.get()->loader()->acceptDataFromThreadedReceiver(data, dat aLength, encodedDataLength); | |
108 } | |
109 | |
101 private: | 110 private: |
102 WeakPtr<BackgroundHTMLParser> m_backgroundParser; | 111 WeakPtr<BackgroundHTMLParser> m_backgroundParser; |
112 WeakPtrWillBeRawPtr<Document> m_document; | |
kouhei (in TOK)
2014/11/18 04:49:55
This would not work on Oilpan, as RawPtr is not nu
haraken
2014/11/18 04:57:27
Can't this simply be a RefPtr?
In the first place
| |
103 }; | 113 }; |
104 | 114 |
105 HTMLDocumentParser::HTMLDocumentParser(HTMLDocument& document, bool reportErrors ) | 115 HTMLDocumentParser::HTMLDocumentParser(HTMLDocument& document, bool reportErrors ) |
106 : ScriptableDocumentParser(document) | 116 : ScriptableDocumentParser(document) |
107 , m_options(&document) | 117 , m_options(&document) |
108 , m_token(nullptr) | 118 , m_token(nullptr) |
109 , m_tokenizer(nullptr) | 119 , m_tokenizer(nullptr) |
110 , m_scriptRunner(HTMLScriptRunner::create(&document, this)) | 120 , m_scriptRunner(HTMLScriptRunner::create(&document, this)) |
111 , m_treeBuilder(HTMLTreeBuilder::create(this, &document, parserContentPolicy (), reportErrors, m_options)) | 121 , m_treeBuilder(HTMLTreeBuilder::create(this, &document, parserContentPolicy (), reportErrors, m_options)) |
112 , m_parserScheduler(HTMLParserScheduler::create(this)) | 122 , m_parserScheduler(HTMLParserScheduler::create(this)) |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
713 { | 723 { |
714 ASSERT(!isStopped()); | 724 ASSERT(!isStopped()); |
715 ASSERT(shouldUseThreading()); | 725 ASSERT(shouldUseThreading()); |
716 ASSERT(!m_haveBackgroundParser); | 726 ASSERT(!m_haveBackgroundParser); |
717 m_haveBackgroundParser = true; | 727 m_haveBackgroundParser = true; |
718 | 728 |
719 RefPtr<WeakReference<BackgroundHTMLParser>> reference = WeakReference<Backgr oundHTMLParser>::createUnbound(); | 729 RefPtr<WeakReference<BackgroundHTMLParser>> reference = WeakReference<Backgr oundHTMLParser>::createUnbound(); |
720 m_backgroundParser = WeakPtr<BackgroundHTMLParser>(reference); | 730 m_backgroundParser = WeakPtr<BackgroundHTMLParser>(reference); |
721 | 731 |
722 // TODO(oysteine): Disabled due to crbug.com/398076 until a full fix can be implemented. | 732 // TODO(oysteine): Disabled due to crbug.com/398076 until a full fix can be implemented. |
723 if (RuntimeEnabledFeatures::threadedParserDataReceiverEnabled()) { | 733 if (RuntimeEnabledFeatures::threadedParserDataReceiverEnabled()) { |
kouhei (in TOK)
2014/11/18 04:49:55
I think this is still marked as experimental and n
oystein (OOO til 10th of July)
2014/11/20 23:24:57
Yes, I put it behind the flag when we discovered t
| |
724 if (DocumentLoader* loader = document()->loader()) | 734 if (DocumentLoader* loader = document()->loader()) |
725 loader->attachThreadedDataReceiver(adoptPtr(new ParserDataReceiver(m _backgroundParser))); | 735 loader->attachThreadedDataReceiver(adoptPtr(new ParserDataReceiver(m _backgroundParser, document()->contextDocument()))); |
726 } | 736 } |
727 | 737 |
728 OwnPtr<BackgroundHTMLParser::Configuration> config = adoptPtr(new Background HTMLParser::Configuration); | 738 OwnPtr<BackgroundHTMLParser::Configuration> config = adoptPtr(new Background HTMLParser::Configuration); |
729 config->options = m_options; | 739 config->options = m_options; |
730 config->parser = m_weakFactory.createWeakPtr(); | 740 config->parser = m_weakFactory.createWeakPtr(); |
731 config->xssAuditor = adoptPtr(new XSSAuditor); | 741 config->xssAuditor = adoptPtr(new XSSAuditor); |
732 config->xssAuditor->init(document(), &m_xssAuditorDelegate); | 742 config->xssAuditor->init(document(), &m_xssAuditorDelegate); |
733 config->preloadScanner = adoptPtr(new TokenPreloadScanner(document()->url(). copy(), createMediaValues(document()))); | 743 config->preloadScanner = adoptPtr(new TokenPreloadScanner(document()->url(). copy(), createMediaValues(document()))); |
734 config->decoder = takeDecoder(); | 744 config->decoder = takeDecoder(); |
735 | 745 |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1048 void HTMLDocumentParser::setDecoder(PassOwnPtr<TextResourceDecoder> decoder) | 1058 void HTMLDocumentParser::setDecoder(PassOwnPtr<TextResourceDecoder> decoder) |
1049 { | 1059 { |
1050 ASSERT(decoder); | 1060 ASSERT(decoder); |
1051 DecodedDataDocumentParser::setDecoder(decoder); | 1061 DecodedDataDocumentParser::setDecoder(decoder); |
1052 | 1062 |
1053 if (m_haveBackgroundParser) | 1063 if (m_haveBackgroundParser) |
1054 HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::setDeco der, m_backgroundParser, takeDecoder())); | 1064 HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::setDeco der, m_backgroundParser, takeDecoder())); |
1055 } | 1065 } |
1056 | 1066 |
1057 } | 1067 } |
OLD | NEW |