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/profiler/scoped_tracker.h" |
11 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
12 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
13 #include "content/browser/appcache/appcache_group.h" | 14 #include "content/browser/appcache/appcache_group.h" |
14 #include "content/browser/appcache/appcache_histograms.h" | 15 #include "content/browser/appcache/appcache_histograms.h" |
15 #include "net/base/host_port_pair.h" | 16 #include "net/base/host_port_pair.h" |
16 #include "net/base/io_buffer.h" | 17 #include "net/base/io_buffer.h" |
17 #include "net/base/load_flags.h" | 18 #include "net/base/load_flags.h" |
18 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
19 #include "net/base/request_priority.h" | 20 #include "net/base/request_priority.h" |
20 #include "net/http/http_request_headers.h" | 21 #include "net/http/http_request_headers.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 // Redirect is not allowed by the update process. | 168 // Redirect is not allowed by the update process. |
168 job_->MadeProgress(); | 169 job_->MadeProgress(); |
169 redirect_response_code_ = request->GetResponseCode(); | 170 redirect_response_code_ = request->GetResponseCode(); |
170 request->Cancel(); | 171 request->Cancel(); |
171 result_ = REDIRECT_ERROR; | 172 result_ = REDIRECT_ERROR; |
172 OnResponseCompleted(); | 173 OnResponseCompleted(); |
173 } | 174 } |
174 | 175 |
175 void AppCacheUpdateJob::URLFetcher::OnResponseStarted( | 176 void AppCacheUpdateJob::URLFetcher::OnResponseStarted( |
176 net::URLRequest *request) { | 177 net::URLRequest *request) { |
| 178 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. |
| 179 tracked_objects::ScopedTracker tracking_profile( |
| 180 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 181 "422516 AppCacheUpdateJob::URLFetcher::OnResponseStarted")); |
| 182 |
177 DCHECK(request == request_); | 183 DCHECK(request == request_); |
178 int response_code = -1; | 184 int response_code = -1; |
179 if (request->status().is_success()) { | 185 if (request->status().is_success()) { |
180 response_code = request->GetResponseCode(); | 186 response_code = request->GetResponseCode(); |
181 job_->MadeProgress(); | 187 job_->MadeProgress(); |
182 } | 188 } |
183 | 189 |
184 if ((response_code / 100) != 2) { | 190 if ((response_code / 100) != 2) { |
185 if (response_code > 0) | 191 if (response_code > 0) |
186 result_ = SERVER_ERROR; | 192 result_ = SERVER_ERROR; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 response_writer_->WriteInfo( | 227 response_writer_->WriteInfo( |
222 io_buffer.get(), | 228 io_buffer.get(), |
223 base::Bind(&URLFetcher::OnWriteComplete, base::Unretained(this))); | 229 base::Bind(&URLFetcher::OnWriteComplete, base::Unretained(this))); |
224 } else { | 230 } else { |
225 ReadResponseData(); | 231 ReadResponseData(); |
226 } | 232 } |
227 } | 233 } |
228 | 234 |
229 void AppCacheUpdateJob::URLFetcher::OnReadCompleted( | 235 void AppCacheUpdateJob::URLFetcher::OnReadCompleted( |
230 net::URLRequest* request, int bytes_read) { | 236 net::URLRequest* request, int bytes_read) { |
| 237 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. |
| 238 tracked_objects::ScopedTracker tracking_profile( |
| 239 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 240 "422516 AppCacheUpdateJob::URLFetcher::OnReadCompleted")); |
| 241 |
231 DCHECK(request_ == request); | 242 DCHECK(request_ == request); |
232 bool data_consumed = true; | 243 bool data_consumed = true; |
233 if (request->status().is_success() && bytes_read > 0) { | 244 if (request->status().is_success() && bytes_read > 0) { |
234 job_->MadeProgress(); | 245 job_->MadeProgress(); |
235 data_consumed = ConsumeResponseData(bytes_read); | 246 data_consumed = ConsumeResponseData(bytes_read); |
236 if (data_consumed) { | 247 if (data_consumed) { |
237 bytes_read = 0; | 248 bytes_read = 0; |
238 while (request->Read(buffer_.get(), kBufferSize, &bytes_read)) { | 249 while (request->Read(buffer_.get(), kBufferSize, &bytes_read)) { |
239 if (bytes_read > 0) { | 250 if (bytes_read > 0) { |
240 data_consumed = ConsumeResponseData(bytes_read); | 251 data_consumed = ConsumeResponseData(bytes_read); |
(...skipping 1386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1627 | 1638 |
1628 // Break the connection with the group so the group cannot call delete | 1639 // Break the connection with the group so the group cannot call delete |
1629 // on this object after we've posted a task to delete ourselves. | 1640 // on this object after we've posted a task to delete ourselves. |
1630 group_->SetUpdateAppCacheStatus(AppCacheGroup::IDLE); | 1641 group_->SetUpdateAppCacheStatus(AppCacheGroup::IDLE); |
1631 group_ = NULL; | 1642 group_ = NULL; |
1632 | 1643 |
1633 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 1644 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
1634 } | 1645 } |
1635 | 1646 |
1636 } // namespace content | 1647 } // namespace content |
OLD | NEW |