| 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/glue/media/buffered_resource_loader.h" | 5 #include "webkit/glue/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 "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| 11 #include "net/http/http_request_headers.h" |
| 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" |
| 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKitClient.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKitClient.h" |
| 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" |
| 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLError.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLError.h" |
| 15 #include "webkit/glue/multipart_response_delegate.h" | 16 #include "webkit/glue/multipart_response_delegate.h" |
| 16 #include "webkit/glue/webkit_glue.h" | 17 #include "webkit/glue/webkit_glue.h" |
| 17 | 18 |
| 18 using WebKit::WebFrame; | 19 using WebKit::WebFrame; |
| 19 using WebKit::WebString; | 20 using WebKit::WebString; |
| 20 using WebKit::WebURLError; | 21 using WebKit::WebURLError; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // Increment the reference count right before we start the request. This | 100 // Increment the reference count right before we start the request. This |
| 100 // reference will be release when this request has ended. | 101 // reference will be release when this request has ended. |
| 101 AddRef(); | 102 AddRef(); |
| 102 | 103 |
| 103 // Prepare the request. | 104 // Prepare the request. |
| 104 WebURLRequest request(url_); | 105 WebURLRequest request(url_); |
| 105 request.setTargetType(WebURLRequest::TargetIsMedia); | 106 request.setTargetType(WebURLRequest::TargetIsMedia); |
| 106 | 107 |
| 107 if (IsRangeRequest()) { | 108 if (IsRangeRequest()) { |
| 108 range_requested_ = true; | 109 range_requested_ = true; |
| 109 request.setHTTPHeaderField(WebString::fromUTF8("Range"), | 110 request.setHTTPHeaderField( |
| 110 WebString::fromUTF8(GenerateHeaders( | 111 WebString::fromUTF8(net::HttpRequestHeaders::kRange), |
| 111 first_byte_position_, | 112 WebString::fromUTF8(GenerateHeaders(first_byte_position_, |
| 112 last_byte_position_))); | 113 last_byte_position_))); |
| 113 } | 114 } |
| 114 frame->setReferrerForRequest(request, WebKit::WebURL()); | 115 frame->setReferrerForRequest(request, WebKit::WebURL()); |
| 115 | 116 |
| 117 // Disable compression, compression for audio/video doesn't make sense... |
| 118 request.setHTTPHeaderField( |
| 119 WebString::fromUTF8(net::HttpRequestHeaders::kAcceptEncoding), |
| 120 WebString::fromUTF8("identity;q=1, *;q=0")); |
| 121 |
| 116 // This flag is for unittests as we don't want to reset |url_loader| | 122 // This flag is for unittests as we don't want to reset |url_loader| |
| 117 if (!keep_test_loader_) | 123 if (!keep_test_loader_) |
| 118 url_loader_.reset(frame->createAssociatedURLLoader()); | 124 url_loader_.reset(frame->createAssociatedURLLoader()); |
| 119 | 125 |
| 120 // Start the resource loading. | 126 // Start the resource loading. |
| 121 url_loader_->loadAsynchronously(request, this); | 127 url_loader_->loadAsynchronously(request, this); |
| 122 } | 128 } |
| 123 | 129 |
| 124 void BufferedResourceLoader::Stop() { | 130 void BufferedResourceLoader::Stop() { |
| 125 // Reset callbacks. | 131 // Reset callbacks. |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 void BufferedResourceLoader::NotifyNetworkEvent() { | 656 void BufferedResourceLoader::NotifyNetworkEvent() { |
| 651 if (event_callback_.get()) | 657 if (event_callback_.get()) |
| 652 event_callback_->Run(); | 658 event_callback_->Run(); |
| 653 } | 659 } |
| 654 | 660 |
| 655 bool BufferedResourceLoader::IsRangeRequest() const { | 661 bool BufferedResourceLoader::IsRangeRequest() const { |
| 656 return first_byte_position_ != kPositionNotSpecified; | 662 return first_byte_position_ != kPositionNotSpecified; |
| 657 } | 663 } |
| 658 | 664 |
| 659 } // namespace webkit_glue | 665 } // namespace webkit_glue |
| OLD | NEW |