DescriptionRefactoring: Simplify DocumentWriter by reorganizing its lifetime.
This change simplifies DocumentWriter by
1. Letting its lifetime match to the actual "writing" process:
It is now created when actual data is arrived to be parsed,
and is discarded once all the data is loaded.
Then we no longer neeed DocumentWriter::m_state.
2. Moving most of its Frame dependency to DocumentLoader.
DocumentWriter::begin() is factored to DocumentLoader::createWriter(), and
DocumentWriter::replaceDocument is factored to DocumentLoader::replaceDocument()
and DocumentWriter::appendReplacingData(). DocumentWriter::m_frame is now
able to be replaced by DocumentWriter::m_documnet. This narrows the dependency surface.
(Also it makes more sense because it is "document" writer after all.)
3. Making TextResourceDecoderBuilder an immutable object by stripping
its setters out.
Note that (2) and (3) become possible because of (1).
Key observations here are that
- DocumentWriter had longer lifetime just because it stored mimetype and encoding.
However, these can be computed on the fly in DocumentLoader when it starts
actual writing. See ensureWriter() callsites.
- Some of extra states in DocumentWriter was needed because it had to "reset" itself.
Once its lifetime aligns the single loading/parsing, we no longer need such reset thing.
- The main reason of dependency from DocumentWriter to Frame was DocumentWriter::begin(),
which did connect the fresh, to-be-built Document and given Frame. This should be part
of the DocumentWriter creation process and doesn't need to be in DocumentWriter itself.
This change factors such setup into DocumentLoader::createWriter factory method.
BUG=none
TEST=none
R=abarth@chromium.org
Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=153115
Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=153125
Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=153216
Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=153318
Patch Set 1 #Patch Set 2 : Fixed a test failure. #Patch Set 3 : Fixed a build breakage #
Total comments: 6
Patch Set 4 : Fixed another failure.w #Patch Set 5 : Fixed yet anotehr test failure. #Patch Set 6 : Fixed a test on content_browsertests, added a test for covering base url. #Patch Set 7 : Re-landing after fixing ASAN failure on set-parent-src-synchronously.xhtml. #Messages
Total messages: 13 (0 generated)
|