OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ios/chrome/browser/net/ios_chrome_network_delegate.h" | 5 #include "ios/chrome/browser/net/ios_chrome_network_delegate.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 | 8 |
9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
10 #include "base/debug/alias.h" | 10 #include "base/debug/alias.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 if (!target_url.SchemeIsHTTPOrHTTPS()) | 44 if (!target_url.SchemeIsHTTPOrHTTPS()) |
45 return; | 45 return; |
46 web::WebThread::PostTask(web::WebThread::UI, FROM_HERE, | 46 web::WebThread::PostTask(web::WebThread::UI, FROM_HERE, |
47 base::Bind(&ReportInvalidReferrerSendOnUI)); | 47 base::Bind(&ReportInvalidReferrerSendOnUI)); |
48 base::debug::DumpWithoutCrashing(); | 48 base::debug::DumpWithoutCrashing(); |
49 NOTREACHED(); | 49 NOTREACHED(); |
50 } | 50 } |
51 | 51 |
52 // Record network errors that HTTP requests complete with, including OK and | 52 // Record network errors that HTTP requests complete with, including OK and |
53 // ABORTED. | 53 // ABORTED. |
54 void RecordNetworkErrorHistograms(const net::URLRequest* request) { | 54 void RecordNetworkErrorHistograms(const net::URLRequest* request, |
| 55 int net_error) { |
55 if (request->url().SchemeIs("http")) { | 56 if (request->url().SchemeIs("http")) { |
56 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.HttpRequestCompletionErrorCodes", | 57 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.HttpRequestCompletionErrorCodes", |
57 std::abs(request->status().error())); | 58 std::abs(net_error)); |
58 | 59 |
59 if (request->load_flags() & net::LOAD_MAIN_FRAME_DEPRECATED) { | 60 if (request->load_flags() & net::LOAD_MAIN_FRAME_DEPRECATED) { |
60 UMA_HISTOGRAM_SPARSE_SLOWLY( | 61 UMA_HISTOGRAM_SPARSE_SLOWLY( |
61 "Net.HttpRequestCompletionErrorCodes.MainFrame", | 62 "Net.HttpRequestCompletionErrorCodes.MainFrame", std::abs(net_error)); |
62 std::abs(request->status().error())); | |
63 } | 63 } |
64 } | 64 } |
65 } | 65 } |
66 | 66 |
67 } // namespace | 67 } // namespace |
68 | 68 |
69 IOSChromeNetworkDelegate::IOSChromeNetworkDelegate() | 69 IOSChromeNetworkDelegate::IOSChromeNetworkDelegate() |
70 : enable_do_not_track_(nullptr) {} | 70 : enable_do_not_track_(nullptr) {} |
71 | 71 |
72 IOSChromeNetworkDelegate::~IOSChromeNetworkDelegate() {} | 72 IOSChromeNetworkDelegate::~IOSChromeNetworkDelegate() {} |
(...skipping 29 matching lines...) Expand all Loading... |
102 | 102 |
103 // TODO(mmenke): Remove ScopedTracker below once crbug.com/456327 is fixed. | 103 // TODO(mmenke): Remove ScopedTracker below once crbug.com/456327 is fixed. |
104 tracked_objects::ScopedTracker tracking_profile4( | 104 tracked_objects::ScopedTracker tracking_profile4( |
105 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 105 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
106 "456327 URLRequest::IOSChromeNetworkDelegate::OnBeforeURLRequest 4")); | 106 "456327 URLRequest::IOSChromeNetworkDelegate::OnBeforeURLRequest 4")); |
107 | 107 |
108 return net::OK; | 108 return net::OK; |
109 } | 109 } |
110 | 110 |
111 void IOSChromeNetworkDelegate::OnCompleted(net::URLRequest* request, | 111 void IOSChromeNetworkDelegate::OnCompleted(net::URLRequest* request, |
112 bool started) { | 112 bool started, |
113 RecordNetworkErrorHistograms(request); | 113 int net_error) { |
| 114 RecordNetworkErrorHistograms(request, net_error); |
114 } | 115 } |
115 | 116 |
116 net::NetworkDelegate::AuthRequiredResponse | 117 net::NetworkDelegate::AuthRequiredResponse |
117 IOSChromeNetworkDelegate::OnAuthRequired( | 118 IOSChromeNetworkDelegate::OnAuthRequired( |
118 net::URLRequest* request, | 119 net::URLRequest* request, |
119 const net::AuthChallengeInfo& auth_info, | 120 const net::AuthChallengeInfo& auth_info, |
120 const AuthCallback& callback, | 121 const AuthCallback& callback, |
121 net::AuthCredentials* credentials) { | 122 net::AuthCredentials* credentials) { |
122 return net::NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION; | 123 return net::NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION; |
123 } | 124 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 } | 167 } |
167 | 168 |
168 bool IOSChromeNetworkDelegate:: | 169 bool IOSChromeNetworkDelegate:: |
169 OnCancelURLRequestWithPolicyViolatingReferrerHeader( | 170 OnCancelURLRequestWithPolicyViolatingReferrerHeader( |
170 const net::URLRequest& request, | 171 const net::URLRequest& request, |
171 const GURL& target_url, | 172 const GURL& target_url, |
172 const GURL& referrer_url) const { | 173 const GURL& referrer_url) const { |
173 ReportInvalidReferrerSend(target_url, referrer_url); | 174 ReportInvalidReferrerSend(target_url, referrer_url); |
174 return true; | 175 return true; |
175 } | 176 } |
OLD | NEW |