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

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

Issue 16155009: Update webkit/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 // attempt will fallthru to the network instead of trying to load 152 // attempt will fallthru to the network instead of trying to load
153 // from the appcache. 153 // from the appcache.
154 storage_->service()->CheckAppCacheResponse(manifest_url_, cache_id_, 154 storage_->service()->CheckAppCacheResponse(manifest_url_, cache_id_,
155 entry_.response_id()); 155 entry_.response_id());
156 cache_entry_not_found_ = true; 156 cache_entry_not_found_ = true;
157 NotifyRestartRequired(); 157 NotifyRestartRequired();
158 } 158 }
159 } 159 }
160 160
161 const net::HttpResponseInfo* AppCacheURLRequestJob::http_info() const { 161 const net::HttpResponseInfo* AppCacheURLRequestJob::http_info() const {
162 if (!info_) 162 if (!info_.get())
163 return NULL; 163 return NULL;
164 if (range_response_info_) 164 if (range_response_info_)
165 return range_response_info_.get(); 165 return range_response_info_.get();
166 return info_->http_response_info(); 166 return info_->http_response_info();
167 } 167 }
168 168
169 void AppCacheURLRequestJob::SetupRangeResponse() { 169 void AppCacheURLRequestJob::SetupRangeResponse() {
170 DCHECK(is_range_request() && info_.get() && reader_.get() && 170 DCHECK(is_range_request() && info_.get() && reader_.get() &&
171 is_delivering_appcache_response()); 171 is_delivering_appcache_response());
172 int resource_size = static_cast<int>(info_->response_data_size()); 172 int resource_size = static_cast<int>(info_->response_data_size());
(...skipping 11 matching lines...) Expand all
184 // Tell the reader about the range to read. 184 // Tell the reader about the range to read.
185 reader_->SetReadRange(offset, length); 185 reader_->SetReadRange(offset, length);
186 186
187 // Make a copy of the full response headers and fix them up 187 // Make a copy of the full response headers and fix them up
188 // for the range we'll be returning. 188 // for the range we'll be returning.
189 const char kLengthHeader[] = "Content-Length"; 189 const char kLengthHeader[] = "Content-Length";
190 const char kRangeHeader[] = "Content-Range"; 190 const char kRangeHeader[] = "Content-Range";
191 const char kPartialStatusLine[] = "HTTP/1.1 206 Partial Content"; 191 const char kPartialStatusLine[] = "HTTP/1.1 206 Partial Content";
192 range_response_info_.reset( 192 range_response_info_.reset(
193 new net::HttpResponseInfo(*info_->http_response_info())); 193 new net::HttpResponseInfo(*info_->http_response_info()));
194 net::HttpResponseHeaders* headers = range_response_info_->headers; 194 net::HttpResponseHeaders* headers = range_response_info_->headers.get();
195 headers->RemoveHeader(kLengthHeader); 195 headers->RemoveHeader(kLengthHeader);
196 headers->RemoveHeader(kRangeHeader); 196 headers->RemoveHeader(kRangeHeader);
197 headers->ReplaceStatusLine(kPartialStatusLine); 197 headers->ReplaceStatusLine(kPartialStatusLine);
198 headers->AddHeader( 198 headers->AddHeader(
199 base::StringPrintf("%s: %d", kLengthHeader, length)); 199 base::StringPrintf("%s: %d", kLengthHeader, length));
200 headers->AddHeader( 200 headers->AddHeader(
201 base::StringPrintf("%s: bytes %d-%d/%d", 201 base::StringPrintf("%s: bytes %d-%d/%d",
202 kRangeHeader, 202 kRangeHeader,
203 offset, 203 offset,
204 offset + length - 1, 204 offset + length - 1,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 } 241 }
242 } 242 }
243 243
244 net::LoadState AppCacheURLRequestJob::GetLoadState() const { 244 net::LoadState AppCacheURLRequestJob::GetLoadState() const {
245 if (!has_been_started()) 245 if (!has_been_started())
246 return net::LOAD_STATE_IDLE; 246 return net::LOAD_STATE_IDLE;
247 if (!has_delivery_orders()) 247 if (!has_delivery_orders())
248 return net::LOAD_STATE_WAITING_FOR_APPCACHE; 248 return net::LOAD_STATE_WAITING_FOR_APPCACHE;
249 if (delivery_type_ != APPCACHED_DELIVERY) 249 if (delivery_type_ != APPCACHED_DELIVERY)
250 return net::LOAD_STATE_IDLE; 250 return net::LOAD_STATE_IDLE;
251 if (!info_) 251 if (!info_.get())
252 return net::LOAD_STATE_WAITING_FOR_APPCACHE; 252 return net::LOAD_STATE_WAITING_FOR_APPCACHE;
253 if (reader_.get() && reader_->IsReadPending()) 253 if (reader_.get() && reader_->IsReadPending())
254 return net::LOAD_STATE_READING_RESPONSE; 254 return net::LOAD_STATE_READING_RESPONSE;
255 return net::LOAD_STATE_IDLE; 255 return net::LOAD_STATE_IDLE;
256 } 256 }
257 257
258 bool AppCacheURLRequestJob::GetMimeType(std::string* mime_type) const { 258 bool AppCacheURLRequestJob::GetMimeType(std::string* mime_type) const {
259 if (!http_info()) 259 if (!http_info())
260 return false; 260 return false;
261 return http_info()->headers->GetMimeType(mime_type); 261 return http_info()->headers->GetMimeType(mime_type);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 return; 301 return;
302 } 302 }
303 303
304 // If multiple ranges are requested, we play dumb and 304 // If multiple ranges are requested, we play dumb and
305 // return the entire response with 200 OK. 305 // return the entire response with 200 OK.
306 if (ranges.size() == 1U) 306 if (ranges.size() == 1U)
307 range_requested_ = ranges[0]; 307 range_requested_ = ranges[0];
308 } 308 }
309 309
310 } // namespace appcache 310 } // namespace appcache
OLDNEW
« no previous file with comments | « webkit/appcache/appcache_update_job_unittest.cc ('k') | webkit/appcache/appcache_url_request_job_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698