| 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, |
| 82 int net_error) { |
| 83 DCHECK(CalledOnValidThread()); |
| 84 DCHECK(request); |
| 85 |
| 86 implemented_ = true; |
| 87 |
| 88 OnResponseStarted(request, net_error); |
| 89 if (!implemented_) |
| 90 OnResponseStarted(request); |
| 91 } |
| 92 |
| 93 // Deprecated. |
| 81 void NetworkDelegate::NotifyResponseStarted(URLRequest* request) { | 94 void NetworkDelegate::NotifyResponseStarted(URLRequest* request) { |
| 82 DCHECK(CalledOnValidThread()); | 95 DCHECK(CalledOnValidThread()); |
| 83 DCHECK(request); | 96 DCHECK(request); |
| 84 OnResponseStarted(request); | 97 OnResponseStarted(request); |
| 85 } | 98 } |
| 86 | 99 |
| 100 void NetworkDelegate::OnResponseStarted(URLRequest* request, int net_error) { |
| 101 implemented_ = false; |
| 102 } |
| 103 |
| 104 // Deprecated |
| 105 void NetworkDelegate::OnResponseStarted(URLRequest* request) {} |
| 106 |
| 87 void NetworkDelegate::NotifyNetworkBytesReceived(URLRequest* request, | 107 void NetworkDelegate::NotifyNetworkBytesReceived(URLRequest* request, |
| 88 int64_t bytes_received) { | 108 int64_t bytes_received) { |
| 89 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), | 109 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), |
| 90 "NetworkDelegate::NotifyNetworkBytesReceived"); | 110 "NetworkDelegate::NotifyNetworkBytesReceived"); |
| 91 DCHECK(CalledOnValidThread()); | 111 DCHECK(CalledOnValidThread()); |
| 92 DCHECK_GT(bytes_received, 0); | 112 DCHECK_GT(bytes_received, 0); |
| 93 OnNetworkBytesReceived(request, bytes_received); | 113 OnNetworkBytesReceived(request, bytes_received); |
| 94 } | 114 } |
| 95 | 115 |
| 96 void NetworkDelegate::NotifyNetworkBytesSent(URLRequest* request, | 116 void NetworkDelegate::NotifyNetworkBytesSent(URLRequest* request, |
| 97 int64_t bytes_sent) { | 117 int64_t bytes_sent) { |
| 98 DCHECK(CalledOnValidThread()); | 118 DCHECK(CalledOnValidThread()); |
| 99 DCHECK_GT(bytes_sent, 0); | 119 DCHECK_GT(bytes_sent, 0); |
| 100 OnNetworkBytesSent(request, bytes_sent); | 120 OnNetworkBytesSent(request, bytes_sent); |
| 101 } | 121 } |
| 102 | 122 |
| 103 void NetworkDelegate::NotifyBeforeRedirect(URLRequest* request, | 123 void NetworkDelegate::NotifyBeforeRedirect(URLRequest* request, |
| 104 const GURL& new_location) { | 124 const GURL& new_location) { |
| 105 DCHECK(CalledOnValidThread()); | 125 DCHECK(CalledOnValidThread()); |
| 106 DCHECK(request); | 126 DCHECK(request); |
| 107 OnBeforeRedirect(request, new_location); | 127 OnBeforeRedirect(request, new_location); |
| 108 } | 128 } |
| 109 | 129 |
| 130 void NetworkDelegate::NotifyCompleted(URLRequest* request, |
| 131 bool started, |
| 132 int net_error) { |
| 133 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), |
| 134 "NetworkDelegate::NotifyCompleted"); |
| 135 DCHECK(CalledOnValidThread()); |
| 136 DCHECK(request); |
| 137 // TODO(cbentzel): Remove ScopedTracker below once crbug.com/475753 is fixed. |
| 138 tracked_objects::ScopedTracker tracking_profile( |
| 139 FROM_HERE_WITH_EXPLICIT_FUNCTION("475753 NetworkDelegate::OnCompleted")); |
| 140 implemented_ = true; |
| 141 |
| 142 OnCompleted(request, started, net_error); |
| 143 if (!implemented_) |
| 144 OnCompleted(request, started); |
| 145 } |
| 146 |
| 147 void NetworkDelegate::OnCompleted(URLRequest* request, |
| 148 bool started, |
| 149 int net_error) { |
| 150 implemented_ = false; |
| 151 } |
| 152 |
| 153 // Deprecated. |
| 154 void NetworkDelegate::OnCompleted(URLRequest* request, bool started) {} |
| 155 |
| 156 // Deprecated. |
| 110 void NetworkDelegate::NotifyCompleted(URLRequest* request, bool started) { | 157 void NetworkDelegate::NotifyCompleted(URLRequest* request, bool started) { |
| 111 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), | 158 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), |
| 112 "NetworkDelegate::NotifyCompleted"); | 159 "NetworkDelegate::NotifyCompleted"); |
| 113 DCHECK(CalledOnValidThread()); | 160 DCHECK(CalledOnValidThread()); |
| 114 DCHECK(request); | 161 DCHECK(request); |
| 115 // TODO(cbentzel): Remove ScopedTracker below once crbug.com/475753 is fixed. | 162 // TODO(cbentzel): Remove ScopedTracker below once crbug.com/475753 is fixed. |
| 116 tracked_objects::ScopedTracker tracking_profile( | 163 tracked_objects::ScopedTracker tracking_profile( |
| 117 FROM_HERE_WITH_EXPLICIT_FUNCTION("475753 NetworkDelegate::OnCompleted")); | 164 FROM_HERE_WITH_EXPLICIT_FUNCTION("475753 NetworkDelegate::OnCompleted")); |
| 165 |
| 118 OnCompleted(request, started); | 166 OnCompleted(request, started); |
| 119 } | 167 } |
| 120 | 168 |
| 121 void NetworkDelegate::NotifyURLRequestDestroyed(URLRequest* request) { | 169 void NetworkDelegate::NotifyURLRequestDestroyed(URLRequest* request) { |
| 122 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), | 170 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), |
| 123 "NetworkDelegate::NotifyURLRequestDestroyed"); | 171 "NetworkDelegate::NotifyURLRequestDestroyed"); |
| 124 DCHECK(CalledOnValidThread()); | 172 DCHECK(CalledOnValidThread()); |
| 125 DCHECK(request); | 173 DCHECK(request); |
| 126 OnURLRequestDestroyed(request); | 174 OnURLRequestDestroyed(request); |
| 127 } | 175 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 bool NetworkDelegate::CancelURLRequestWithPolicyViolatingReferrerHeader( | 230 bool NetworkDelegate::CancelURLRequestWithPolicyViolatingReferrerHeader( |
| 183 const URLRequest& request, | 231 const URLRequest& request, |
| 184 const GURL& target_url, | 232 const GURL& target_url, |
| 185 const GURL& referrer_url) const { | 233 const GURL& referrer_url) const { |
| 186 DCHECK(CalledOnValidThread()); | 234 DCHECK(CalledOnValidThread()); |
| 187 return OnCancelURLRequestWithPolicyViolatingReferrerHeader( | 235 return OnCancelURLRequestWithPolicyViolatingReferrerHeader( |
| 188 request, target_url, referrer_url); | 236 request, target_url, referrer_url); |
| 189 } | 237 } |
| 190 | 238 |
| 191 } // namespace net | 239 } // namespace net |
| OLD | NEW |