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 | 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 14 matching lines...) Expand all Loading... |
25 | 25 |
26 #include "config.h" | 26 #include "config.h" |
27 #include "core/html/parser/HTMLResourcePreloader.h" | 27 #include "core/html/parser/HTMLResourcePreloader.h" |
28 | 28 |
29 #include "core/dom/Document.h" | 29 #include "core/dom/Document.h" |
30 #include "core/fetch/FetchInitiatorInfo.h" | 30 #include "core/fetch/FetchInitiatorInfo.h" |
31 #include "core/fetch/ResourceFetcher.h" | 31 #include "core/fetch/ResourceFetcher.h" |
32 #include "core/html/imports/HTMLImport.h" | 32 #include "core/html/imports/HTMLImport.h" |
33 #include "core/rendering/RenderObject.h" | 33 #include "core/rendering/RenderObject.h" |
34 #include "public/platform/Platform.h" | 34 #include "public/platform/Platform.h" |
| 35 #include "public/platform/WebURLRequest.h" |
35 | 36 |
36 namespace blink { | 37 namespace blink { |
37 | 38 |
38 bool PreloadRequest::isSafeToSendToAnotherThread() const | 39 bool PreloadRequest::isSafeToSendToAnotherThread() const |
39 { | 40 { |
40 return m_initiatorName.isSafeToSendToAnotherThread() | 41 return m_initiatorName.isSafeToSendToAnotherThread() |
41 && m_charset.isSafeToSendToAnotherThread() | 42 && m_charset.isSafeToSendToAnotherThread() |
42 && m_resourceURL.isSafeToSendToAnotherThread() | 43 && m_resourceURL.isSafeToSendToAnotherThread() |
43 && m_baseURL.isSafeToSendToAnotherThread(); | 44 && m_baseURL.isSafeToSendToAnotherThread(); |
44 } | 45 } |
45 | 46 |
46 KURL PreloadRequest::completeURL(Document* document) | 47 KURL PreloadRequest::completeURL(Document* document) |
47 { | 48 { |
48 return document->completeURLWithOverride(m_resourceURL, m_baseURL.isEmpty()
? document->url() : m_baseURL); | 49 return document->completeURLWithOverride(m_resourceURL, m_baseURL.isEmpty()
? document->url() : m_baseURL); |
49 } | 50 } |
50 | 51 |
51 FetchRequest PreloadRequest::resourceRequest(Document* document) | 52 FetchRequest PreloadRequest::resourceRequest(Document* document) |
52 { | 53 { |
53 ASSERT(isMainThread()); | 54 ASSERT(isMainThread()); |
54 FetchInitiatorInfo initiatorInfo; | 55 FetchInitiatorInfo initiatorInfo; |
55 initiatorInfo.name = AtomicString(m_initiatorName); | 56 initiatorInfo.name = AtomicString(m_initiatorName); |
56 initiatorInfo.position = m_initiatorPosition; | 57 initiatorInfo.position = m_initiatorPosition; |
57 FetchRequest request(ResourceRequest(completeURL(document)), initiatorInfo); | 58 FetchRequest request(ResourceRequest(completeURL(document)), initiatorInfo); |
| 59 request.mutableResourceRequest().setRequestContext(blink::WebURLRequest::Req
uestContextPrefetch); |
58 | 60 |
59 if (m_isCORSEnabled) | 61 if (m_isCORSEnabled) |
60 request.setCrossOriginAccessControl(document->securityOrigin(), m_allowC
redentials); | 62 request.setCrossOriginAccessControl(document->securityOrigin(), m_allowC
redentials); |
61 return request; | 63 return request; |
62 } | 64 } |
63 | 65 |
64 inline HTMLResourcePreloader::HTMLResourcePreloader(Document& document) | 66 inline HTMLResourcePreloader::HTMLResourcePreloader(Document& document) |
65 : m_document(document) | 67 : m_document(document) |
66 { | 68 { |
67 } | 69 } |
(...skipping 18 matching lines...) Expand all Loading... |
86 } | 88 } |
87 | 89 |
88 void HTMLResourcePreloader::preload(PassOwnPtr<PreloadRequest> preload) | 90 void HTMLResourcePreloader::preload(PassOwnPtr<PreloadRequest> preload) |
89 { | 91 { |
90 FetchRequest request = preload->resourceRequest(m_document); | 92 FetchRequest request = preload->resourceRequest(m_document); |
91 blink::Platform::current()->histogramCustomCounts("WebCore.PreloadDelayMs",
static_cast<int>(1000 * (monotonicallyIncreasingTime() - preload->discoveryTime(
))), 0, 2000, 20); | 93 blink::Platform::current()->histogramCustomCounts("WebCore.PreloadDelayMs",
static_cast<int>(1000 * (monotonicallyIncreasingTime() - preload->discoveryTime(
))), 0, 2000, 20); |
92 m_document->fetcher()->preload(preload->resourceType(), request, preload->ch
arset()); | 94 m_document->fetcher()->preload(preload->resourceType(), request, preload->ch
arset()); |
93 } | 95 } |
94 | 96 |
95 } | 97 } |
OLD | NEW |