OLD | NEW |
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 22 matching lines...) Expand all Loading... |
33 | 33 |
34 #include "core/html/LinkResource.h" | 34 #include "core/html/LinkResource.h" |
35 #include "core/loader/cache/CachedResourceClient.h" | 35 #include "core/loader/cache/CachedResourceClient.h" |
36 #include "core/loader/cache/CachedResourceHandle.h" | 36 #include "core/loader/cache/CachedResourceHandle.h" |
37 #include "wtf/FastAllocBase.h" | 37 #include "wtf/FastAllocBase.h" |
38 #include "wtf/PassOwnPtr.h" | 38 #include "wtf/PassOwnPtr.h" |
39 #include "wtf/Vector.h" | 39 #include "wtf/Vector.h" |
40 | 40 |
41 namespace WebCore { | 41 namespace WebCore { |
42 | 42 |
43 class DocumentFragment; | 43 class HTMLImportLoader; |
44 class HTMLImportsController; | 44 class HTMLImportsController; |
45 | 45 |
46 // | 46 // |
47 // A LinkResource subclasss used for @rel=import. | 47 // A LinkResource subclasss used for @rel=import. |
48 // | 48 // |
49 class LinkImport : public LinkResource, CachedResourceClient { | 49 class LinkImport : public LinkResource { |
50 WTF_MAKE_FAST_ALLOCATED; | 50 WTF_MAKE_FAST_ALLOCATED; |
51 public: | 51 public: |
52 enum State { | |
53 StatePreparing, | |
54 StateStarted, | |
55 StateError, | |
56 StateReady | |
57 }; | |
58 | 52 |
59 static PassRefPtr<LinkImport> create(HTMLLinkElement* owner); | 53 static PassRefPtr<LinkImport> create(HTMLLinkElement* owner); |
60 | 54 |
61 explicit LinkImport(HTMLLinkElement* owner); | 55 explicit LinkImport(HTMLLinkElement* owner); |
62 virtual ~LinkImport(); | 56 virtual ~LinkImport(); |
63 | 57 |
64 // LinkResource | 58 // LinkResource |
65 virtual void process() OVERRIDE; | 59 virtual void process() OVERRIDE; |
66 virtual Type type() const OVERRIDE { return Import; } | 60 virtual Type type() const OVERRIDE { return Import; } |
67 virtual void ownerRemoved() OVERRIDE; | 61 virtual void ownerRemoved() OVERRIDE; |
68 | 62 |
69 Document* importedDocument() const; | 63 Document* importedDocument() const; |
| 64 |
| 65 private: |
| 66 RefPtr<HTMLImportLoader> m_loader; |
| 67 }; |
| 68 |
| 69 |
| 70 class HTMLImportLoader : public RefCounted<HTMLImportLoader>, public CachedResou
rceClient { |
| 71 public: |
| 72 enum State { |
| 73 StateLoading, |
| 74 StateError, |
| 75 StateReady |
| 76 }; |
| 77 |
| 78 static PassRefPtr<HTMLImportLoader> create(HTMLImportsController*, const KUR
L&, const CachedResourceHandle<CachedScript>&); |
| 79 virtual ~HTMLImportLoader(); |
| 80 |
| 81 Document* importedDocument() const; |
70 const KURL& url() const { return m_url; } | 82 const KURL& url() const { return m_url; } |
| 83 |
71 void importDestroyed(); | 84 void importDestroyed(); |
72 bool isDone() const { return m_state == StateReady || m_state == StateError;
} | 85 bool isDone() const { return m_state == StateReady || m_state == StateError;
} |
73 | 86 |
74 private: | 87 private: |
75 State startRequest(); | 88 HTMLImportLoader(HTMLImportsController*, const KURL&, const CachedResourceHa
ndle<CachedScript>&); |
76 State finish(); | |
77 void setState(State); | |
78 | 89 |
79 // CachedResourceClient | 90 // CachedResourceClient |
80 virtual void notifyFinished(CachedResource*) OVERRIDE; | 91 virtual void notifyFinished(CachedResource*) OVERRIDE; |
81 | 92 |
| 93 State finish(); |
| 94 void setState(State); |
| 95 |
82 HTMLImportsController* m_controller; | 96 HTMLImportsController* m_controller; |
83 LinkImport* m_ofSameLocation; | 97 State m_state; |
84 KURL m_url; | 98 KURL m_url; |
85 State m_state; | |
86 CachedResourceHandle<CachedScript> m_resource; | 99 CachedResourceHandle<CachedScript> m_resource; |
87 RefPtr<Document> m_importedDocument; | 100 RefPtr<Document> m_importedDocument; |
88 }; | 101 }; |
89 | 102 |
90 | 103 |
91 class HTMLImportsController { | 104 class HTMLImportsController { |
92 WTF_MAKE_FAST_ALLOCATED; | 105 WTF_MAKE_FAST_ALLOCATED; |
93 public: | 106 public: |
94 static PassOwnPtr<HTMLImportsController> create(Document*); | 107 static PassOwnPtr<HTMLImportsController> create(Document*); |
95 | 108 |
96 explicit HTMLImportsController(Document*); | 109 explicit HTMLImportsController(Document*); |
97 virtual ~HTMLImportsController(); | 110 virtual ~HTMLImportsController(); |
98 | 111 |
99 void addImport(PassRefPtr<LinkImport>); | 112 void addImport(PassRefPtr<HTMLImportLoader>); |
100 void showSecurityErrorMessage(const String&); | 113 void showSecurityErrorMessage(const String&); |
101 PassRefPtr<LinkImport> findLinkFor(const KURL&) const; | 114 PassRefPtr<HTMLImportLoader> findLinkFor(const KURL&) const; |
102 SecurityOrigin* securityOrigin() const; | 115 SecurityOrigin* securityOrigin() const; |
103 bool haveLoaded() const; | 116 bool haveLoaded() const; |
104 void didLoad(); | 117 void didLoad(); |
105 | 118 |
106 private: | 119 private: |
107 | |
108 Document* m_master; | 120 Document* m_master; |
109 | 121 |
110 // List of import which has been loaded or being loaded. | 122 // List of import which has been loaded or being loaded. |
111 typedef Vector<RefPtr<LinkImport> > ImportList; | 123 typedef Vector<RefPtr<HTMLImportLoader> > ImportList; |
112 ImportList m_imports; | 124 ImportList m_imports; |
113 }; | 125 }; |
114 | 126 |
115 } // namespace WebCore | 127 } // namespace WebCore |
116 | 128 |
117 #endif // HTMLImportsController_h | 129 #endif // HTMLImportsController_h |
OLD | NEW |