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

Side by Side Diff: sky/engine/core/html/parser/BackgroundHTMLParser.h

Issue 664573004: Live the dream (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: DEPS 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
OLDNEW
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 13 matching lines...) Expand all
24 */ 24 */
25 25
26 #ifndef BackgroundHTMLParser_h 26 #ifndef BackgroundHTMLParser_h
27 #define BackgroundHTMLParser_h 27 #define BackgroundHTMLParser_h
28 28
29 #include "base/memory/weak_ptr.h" 29 #include "base/memory/weak_ptr.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/HTMLTokenizer.h" 32 #include "core/html/parser/HTMLTokenizer.h"
33 #include "core/html/parser/TextResourceDecoder.h" 33 #include "core/html/parser/TextResourceDecoder.h"
34 #include "mojo/public/cpp/system/core.h"
35 #include "platform/fetcher/DataPipeDrainer.h"
34 #include "platform/text/SegmentedString.h" 36 #include "platform/text/SegmentedString.h"
35 #include "wtf/PassOwnPtr.h" 37 #include "wtf/PassOwnPtr.h"
36 #include "wtf/WeakPtr.h" 38 #include "wtf/WeakPtr.h"
37 39
38 namespace blink { 40 namespace blink {
39 41
40 class HTMLDocumentParser; 42 class HTMLDocumentParser;
41 class SharedBuffer; 43 class SharedBuffer;
42 44
43 class BackgroundHTMLParser { 45 class BackgroundHTMLParser : public DataPipeDrainer::Client {
44 WTF_MAKE_FAST_ALLOCATED; 46 WTF_MAKE_FAST_ALLOCATED;
45 public: 47 public:
46 struct Configuration { 48 struct Configuration {
47 HTMLParserOptions options; 49 HTMLParserOptions options;
50 mojo::ScopedDataPipeConsumerHandle source;
48 WeakPtr<HTMLDocumentParser> parser; 51 WeakPtr<HTMLDocumentParser> parser;
49 }; 52 };
50 53
51 static base::WeakPtr<BackgroundHTMLParser> create(PassOwnPtr<Configuration>) ; 54 static base::WeakPtr<BackgroundHTMLParser> create(PassOwnPtr<Configuration>) ;
52 55
53 void appendRawBytesFromMainThread(PassOwnPtr<Vector<char> >); 56 void start();
54 void flush();
55 void finish();
56 void stop(); 57 void stop();
57 58
58 private: 59 private:
59 explicit BackgroundHTMLParser(PassOwnPtr<Configuration>); 60 explicit BackgroundHTMLParser(PassOwnPtr<Configuration>);
60 ~BackgroundHTMLParser(); 61 ~BackgroundHTMLParser();
61 62
62 void appendDecodedBytes(const String&); 63 void OnDataAvailable(const void* data, size_t numberOfBytes) override;
64 void OnDataComplete() override;
65
66 void finish();
63 void markEndOfFile(); 67 void markEndOfFile();
64 void pumpTokenizer(); 68 void pumpTokenizer();
65 void sendTokensToMainThread(); 69 void sendTokensToMainThread();
66 void updateDocument(const String& decodedData);
67 bool updateTokenizerState(const CompactHTMLToken& token); 70 bool updateTokenizerState(const CompactHTMLToken& token);
68 71
69 SegmentedString m_input; 72 SegmentedString m_input;
70 OwnPtr<HTMLToken> m_token; 73 OwnPtr<HTMLToken> m_token;
71 OwnPtr<HTMLTokenizer> m_tokenizer; 74 OwnPtr<HTMLTokenizer> m_tokenizer;
72 WeakPtr<HTMLDocumentParser> m_parser; 75 WeakPtr<HTMLDocumentParser> m_parser;
73 76
74 OwnPtr<CompactHTMLTokenStream> m_pendingTokens; 77 OwnPtr<CompactHTMLTokenStream> m_pendingTokens;
75 OwnPtr<TextResourceDecoder> m_decoder; 78 OwnPtr<TextResourceDecoder> m_decoder;
76 79
80 mojo::ScopedDataPipeConsumerHandle m_source;
81 OwnPtr<DataPipeDrainer> m_drainer;
82
77 base::WeakPtrFactory<BackgroundHTMLParser> m_weakFactory; 83 base::WeakPtrFactory<BackgroundHTMLParser> m_weakFactory;
78 }; 84 };
79 85
80 } 86 }
81 87
82 #endif 88 #endif
OLDNEW
« no previous file with comments | « sky/engine/core/html/imports/HTMLImportLoader.cpp ('k') | sky/engine/core/html/parser/BackgroundHTMLParser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698