OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/renderer/media/buffered_data_source.h" | 5 #include "content/renderer/media/buffered_data_source.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
10 #include "content/public/common/url_constants.h" | 10 #include "content/public/common/url_constants.h" |
11 #include "media/base/media_log.h" | 11 #include "media/base/media_log.h" |
12 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
| 13 #include "url/url_constants.h" |
13 | 14 |
14 using blink::WebFrame; | 15 using blink::WebFrame; |
15 | 16 |
16 namespace { | 17 namespace { |
17 | 18 |
18 // BufferedDataSource has an intermediate buffer, this value governs the initial | 19 // BufferedDataSource has an intermediate buffer, this value governs the initial |
19 // size of that buffer. It is set to 32KB because this is a typical read size | 20 // size of that buffer. It is set to 32KB because this is a typical read size |
20 // of FFmpeg. | 21 // of FFmpeg. |
21 const int kInitialReadBufferSize = 32768; | 22 const int kInitialReadBufferSize = 32768; |
22 | 23 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 BufferedResourceLoader::CORSMode cors_mode, | 134 BufferedResourceLoader::CORSMode cors_mode, |
134 const InitializeCB& init_cb) { | 135 const InitializeCB& init_cb) { |
135 DCHECK(render_loop_->BelongsToCurrentThread()); | 136 DCHECK(render_loop_->BelongsToCurrentThread()); |
136 DCHECK(!init_cb.is_null()); | 137 DCHECK(!init_cb.is_null()); |
137 DCHECK(!loader_.get()); | 138 DCHECK(!loader_.get()); |
138 url_ = url; | 139 url_ = url; |
139 cors_mode_ = cors_mode; | 140 cors_mode_ = cors_mode; |
140 | 141 |
141 init_cb_ = init_cb; | 142 init_cb_ = init_cb; |
142 | 143 |
143 if (url_.SchemeIs(kHttpScheme) || url_.SchemeIs(kHttpsScheme)) { | 144 if (url_.SchemeIs(url::kHttpScheme) || url_.SchemeIs(url::kHttpsScheme)) { |
144 // Do an unbounded range request starting at the beginning. If the server | 145 // Do an unbounded range request starting at the beginning. If the server |
145 // responds with 200 instead of 206 we'll fall back into a streaming mode. | 146 // responds with 200 instead of 206 we'll fall back into a streaming mode. |
146 loader_.reset(CreateResourceLoader(0, kPositionNotSpecified)); | 147 loader_.reset(CreateResourceLoader(0, kPositionNotSpecified)); |
147 } else { | 148 } else { |
148 // For all other protocols, assume they support range request. We fetch | 149 // For all other protocols, assume they support range request. We fetch |
149 // the full range of the resource to obtain the instance size because | 150 // the full range of the resource to obtain the instance size because |
150 // we won't be served HTTP headers. | 151 // we won't be served HTTP headers. |
151 loader_.reset(CreateResourceLoader(kPositionNotSpecified, | 152 loader_.reset(CreateResourceLoader(kPositionNotSpecified, |
152 kPositionNotSpecified)); | 153 kPositionNotSpecified)); |
153 assume_fully_buffered_ = true; | 154 assume_fully_buffered_ = true; |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 return; | 532 return; |
532 } | 533 } |
533 | 534 |
534 // If media is currently playing or the page indicated preload=auto, | 535 // If media is currently playing or the page indicated preload=auto, |
535 // use threshold strategy to enable/disable deferring when the buffer | 536 // use threshold strategy to enable/disable deferring when the buffer |
536 // is full/depleted. | 537 // is full/depleted. |
537 loader_->UpdateDeferStrategy(BufferedResourceLoader::kCapacityDefer); | 538 loader_->UpdateDeferStrategy(BufferedResourceLoader::kCapacityDefer); |
538 } | 539 } |
539 | 540 |
540 } // namespace content | 541 } // namespace content |
OLD | NEW |