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