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

Side by Side Diff: Source/core/loader/DocumentWriter.h

Issue 17640007: Refactoring: Simplify DocumentWriter by reorganizing its lifetime. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed a build breakage Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010. Adam Barth. All rights reserved. 2 * Copyright (C) 2010. Adam Barth. 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 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 26 matching lines...) Expand all
37 class Document; 37 class Document;
38 class DocumentParser; 38 class DocumentParser;
39 class Frame; 39 class Frame;
40 class KURL; 40 class KURL;
41 class SecurityOrigin; 41 class SecurityOrigin;
42 class TextResourceDecoder; 42 class TextResourceDecoder;
43 43
44 class DocumentWriter { 44 class DocumentWriter {
45 WTF_MAKE_NONCOPYABLE(DocumentWriter); 45 WTF_MAKE_NONCOPYABLE(DocumentWriter);
46 public: 46 public:
47 explicit DocumentWriter(Frame*); 47 static PassOwnPtr<DocumentWriter> create(Document*, const String& mimeType = "", const String& encoding = "", bool encodingUserChoosen = false);
48
49 ~DocumentWriter();
50
51 void end();
48 52
49 // This is only called by ScriptController::executeScriptIfJavaScriptURL 53 // This is only called by ScriptController::executeScriptIfJavaScriptURL
50 // and always contains the result of evaluating a javascript: url. 54 // and always contains the result of evaluating a javascript: url.
51 void replaceDocument(const String&, Document* ownerDocument); 55 void replaceDocument(const String&, Document* ownerDocument);
52 56
53 void begin();
54 void begin(const KURL&, bool dispatchWindowObjectAvailable = true, Document* ownerDocument = 0);
55 void addData(const char* bytes, size_t length); 57 void addData(const char* bytes, size_t length);
56 void end();
57 58
58 void setFrame(Frame* frame) { m_frame = frame; }
59
60 const String& mimeType() const { return m_decoderBuilder.mimeType(); } 59 const String& mimeType() const { return m_decoderBuilder.mimeType(); }
61 void setMIMEType(const String& type) { m_decoderBuilder.setMIMEType(type); }
62 void setEncoding(const String& encoding, bool userChosen) { m_decoderBuilder .setEncoding(encoding, userChosen); }
63 60
64 // Exposed for DocumentParser::appendBytes. 61 // Exposed for DocumentParser::appendBytes.
65 void reportDataReceived(); 62 void reportDataReceived();
63 // Exposed for DocumentLoader::replaceDocument.
64 void appendReplacingData(const String&);
66 65
67 void setDocumentWasLoadedAsPartOfNavigation(); 66 void setDocumentWasLoadedAsPartOfNavigation();
68 67
69 private: 68 private:
69 DocumentWriter(Document*, const String& mimeType, const String& encoding, bo ol encodingUserChoosen);
70
70 PassRefPtr<Document> createDocument(const KURL&); 71 PassRefPtr<Document> createDocument(const KURL&);
71 void clear();
72 72
73 Frame* m_frame; 73 Document* m_document;
74
75 bool m_hasReceivedSomeData; 74 bool m_hasReceivedSomeData;
76 TextResourceDecoderBuilder m_decoderBuilder; 75 TextResourceDecoderBuilder m_decoderBuilder;
77 76
78 RefPtr<TextResourceDecoder> m_decoder; 77 RefPtr<TextResourceDecoder> m_decoder;
79 RefPtr<DocumentParser> m_parser; 78 RefPtr<DocumentParser> m_parser;
80
81 enum WriterState {
82 NotStartedWritingState,
83 StartedWritingState,
84 FinishedWritingState,
85 };
86 WriterState m_state;
87 }; 79 };
88 80
89 } // namespace WebCore 81 } // namespace WebCore
90 82
91 #endif // DocumentWriter_h 83 #endif // DocumentWriter_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698