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

Side by Side Diff: content/browser/appcache/appcache_update_job.cc

Issue 1440593004: Make operators on scoped_ptr match the ones defined for std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptrequals: followupfix-after-rebase Created 5 years, 1 month 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
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 "content/browser/appcache/appcache_update_job.h" 5 #include "content/browser/appcache/appcache_update_job.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 request_->SetLoadFlags(request_->load_flags() | net::LOAD_BYPASS_CACHE); 167 request_->SetLoadFlags(request_->load_flags() | net::LOAD_BYPASS_CACHE);
168 else if (existing_response_headers_.get()) 168 else if (existing_response_headers_.get())
169 AddConditionalHeaders(existing_response_headers_.get()); 169 AddConditionalHeaders(existing_response_headers_.get());
170 request_->Start(); 170 request_->Start();
171 } 171 }
172 172
173 void AppCacheUpdateJob::URLFetcher::OnReceivedRedirect( 173 void AppCacheUpdateJob::URLFetcher::OnReceivedRedirect(
174 net::URLRequest* request, 174 net::URLRequest* request,
175 const net::RedirectInfo& redirect_info, 175 const net::RedirectInfo& redirect_info,
176 bool* defer_redirect) { 176 bool* defer_redirect) {
177 DCHECK(request_ == request); 177 DCHECK_EQ(request_.get(), request);
178 // Redirect is not allowed by the update process. 178 // Redirect is not allowed by the update process.
179 job_->MadeProgress(); 179 job_->MadeProgress();
180 redirect_response_code_ = request->GetResponseCode(); 180 redirect_response_code_ = request->GetResponseCode();
181 request->Cancel(); 181 request->Cancel();
182 result_ = REDIRECT_ERROR; 182 result_ = REDIRECT_ERROR;
183 OnResponseCompleted(); 183 OnResponseCompleted();
184 } 184 }
185 185
186 void AppCacheUpdateJob::URLFetcher::OnResponseStarted( 186 void AppCacheUpdateJob::URLFetcher::OnResponseStarted(
187 net::URLRequest *request) { 187 net::URLRequest *request) {
188 DCHECK(request == request_); 188 DCHECK_EQ(request_.get(), request);
189 int response_code = -1; 189 int response_code = -1;
190 if (request->status().is_success()) { 190 if (request->status().is_success()) {
191 response_code = request->GetResponseCode(); 191 response_code = request->GetResponseCode();
192 job_->MadeProgress(); 192 job_->MadeProgress();
193 } 193 }
194 194
195 if ((response_code / 100) != 2) { 195 if ((response_code / 100) != 2) {
196 if (response_code > 0) 196 if (response_code > 0)
197 result_ = SERVER_ERROR; 197 result_ = SERVER_ERROR;
198 else 198 else
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 response_writer_->WriteInfo( 237 response_writer_->WriteInfo(
238 io_buffer.get(), 238 io_buffer.get(),
239 base::Bind(&URLFetcher::OnWriteComplete, base::Unretained(this))); 239 base::Bind(&URLFetcher::OnWriteComplete, base::Unretained(this)));
240 } else { 240 } else {
241 ReadResponseData(); 241 ReadResponseData();
242 } 242 }
243 } 243 }
244 244
245 void AppCacheUpdateJob::URLFetcher::OnReadCompleted( 245 void AppCacheUpdateJob::URLFetcher::OnReadCompleted(
246 net::URLRequest* request, int bytes_read) { 246 net::URLRequest* request, int bytes_read) {
247 DCHECK(request_ == request); 247 DCHECK_EQ(request_.get(), request);
248 bool data_consumed = true; 248 bool data_consumed = true;
249 if (request->status().is_success() && bytes_read > 0) { 249 if (request->status().is_success() && bytes_read > 0) {
250 job_->MadeProgress(); 250 job_->MadeProgress();
251 data_consumed = ConsumeResponseData(bytes_read); 251 data_consumed = ConsumeResponseData(bytes_read);
252 if (data_consumed) { 252 if (data_consumed) {
253 bytes_read = 0; 253 bytes_read = 0;
254 while (request->Read(buffer_.get(), kBufferSize, &bytes_read)) { 254 while (request->Read(buffer_.get(), kBufferSize, &bytes_read)) {
255 if (bytes_read > 0) { 255 if (bytes_read > 0) {
256 data_consumed = ConsumeResponseData(bytes_read); 256 data_consumed = ConsumeResponseData(bytes_read);
257 if (!data_consumed) 257 if (!data_consumed)
258 break; // wait for async data processing, then read more 258 break; // wait for async data processing, then read more
259 } else { 259 } else {
260 break; 260 break;
261 } 261 }
262 } 262 }
263 } 263 }
264 } 264 }
265 if (data_consumed && !request->status().is_io_pending()) { 265 if (data_consumed && !request->status().is_io_pending()) {
266 DCHECK_EQ(UPDATE_OK, result_); 266 DCHECK_EQ(UPDATE_OK, result_);
267 OnResponseCompleted(); 267 OnResponseCompleted();
268 } 268 }
269 } 269 }
270 270
271 void AppCacheUpdateJob::URLFetcher::AddConditionalHeaders( 271 void AppCacheUpdateJob::URLFetcher::AddConditionalHeaders(
272 const net::HttpResponseHeaders* headers) { 272 const net::HttpResponseHeaders* headers) {
273 DCHECK(request_.get() && headers); 273 DCHECK(request_);
274 DCHECK(headers);
274 net::HttpRequestHeaders extra_headers; 275 net::HttpRequestHeaders extra_headers;
275 276
276 // Add If-Modified-Since header if response info has Last-Modified header. 277 // Add If-Modified-Since header if response info has Last-Modified header.
277 const std::string last_modified = "Last-Modified"; 278 const std::string last_modified = "Last-Modified";
278 std::string last_modified_value; 279 std::string last_modified_value;
279 headers->EnumerateHeader(NULL, last_modified, &last_modified_value); 280 headers->EnumerateHeader(NULL, last_modified, &last_modified_value);
280 if (!last_modified_value.empty()) { 281 if (!last_modified_value.empty()) {
281 extra_headers.SetHeader(net::HttpRequestHeaders::kIfModifiedSince, 282 extra_headers.SetHeader(net::HttpRequestHeaders::kIfModifiedSince,
282 last_modified_value); 283 last_modified_value);
283 } 284 }
(...skipping 1414 matching lines...) Expand 10 before | Expand all | Expand 10 after
1698 // on this object after we've posted a task to delete ourselves. 1699 // on this object after we've posted a task to delete ourselves.
1699 if (group_) { 1700 if (group_) {
1700 group_->SetUpdateAppCacheStatus(AppCacheGroup::IDLE); 1701 group_->SetUpdateAppCacheStatus(AppCacheGroup::IDLE);
1701 group_ = NULL; 1702 group_ = NULL;
1702 } 1703 }
1703 1704
1704 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); 1705 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
1705 } 1706 }
1706 1707
1707 } // namespace content 1708 } // namespace content
OLDNEW
« no previous file with comments | « components/sync_driver/profile_sync_auth_provider.cc ('k') | content/browser/frame_host/render_frame_host_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698