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

Side by Side Diff: third_party/WebKit/Source/core/html/parser/BackgroundHTMLParser.h

Issue 2065163005: ParseHTMLOnMainThread: notify main thread of chunks less frequently (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a setting to the experiment Created 4 years, 4 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 Configuration(); 55 Configuration();
56 HTMLParserOptions options; 56 HTMLParserOptions options;
57 WeakPtr<HTMLDocumentParser> parser; 57 WeakPtr<HTMLDocumentParser> parser;
58 std::unique_ptr<XSSAuditor> xssAuditor; 58 std::unique_ptr<XSSAuditor> xssAuditor;
59 std::unique_ptr<TextResourceDecoder> decoder; 59 std::unique_ptr<TextResourceDecoder> decoder;
60 RefPtr<TokenizedChunkQueue> tokenizedChunkQueue; 60 RefPtr<TokenizedChunkQueue> tokenizedChunkQueue;
61 // outstandingTokenLimit must be greater than or equal to 61 // outstandingTokenLimit must be greater than or equal to
62 // pendingTokenLimit 62 // pendingTokenLimit
63 size_t outstandingTokenLimit; 63 size_t outstandingTokenLimit;
64 size_t pendingTokenLimit; 64 size_t pendingTokenLimit;
65 bool shouldCoalesceChunks;
65 }; 66 };
66 67
67 static void start(PassRefPtr<WeakReference<BackgroundHTMLParser>>, std::uniq ue_ptr<Configuration>, const KURL& documentURL, std::unique_ptr<CachedDocumentPa rameters>, const MediaValuesCached::MediaValuesCachedData&, std::unique_ptr<WebT askRunner>); 68 static void start(PassRefPtr<WeakReference<BackgroundHTMLParser>>, std::uniq ue_ptr<Configuration>, const KURL& documentURL, std::unique_ptr<CachedDocumentPa rameters>, const MediaValuesCached::MediaValuesCachedData&, std::unique_ptr<WebT askRunner>);
68 69
69 struct Checkpoint { 70 struct Checkpoint {
70 USING_FAST_MALLOC(Checkpoint); 71 USING_FAST_MALLOC(Checkpoint);
71 public: 72 public:
72 WeakPtr<HTMLDocumentParser> parser; 73 WeakPtr<HTMLDocumentParser> parser;
73 std::unique_ptr<HTMLToken> token; 74 std::unique_ptr<HTMLToken> token;
74 std::unique_ptr<HTMLTokenizer> tokenizer; 75 std::unique_ptr<HTMLTokenizer> tokenizer;
(...skipping 13 matching lines...) Expand all
88 89
89 void forcePlaintextForTextDocument(); 90 void forcePlaintextForTextDocument();
90 91
91 private: 92 private:
92 BackgroundHTMLParser(PassRefPtr<WeakReference<BackgroundHTMLParser>>, std::u nique_ptr<Configuration>, const KURL& documentURL, std::unique_ptr<CachedDocumen tParameters>, const MediaValuesCached::MediaValuesCachedData&, std::unique_ptr<W ebTaskRunner>); 93 BackgroundHTMLParser(PassRefPtr<WeakReference<BackgroundHTMLParser>>, std::u nique_ptr<Configuration>, const KURL& documentURL, std::unique_ptr<CachedDocumen tParameters>, const MediaValuesCached::MediaValuesCachedData&, std::unique_ptr<W ebTaskRunner>);
93 ~BackgroundHTMLParser(); 94 ~BackgroundHTMLParser();
94 95
95 void appendDecodedBytes(const String&); 96 void appendDecodedBytes(const String&);
96 void markEndOfFile(); 97 void markEndOfFile();
97 void pumpTokenizer(); 98 void pumpTokenizer();
98 void sendTokensToMainThread(); 99
100 // Returns whether or not the HTMLDocumentParser should be notified of
101 // pending chunks.
102 bool queueChunkForMainThread();
103 void notifyMainThreadOfNewChunks();
99 void updateDocument(const String& decodedData); 104 void updateDocument(const String& decodedData);
100 105
101 template <typename FunctionType, typename... Ps> 106 template <typename FunctionType, typename... Ps>
102 void runOnMainThread(FunctionType, Ps&&...); 107 void runOnMainThread(FunctionType, Ps&&...);
103 108
104 WeakPtrFactory<BackgroundHTMLParser> m_weakFactory; 109 WeakPtrFactory<BackgroundHTMLParser> m_weakFactory;
105 BackgroundHTMLInputStream m_input; 110 BackgroundHTMLInputStream m_input;
106 HTMLSourceTracker m_sourceTracker; 111 HTMLSourceTracker m_sourceTracker;
107 std::unique_ptr<HTMLToken> m_token; 112 std::unique_ptr<HTMLToken> m_token;
108 std::unique_ptr<HTMLTokenizer> m_tokenizer; 113 std::unique_ptr<HTMLTokenizer> m_tokenizer;
(...skipping 12 matching lines...) Expand all
121 126
122 std::unique_ptr<XSSAuditor> m_xssAuditor; 127 std::unique_ptr<XSSAuditor> m_xssAuditor;
123 std::unique_ptr<TokenPreloadScanner> m_preloadScanner; 128 std::unique_ptr<TokenPreloadScanner> m_preloadScanner;
124 std::unique_ptr<TextResourceDecoder> m_decoder; 129 std::unique_ptr<TextResourceDecoder> m_decoder;
125 DocumentEncodingData m_lastSeenEncodingData; 130 DocumentEncodingData m_lastSeenEncodingData;
126 std::unique_ptr<WebTaskRunner> m_loadingTaskRunner; 131 std::unique_ptr<WebTaskRunner> m_loadingTaskRunner;
127 RefPtr<TokenizedChunkQueue> m_tokenizedChunkQueue; 132 RefPtr<TokenizedChunkQueue> m_tokenizedChunkQueue;
128 133
129 bool m_startingScript; 134 bool m_startingScript;
130 double m_lastBytesReceivedTime; 135 double m_lastBytesReceivedTime;
136 bool m_shouldCoalesceChunks;
131 }; 137 };
132 138
133 } // namespace blink 139 } // namespace blink
134 140
135 #endif 141 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/Settings.in ('k') | third_party/WebKit/Source/core/html/parser/BackgroundHTMLParser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698