OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2010, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2010, 2011 Apple Inc. All rights reserved. |
3 * (C) 2007 Graham Dennis (graham.dennis@gmail.com) | 3 * (C) 2007 Graham Dennis (graham.dennis@gmail.com) |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 ResourceLoader::~ResourceLoader() { | 65 ResourceLoader::~ResourceLoader() { |
66 DCHECK(!m_loader); | 66 DCHECK(!m_loader); |
67 } | 67 } |
68 | 68 |
69 DEFINE_TRACE(ResourceLoader) { | 69 DEFINE_TRACE(ResourceLoader) { |
70 visitor->trace(m_fetcher); | 70 visitor->trace(m_fetcher); |
71 visitor->trace(m_resource); | 71 visitor->trace(m_resource); |
72 } | 72 } |
73 | 73 |
74 void ResourceLoader::start(const ResourceRequest& request, | 74 void ResourceLoader::start(const ResourceRequest& request, |
75 WebTaskRunner* loadingTaskRunner, | 75 RefPtr<WebTaskRunner> loadingTaskRunner, |
76 bool defersLoading) { | 76 bool defersLoading) { |
77 DCHECK(!m_loader); | 77 DCHECK(!m_loader); |
78 if (m_resource->options().synchronousPolicy == RequestSynchronously && | 78 if (m_resource->options().synchronousPolicy == RequestSynchronously && |
79 defersLoading) { | 79 defersLoading) { |
80 cancel(); | 80 cancel(); |
81 return; | 81 return; |
82 } | 82 } |
83 | 83 |
84 m_loader = wrapUnique(Platform::current()->createURLLoader()); | 84 m_loader = wrapUnique(Platform::current()->createURLLoader()); |
85 DCHECK(m_loader); | 85 DCHECK(m_loader); |
86 m_loader->setDefersLoading(defersLoading); | 86 m_loader->setDefersLoading(defersLoading); |
87 m_loader->setLoadingTaskRunner(loadingTaskRunner); | 87 m_loader->setLoadingTaskRunner(loadingTaskRunner.get()); |
haraken
2016/12/08 01:49:02
Why do we need get()?
tzik
2016/12/12 12:18:52
eOn 2016/12/08 01:49:02, haraken wrote:
| |
88 | 88 |
89 if (m_isCacheAwareLoadingActivated) { | 89 if (m_isCacheAwareLoadingActivated) { |
90 // Override cache policy for cache-aware loading. If this request fails, a | 90 // Override cache policy for cache-aware loading. If this request fails, a |
91 // reload with original request will be triggered in didFail(). | 91 // reload with original request will be triggered in didFail(). |
92 ResourceRequest cacheAwareRequest(request); | 92 ResourceRequest cacheAwareRequest(request); |
93 cacheAwareRequest.setCachePolicy(WebCachePolicy::ReturnCacheDataIfValid); | 93 cacheAwareRequest.setCachePolicy(WebCachePolicy::ReturnCacheDataIfValid); |
94 m_loader->loadAsynchronously(WrappedResourceRequest(cacheAwareRequest), | 94 m_loader->loadAsynchronously(WrappedResourceRequest(cacheAwareRequest), |
95 this); | 95 this); |
96 return; | 96 return; |
97 } | 97 } |
98 | 98 |
99 if (m_resource->options().synchronousPolicy == RequestSynchronously) | 99 if (m_resource->options().synchronousPolicy == RequestSynchronously) |
100 requestSynchronously(request); | 100 requestSynchronously(request); |
101 else | 101 else |
102 m_loader->loadAsynchronously(WrappedResourceRequest(request), this); | 102 m_loader->loadAsynchronously(WrappedResourceRequest(request), this); |
103 } | 103 } |
104 | 104 |
105 void ResourceLoader::restart(const ResourceRequest& request, | 105 void ResourceLoader::restart(const ResourceRequest& request, |
106 WebTaskRunner* loadingTaskRunner, | 106 RefPtr<WebTaskRunner> loadingTaskRunner, |
107 bool defersLoading) { | 107 bool defersLoading) { |
108 CHECK_EQ(m_resource->options().synchronousPolicy, RequestAsynchronously); | 108 CHECK_EQ(m_resource->options().synchronousPolicy, RequestAsynchronously); |
109 m_loader.reset(); | 109 m_loader.reset(); |
110 start(request, loadingTaskRunner, defersLoading); | 110 start(request, std::move(loadingTaskRunner), defersLoading); |
111 } | 111 } |
112 | 112 |
113 void ResourceLoader::setDefersLoading(bool defers) { | 113 void ResourceLoader::setDefersLoading(bool defers) { |
114 DCHECK(m_loader); | 114 DCHECK(m_loader); |
115 m_loader->setDefersLoading(defers); | 115 m_loader->setDefersLoading(defers); |
116 } | 116 } |
117 | 117 |
118 void ResourceLoader::didDownloadData(int length, int encodedDataLength) { | 118 void ResourceLoader::didDownloadData(int length, int encodedDataLength) { |
119 m_fetcher->didDownloadData(m_resource.get(), length, encodedDataLength); | 119 m_fetcher->didDownloadData(m_resource.get(), length, encodedDataLength); |
120 m_resource->didDownloadData(length); | 120 m_resource->didDownloadData(length); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
312 return; | 312 return; |
313 | 313 |
314 // Don't activate if cache policy is explicitly set. | 314 // Don't activate if cache policy is explicitly set. |
315 if (request.getCachePolicy() != WebCachePolicy::UseProtocolCachePolicy) | 315 if (request.getCachePolicy() != WebCachePolicy::UseProtocolCachePolicy) |
316 return; | 316 return; |
317 | 317 |
318 m_isCacheAwareLoadingActivated = true; | 318 m_isCacheAwareLoadingActivated = true; |
319 } | 319 } |
320 | 320 |
321 } // namespace blink | 321 } // namespace blink |
OLD | NEW |