Chromium Code Reviews| 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/host_port_pair.h" | |
| 15 #include "net/base/io_buffer.h" | 16 #include "net/base/io_buffer.h" |
| 16 #include "net/base/load_flags.h" | 17 #include "net/base/load_flags.h" |
| 17 #include "net/base/net_errors.h" | 18 #include "net/base/net_errors.h" |
| 18 #include "net/base/request_priority.h" | 19 #include "net/base/request_priority.h" |
| 19 #include "net/http/http_request_headers.h" | 20 #include "net/http/http_request_headers.h" |
| 20 #include "net/http/http_response_headers.h" | 21 #include "net/http/http_response_headers.h" |
| 21 #include "net/url_request/url_request_context.h" | 22 #include "net/url_request/url_request_context.h" |
| 22 | 23 |
| 24 namespace { | |
| 25 bool IsDataReductionProxy(const net::HostPortPair& proxy_server) { | |
| 26 if (proxy_server.Equals(net::HostPortPair("proxy.googlezip.net", 443)) || | |
| 27 proxy_server.Equals(net::HostPortPair("compress.googlezip.net", 80)) || | |
| 28 proxy_server.Equals(net::HostPortPair("proxy-dev.googlezip.net", 80))) { | |
|
michaeln1
2014/11/03 23:11:12
i hope this isn't here for long
bengr
2014/11/03 23:48:32
Acknowledged.
| |
| 29 return true; | |
| 30 } | |
| 31 return false; | |
| 32 } | |
| 33 } // namspace | |
| 34 | |
| 23 namespace content { | 35 namespace content { |
| 24 | 36 |
| 25 static const int kBufferSize = 32768; | 37 static const int kBufferSize = 32768; |
| 26 static const size_t kMaxConcurrentUrlFetches = 2; | 38 static const size_t kMaxConcurrentUrlFetches = 2; |
| 27 static const int kMax503Retries = 3; | 39 static const int kMax503Retries = 3; |
| 28 | 40 |
| 29 static std::string FormatUrlErrorMessage( | 41 static std::string FormatUrlErrorMessage( |
| 30 const char* format, const GURL& url, | 42 const char* format, const GURL& url, |
| 31 AppCacheUpdateJob::ResultType error, | 43 AppCacheUpdateJob::ResultType error, |
| 32 int response_code) { | 44 int response_code) { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 if (existing_response_headers_.get()) | 149 if (existing_response_headers_.get()) |
| 138 AddConditionalHeaders(existing_response_headers_.get()); | 150 AddConditionalHeaders(existing_response_headers_.get()); |
| 139 request_->Start(); | 151 request_->Start(); |
| 140 } | 152 } |
| 141 | 153 |
| 142 void AppCacheUpdateJob::URLFetcher::OnReceivedRedirect( | 154 void AppCacheUpdateJob::URLFetcher::OnReceivedRedirect( |
| 143 net::URLRequest* request, | 155 net::URLRequest* request, |
| 144 const net::RedirectInfo& redirect_info, | 156 const net::RedirectInfo& redirect_info, |
| 145 bool* defer_redirect) { | 157 bool* defer_redirect) { |
| 146 DCHECK(request_ == request); | 158 DCHECK(request_ == request); |
| 159 // TODO(bengr): Remove this special case logic when crbug.com/429505 is | |
| 160 // resolved. Until then, the data reduction proxy client logic uses the | |
| 161 // redirect mechanism to resend requests over a direct connection when | |
| 162 // the proxy instructs it to do so. | |
| 163 if ((request->load_flags() & net::LOAD_BYPASS_PROXY) && | |
|
michaeln
2014/11/03 21:37:20
Is the 'redirect' to the same url in this case?
bengr
2014/11/03 22:58:24
Yes
michaeln1
2014/11/03 23:11:12
Can you add that info to the comment and it'd be g
bengr
2014/11/03 23:48:32
Done.
| |
| 164 IsDataReductionProxy(request->proxy_server())) { | |
| 165 return; | |
| 166 } | |
| 147 // Redirect is not allowed by the update process. | 167 // Redirect is not allowed by the update process. |
| 148 job_->MadeProgress(); | 168 job_->MadeProgress(); |
| 149 redirect_response_code_ = request->GetResponseCode(); | 169 redirect_response_code_ = request->GetResponseCode(); |
| 150 request->Cancel(); | 170 request->Cancel(); |
| 151 result_ = REDIRECT_ERROR; | 171 result_ = REDIRECT_ERROR; |
| 152 OnResponseCompleted(); | 172 OnResponseCompleted(); |
| 153 } | 173 } |
| 154 | 174 |
| 155 void AppCacheUpdateJob::URLFetcher::OnResponseStarted( | 175 void AppCacheUpdateJob::URLFetcher::OnResponseStarted( |
| 156 net::URLRequest *request) { | 176 net::URLRequest *request) { |
| (...skipping 1450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1607 | 1627 |
| 1608 // Break the connection with the group so the group cannot call delete | 1628 // Break the connection with the group so the group cannot call delete |
| 1609 // on this object after we've posted a task to delete ourselves. | 1629 // on this object after we've posted a task to delete ourselves. |
| 1610 group_->SetUpdateAppCacheStatus(AppCacheGroup::IDLE); | 1630 group_->SetUpdateAppCacheStatus(AppCacheGroup::IDLE); |
| 1611 group_ = NULL; | 1631 group_ = NULL; |
| 1612 | 1632 |
| 1613 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 1633 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| 1614 } | 1634 } |
| 1615 | 1635 |
| 1616 } // namespace content | 1636 } // namespace content |
| OLD | NEW |