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

Side by Side Diff: Source/WebCore/html/parser/HTMLResourcePreloader.h

Issue 13945017: External Stylesheets preloaded according to their media attribute (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 8 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
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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 15 matching lines...) Expand all
26 #ifndef HTMLResourcePreloader_h 26 #ifndef HTMLResourcePreloader_h
27 #define HTMLResourcePreloader_h 27 #define HTMLResourcePreloader_h
28 28
29 #include "CachedResource.h" 29 #include "CachedResource.h"
30 #include "CachedResourceRequest.h" 30 #include "CachedResourceRequest.h"
31 31
32 namespace WebCore { 32 namespace WebCore {
33 33
34 class PreloadRequest { 34 class PreloadRequest {
35 public: 35 public:
36 static PassOwnPtr<PreloadRequest> create(const String& initiator, const Stri ng& resourceURL, const KURL& baseURL, CachedResource::Type resourceType, const S tring& mediaAttribute)
37 {
38 return adoptPtr(new PreloadRequest(initiator, resourceURL, baseURL, reso urceType, mediaAttribute));
39 }
40
36 static PassOwnPtr<PreloadRequest> create(const String& initiator, const Stri ng& resourceURL, const KURL& baseURL, CachedResource::Type resourceType) 41 static PassOwnPtr<PreloadRequest> create(const String& initiator, const Stri ng& resourceURL, const KURL& baseURL, CachedResource::Type resourceType)
37 { 42 {
38 return adoptPtr(new PreloadRequest(initiator, resourceURL, baseURL, reso urceType)); 43 return adoptPtr(new PreloadRequest(initiator, resourceURL, baseURL, reso urceType, ""));
39 } 44 }
40 45
41 bool isSafeToSendToAnotherThread() const; 46 bool isSafeToSendToAnotherThread() const;
42 47
43 CachedResourceRequest resourceRequest(Document*); 48 CachedResourceRequest resourceRequest(Document*);
44 49
45 const String& charset() const { return m_charset; } 50 const String& charset() const { return m_charset; }
51 const String& media() const { return m_mediaAttribute; }
46 void setCharset(const String& charset) { m_charset = charset.isolatedCopy(); } 52 void setCharset(const String& charset) { m_charset = charset.isolatedCopy(); }
47 void setCrossOriginModeAllowsCookies(bool allowsCookies) { m_crossOriginMode AllowsCookies = allowsCookies; } 53 void setCrossOriginModeAllowsCookies(bool allowsCookies) { m_crossOriginMode AllowsCookies = allowsCookies; }
48 CachedResource::Type resourceType() const { return m_resourceType; } 54 CachedResource::Type resourceType() const { return m_resourceType; }
49 55
50 private: 56 private:
51 PreloadRequest(const String& initiator, const String& resourceURL, const KUR L& baseURL, CachedResource::Type resourceType) 57 PreloadRequest(const String& initiator, const String& resourceURL, const KUR L& baseURL, CachedResource::Type resourceType, const String& mediaAttribute)
52 : m_initiator(initiator) 58 : m_initiator(initiator)
53 , m_resourceURL(resourceURL.isolatedCopy()) 59 , m_resourceURL(resourceURL.isolatedCopy())
54 , m_baseURL(baseURL.copy()) 60 , m_baseURL(baseURL.copy())
55 , m_resourceType(resourceType) 61 , m_resourceType(resourceType)
62 , m_mediaAttribute(mediaAttribute.isolatedCopy())
56 , m_crossOriginModeAllowsCookies(false) 63 , m_crossOriginModeAllowsCookies(false)
57 { 64 {
58 } 65 }
59 66
60 KURL completeURL(Document*); 67 KURL completeURL(Document*);
61 68
62 String m_initiator; 69 String m_initiator;
63 String m_resourceURL; 70 String m_resourceURL;
64 KURL m_baseURL; 71 KURL m_baseURL;
65 String m_charset; 72 String m_charset;
66 CachedResource::Type m_resourceType; 73 CachedResource::Type m_resourceType;
74 String m_mediaAttribute;
67 bool m_crossOriginModeAllowsCookies; 75 bool m_crossOriginModeAllowsCookies;
68 }; 76 };
69 77
70 typedef Vector<OwnPtr<PreloadRequest> > PreloadRequestStream; 78 typedef Vector<OwnPtr<PreloadRequest> > PreloadRequestStream;
71 79
72 class HTMLResourcePreloader { 80 class HTMLResourcePreloader {
73 WTF_MAKE_NONCOPYABLE(HTMLResourcePreloader); WTF_MAKE_FAST_ALLOCATED; 81 WTF_MAKE_NONCOPYABLE(HTMLResourcePreloader); WTF_MAKE_FAST_ALLOCATED;
74 public: 82 public:
75 explicit HTMLResourcePreloader(Document* document) 83 explicit HTMLResourcePreloader(Document* document)
76 : m_document(document) 84 : m_document(document)
77 , m_weakFactory(this) 85 , m_weakFactory(this)
78 { 86 {
79 } 87 }
80 88
81 void takeAndPreload(PreloadRequestStream&); 89 void takeAndPreload(PreloadRequestStream&);
82 void preload(PassOwnPtr<PreloadRequest>); 90 void preload(PassOwnPtr<PreloadRequest>);
83 91
84 WeakPtr<HTMLResourcePreloader> createWeakPtr() { return m_weakFactory.create WeakPtr(); } 92 WeakPtr<HTMLResourcePreloader> createWeakPtr() { return m_weakFactory.create WeakPtr(); }
85 93
86 private: 94 private:
87 Document* m_document; 95 Document* m_document;
88 WeakPtrFactory<HTMLResourcePreloader> m_weakFactory; 96 WeakPtrFactory<HTMLResourcePreloader> m_weakFactory;
89 }; 97 };
90 98
91 } 99 }
92 100
93 #endif 101 #endif
OLDNEW
« no previous file with comments | « Source/WebCore/html/parser/HTMLPreloadScanner.cpp ('k') | Source/WebCore/html/parser/HTMLResourcePreloader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698