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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 void 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 redirects_to_ = newRequest.url(); | 171 redirects_to_ = newRequest.url(); |
171 url_data_->set_valid_until(base::Time::Now() + | 172 url_data_->set_valid_until(base::Time::Now() + |
172 GetCacheValidUntil(redirectResponse)); | 173 GetCacheValidUntil(redirectResponse)); |
173 | 174 |
174 // This test is vital for security! | 175 // This test is vital for security! |
175 if (cors_mode_ == UrlData::CORS_UNSPECIFIED) { | 176 if (cors_mode_ == UrlData::CORS_UNSPECIFIED) { |
176 // We allow the redirect if the origin is the same. | 177 // We allow the redirect if the origin is the same. |
177 if (origin_ != redirects_to_.GetOrigin()) { | 178 if (origin_ != redirects_to_.GetOrigin()) { |
178 // 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 |
179 // cache, as that means that no dangerous data mixing can occur. | 180 // cache, as that means that no dangerous data mixing can occur. |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 | 346 |
346 if (end_of_file) { | 347 if (end_of_file) { |
347 fifo_.push_back(DataBuffer::CreateEOSBuffer()); | 348 fifo_.push_back(DataBuffer::CreateEOSBuffer()); |
348 url_data_->multibuffer()->OnDataProviderEvent(this); | 349 url_data_->multibuffer()->OnDataProviderEvent(this); |
349 } | 350 } |
350 } | 351 } |
351 | 352 |
352 void ResourceMultiBufferDataProvider::didReceiveData(WebURLLoader* loader, | 353 void ResourceMultiBufferDataProvider::didReceiveData(WebURLLoader* loader, |
353 const char* data, | 354 const char* data, |
354 int data_length, | 355 int data_length, |
355 int encoded_data_length) { | 356 int encoded_data_length, |
| 357 int encoded_body_length) { |
356 DVLOG(1) << "didReceiveData: " << data_length << " bytes"; | 358 DVLOG(1) << "didReceiveData: " << data_length << " bytes"; |
357 DCHECK(!Available()); | 359 DCHECK(!Available()); |
358 DCHECK(active_loader_); | 360 DCHECK(active_loader_); |
359 DCHECK_GT(data_length, 0); | 361 DCHECK_GT(data_length, 0); |
360 | 362 |
361 // When we receive data, we allow more retries. | 363 // When we receive data, we allow more retries. |
362 retries_ = 0; | 364 retries_ = 0; |
363 | 365 |
364 while (data_length) { | 366 while (data_length) { |
365 if (fifo_.empty() || fifo_.back()->data_size() == block_size()) { | 367 if (fifo_.empty() || fifo_.back()->data_size() == block_size()) { |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 } | 539 } |
538 | 540 |
539 if (byte_pos() != first_byte_position) { | 541 if (byte_pos() != first_byte_position) { |
540 return false; | 542 return false; |
541 } | 543 } |
542 | 544 |
543 return true; | 545 return true; |
544 } | 546 } |
545 | 547 |
546 } // namespace media | 548 } // namespace media |
OLD | NEW |