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

Side by Side Diff: Source/core/html/imports/HTMLImportLoader.h

Issue 211663002: Refactoring: Get rid of HTMLImportLoaerClient (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed typo and bad grammar Created 6 years, 9 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) 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 21 matching lines...) Expand all
32 #define HTMLImportLoader_h 32 #define HTMLImportLoader_h
33 33
34 #include "core/fetch/RawResource.h" 34 #include "core/fetch/RawResource.h"
35 #include "core/fetch/ResourceOwner.h" 35 #include "core/fetch/ResourceOwner.h"
36 #include "wtf/Vector.h" 36 #include "wtf/Vector.h"
37 37
38 namespace WebCore { 38 namespace WebCore {
39 39
40 class Document; 40 class Document;
41 class DocumentWriter; 41 class DocumentWriter;
42 class HTMLImport; 42 class HTMLImportChild;
43 class HTMLImportLoaderClient;
44 43
45 // 44 //
46 // Owning imported Document lifetime. It also implements ResourceClient through ResourceOwner 45 // Owning imported Document lifetime. It also implements ResourceClient through ResourceOwner
47 // to feed fetched bytes to the DocumentWriter of the imported document. 46 // to feed fetched bytes to the DocumentWriter of the imported document.
48 // HTMLImportLoader is owned by and shared between HTMLImportChild. 47 // HTMLImportLoader is owned by and shared between HTMLImportChild.
49 // 48 //
50 // 49 //
51 class HTMLImportLoader FINAL : public RefCounted<HTMLImportLoader>, public Resou rceOwner<RawResource> { 50 class HTMLImportLoader FINAL : public RefCounted<HTMLImportLoader>, public Resou rceOwner<RawResource> {
52 public: 51 public:
53 enum State { 52 enum State {
54 StateLoading, 53 StateLoading,
55 StateWritten, 54 StateWritten,
56 StateParsed, 55 StateParsed,
57 StateLoaded, 56 StateLoaded,
58 StateError 57 StateError
59 }; 58 };
60 59
61 static PassRefPtr<HTMLImportLoader> create(HTMLImport* import) 60 static PassRefPtr<HTMLImportLoader> create()
62 { 61 {
63 return adoptRef(new HTMLImportLoader(import)); 62 return adoptRef(new HTMLImportLoader());
64 } 63 }
65 64
66 virtual ~HTMLImportLoader(); 65 virtual ~HTMLImportLoader();
67 66
68 Document* document() const { return m_importedDocument.get(); } 67 Document* document() const { return m_importedDocument.get(); }
69 Document* importedDocument() const; 68 Document* importedDocument() const;
70 void addClient(HTMLImportLoaderClient*); 69 void addImport(HTMLImportChild*);
71 void removeClient(HTMLImportLoaderClient*); 70 void removeImport(HTMLImportChild*);
72 71
73 bool isDone() const { return m_state == StateLoaded || m_state == StateError ; } 72 bool isDone() const { return m_state == StateLoaded || m_state == StateError ; }
74 bool hasError() const { return m_state == StateError; } 73 bool hasError() const { return m_state == StateError; }
75 74
76 void startLoading(const ResourcePtr<RawResource>&); 75 void startLoading(const ResourcePtr<RawResource>&);
77 void didFinishParsing(); 76 void didFinishParsing();
78 void didRemoveAllPendingStylesheet(); 77 void didRemoveAllPendingStylesheet();
79 bool isOwnedBy(const HTMLImport* import) const { return m_import == import; } 78 bool isOwnedBy(const HTMLImportChild* import) const { return m_imports[0] == import; }
80 79
81 private: 80 private:
82 HTMLImportLoader(HTMLImport*); 81 HTMLImportLoader();
83 82
84 // RawResourceClient 83 // RawResourceClient
85 virtual void responseReceived(Resource*, const ResourceResponse&) OVERRIDE; 84 virtual void responseReceived(Resource*, const ResourceResponse&) OVERRIDE;
86 virtual void dataReceived(Resource*, const char* data, int length) OVERRIDE; 85 virtual void dataReceived(Resource*, const char* data, int length) OVERRIDE;
87 virtual void notifyFinished(Resource*) OVERRIDE; 86 virtual void notifyFinished(Resource*) OVERRIDE;
88 87
89 State startWritingAndParsing(const ResourceResponse&); 88 State startWritingAndParsing(const ResourceResponse&);
90 State finishWriting(); 89 State finishWriting();
91 State finishParsing(); 90 State finishParsing();
92 State finishLoading(); 91 State finishLoading();
93 92
94 void setState(State); 93 void setState(State);
95 void didFinishLoading(); 94 void didFinishLoading();
96 bool hasPendingResources() const; 95 bool hasPendingResources() const;
97 96
98 HTMLImport* m_import; 97 Vector<HTMLImportChild*> m_imports;
99 Vector<HTMLImportLoaderClient*> m_clients;
100 State m_state; 98 State m_state;
101 RefPtr<Document> m_importedDocument; 99 RefPtr<Document> m_importedDocument;
102 RefPtr<DocumentWriter> m_writer; 100 RefPtr<DocumentWriter> m_writer;
103 }; 101 };
104 102
105 } // namespace WebCore 103 } // namespace WebCore
106 104
107 #endif // HTMLImportLoader_h 105 #endif // HTMLImportLoader_h
OLDNEW
« no previous file with comments | « Source/core/html/imports/HTMLImportChild.cpp ('k') | Source/core/html/imports/HTMLImportLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698