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