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

Unified Diff: Source/core/html/LinkImport.cpp

Issue 22573005: [HTML Imports] Implement "load" and "error" events. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: For landing Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/html/LinkImport.h ('k') | Source/core/html/LinkResource.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/LinkImport.cpp
diff --git a/Source/core/html/LinkImport.cpp b/Source/core/html/LinkImport.cpp
index 753751ee5dbdd0ba02b56b7268cb8e94dcd616e5..31703ac85ef4d7c946b742ef183752ac05a5dd72 100644
--- a/Source/core/html/LinkImport.cpp
+++ b/Source/core/html/LinkImport.cpp
@@ -36,7 +36,6 @@
#include "core/html/HTMLImportsController.h"
#include "core/html/HTMLLinkElement.h"
#include "core/loader/CrossOriginAccessControl.h"
-#include "core/loader/cache/ResourceFetcher.h"
namespace WebCore {
@@ -52,6 +51,7 @@ LinkImport::LinkImport(HTMLLinkElement* owner)
LinkImport::~LinkImport()
{
+ clear();
}
Document* LinkImport::importedDocument() const
@@ -67,39 +67,56 @@ void LinkImport::process()
return;
if (!m_owner)
return;
-
if (!m_owner->document()->frame() && !m_owner->document()->import())
return;
- LinkRequestBuilder builder(m_owner);
- if (!builder.isValid())
- return;
-
if (!m_owner->document()->import()) {
ASSERT(m_owner->document()->frame()); // The document should be the master.
HTMLImportsController::provideTo(m_owner->document());
}
+ LinkRequestBuilder builder(m_owner);
+ if (!builder.isValid()) {
+ didFinish();
+ return;
+ }
+
HTMLImport* parent = m_owner->document()->import();
HTMLImportsController* controller = parent->controller();
- if (RefPtr<HTMLImportLoader> found = controller->findLinkFor(builder.url())) {
- m_loader = found;
+ m_loader = controller->createLoader(parent, builder.build(true));
+ if (!m_loader) {
+ didFinish();
return;
}
- FetchRequest request = builder.build(true);
- request.setPotentiallyCrossOriginEnabled(controller->securityOrigin(), DoNotAllowStoredCredentials);
- ResourcePtr<CachedRawResource> resource = m_owner->document()->fetcher()->requestImport(request);
- if (!resource)
- return;
+ m_loader->addClient(this);
+}
- m_loader = controller->createLoader(parent, builder.url(), resource);
+void LinkImport::clear()
+{
+ m_owner = 0;
+
+ if (m_loader) {
+ m_loader->removeClient(this);
+ m_loader.clear();
+ }
}
void LinkImport::ownerRemoved()
{
- m_owner = 0;
- m_loader.clear();
+ clear();
+}
+
+void LinkImport::didFinish()
+{
+ if (!m_owner)
+ return;
+ m_owner->scheduleEvent();
+}
+
+bool LinkImport::hasLoaded() const
+{
+ return m_loader && m_loader->isLoaded();
}
} // namespace WebCore
« no previous file with comments | « Source/core/html/LinkImport.h ('k') | Source/core/html/LinkResource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698