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/base/network_delegate.h" | 5 #include "net/base/network_delegate.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/profiler/scoped_tracker.h" | 8 #include "base/profiler/scoped_tracker.h" |
9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
10 #include "net/base/load_flags.h" | 10 #include "net/base/load_flags.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 DCHECK(CalledOnValidThread()); | 71 DCHECK(CalledOnValidThread()); |
72 DCHECK(original_response_headers); | 72 DCHECK(original_response_headers); |
73 DCHECK(!callback.is_null()); | 73 DCHECK(!callback.is_null()); |
74 return OnHeadersReceived(request, | 74 return OnHeadersReceived(request, |
75 callback, | 75 callback, |
76 original_response_headers, | 76 original_response_headers, |
77 override_response_headers, | 77 override_response_headers, |
78 allowed_unsafe_redirect_url); | 78 allowed_unsafe_redirect_url); |
79 } | 79 } |
80 | 80 |
81 void NetworkDelegate::NotifyResponseStarted(URLRequest* request) { | 81 void NetworkDelegate::NotifyResponseStarted(URLRequest* request, |
| 82 int net_error) { |
82 DCHECK(CalledOnValidThread()); | 83 DCHECK(CalledOnValidThread()); |
83 DCHECK(request); | 84 DCHECK(request); |
84 OnResponseStarted(request); | 85 |
| 86 OnResponseStarted(request, net_error); |
85 } | 87 } |
86 | 88 |
87 void NetworkDelegate::NotifyNetworkBytesReceived(URLRequest* request, | 89 void NetworkDelegate::NotifyNetworkBytesReceived(URLRequest* request, |
88 int64_t bytes_received) { | 90 int64_t bytes_received) { |
89 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), | 91 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), |
90 "NetworkDelegate::NotifyNetworkBytesReceived"); | 92 "NetworkDelegate::NotifyNetworkBytesReceived"); |
91 DCHECK(CalledOnValidThread()); | 93 DCHECK(CalledOnValidThread()); |
92 DCHECK_GT(bytes_received, 0); | 94 DCHECK_GT(bytes_received, 0); |
93 OnNetworkBytesReceived(request, bytes_received); | 95 OnNetworkBytesReceived(request, bytes_received); |
94 } | 96 } |
95 | 97 |
96 void NetworkDelegate::NotifyNetworkBytesSent(URLRequest* request, | 98 void NetworkDelegate::NotifyNetworkBytesSent(URLRequest* request, |
97 int64_t bytes_sent) { | 99 int64_t bytes_sent) { |
98 DCHECK(CalledOnValidThread()); | 100 DCHECK(CalledOnValidThread()); |
99 DCHECK_GT(bytes_sent, 0); | 101 DCHECK_GT(bytes_sent, 0); |
100 OnNetworkBytesSent(request, bytes_sent); | 102 OnNetworkBytesSent(request, bytes_sent); |
101 } | 103 } |
102 | 104 |
103 void NetworkDelegate::NotifyBeforeRedirect(URLRequest* request, | 105 void NetworkDelegate::NotifyBeforeRedirect(URLRequest* request, |
104 const GURL& new_location) { | 106 const GURL& new_location) { |
105 DCHECK(CalledOnValidThread()); | 107 DCHECK(CalledOnValidThread()); |
106 DCHECK(request); | 108 DCHECK(request); |
107 OnBeforeRedirect(request, new_location); | 109 OnBeforeRedirect(request, new_location); |
108 } | 110 } |
109 | 111 |
110 void NetworkDelegate::NotifyCompleted(URLRequest* request, bool started) { | 112 void NetworkDelegate::NotifyCompleted(URLRequest* request, |
| 113 bool started, |
| 114 int net_error) { |
111 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), | 115 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), |
112 "NetworkDelegate::NotifyCompleted"); | 116 "NetworkDelegate::NotifyCompleted"); |
113 DCHECK(CalledOnValidThread()); | 117 DCHECK(CalledOnValidThread()); |
114 DCHECK(request); | 118 DCHECK(request); |
115 // TODO(cbentzel): Remove ScopedTracker below once crbug.com/475753 is fixed. | 119 // TODO(cbentzel): Remove ScopedTracker below once crbug.com/475753 is fixed. |
116 tracked_objects::ScopedTracker tracking_profile( | 120 tracked_objects::ScopedTracker tracking_profile( |
117 FROM_HERE_WITH_EXPLICIT_FUNCTION("475753 NetworkDelegate::OnCompleted")); | 121 FROM_HERE_WITH_EXPLICIT_FUNCTION("475753 NetworkDelegate::OnCompleted")); |
118 OnCompleted(request, started); | 122 |
| 123 OnCompleted(request, started, net_error); |
119 } | 124 } |
120 | 125 |
121 void NetworkDelegate::NotifyURLRequestDestroyed(URLRequest* request) { | 126 void NetworkDelegate::NotifyURLRequestDestroyed(URLRequest* request) { |
122 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), | 127 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), |
123 "NetworkDelegate::NotifyURLRequestDestroyed"); | 128 "NetworkDelegate::NotifyURLRequestDestroyed"); |
124 DCHECK(CalledOnValidThread()); | 129 DCHECK(CalledOnValidThread()); |
125 DCHECK(request); | 130 DCHECK(request); |
126 OnURLRequestDestroyed(request); | 131 OnURLRequestDestroyed(request); |
127 } | 132 } |
128 | 133 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 | 186 |
182 bool NetworkDelegate::CancelURLRequestWithPolicyViolatingReferrerHeader( | 187 bool NetworkDelegate::CancelURLRequestWithPolicyViolatingReferrerHeader( |
183 const URLRequest& request, | 188 const URLRequest& request, |
184 const GURL& target_url, | 189 const GURL& target_url, |
185 const GURL& referrer_url) const { | 190 const GURL& referrer_url) const { |
186 DCHECK(CalledOnValidThread()); | 191 DCHECK(CalledOnValidThread()); |
187 return OnCancelURLRequestWithPolicyViolatingReferrerHeader( | 192 return OnCancelURLRequestWithPolicyViolatingReferrerHeader( |
188 request, target_url, referrer_url); | 193 request, target_url, referrer_url); |
189 } | 194 } |
190 | 195 |
| 196 void NetworkDelegate::OnResponseStarted(URLRequest* request, int net_error) { |
| 197 OnResponseStarted(request); |
| 198 } |
| 199 |
| 200 // Deprecated |
| 201 void NetworkDelegate::OnResponseStarted(URLRequest* request) { |
| 202 NOTREACHED(); |
| 203 } |
| 204 |
| 205 void NetworkDelegate::OnCompleted(URLRequest* request, |
| 206 bool started, |
| 207 int net_error) { |
| 208 OnCompleted(request, started); |
| 209 } |
| 210 |
| 211 // Deprecated. |
| 212 void NetworkDelegate::OnCompleted(URLRequest* request, bool started) { |
| 213 NOTREACHED(); |
| 214 } |
| 215 |
191 } // namespace net | 216 } // namespace net |
OLD | NEW |