| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 return; | 155 return; |
| 156 active_loader_->SetDeferred(deferred); | 156 active_loader_->SetDeferred(deferred); |
| 157 } | 157 } |
| 158 | 158 |
| 159 ///////////////////////////////////////////////////////////////////////////// | 159 ///////////////////////////////////////////////////////////////////////////// |
| 160 // WebURLLoaderClient implementation. | 160 // WebURLLoaderClient implementation. |
| 161 | 161 |
| 162 void ResourceMultiBufferDataProvider::willFollowRedirect( | 162 void ResourceMultiBufferDataProvider::willFollowRedirect( |
| 163 WebURLLoader* loader, | 163 WebURLLoader* loader, |
| 164 WebURLRequest& newRequest, | 164 WebURLRequest& newRequest, |
| 165 const WebURLResponse& redirectResponse) { | 165 const WebURLResponse& redirectResponse, |
| 166 int64_t encodedDataLength) { |
| 166 redirects_to_ = newRequest.url(); | 167 redirects_to_ = newRequest.url(); |
| 167 url_data_->set_valid_until(base::Time::Now() + | 168 url_data_->set_valid_until(base::Time::Now() + |
| 168 GetCacheValidUntil(redirectResponse)); | 169 GetCacheValidUntil(redirectResponse)); |
| 169 | 170 |
| 170 // This test is vital for security! | 171 // This test is vital for security! |
| 171 if (cors_mode_ == UrlData::CORS_UNSPECIFIED) { | 172 if (cors_mode_ == UrlData::CORS_UNSPECIFIED) { |
| 172 // We allow the redirect if the origin is the same. | 173 // We allow the redirect if the origin is the same. |
| 173 if (origin_ != redirects_to_.GetOrigin()) { | 174 if (origin_ != redirects_to_.GetOrigin()) { |
| 174 // We also allow the redirect if we don't have any data in the | 175 // We also allow the redirect if we don't have any data in the |
| 175 // cache, as that means that no dangerous data mixing can occur. | 176 // cache, as that means that no dangerous data mixing can occur. |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 if (!url_data_->ValidateDataOrigin(original_url.GetOrigin())) { | 336 if (!url_data_->ValidateDataOrigin(original_url.GetOrigin())) { |
| 336 active_loader_ = nullptr; | 337 active_loader_ = nullptr; |
| 337 url_data_->Fail(); | 338 url_data_->Fail(); |
| 338 return; // "this" may be deleted now. | 339 return; // "this" may be deleted now. |
| 339 } | 340 } |
| 340 } | 341 } |
| 341 | 342 |
| 342 void ResourceMultiBufferDataProvider::didReceiveData(WebURLLoader* loader, | 343 void ResourceMultiBufferDataProvider::didReceiveData(WebURLLoader* loader, |
| 343 const char* data, | 344 const char* data, |
| 344 int data_length, | 345 int data_length, |
| 345 int encoded_data_length) { | 346 int encoded_data_length, |
| 347 int encoded_body_length) { |
| 346 DVLOG(1) << "didReceiveData: " << data_length << " bytes"; | 348 DVLOG(1) << "didReceiveData: " << data_length << " bytes"; |
| 347 DCHECK(!Available()); | 349 DCHECK(!Available()); |
| 348 DCHECK(active_loader_); | 350 DCHECK(active_loader_); |
| 349 DCHECK_GT(data_length, 0); | 351 DCHECK_GT(data_length, 0); |
| 350 | 352 |
| 351 // When we receive data, we allow more retries. | 353 // When we receive data, we allow more retries. |
| 352 retries_ = 0; | 354 retries_ = 0; |
| 353 | 355 |
| 354 while (data_length) { | 356 while (data_length) { |
| 355 if (fifo_.empty() || fifo_.back()->data_size() == block_size()) { | 357 if (fifo_.empty() || fifo_.back()->data_size() == block_size()) { |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 } | 524 } |
| 523 | 525 |
| 524 if (byte_pos() != first_byte_position) { | 526 if (byte_pos() != first_byte_position) { |
| 525 return false; | 527 return false; |
| 526 } | 528 } |
| 527 | 529 |
| 528 return true; | 530 return true; |
| 529 } | 531 } |
| 530 | 532 |
| 531 } // namespace media | 533 } // namespace media |
| OLD | NEW |