Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: webkit/glue/media/buffered_resource_loader.cc

Issue 6926002: Merge 83942 - Partial revert of 82061 so we keep the initial unbounded range request. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/742/src/
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/string_util.h" 8 #include "base/string_util.h"
9 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 } 96 }
97 97
98 // Increment the reference count right before we start the request. This 98 // Increment the reference count right before we start the request. This
99 // reference will be release when this request has ended. 99 // reference will be release when this request has ended.
100 AddRef(); 100 AddRef();
101 101
102 // Prepare the request. 102 // Prepare the request.
103 WebURLRequest request(url_); 103 WebURLRequest request(url_);
104 request.setTargetType(WebURLRequest::TargetIsMedia); 104 request.setTargetType(WebURLRequest::TargetIsMedia);
105 105
106 if (!IsWholeFileRange()) { 106 if (IsRangeRequest()) {
107 range_requested_ = true; 107 range_requested_ = true;
108 request.setHTTPHeaderField(WebString::fromUTF8("Range"), 108 request.setHTTPHeaderField(WebString::fromUTF8("Range"),
109 WebString::fromUTF8(GenerateHeaders( 109 WebString::fromUTF8(GenerateHeaders(
110 first_byte_position_, 110 first_byte_position_,
111 last_byte_position_))); 111 last_byte_position_)));
112 } 112 }
113 frame->setReferrerForRequest(request, WebKit::WebURL()); 113 frame->setReferrerForRequest(request, WebKit::WebURL());
114 114
115 // This flag is for unittests as we don't want to reset |url_loader| 115 // This flag is for unittests as we don't want to reset |url_loader|
116 if (!keep_test_loader_) 116 if (!keep_test_loader_)
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 288
289 // Check to see whether the server supports byte ranges. 289 // Check to see whether the server supports byte ranges.
290 std::string accept_ranges = 290 std::string accept_ranges =
291 response.httpHeaderField("Accept-Ranges").utf8(); 291 response.httpHeaderField("Accept-Ranges").utf8();
292 range_supported_ = (accept_ranges.find("bytes") != std::string::npos); 292 range_supported_ = (accept_ranges.find("bytes") != std::string::npos);
293 293
294 partial_response = (response.httpStatusCode() == kHttpPartialContent); 294 partial_response = (response.httpStatusCode() == kHttpPartialContent);
295 295
296 if (range_requested_) { 296 if (range_requested_) {
297 // If we have verified the partial response and it is correct, we will 297 // If we have verified the partial response and it is correct, we will
298 // return net::OK. 298 // return net::OK. It's also possible for a server to support range
299 if (!partial_response || !VerifyPartialResponse(response)) 299 // requests without advertising Accept-Ranges: bytes.
300 if (partial_response && VerifyPartialResponse(response))
301 range_supported_ = true;
302 else
300 error = net::ERR_INVALID_RESPONSE; 303 error = net::ERR_INVALID_RESPONSE;
301 } else if (response.httpStatusCode() != kHttpOK) { 304 } else if (response.httpStatusCode() != kHttpOK) {
302 // We didn't request a range but server didn't reply with "200 OK". 305 // We didn't request a range but server didn't reply with "200 OK".
303 error = net::ERR_FAILED; 306 error = net::ERR_FAILED;
304 } 307 }
305 308
306 if (error != net::OK) { 309 if (error != net::OK) {
307 DoneStart(error); 310 DoneStart(error);
308 Stop(); 311 Stop();
309 return; 312 return;
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 void BufferedResourceLoader::DoneStart(int error) { 639 void BufferedResourceLoader::DoneStart(int error) {
637 start_callback_->RunWithParams(Tuple1<int>(error)); 640 start_callback_->RunWithParams(Tuple1<int>(error));
638 start_callback_.reset(); 641 start_callback_.reset();
639 } 642 }
640 643
641 void BufferedResourceLoader::NotifyNetworkEvent() { 644 void BufferedResourceLoader::NotifyNetworkEvent() {
642 if (event_callback_.get()) 645 if (event_callback_.get())
643 event_callback_->Run(); 646 event_callback_->Run();
644 } 647 }
645 648
646 bool BufferedResourceLoader::IsWholeFileRange() const { 649 bool BufferedResourceLoader::IsRangeRequest() const {
647 return ((first_byte_position_ == kPositionNotSpecified || 650 return first_byte_position_ != kPositionNotSpecified;
648 first_byte_position_ == 0) &&
649 last_byte_position_ == kPositionNotSpecified);
650 } 651 }
651 652
652 } // namespace webkit_glue 653 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « webkit/glue/media/buffered_resource_loader.h ('k') | webkit/glue/media/buffered_resource_loader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698