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 return ( |
| 27 proxy_server.Equals(net::HostPortPair("proxy.googlezip.net", 443)) || |
| 28 proxy_server.Equals(net::HostPortPair("compress.googlezip.net", 80)) || |
| 29 proxy_server.Equals(net::HostPortPair("proxy-dev.googlezip.net", 80))); |
| 30 } |
| 31 } // namspace |
| 32 |
23 namespace content { | 33 namespace content { |
24 | 34 |
25 static const int kBufferSize = 32768; | 35 static const int kBufferSize = 32768; |
26 static const size_t kMaxConcurrentUrlFetches = 2; | 36 static const size_t kMaxConcurrentUrlFetches = 2; |
27 static const int kMax503Retries = 3; | 37 static const int kMax503Retries = 3; |
28 | 38 |
29 static std::string FormatUrlErrorMessage( | 39 static std::string FormatUrlErrorMessage( |
30 const char* format, const GURL& url, | 40 const char* format, const GURL& url, |
31 AppCacheUpdateJob::ResultType error, | 41 AppCacheUpdateJob::ResultType error, |
32 int response_code) { | 42 int response_code) { |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 if (existing_response_headers_.get()) | 147 if (existing_response_headers_.get()) |
138 AddConditionalHeaders(existing_response_headers_.get()); | 148 AddConditionalHeaders(existing_response_headers_.get()); |
139 request_->Start(); | 149 request_->Start(); |
140 } | 150 } |
141 | 151 |
142 void AppCacheUpdateJob::URLFetcher::OnReceivedRedirect( | 152 void AppCacheUpdateJob::URLFetcher::OnReceivedRedirect( |
143 net::URLRequest* request, | 153 net::URLRequest* request, |
144 const net::RedirectInfo& redirect_info, | 154 const net::RedirectInfo& redirect_info, |
145 bool* defer_redirect) { | 155 bool* defer_redirect) { |
146 DCHECK(request_ == request); | 156 DCHECK(request_ == request); |
| 157 // TODO(bengr): Remove this special case logic when crbug.com/429505 is |
| 158 // resolved. Until then, the data reduction proxy client logic uses the |
| 159 // redirect mechanism to resend requests over a direct connection when |
| 160 // the proxy instructs it to do so. The redirect is to the same location |
| 161 // as the original URL. |
| 162 if ((request->load_flags() & net::LOAD_BYPASS_PROXY) && |
| 163 IsDataReductionProxy(request->proxy_server())) { |
| 164 DCHECK_EQ(request->original_url(), request->url()); |
| 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 |