| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google, Inc. All Rights Reserved. | 2 * Copyright (C) 2013 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 15 matching lines...) Expand all Loading... |
| 26 #ifndef BackgroundHTMLParser_h | 26 #ifndef BackgroundHTMLParser_h |
| 27 #define BackgroundHTMLParser_h | 27 #define BackgroundHTMLParser_h |
| 28 | 28 |
| 29 #include "core/html/parser/BackgroundHTMLInputStream.h" | 29 #include "core/html/parser/BackgroundHTMLInputStream.h" |
| 30 #include "core/html/parser/CompactHTMLToken.h" | 30 #include "core/html/parser/CompactHTMLToken.h" |
| 31 #include "core/html/parser/HTMLParserOptions.h" | 31 #include "core/html/parser/HTMLParserOptions.h" |
| 32 #include "core/html/parser/HTMLPreloadScanner.h" | 32 #include "core/html/parser/HTMLPreloadScanner.h" |
| 33 #include "core/html/parser/HTMLSourceTracker.h" | 33 #include "core/html/parser/HTMLSourceTracker.h" |
| 34 #include "core/html/parser/HTMLTreeBuilderSimulator.h" | 34 #include "core/html/parser/HTMLTreeBuilderSimulator.h" |
| 35 #include "core/html/parser/XSSAuditorDelegate.h" | 35 #include "core/html/parser/XSSAuditorDelegate.h" |
| 36 #include "public/platform/WebThreadedResourceProvider.h" |
| 36 #include "wtf/PassOwnPtr.h" | 37 #include "wtf/PassOwnPtr.h" |
| 38 #include "wtf/Vector.h" |
| 37 #include "wtf/WeakPtr.h" | 39 #include "wtf/WeakPtr.h" |
| 38 | 40 |
| 39 namespace WebCore { | 41 namespace WebCore { |
| 40 | 42 |
| 41 class HTMLDocumentParser; | 43 class HTMLDocumentParser; |
| 42 class SharedBuffer; | 44 class SharedBuffer; |
| 43 class XSSAuditor; | 45 class XSSAuditor; |
| 44 | 46 |
| 45 class BackgroundHTMLParser { | 47 class BackgroundHTMLParser : public blink::WebThreadedResourceBackgroundClient { |
| 46 WTF_MAKE_FAST_ALLOCATED; | 48 WTF_MAKE_FAST_ALLOCATED; |
| 47 public: | 49 public: |
| 48 struct Configuration { | 50 struct Configuration { |
| 49 HTMLParserOptions options; | 51 HTMLParserOptions options; |
| 50 WeakPtr<HTMLDocumentParser> parser; | 52 WeakPtr<HTMLDocumentParser> parser; |
| 51 OwnPtr<XSSAuditor> xssAuditor; | 53 OwnPtr<XSSAuditor> xssAuditor; |
| 52 OwnPtr<TokenPreloadScanner> preloadScanner; | 54 OwnPtr<TokenPreloadScanner> preloadScanner; |
| 53 OwnPtr<TextResourceDecoder> decoder; | 55 OwnPtr<TextResourceDecoder> decoder; |
| 56 OwnPtr<blink::WebThreadedResourceProvider> resourceProvider; |
| 54 }; | 57 }; |
| 55 | 58 |
| 56 static void start(PassRefPtr<WeakReference<BackgroundHTMLParser> >, PassOwnP
tr<Configuration>); | 59 static void start(PassRefPtr<WeakReference<BackgroundHTMLParser> >, PassOwnP
tr<Configuration>); |
| 57 | 60 |
| 58 struct Checkpoint { | 61 struct Checkpoint { |
| 59 WeakPtr<HTMLDocumentParser> parser; | 62 WeakPtr<HTMLDocumentParser> parser; |
| 60 OwnPtr<HTMLToken> token; | 63 OwnPtr<HTMLToken> token; |
| 61 OwnPtr<HTMLTokenizer> tokenizer; | 64 OwnPtr<HTMLTokenizer> tokenizer; |
| 62 HTMLTreeBuilderSimulator::State treeBuilderState; | 65 HTMLTreeBuilderSimulator::State treeBuilderState; |
| 63 HTMLInputCheckpoint inputCheckpoint; | 66 HTMLInputCheckpoint inputCheckpoint; |
| 64 TokenPreloadScannerCheckpoint preloadScannerCheckpoint; | 67 TokenPreloadScannerCheckpoint preloadScannerCheckpoint; |
| 65 String unparsedInput; | 68 String unparsedInput; |
| 66 }; | 69 }; |
| 67 | 70 |
| 71 // From blink::WebThreadedResourceBackgroundClient |
| 72 virtual void didReceivedData(const char* data, size_t length) OVERRIDE FINAL
; |
| 73 |
| 68 void appendBytes(PassOwnPtr<Vector<char> >); | 74 void appendBytes(PassOwnPtr<Vector<char> >); |
| 69 void setDecoder(PassOwnPtr<TextResourceDecoder>); | 75 void setDecoder(PassOwnPtr<TextResourceDecoder>); |
| 70 void flush(); | 76 void flush(); |
| 71 void resumeFrom(PassOwnPtr<Checkpoint>); | 77 void resumeFrom(PassOwnPtr<Checkpoint>); |
| 72 void startedChunkWithCheckpoint(HTMLInputCheckpoint); | 78 void startedChunkWithCheckpoint(HTMLInputCheckpoint); |
| 73 void finish(); | 79 void finish(); |
| 74 void stop(); | 80 void stop(); |
| 81 void didSwitchedToBackgroundClient(); |
| 75 | 82 |
| 76 void forcePlaintextForTextDocument(); | 83 void forcePlaintextForTextDocument(); |
| 77 | 84 |
| 78 private: | 85 private: |
| 79 BackgroundHTMLParser(PassRefPtr<WeakReference<BackgroundHTMLParser> >, PassO
wnPtr<Configuration>); | 86 BackgroundHTMLParser(PassRefPtr<WeakReference<BackgroundHTMLParser> >, PassO
wnPtr<Configuration>); |
| 80 ~BackgroundHTMLParser(); | 87 virtual ~BackgroundHTMLParser(); |
| 81 | 88 |
| 82 void append(const String&); | 89 void append(const String&); |
| 83 void markEndOfFile(); | 90 void markEndOfFile(); |
| 84 void pumpTokenizer(); | 91 void pumpTokenizer(); |
| 85 void sendTokensToMainThread(); | 92 void sendTokensToMainThread(); |
| 86 void updateDocument(const String& decodedData); | 93 void updateDocument(const String& decodedData); |
| 94 void flushQueuedData(); |
| 87 | 95 |
| 88 WeakPtrFactory<BackgroundHTMLParser> m_weakFactory; | 96 WeakPtrFactory<BackgroundHTMLParser> m_weakFactory; |
| 89 BackgroundHTMLInputStream m_input; | 97 BackgroundHTMLInputStream m_input; |
| 90 HTMLSourceTracker m_sourceTracker; | 98 HTMLSourceTracker m_sourceTracker; |
| 91 OwnPtr<HTMLToken> m_token; | 99 OwnPtr<HTMLToken> m_token; |
| 92 OwnPtr<HTMLTokenizer> m_tokenizer; | 100 OwnPtr<HTMLTokenizer> m_tokenizer; |
| 93 HTMLTreeBuilderSimulator m_treeBuilderSimulator; | 101 HTMLTreeBuilderSimulator m_treeBuilderSimulator; |
| 94 HTMLParserOptions m_options; | 102 HTMLParserOptions m_options; |
| 95 WeakPtr<HTMLDocumentParser> m_parser; | 103 WeakPtr<HTMLDocumentParser> m_parser; |
| 96 | 104 |
| 97 OwnPtr<CompactHTMLTokenStream> m_pendingTokens; | 105 OwnPtr<CompactHTMLTokenStream> m_pendingTokens; |
| 98 PreloadRequestStream m_pendingPreloads; | 106 PreloadRequestStream m_pendingPreloads; |
| 99 XSSInfoStream m_pendingXSSInfos; | 107 XSSInfoStream m_pendingXSSInfos; |
| 100 | 108 |
| 101 OwnPtr<XSSAuditor> m_xssAuditor; | 109 OwnPtr<XSSAuditor> m_xssAuditor; |
| 102 OwnPtr<TokenPreloadScanner> m_preloadScanner; | 110 OwnPtr<TokenPreloadScanner> m_preloadScanner; |
| 103 OwnPtr<TextResourceDecoder> m_decoder; | 111 OwnPtr<TextResourceDecoder> m_decoder; |
| 112 OwnPtr<blink::WebThreadedResourceProvider> m_resourceProvider; |
| 104 DocumentEncodingData m_lastSeenEncodingData; | 113 DocumentEncodingData m_lastSeenEncodingData; |
| 114 bool m_receivingDataOnlyFromResourceProvider; |
| 115 RefPtr<SharedBuffer> m_queuedData; |
| 105 }; | 116 }; |
| 106 | 117 |
| 107 } | 118 } |
| 108 | 119 |
| 109 #endif | 120 #endif |
| OLD | NEW |