| OLD | NEW |
| 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/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "content/browser/appcache/appcache_group.h" | 13 #include "content/browser/appcache/appcache_group.h" |
| 14 #include "content/browser/appcache/appcache_histograms.h" | 14 #include "content/browser/appcache/appcache_histograms.h" |
| 15 #include "net/base/io_buffer.h" | 15 #include "net/base/io_buffer.h" |
| 16 #include "net/base/load_flags.h" | 16 #include "net/base/load_flags.h" |
| 17 #include "net/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
| 18 #include "net/base/request_priority.h" | 18 #include "net/base/request_priority.h" |
| 19 #include "net/http/http_request_headers.h" | 19 #include "net/http/http_request_headers.h" |
| 20 #include "net/http/http_response_headers.h" | 20 #include "net/http/http_response_headers.h" |
| 21 #include "net/ssl/ssl_info.h" |
| 21 #include "net/url_request/url_request_context.h" | 22 #include "net/url_request/url_request_context.h" |
| 22 | 23 |
| 23 namespace content { | 24 namespace content { |
| 24 | 25 |
| 25 static const int kBufferSize = 32768; | 26 static const int kBufferSize = 32768; |
| 26 static const size_t kMaxConcurrentUrlFetches = 2; | 27 static const size_t kMaxConcurrentUrlFetches = 2; |
| 27 static const int kMax503Retries = 3; | 28 static const int kMax503Retries = 3; |
| 28 | 29 |
| 29 static std::string FormatUrlErrorMessage( | 30 static std::string FormatUrlErrorMessage( |
| 30 const char* format, const GURL& url, | 31 const char* format, const GURL& url, |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 } | 223 } |
| 223 } | 224 } |
| 224 } | 225 } |
| 225 } | 226 } |
| 226 if (data_consumed && !request->status().is_io_pending()) { | 227 if (data_consumed && !request->status().is_io_pending()) { |
| 227 DCHECK_EQ(UPDATE_OK, result_); | 228 DCHECK_EQ(UPDATE_OK, result_); |
| 228 OnResponseCompleted(); | 229 OnResponseCompleted(); |
| 229 } | 230 } |
| 230 } | 231 } |
| 231 | 232 |
| 233 void AppCacheUpdateJob::URLFetcher::OnSSLCertificateError( |
| 234 net::URLRequest* request, |
| 235 const net::SSLInfo& ssl_info, |
| 236 bool fatal) { |
| 237 DCHECK(request_ == request); |
| 238 request->Cancel(); |
| 239 } |
| 240 |
| 241 |
| 232 void AppCacheUpdateJob::URLFetcher::AddConditionalHeaders( | 242 void AppCacheUpdateJob::URLFetcher::AddConditionalHeaders( |
| 233 const net::HttpResponseHeaders* headers) { | 243 const net::HttpResponseHeaders* headers) { |
| 234 DCHECK(request_.get() && headers); | 244 DCHECK(request_.get() && headers); |
| 235 net::HttpRequestHeaders extra_headers; | 245 net::HttpRequestHeaders extra_headers; |
| 236 | 246 |
| 237 // Add If-Modified-Since header if response info has Last-Modified header. | 247 // Add If-Modified-Since header if response info has Last-Modified header. |
| 238 const std::string last_modified = "Last-Modified"; | 248 const std::string last_modified = "Last-Modified"; |
| 239 std::string last_modified_value; | 249 std::string last_modified_value; |
| 240 headers->EnumerateHeader(NULL, last_modified, &last_modified_value); | 250 headers->EnumerateHeader(NULL, last_modified, &last_modified_value); |
| 241 if (!last_modified_value.empty()) { | 251 if (!last_modified_value.empty()) { |
| (...skipping 1362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1604 | 1614 |
| 1605 // Break the connection with the group so the group cannot call delete | 1615 // Break the connection with the group so the group cannot call delete |
| 1606 // on this object after we've posted a task to delete ourselves. | 1616 // on this object after we've posted a task to delete ourselves. |
| 1607 group_->SetUpdateAppCacheStatus(AppCacheGroup::IDLE); | 1617 group_->SetUpdateAppCacheStatus(AppCacheGroup::IDLE); |
| 1608 group_ = NULL; | 1618 group_ = NULL; |
| 1609 | 1619 |
| 1610 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 1620 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| 1611 } | 1621 } |
| 1612 | 1622 |
| 1613 } // namespace content | 1623 } // namespace content |
| OLD | NEW |