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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 net::HttpByteRange::RightUnbounded(byte_pos()).GetHeaderValue())); | 79 net::HttpByteRange::RightUnbounded(byte_pos()).GetHeaderValue())); |
80 | 80 |
81 url_data_->frame()->setReferrerForRequest(request, blink::WebURL()); | 81 url_data_->frame()->setReferrerForRequest(request, blink::WebURL()); |
82 | 82 |
83 // Disable compression, compression for audio/video doesn't make sense... | 83 // Disable compression, compression for audio/video doesn't make sense... |
84 request.setHTTPHeaderField( | 84 request.setHTTPHeaderField( |
85 WebString::fromUTF8(net::HttpRequestHeaders::kAcceptEncoding), | 85 WebString::fromUTF8(net::HttpRequestHeaders::kAcceptEncoding), |
86 WebString::fromUTF8("identity;q=1, *;q=0")); | 86 WebString::fromUTF8("identity;q=1, *;q=0")); |
87 | 87 |
88 // Check for our test WebURLLoader. | 88 // Check for our test WebURLLoader. |
89 scoped_ptr<WebURLLoader> loader; | 89 std::unique_ptr<WebURLLoader> loader; |
90 if (test_loader_) { | 90 if (test_loader_) { |
91 loader = std::move(test_loader_); | 91 loader = std::move(test_loader_); |
92 } else { | 92 } else { |
93 WebURLLoaderOptions options; | 93 WebURLLoaderOptions options; |
94 if (url_data_->cors_mode() == UrlData::CORS_UNSPECIFIED) { | 94 if (url_data_->cors_mode() == UrlData::CORS_UNSPECIFIED) { |
95 options.allowCredentials = true; | 95 options.allowCredentials = true; |
96 options.crossOriginRequestPolicy = | 96 options.crossOriginRequestPolicy = |
97 WebURLLoaderOptions::CrossOriginRequestPolicyAllow; | 97 WebURLLoaderOptions::CrossOriginRequestPolicyAllow; |
98 } else { | 98 } else { |
99 options.exposeAllResponseHeaders = true; | 99 options.exposeAllResponseHeaders = true; |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 | 293 |
294 if (destination_url_data != url_data_) { | 294 if (destination_url_data != url_data_) { |
295 // At this point, we've encountered a redirect, or found a better url data | 295 // At this point, we've encountered a redirect, or found a better url data |
296 // instance for the data that we're about to download. | 296 // instance for the data that we're about to download. |
297 | 297 |
298 // First, let's take a ref on the current url data. | 298 // First, let's take a ref on the current url data. |
299 scoped_refptr<UrlData> old_url_data(url_data_); | 299 scoped_refptr<UrlData> old_url_data(url_data_); |
300 destination_url_data->Use(); | 300 destination_url_data->Use(); |
301 | 301 |
302 // Take ownership of ourselves. (From the multibuffer) | 302 // Take ownership of ourselves. (From the multibuffer) |
303 scoped_ptr<DataProvider> self( | 303 std::unique_ptr<DataProvider> self( |
304 url_data_->multibuffer()->RemoveProvider(this)); | 304 url_data_->multibuffer()->RemoveProvider(this)); |
305 url_data_ = destination_url_data.get(); | 305 url_data_ = destination_url_data.get(); |
306 // Give the ownership to our new owner. | 306 // Give the ownership to our new owner. |
307 url_data_->multibuffer()->AddProvider(std::move(self)); | 307 url_data_->multibuffer()->AddProvider(std::move(self)); |
308 | 308 |
309 // Call callback to let upstream users know about the transfer. | 309 // Call callback to let upstream users know about the transfer. |
310 // This will merge the data from the two multibuffers and | 310 // This will merge the data from the two multibuffers and |
311 // cause clients to start using the new UrlData. | 311 // cause clients to start using the new UrlData. |
312 old_url_data->RedirectTo(destination_url_data); | 312 old_url_data->RedirectTo(destination_url_data); |
313 } | 313 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 size < url_data_->length()) { | 380 size < url_data_->length()) { |
381 if (retries_ < kMaxRetries) { | 381 if (retries_ < kMaxRetries) { |
382 DVLOG(1) << " Partial data received.... @ pos = " << size; | 382 DVLOG(1) << " Partial data received.... @ pos = " << size; |
383 retries_++; | 383 retries_++; |
384 base::MessageLoop::current()->PostDelayedTask( | 384 base::MessageLoop::current()->PostDelayedTask( |
385 FROM_HERE, base::Bind(&ResourceMultiBufferDataProvider::Start, | 385 FROM_HERE, base::Bind(&ResourceMultiBufferDataProvider::Start, |
386 weak_factory_.GetWeakPtr()), | 386 weak_factory_.GetWeakPtr()), |
387 base::TimeDelta::FromMilliseconds(kLoaderPartialRetryDelayMs)); | 387 base::TimeDelta::FromMilliseconds(kLoaderPartialRetryDelayMs)); |
388 return; | 388 return; |
389 } else { | 389 } else { |
390 scoped_ptr<ActiveLoader> active_loader = std::move(active_loader_); | 390 std::unique_ptr<ActiveLoader> active_loader = std::move(active_loader_); |
391 url_data_->Fail(); | 391 url_data_->Fail(); |
392 return; | 392 return; |
393 } | 393 } |
394 } | 394 } |
395 | 395 |
396 url_data_->set_length(size); | 396 url_data_->set_length(size); |
397 fifo_.push_back(DataBuffer::CreateEOSBuffer()); | 397 fifo_.push_back(DataBuffer::CreateEOSBuffer()); |
398 | 398 |
399 DCHECK(Available()); | 399 DCHECK(Available()); |
400 url_data_->multibuffer()->OnDataProviderEvent(this); | 400 url_data_->multibuffer()->OnDataProviderEvent(this); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 } | 496 } |
497 | 497 |
498 if (byte_pos() != first_byte_position) { | 498 if (byte_pos() != first_byte_position) { |
499 return false; | 499 return false; |
500 } | 500 } |
501 | 501 |
502 return true; | 502 return true; |
503 } | 503 } |
504 | 504 |
505 } // namespace media | 505 } // namespace media |
OLD | NEW |