| OLD | NEW | 
|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/media/buffered_resource_loader.h" | 5 #include "webkit/media/buffered_resource_loader.h" | 
| 6 | 6 | 
| 7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" | 
| 8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" | 
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" | 
| 10 #include "media/base/media_log.h" | 10 #include "media/base/media_log.h" | 
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 162                                             last_byte_position_))); | 162                                             last_byte_position_))); | 
| 163   } | 163   } | 
| 164   frame->setReferrerForRequest(request, WebKit::WebURL()); | 164   frame->setReferrerForRequest(request, WebKit::WebURL()); | 
| 165 | 165 | 
| 166   // Disable compression, compression for audio/video doesn't make sense... | 166   // Disable compression, compression for audio/video doesn't make sense... | 
| 167   request.setHTTPHeaderField( | 167   request.setHTTPHeaderField( | 
| 168       WebString::fromUTF8(net::HttpRequestHeaders::kAcceptEncoding), | 168       WebString::fromUTF8(net::HttpRequestHeaders::kAcceptEncoding), | 
| 169       WebString::fromUTF8("identity;q=1, *;q=0")); | 169       WebString::fromUTF8("identity;q=1, *;q=0")); | 
| 170 | 170 | 
| 171   // Check for our test WebURLLoader. | 171   // Check for our test WebURLLoader. | 
| 172   WebURLLoader* loader = NULL; | 172   scoped_ptr<WebURLLoader> loader; | 
| 173   if (test_loader_.get()) { | 173   if (test_loader_.get()) { | 
| 174     loader = test_loader_.release(); | 174     loader = test_loader_.Pass(); | 
| 175   } else { | 175   } else { | 
| 176     WebURLLoaderOptions options; | 176     WebURLLoaderOptions options; | 
| 177     options.allowCredentials = true; | 177     options.allowCredentials = true; | 
| 178     options.crossOriginRequestPolicy = | 178     options.crossOriginRequestPolicy = | 
| 179         WebURLLoaderOptions::CrossOriginRequestPolicyAllow; | 179         WebURLLoaderOptions::CrossOriginRequestPolicyAllow; | 
| 180     loader = frame->createAssociatedURLLoader(options); | 180     loader.reset(frame->createAssociatedURLLoader(options)); | 
| 181   } | 181   } | 
| 182 | 182 | 
| 183   // Start the resource loading. | 183   // Start the resource loading. | 
| 184   loader->loadAsynchronously(request, this); | 184   loader->loadAsynchronously(request, this); | 
| 185   active_loader_.reset(new ActiveLoader(loader)); | 185   active_loader_.reset(new ActiveLoader(loader.Pass())); | 
| 186 } | 186 } | 
| 187 | 187 | 
| 188 void BufferedResourceLoader::Stop() { | 188 void BufferedResourceLoader::Stop() { | 
| 189   // Reset callbacks. | 189   // Reset callbacks. | 
| 190   start_callback_.Reset(); | 190   start_callback_.Reset(); | 
| 191   event_callback_.Reset(); | 191   event_callback_.Reset(); | 
| 192   read_callback_.Reset(); | 192   read_callback_.Reset(); | 
| 193 | 193 | 
| 194   // Use the internal buffer to signal that we have been stopped. | 194   // Use the internal buffer to signal that we have been stopped. | 
| 195   // TODO(hclam): Not so pretty to do this. | 195   // TODO(hclam): Not so pretty to do this. | 
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 310 } | 310 } | 
| 311 | 311 | 
| 312 bool BufferedResourceLoader::is_downloading_data() { | 312 bool BufferedResourceLoader::is_downloading_data() { | 
| 313   return active_loader_.get() && !active_loader_->deferred(); | 313   return active_loader_.get() && !active_loader_->deferred(); | 
| 314 } | 314 } | 
| 315 | 315 | 
| 316 const GURL& BufferedResourceLoader::url() { | 316 const GURL& BufferedResourceLoader::url() { | 
| 317   return url_; | 317   return url_; | 
| 318 } | 318 } | 
| 319 | 319 | 
| 320 void BufferedResourceLoader::SetURLLoaderForTest(WebURLLoader* test_loader) { | 320 void BufferedResourceLoader::SetURLLoaderForTest( | 
| 321   test_loader_.reset(test_loader); | 321     scoped_ptr<WebURLLoader> test_loader) { | 
|  | 322   test_loader_ = test_loader.Pass(); | 
| 322 } | 323 } | 
| 323 | 324 | 
| 324 ///////////////////////////////////////////////////////////////////////////// | 325 ///////////////////////////////////////////////////////////////////////////// | 
| 325 // WebKit::WebURLLoaderClient implementation. | 326 // WebKit::WebURLLoaderClient implementation. | 
| 326 void BufferedResourceLoader::willSendRequest( | 327 void BufferedResourceLoader::willSendRequest( | 
| 327     WebURLLoader* loader, | 328     WebURLLoader* loader, | 
| 328     WebURLRequest& newRequest, | 329     WebURLRequest& newRequest, | 
| 329     const WebURLResponse& redirectResponse) { | 330     const WebURLResponse& redirectResponse) { | 
| 330 | 331 | 
| 331   // The load may have been stopped and |start_callback| is destroyed. | 332   // The load may have been stopped and |start_callback| is destroyed. | 
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 775   if (buffer_.get()) { | 776   if (buffer_.get()) { | 
| 776     media_log_->AddEvent( | 777     media_log_->AddEvent( | 
| 777         media_log_->CreateBufferedExtentsChangedEvent( | 778         media_log_->CreateBufferedExtentsChangedEvent( | 
| 778             offset_ - buffer_->backward_bytes(), | 779             offset_ - buffer_->backward_bytes(), | 
| 779             offset_, | 780             offset_, | 
| 780             offset_ + buffer_->forward_bytes())); | 781             offset_ + buffer_->forward_bytes())); | 
| 781   } | 782   } | 
| 782 } | 783 } | 
| 783 | 784 | 
| 784 }  // namespace webkit_media | 785 }  // namespace webkit_media | 
| OLD | NEW | 
|---|