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

Unified Diff: third_party/WebKit/Source/core/loader/LinkPreloadResourceClients.h

Issue 1586563014: Add <link rel=preload> onload support for scripts and styles (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: oilpan build fixes and review comments Created 4 years, 11 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
Index: third_party/WebKit/Source/core/loader/LinkPreloadResourceClients.h
diff --git a/third_party/WebKit/Source/core/loader/LinkPreloadResourceClients.h b/third_party/WebKit/Source/core/loader/LinkPreloadResourceClients.h
new file mode 100644
index 0000000000000000000000000000000000000000..370763633542e714b0532ff3bfcd35b2d11230c0
--- /dev/null
+++ b/third_party/WebKit/Source/core/loader/LinkPreloadResourceClients.h
@@ -0,0 +1,103 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
sof 2016/01/20 13:22:41 off by one :)
Yoav Weiss 2016/01/20 13:28:05 thinking ahead :)
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LinkPreloadResourceClients_h
+#define LinkPreloadResourceClients_h
+
+#include "core/fetch/CSSStyleSheetResource.h"
+#include "core/fetch/FontResource.h"
+#include "core/fetch/ImageResourceClient.h"
+#include "core/fetch/ResourceOwner.h"
+#include "core/fetch/ScriptResource.h"
+#include "core/fetch/StyleSheetResourceClient.h"
+
+namespace blink {
+
+class LinkLoader;
+
+class LinkPreloadResourceClient : public NoBaseWillBeGarbageCollectedFinalized<LinkPreloadResourceClient> {
+public:
+ virtual ~LinkPreloadResourceClient() { }
+
+ void triggerEvents(const Resource*) const;
sof 2016/01/20 13:16:15 (odd-looking const method)
Yoav Weiss 2016/01/20 13:28:05 removed the const part as it's not necessary.
+
+ DEFINE_INLINE_VIRTUAL_TRACE()
+ {
+ visitor->trace(m_loader);
+ }
+
+protected:
+ LinkPreloadResourceClient(LinkLoader* loader)
+ : m_loader(loader)
+ {
+ ASSERT(loader);
+ }
+
+private:
+ RawPtrWillBeMember<LinkLoader> m_loader;
+};
+
+class LinkPreloadScriptResourceClient: public ResourceOwner<ScriptResource, ScriptResourceClient>, public LinkPreloadResourceClient {
sof 2016/01/20 13:16:15 LinkPreloadResourceClient needs to be the leftmost
Yoav Weiss 2016/01/20 13:28:05 switched order
+ WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(LinkPreloadScriptResourceClient);
+public:
+ static PassOwnPtrWillBeRawPtr<LinkPreloadScriptResourceClient> create(LinkLoader* loader, ScriptResource* resource)
+ {
+ return adoptPtrWillBeNoop(new LinkPreloadScriptResourceClient(loader, resource));
+ }
+
+ virtual String debugName() const { return "LinkPreloadScript"; }
+
+ void notifyFinished(Resource* resource) override
+ {
+ ASSERT(this->resource() == resource);
+ triggerEvents(resource);
+ }
+
+ DEFINE_INLINE_VIRTUAL_TRACE()
+ {
+ LinkPreloadResourceClient::trace(visitor);
+ ResourceOwner<ScriptResource, ScriptResourceClient>::trace(visitor);
+ }
+
+private:
+ LinkPreloadScriptResourceClient(LinkLoader* loader, ScriptResource* resource)
+ : LinkPreloadResourceClient(loader)
+ {
+ setResource(resource);
+ }
+};
+
+class LinkPreloadStyleResourceClient: public ResourceOwner<CSSStyleSheetResource, StyleSheetResourceClient>, public LinkPreloadResourceClient {
sof 2016/01/20 13:16:15 ditto
Yoav Weiss 2016/01/20 13:28:05 switched order
+ WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(LinkPreloadStyleResourceClient);
+public:
+ static PassOwnPtrWillBeRawPtr<LinkPreloadStyleResourceClient> create(LinkLoader* loader, CSSStyleSheetResource* resource)
+ {
+ return adoptPtrWillBeNoop(new LinkPreloadStyleResourceClient(loader, resource));
+ }
+
+ virtual String debugName() const { return "LinkPreloadStyle"; }
+
+ void setCSSStyleSheet(const String&, const KURL&, const String&, const CSSStyleSheetResource* resource) override
+ {
+ ASSERT(this->resource() == resource);
+ triggerEvents(static_cast<const Resource*>(resource));
+ }
+
+ DEFINE_INLINE_VIRTUAL_TRACE()
+ {
+ LinkPreloadResourceClient::trace(visitor);
+ ResourceOwner<CSSStyleSheetResource, StyleSheetResourceClient>::trace(visitor);
+ }
+
+private:
+ LinkPreloadStyleResourceClient(LinkLoader* loader, CSSStyleSheetResource* resource)
+ : LinkPreloadResourceClient(loader)
+ {
+ setResource(resource);
+ }
+};
+
+}
+
+#endif // LinkPreloadResourceClients_h

Powered by Google App Engine
This is Rietveld 408576698