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 "net/url_request/url_request.h" | 5 #include "net/url_request/url_request.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/callback.h" | 9 #include "base/callback.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/debug/alias.h" |
| 12 #include "base/debug/dump_without_crashing.h" |
11 #include "base/debug/stack_trace.h" | 13 #include "base/debug/stack_trace.h" |
12 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
13 #include "base/memory/singleton.h" | 15 #include "base/memory/singleton.h" |
14 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
15 #include "base/profiler/scoped_tracker.h" | 17 #include "base/profiler/scoped_tracker.h" |
| 18 #include "base/rand_util.h" |
16 #include "base/stl_util.h" | 19 #include "base/stl_util.h" |
17 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
18 #include "base/synchronization/lock.h" | 21 #include "base/synchronization/lock.h" |
19 #include "base/values.h" | 22 #include "base/values.h" |
20 #include "net/base/auth.h" | 23 #include "net/base/auth.h" |
21 #include "net/base/chunked_upload_data_stream.h" | 24 #include "net/base/chunked_upload_data_stream.h" |
22 #include "net/base/host_port_pair.h" | 25 #include "net/base/host_port_pair.h" |
23 #include "net/base/load_flags.h" | 26 #include "net/base/load_flags.h" |
24 #include "net/base/load_timing_info.h" | 27 #include "net/base/load_timing_info.h" |
25 #include "net/base/net_errors.h" | 28 #include "net/base/net_errors.h" |
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 // This should only be called on a started request. | 678 // This should only be called on a started request. |
676 if (!is_pending_ || !job_.get() || job_->has_response_started()) { | 679 if (!is_pending_ || !job_.get() || job_->has_response_started()) { |
677 NOTREACHED(); | 680 NOTREACHED(); |
678 return; | 681 return; |
679 } | 682 } |
680 DoCancel(error, ssl_info); | 683 DoCancel(error, ssl_info); |
681 } | 684 } |
682 | 685 |
683 void URLRequest::DoCancel(int error, const SSLInfo& ssl_info) { | 686 void URLRequest::DoCancel(int error, const SSLInfo& ssl_info) { |
684 DCHECK(error < 0); | 687 DCHECK(error < 0); |
| 688 // ~500,000 ERR_ABORTED < 100ms in Canary channel a day. Sample .01% to get |
| 689 // ~50 reports a day. |
| 690 // TODO(csharrison) Remove this code when crbug.com/557430 is resolved. |
| 691 int64 request_time = |
| 692 (base::TimeTicks::Now() - creation_time_).InMilliseconds(); |
| 693 if (error == ERR_ABORTED && request_time <= 100 && |
| 694 load_flags_ & LOAD_MAIN_FRAME && base::RandDouble() < .0001) { |
| 695 static int dump_times = 0; |
| 696 if (dump_times < 5) { |
| 697 char url_copy[256] = {0}; |
| 698 strncpy(url_copy, url().spec().c_str(), sizeof(url_copy)); |
| 699 base::debug::Alias(&url_copy); |
| 700 base::debug::Alias(&request_time); |
| 701 base::debug::DumpWithoutCrashing(); |
| 702 dump_times++; |
| 703 } |
| 704 } |
685 // If cancelled while calling a delegate, clear delegate info. | 705 // If cancelled while calling a delegate, clear delegate info. |
686 if (calling_delegate_) { | 706 if (calling_delegate_) { |
687 LogUnblocked(); | 707 LogUnblocked(); |
688 OnCallToDelegateComplete(); | 708 OnCallToDelegateComplete(); |
689 } | 709 } |
690 | 710 |
691 // If the URL request already has an error status, then canceling is a no-op. | 711 // If the URL request already has an error status, then canceling is a no-op. |
692 // Plus, we don't want to change the error status once it has been set. | 712 // Plus, we don't want to change the error status once it has been set. |
693 if (status_.is_success()) { | 713 if (status_.is_success()) { |
694 status_ = URLRequestStatus(URLRequestStatus::CANCELED, error); | 714 status_ = URLRequestStatus(URLRequestStatus::CANCELED, error); |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1195 } | 1215 } |
1196 | 1216 |
1197 void URLRequest::GetConnectionAttempts(ConnectionAttempts* out) const { | 1217 void URLRequest::GetConnectionAttempts(ConnectionAttempts* out) const { |
1198 if (job_) | 1218 if (job_) |
1199 job_->GetConnectionAttempts(out); | 1219 job_->GetConnectionAttempts(out); |
1200 else | 1220 else |
1201 out->clear(); | 1221 out->clear(); |
1202 } | 1222 } |
1203 | 1223 |
1204 } // namespace net | 1224 } // namespace net |
OLD | NEW |