OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/blink/resource_multibuffer_data_provider.h" | 5 #include "media/blink/resource_multibuffer_data_provider.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 | 156 |
157 void ResourceMultiBufferDataProvider::SetDeferred(bool deferred) { | 157 void ResourceMultiBufferDataProvider::SetDeferred(bool deferred) { |
158 if (!active_loader_ || active_loader_->deferred() == deferred) | 158 if (!active_loader_ || active_loader_->deferred() == deferred) |
159 return; | 159 return; |
160 active_loader_->SetDeferred(deferred); | 160 active_loader_->SetDeferred(deferred); |
161 } | 161 } |
162 | 162 |
163 ///////////////////////////////////////////////////////////////////////////// | 163 ///////////////////////////////////////////////////////////////////////////// |
164 // WebURLLoaderClient implementation. | 164 // WebURLLoaderClient implementation. |
165 | 165 |
166 void ResourceMultiBufferDataProvider::willFollowRedirect( | 166 bool ResourceMultiBufferDataProvider::willFollowRedirect( |
167 WebURLLoader* loader, | 167 WebURLLoader* loader, |
168 WebURLRequest& newRequest, | 168 WebURLRequest& newRequest, |
169 const WebURLResponse& redirectResponse, | 169 const WebURLResponse& redirectResponse, |
170 int64_t encodedDataLength) { | 170 int64_t encodedDataLength) { |
171 redirects_to_ = newRequest.url(); | 171 redirects_to_ = newRequest.url(); |
172 url_data_->set_valid_until(base::Time::Now() + | 172 url_data_->set_valid_until(base::Time::Now() + |
173 GetCacheValidUntil(redirectResponse)); | 173 GetCacheValidUntil(redirectResponse)); |
174 | 174 |
175 // This test is vital for security! | 175 // This test is vital for security! |
176 if (cors_mode_ == UrlData::CORS_UNSPECIFIED) { | 176 if (cors_mode_ == UrlData::CORS_UNSPECIFIED) { |
177 // We allow the redirect if the origin is the same. | 177 // We allow the redirect if the origin is the same. |
178 if (origin_ != redirects_to_.GetOrigin()) { | 178 if (origin_ != redirects_to_.GetOrigin()) { |
179 // We also allow the redirect if we don't have any data in the | 179 // We also allow the redirect if we don't have any data in the |
180 // cache, as that means that no dangerous data mixing can occur. | 180 // cache, as that means that no dangerous data mixing can occur. |
181 if (url_data_->multibuffer()->map().empty() && fifo_.empty()) | 181 if (url_data_->multibuffer()->map().empty() && fifo_.empty()) |
182 return; | 182 return true; |
183 | 183 |
184 active_loader_ = nullptr; | 184 active_loader_ = nullptr; |
185 url_data_->Fail(); | 185 url_data_->Fail(); |
Nate Chapin
2016/09/06 16:46:14
I don't know this code at all, but it smells like
tyoshino (SeeGerritForStatus)
2016/09/07 10:52:28
Yeah. I'll ask the owner for review.
| |
186 return; // "this" may be deleted now. | 186 // "this" may be deleted now. |
187 } | 187 } |
188 } | 188 } |
189 return true; | |
189 } | 190 } |
190 | 191 |
191 void ResourceMultiBufferDataProvider::didSendData( | 192 void ResourceMultiBufferDataProvider::didSendData( |
192 WebURLLoader* loader, | 193 WebURLLoader* loader, |
193 unsigned long long bytes_sent, | 194 unsigned long long bytes_sent, |
194 unsigned long long total_bytes_to_be_sent) { | 195 unsigned long long total_bytes_to_be_sent) { |
195 NOTIMPLEMENTED(); | 196 NOTIMPLEMENTED(); |
196 } | 197 } |
197 | 198 |
198 void ResourceMultiBufferDataProvider::didReceiveResponse( | 199 void ResourceMultiBufferDataProvider::didReceiveResponse( |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
539 } | 540 } |
540 | 541 |
541 if (byte_pos() != first_byte_position) { | 542 if (byte_pos() != first_byte_position) { |
542 return false; | 543 return false; |
543 } | 544 } |
544 | 545 |
545 return true; | 546 return true; |
546 } | 547 } |
547 | 548 |
548 } // namespace media | 549 } // namespace media |
OLD | NEW |