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

Side by Side Diff: Source/core/html/parser/HTMLPreloadScanner.cpp

Issue 1108303002: HTMLPreloadScanner unit tests (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: nit Created 5 years, 7 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) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2009 Torch Mobile, Inc. http://www.torchmobile.com/ 3 * Copyright (C) 2009 Torch Mobile, Inc. http://www.torchmobile.com/
4 * Copyright (C) 2010 Google Inc. All Rights Reserved. 4 * Copyright (C) 2010 Google Inc. All Rights Reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 14 matching lines...) Expand all
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28 #include "config.h" 28 #include "config.h"
29 #include "core/html/parser/HTMLPreloadScanner.h" 29 #include "core/html/parser/HTMLPreloadScanner.h"
30 30
31 #include "core/HTMLNames.h" 31 #include "core/HTMLNames.h"
32 #include "core/InputTypeNames.h" 32 #include "core/InputTypeNames.h"
33 #include "core/css/MediaList.h" 33 #include "core/css/MediaList.h"
34 #include "core/css/MediaQueryEvaluator.h" 34 #include "core/css/MediaQueryEvaluator.h"
35 #include "core/css/MediaValues.h"
36 #include "core/css/parser/SizesAttributeParser.h" 35 #include "core/css/parser/SizesAttributeParser.h"
37 #include "core/html/LinkRelAttribute.h" 36 #include "core/html/LinkRelAttribute.h"
38 #include "core/html/parser/HTMLParserIdioms.h" 37 #include "core/html/parser/HTMLParserIdioms.h"
39 #include "core/html/parser/HTMLSrcsetParser.h" 38 #include "core/html/parser/HTMLSrcsetParser.h"
40 #include "core/html/parser/HTMLTokenizer.h" 39 #include "core/html/parser/HTMLTokenizer.h"
41 #include "platform/RuntimeEnabledFeatures.h" 40 #include "platform/RuntimeEnabledFeatures.h"
42 #include "platform/TraceEvent.h" 41 #include "platform/TraceEvent.h"
43 #include "wtf/MainThread.h" 42 #include "wtf/MainThread.h"
44 43
45 namespace blink { 44 namespace blink {
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 533
535 HTMLPreloadScanner::~HTMLPreloadScanner() 534 HTMLPreloadScanner::~HTMLPreloadScanner()
536 { 535 {
537 } 536 }
538 537
539 void HTMLPreloadScanner::appendToEnd(const SegmentedString& source) 538 void HTMLPreloadScanner::appendToEnd(const SegmentedString& source)
540 { 539 {
541 m_source.append(source); 540 m_source.append(source);
542 } 541 }
543 542
544 void HTMLPreloadScanner::scan(HTMLResourcePreloader* preloader, const KURL& star tingBaseElementURL) 543 void HTMLPreloadScanner::scan(ResourcePreloader* preloader, const KURL& starting BaseElementURL)
545 { 544 {
546 ASSERT(isMainThread()); // HTMLTokenizer::updateStateFor only works on the m ain thread. 545 ASSERT(isMainThread()); // HTMLTokenizer::updateStateFor only works on the m ain thread.
547 546
548 TRACE_EVENT1("blink", "HTMLPreloadScanner::scan", "source_length", m_source. length()); 547 TRACE_EVENT1("blink", "HTMLPreloadScanner::scan", "source_length", m_source. length());
549 548
550 // When we start scanning, our best prediction of the baseElementURL is the real one! 549 // When we start scanning, our best prediction of the baseElementURL is the real one!
551 if (!startingBaseElementURL.isEmpty()) 550 if (!startingBaseElementURL.isEmpty())
552 m_scanner.setPredictedBaseElementURL(startingBaseElementURL); 551 m_scanner.setPredictedBaseElementURL(startingBaseElementURL);
553 552
554 PreloadRequestStream requests; 553 PreloadRequestStream requests;
555 554
556 while (m_tokenizer->nextToken(m_source, m_token)) { 555 while (m_tokenizer->nextToken(m_source, m_token)) {
557 if (m_token.type() == HTMLToken::StartTag) 556 if (m_token.type() == HTMLToken::StartTag)
558 m_tokenizer->updateStateFor(attemptStaticStringCreation(m_token.name (), Likely8Bit)); 557 m_tokenizer->updateStateFor(attemptStaticStringCreation(m_token.name (), Likely8Bit));
559 m_scanner.scan(m_token, m_source, requests); 558 m_scanner.scan(m_token, m_source, requests);
560 m_token.clear(); 559 m_token.clear();
561 } 560 }
562 561
563 preloader->takeAndPreload(requests); 562 preloader->takeAndPreload(requests);
564 } 563 }
565 564
566 } 565 }
OLDNEW
« no previous file with comments | « Source/core/html/parser/HTMLPreloadScanner.h ('k') | Source/core/html/parser/HTMLPreloadScannerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698