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

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

Issue 2550373005: Make WebTaskRunner ThreadSafeRefCounted (Closed)
Patch Set: mac fix Created 4 years 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 static void checkThatXSSInfosAreSafeToSendToAnotherThread( 81 static void checkThatXSSInfosAreSafeToSendToAnotherThread(
82 const XSSInfoStream& infos) { 82 const XSSInfoStream& infos) {
83 for (size_t i = 0; i < infos.size(); ++i) 83 for (size_t i = 0; i < infos.size(); ++i)
84 ASSERT(infos[i]->isSafeToSendToAnotherThread()); 84 ASSERT(infos[i]->isSafeToSendToAnotherThread());
85 } 85 }
86 86
87 #endif 87 #endif
88 88
89 WeakPtr<BackgroundHTMLParser> BackgroundHTMLParser::create( 89 WeakPtr<BackgroundHTMLParser> BackgroundHTMLParser::create(
90 std::unique_ptr<Configuration> config, 90 std::unique_ptr<Configuration> config,
91 std::unique_ptr<WebTaskRunner> loadingTaskRunner) { 91 RefPtr<WebTaskRunner> loadingTaskRunner) {
92 auto* backgroundParser = 92 auto* backgroundParser =
93 new BackgroundHTMLParser(std::move(config), std::move(loadingTaskRunner)); 93 new BackgroundHTMLParser(std::move(config), std::move(loadingTaskRunner));
94 return backgroundParser->m_weakFactory.createWeakPtr(); 94 return backgroundParser->m_weakFactory.createWeakPtr();
95 } 95 }
96 96
97 void BackgroundHTMLParser::init( 97 void BackgroundHTMLParser::init(
98 const KURL& documentURL, 98 const KURL& documentURL,
99 std::unique_ptr<CachedDocumentParameters> cachedDocumentParameters, 99 std::unique_ptr<CachedDocumentParameters> cachedDocumentParameters,
100 const MediaValuesCached::MediaValuesCachedData& mediaValuesCachedData) { 100 const MediaValuesCached::MediaValuesCachedData& mediaValuesCachedData) {
101 m_preloadScanner.reset(new TokenPreloadScanner( 101 m_preloadScanner.reset(new TokenPreloadScanner(
102 documentURL, std::move(cachedDocumentParameters), mediaValuesCachedData)); 102 documentURL, std::move(cachedDocumentParameters), mediaValuesCachedData));
103 } 103 }
104 104
105 BackgroundHTMLParser::Configuration::Configuration() 105 BackgroundHTMLParser::Configuration::Configuration()
106 : outstandingTokenLimit(defaultOutstandingTokenLimit), 106 : outstandingTokenLimit(defaultOutstandingTokenLimit),
107 pendingTokenLimit(defaultPendingTokenLimit), 107 pendingTokenLimit(defaultPendingTokenLimit),
108 shouldCoalesceChunks(false) {} 108 shouldCoalesceChunks(false) {}
109 109
110 BackgroundHTMLParser::BackgroundHTMLParser( 110 BackgroundHTMLParser::BackgroundHTMLParser(
111 std::unique_ptr<Configuration> config, 111 std::unique_ptr<Configuration> config,
112 std::unique_ptr<WebTaskRunner> loadingTaskRunner) 112 RefPtr<WebTaskRunner> loadingTaskRunner)
113 : m_weakFactory(this), 113 : m_weakFactory(this),
114 m_token(wrapUnique(new HTMLToken)), 114 m_token(wrapUnique(new HTMLToken)),
115 m_tokenizer(HTMLTokenizer::create(config->options)), 115 m_tokenizer(HTMLTokenizer::create(config->options)),
116 m_treeBuilderSimulator(config->options), 116 m_treeBuilderSimulator(config->options),
117 m_options(config->options), 117 m_options(config->options),
118 m_outstandingTokenLimit(config->outstandingTokenLimit), 118 m_outstandingTokenLimit(config->outstandingTokenLimit),
119 m_parser(config->parser), 119 m_parser(config->parser),
120 m_pendingTokens(wrapUnique(new CompactHTMLTokenStream)), 120 m_pendingTokens(wrapUnique(new CompactHTMLTokenStream)),
121 m_pendingTokenLimit(config->pendingTokenLimit), 121 m_pendingTokenLimit(config->pendingTokenLimit),
122 m_xssAuditor(std::move(config->xssAuditor)), 122 m_xssAuditor(std::move(config->xssAuditor)),
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 if (isMainThread()) { 376 if (isMainThread()) {
377 (*WTF::bind(function, std::forward<Ps>(parameters)...))(); 377 (*WTF::bind(function, std::forward<Ps>(parameters)...))();
378 } else { 378 } else {
379 m_loadingTaskRunner->postTask( 379 m_loadingTaskRunner->postTask(
380 BLINK_FROM_HERE, 380 BLINK_FROM_HERE,
381 crossThreadBind(function, std::forward<Ps>(parameters)...)); 381 crossThreadBind(function, std::forward<Ps>(parameters)...));
382 } 382 }
383 } 383 }
384 384
385 } // namespace blink 385 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698