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/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "base/thread_task_runner_handle.h" | 12 #include "base/thread_task_runner_handle.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 "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
16 #include "net/base/io_buffer.h" | 16 #include "net/base/io_buffer.h" |
17 #include "net/base/load_flags.h" | 17 #include "net/base/load_flags.h" |
18 #include "net/base/net_errors.h" | 18 #include "net/base/net_errors.h" |
19 #include "net/base/request_priority.h" | 19 #include "net/base/request_priority.h" |
20 #include "net/http/http_request_headers.h" | 20 #include "net/http/http_request_headers.h" |
21 #include "net/http/http_response_headers.h" | 21 #include "net/http/http_response_headers.h" |
22 #include "net/url_request/url_request_context.h" | 22 #include "net/url_request/url_request_context.h" |
| 23 #include "url/origin.h" |
23 | 24 |
24 namespace content { | 25 namespace content { |
25 | 26 |
26 namespace { | 27 namespace { |
27 | 28 |
28 const int kBufferSize = 32768; | 29 const int kBufferSize = 32768; |
29 const size_t kMaxConcurrentUrlFetches = 2; | 30 const size_t kMaxConcurrentUrlFetches = 2; |
30 const int kMax503Retries = 3; | 31 const int kMax503Retries = 3; |
31 | 32 |
32 std::string FormatUrlErrorMessage( | 33 std::string FormatUrlErrorMessage( |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 request_(job->service_->request_context() | 157 request_(job->service_->request_context() |
157 ->CreateRequest(url, net::DEFAULT_PRIORITY, this)), | 158 ->CreateRequest(url, net::DEFAULT_PRIORITY, this)), |
158 result_(UPDATE_OK), | 159 result_(UPDATE_OK), |
159 redirect_response_code_(-1) {} | 160 redirect_response_code_(-1) {} |
160 | 161 |
161 AppCacheUpdateJob::URLFetcher::~URLFetcher() { | 162 AppCacheUpdateJob::URLFetcher::~URLFetcher() { |
162 } | 163 } |
163 | 164 |
164 void AppCacheUpdateJob::URLFetcher::Start() { | 165 void AppCacheUpdateJob::URLFetcher::Start() { |
165 request_->set_first_party_for_cookies(job_->manifest_url_); | 166 request_->set_first_party_for_cookies(job_->manifest_url_); |
| 167 request_->set_initiator(url::Origin(job_->manifest_url_)); |
166 if (fetch_type_ == MANIFEST_FETCH && job_->doing_full_update_check_) | 168 if (fetch_type_ == MANIFEST_FETCH && job_->doing_full_update_check_) |
167 request_->SetLoadFlags(request_->load_flags() | net::LOAD_BYPASS_CACHE); | 169 request_->SetLoadFlags(request_->load_flags() | net::LOAD_BYPASS_CACHE); |
168 else if (existing_response_headers_.get()) | 170 else if (existing_response_headers_.get()) |
169 AddConditionalHeaders(existing_response_headers_.get()); | 171 AddConditionalHeaders(existing_response_headers_.get()); |
170 request_->Start(); | 172 request_->Start(); |
171 } | 173 } |
172 | 174 |
173 void AppCacheUpdateJob::URLFetcher::OnReceivedRedirect( | 175 void AppCacheUpdateJob::URLFetcher::OnReceivedRedirect( |
174 net::URLRequest* request, | 176 net::URLRequest* request, |
175 const net::RedirectInfo& redirect_info, | 177 const net::RedirectInfo& redirect_info, |
(...skipping 1531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1707 // on this object after we've posted a task to delete ourselves. | 1709 // on this object after we've posted a task to delete ourselves. |
1708 if (group_) { | 1710 if (group_) { |
1709 group_->SetUpdateAppCacheStatus(AppCacheGroup::IDLE); | 1711 group_->SetUpdateAppCacheStatus(AppCacheGroup::IDLE); |
1710 group_ = NULL; | 1712 group_ = NULL; |
1711 } | 1713 } |
1712 | 1714 |
1713 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 1715 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
1714 } | 1716 } |
1715 | 1717 |
1716 } // namespace content | 1718 } // namespace content |
OLD | NEW |