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

Side by Side Diff: webkit/appcache/appcache_url_request_job.cc

Issue 2876040: Fix a regression with satisfying range requests out of the appcache and add a... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 <vector> 5 #include <vector>
6 6
7 #include "webkit/appcache/appcache_url_request_job.h" 7 #include "webkit/appcache/appcache_url_request_job.h"
8 8
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "net/base/net_errors.h" 11 #include "net/base/net_errors.h"
12 #include "net/http/http_request_headers.h"
12 #include "net/http/http_util.h" 13 #include "net/http/http_util.h"
13 #include "net/url_request/url_request_status.h" 14 #include "net/url_request/url_request_status.h"
14 15
15 namespace appcache { 16 namespace appcache {
16 17
17 AppCacheURLRequestJob::AppCacheURLRequestJob( 18 AppCacheURLRequestJob::AppCacheURLRequestJob(
18 URLRequest* request, AppCacheStorage* storage) 19 URLRequest* request, AppCacheStorage* storage)
19 : URLRequestJob(request), storage_(storage), 20 : URLRequestJob(request), storage_(storage),
20 has_been_started_(false), has_been_killed_(false), 21 has_been_started_(false), has_been_killed_(false),
21 delivery_type_(AWAITING_DELIVERY_ORDERS), 22 delivery_type_(AWAITING_DELIVERY_ORDERS),
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 DCHECK(is_delivering_appcache_response()); 237 DCHECK(is_delivering_appcache_response());
237 DCHECK_NE(buf_size, 0); 238 DCHECK_NE(buf_size, 0);
238 DCHECK(bytes_read); 239 DCHECK(bytes_read);
239 DCHECK(!reader_->IsReadPending()); 240 DCHECK(!reader_->IsReadPending());
240 reader_->ReadData(buf, buf_size, &read_callback_); 241 reader_->ReadData(buf, buf_size, &read_callback_);
241 SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0)); 242 SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0));
242 return false; 243 return false;
243 } 244 }
244 245
245 void AppCacheURLRequestJob::SetExtraRequestHeaders( 246 void AppCacheURLRequestJob::SetExtraRequestHeaders(
246 const std::string& headers) { 247 const net::HttpRequestHeaders& headers) {
248 std::string value;
249 std::vector<net::HttpByteRange> ranges;
250 if (!headers.GetHeader(net::HttpRequestHeaders::kRange, &value) ||
251 !net::HttpUtil::ParseRangeHeader(value, &ranges)) {
252 return;
253 }
254
247 // If multiple ranges are requested, we play dumb and 255 // If multiple ranges are requested, we play dumb and
248 // return the entire response with 200 OK. 256 // return the entire response with 200 OK.
249 std::vector<net::HttpByteRange> ranges; 257 if (ranges.size() == 1U)
250 if (!net::HttpUtil::ParseRanges(headers, &ranges) || (ranges.size() > 1U)) 258 range_requested_ = ranges[0];
251 return;
252 range_requested_ = ranges[0];
253 } 259 }
254 260
255 } // namespace appcache 261 } // namespace appcache
256 262
OLDNEW
« no previous file with comments | « webkit/appcache/appcache_url_request_job.h ('k') | webkit/appcache/appcache_url_request_job_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698