| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. | 2 * Copyright (C) 2010 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 #else | 66 #else |
| 67 ASSERT(!m_parserScheduler); | 67 ASSERT(!m_parserScheduler); |
| 68 ASSERT(!m_pumpSessionNestingLevel); | 68 ASSERT(!m_pumpSessionNestingLevel); |
| 69 ASSERT(!m_haveBackgroundParser); | 69 ASSERT(!m_haveBackgroundParser); |
| 70 // FIXME: We should be able to ASSERT(m_speculations.isEmpty()), | 70 // FIXME: We should be able to ASSERT(m_speculations.isEmpty()), |
| 71 // but there are cases where that's not true currently. For example, | 71 // but there are cases where that's not true currently. For example, |
| 72 // we we're told to stop parsing before we've consumed all the input. | 72 // we we're told to stop parsing before we've consumed all the input. |
| 73 #endif | 73 #endif |
| 74 } | 74 } |
| 75 | 75 |
| 76 void HTMLDocumentParser::parse(mojo::ScopedDataPipeConsumerHandle source) | 76 void HTMLDocumentParser::parse(mojo::ScopedDataPipeConsumerHandle source, |
| 77 const base::Closure& completionCallback) |
| 77 { | 78 { |
| 78 ASSERT(!isStopped()); | 79 ASSERT(!isStopped()); |
| 79 ASSERT(!m_haveBackgroundParser); | 80 ASSERT(!m_haveBackgroundParser); |
| 80 m_haveBackgroundParser = true; | 81 m_haveBackgroundParser = true; |
| 81 | 82 |
| 83 m_completionCallback = completionCallback; |
| 84 |
| 82 OwnPtr<BackgroundHTMLParser::Configuration> config = adoptPtr(new Background
HTMLParser::Configuration); | 85 OwnPtr<BackgroundHTMLParser::Configuration> config = adoptPtr(new Background
HTMLParser::Configuration); |
| 83 config->source = source.Pass(); | 86 config->source = source.Pass(); |
| 84 config->parser = m_weakFactory.GetWeakPtr(); | 87 config->parser = m_weakFactory.GetWeakPtr(); |
| 85 | 88 |
| 86 m_backgroundParser = BackgroundHTMLParser::create(config.release()); | 89 m_backgroundParser = BackgroundHTMLParser::create(config.release()); |
| 87 HTMLParserThread::taskRunner()->PostTask(FROM_HERE, | 90 HTMLParserThread::taskRunner()->PostTask(FROM_HERE, |
| 88 base::Bind(&BackgroundHTMLParser::start, m_backgroundParser)); | 91 base::Bind(&BackgroundHTMLParser::start, m_backgroundParser)); |
| 89 } | 92 } |
| 90 | 93 |
| 91 void HTMLDocumentParser::detach() | 94 void HTMLDocumentParser::detach() |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 } | 351 } |
| 349 | 352 |
| 350 void HTMLDocumentParser::end() | 353 void HTMLDocumentParser::end() |
| 351 { | 354 { |
| 352 ASSERT(!isDetached()); | 355 ASSERT(!isDetached()); |
| 353 ASSERT(!isScheduledForResume()); | 356 ASSERT(!isScheduledForResume()); |
| 354 | 357 |
| 355 if (m_haveBackgroundParser) | 358 if (m_haveBackgroundParser) |
| 356 stopBackgroundParser(); | 359 stopBackgroundParser(); |
| 357 | 360 |
| 361 // Notice that we copy the compleition callback into a local variable |
| 362 // because we might be deleted after we call ffinish() below. |
| 363 base::Closure completionCallback = m_completionCallback; |
| 364 |
| 358 // Informs the the rest of WebCore that parsing is really finished (and dele
tes this). | 365 // Informs the the rest of WebCore that parsing is really finished (and dele
tes this). |
| 359 m_treeBuilder->finished(); | 366 m_treeBuilder->finished(); |
| 367 |
| 368 completionCallback.Run(); |
| 360 } | 369 } |
| 361 | 370 |
| 362 void HTMLDocumentParser::attemptToEnd() | 371 void HTMLDocumentParser::attemptToEnd() |
| 363 { | 372 { |
| 364 if (shouldDelayEnd()) { | 373 if (shouldDelayEnd()) { |
| 365 m_endWasDelayed = true; | 374 m_endWasDelayed = true; |
| 366 return; | 375 return; |
| 367 } | 376 } |
| 368 prepareToStopParsing(); | 377 prepareToStopParsing(); |
| 369 } | 378 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 { | 430 { |
| 422 if (!m_scriptRunner.hasPendingScripts()) | 431 if (!m_scriptRunner.hasPendingScripts()) |
| 423 return; | 432 return; |
| 424 RefPtr<HTMLDocumentParser> protect(this); | 433 RefPtr<HTMLDocumentParser> protect(this); |
| 425 m_scriptRunner.executePendingScripts(); | 434 m_scriptRunner.executePendingScripts(); |
| 426 if (!isWaitingForScripts()) | 435 if (!isWaitingForScripts()) |
| 427 resumeParsingAfterScriptExecution(); | 436 resumeParsingAfterScriptExecution(); |
| 428 } | 437 } |
| 429 | 438 |
| 430 } | 439 } |
| OLD | NEW |