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

Side by Side Diff: Source/core/html/imports/HTMLImportChild.cpp

Issue 303643005: Straighten up HTML Imports load vs. share loader logic. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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) 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 23 matching lines...) Expand all
34 #include "core/dom/Document.h" 34 #include "core/dom/Document.h"
35 #include "core/dom/custom/CustomElement.h" 35 #include "core/dom/custom/CustomElement.h"
36 #include "core/dom/custom/CustomElementMicrotaskDispatcher.h" 36 #include "core/dom/custom/CustomElementMicrotaskDispatcher.h"
37 #include "core/dom/custom/CustomElementMicrotaskImportStep.h" 37 #include "core/dom/custom/CustomElementMicrotaskImportStep.h"
38 #include "core/html/imports/HTMLImportChildClient.h" 38 #include "core/html/imports/HTMLImportChildClient.h"
39 #include "core/html/imports/HTMLImportLoader.h" 39 #include "core/html/imports/HTMLImportLoader.h"
40 #include "core/html/imports/HTMLImportsController.h" 40 #include "core/html/imports/HTMLImportsController.h"
41 41
42 namespace WebCore { 42 namespace WebCore {
43 43
44 HTMLImportChild::HTMLImportChild(const KURL& url, SyncMode sync) 44 HTMLImportChild::HTMLImportChild(const KURL& url, HTMLImportLoader* loader, Sync Mode sync)
45 : HTMLImport(sync) 45 : HTMLImport(sync)
46 , m_url(url) 46 , m_url(url)
47 , m_weakFactory(this) 47 , m_weakFactory(this)
48 , m_loader(0) 48 , m_loader(loader)
49 , m_client(0) 49 , m_client(0)
50 { 50 {
51 } 51 }
52 52
53 HTMLImportChild::~HTMLImportChild() 53 HTMLImportChild::~HTMLImportChild()
54 { 54 {
55 // importDestroyed() should be called before the destruction. 55 // importDestroyed() should be called before the destruction.
56 ASSERT(!m_loader); 56 ASSERT(!m_loader);
57 57
58 if (m_client) 58 if (m_client)
59 m_client->importChildWasDestroyed(this); 59 m_client->importChildWasDestroyed(this);
60 } 60 }
61 61
62 void HTMLImportChild::wasAlreadyLoaded() 62 void HTMLImportChild::didShareLoader()
63 { 63 {
64 ASSERT(!m_loader); 64 createCustomElementMicrotaskStepIfNeeded();
65 ASSERT(m_client);
66 shareLoader();
67 stateWillChange(); 65 stateWillChange();
68 } 66 }
69 67
70 void HTMLImportChild::startLoading(const ResourcePtr<RawResource>& resource) 68 void HTMLImportChild::didStartLoading()
71 { 69 {
72 ASSERT(!m_loader);
73
74 if (m_loader)
75 return;
76
77 m_loader = toHTMLImportsController(root())->createLoader();
78 m_loader->addImport(this);
79 m_loader->startLoading(resource);
80
81 createCustomElementMicrotaskStepIfNeeded(); 70 createCustomElementMicrotaskStepIfNeeded();
82 } 71 }
83 72
84 void HTMLImportChild::didFinish() 73 void HTMLImportChild::didFinish()
85 { 74 {
86 if (m_client) 75 if (m_client)
87 m_client->didFinish(); 76 m_client->didFinish();
88 } 77 }
89 78
90 void HTMLImportChild::didFinishLoading() 79 void HTMLImportChild::didFinishLoading()
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 } 149 }
161 150
162 if (!isDone() && !formsCycle()) { 151 if (!isDone() && !formsCycle()) {
163 m_customElementMicrotaskStep = CustomElement::didCreateImport(this)->wea kPtr(); 152 m_customElementMicrotaskStep = CustomElement::didCreateImport(this)->wea kPtr();
164 } 153 }
165 154
166 for (HTMLImport* child = firstChild(); child; child = child->next()) 155 for (HTMLImport* child = firstChild(); child; child = child->next())
167 toHTMLImportChild(child)->createCustomElementMicrotaskStepIfNeeded(); 156 toHTMLImportChild(child)->createCustomElementMicrotaskStepIfNeeded();
168 } 157 }
169 158
170 void HTMLImportChild::shareLoader()
171 {
172 ASSERT(!m_loader);
173
174 if (HTMLImportChild* childToShareWith = toHTMLImportsController(root())->fin dLinkFor(m_url, this)) {
175 m_loader = childToShareWith->m_loader;
176 m_loader->addImport(this);
177 }
178
179 createCustomElementMicrotaskStepIfNeeded();
180 }
181
182 bool HTMLImportChild::isDone() const 159 bool HTMLImportChild::isDone() const
183 { 160 {
184 return m_loader && m_loader->isDone() && !m_loader->microtaskQueue()->needsP rocessOrStop() && !m_customElementMicrotaskStep; 161 return m_loader && m_loader->isDone() && !m_loader->microtaskQueue()->needsP rocessOrStop() && !m_customElementMicrotaskStep;
185 } 162 }
186 163
187 bool HTMLImportChild::loaderHasError() const 164 bool HTMLImportChild::loaderHasError() const
188 { 165 {
189 return m_loader && m_loader->hasError(); 166 return m_loader && m_loader->hasError();
190 } 167 }
191 168
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 fprintf(stderr, " loader=%p first=%d, step=%p sync=%s url=%s", 211 fprintf(stderr, " loader=%p first=%d, step=%p sync=%s url=%s",
235 m_loader, 212 m_loader,
236 isFirst, 213 isFirst,
237 m_customElementMicrotaskStep.get(), 214 m_customElementMicrotaskStep.get(),
238 isSync() ? "Y" : "N", 215 isSync() ? "Y" : "N",
239 url().string().utf8().data()); 216 url().string().utf8().data());
240 } 217 }
241 #endif 218 #endif
242 219
243 } // namespace WebCore 220 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/html/imports/HTMLImportChild.h ('k') | Source/core/html/imports/HTMLImportsController.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698