| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/proxy/proxy_service.h" | 5 #include "net/proxy/proxy_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 OldCompletionCallback* callback, | 111 OldCompletionCallback* callback, |
| 112 RequestHandle* request, | 112 RequestHandle* request, |
| 113 const BoundNetLog& net_log) OVERRIDE { | 113 const BoundNetLog& net_log) OVERRIDE { |
| 114 return ERR_NOT_IMPLEMENTED; | 114 return ERR_NOT_IMPLEMENTED; |
| 115 } | 115 } |
| 116 | 116 |
| 117 virtual void CancelRequest(RequestHandle request) OVERRIDE { | 117 virtual void CancelRequest(RequestHandle request) OVERRIDE { |
| 118 NOTREACHED(); | 118 NOTREACHED(); |
| 119 } | 119 } |
| 120 | 120 |
| 121 virtual LoadState GetLoadState(RequestHandle request) const OVERRIDE { |
| 122 NOTREACHED(); |
| 123 return LOAD_STATE_IDLE; |
| 124 } |
| 125 |
| 126 virtual LoadState GetLoadStateThreadSafe( |
| 127 RequestHandle request) const OVERRIDE { |
| 128 NOTREACHED(); |
| 129 return LOAD_STATE_IDLE; |
| 130 } |
| 131 |
| 121 virtual void CancelSetPacScript() OVERRIDE { | 132 virtual void CancelSetPacScript() OVERRIDE { |
| 122 NOTREACHED(); | 133 NOTREACHED(); |
| 123 } | 134 } |
| 124 | 135 |
| 125 virtual int SetPacScript( | 136 virtual int SetPacScript( |
| 126 const scoped_refptr<ProxyResolverScriptData>& /*script_data*/, | 137 const scoped_refptr<ProxyResolverScriptData>& /*script_data*/, |
| 127 OldCompletionCallback* /*callback*/) OVERRIDE { | 138 OldCompletionCallback* /*callback*/) OVERRIDE { |
| 128 return ERR_NOT_IMPLEMENTED; | 139 return ERR_NOT_IMPLEMENTED; |
| 129 } | 140 } |
| 130 }; | 141 }; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 143 RequestHandle* request, | 154 RequestHandle* request, |
| 144 const BoundNetLog& net_log) OVERRIDE { | 155 const BoundNetLog& net_log) OVERRIDE { |
| 145 results->UsePacString(pac_string_); | 156 results->UsePacString(pac_string_); |
| 146 return OK; | 157 return OK; |
| 147 } | 158 } |
| 148 | 159 |
| 149 virtual void CancelRequest(RequestHandle request) OVERRIDE { | 160 virtual void CancelRequest(RequestHandle request) OVERRIDE { |
| 150 NOTREACHED(); | 161 NOTREACHED(); |
| 151 } | 162 } |
| 152 | 163 |
| 164 virtual LoadState GetLoadState(RequestHandle request) const OVERRIDE { |
| 165 NOTREACHED(); |
| 166 return LOAD_STATE_IDLE; |
| 167 } |
| 168 |
| 169 virtual LoadState GetLoadStateThreadSafe( |
| 170 RequestHandle request) const OVERRIDE { |
| 171 NOTREACHED(); |
| 172 return LOAD_STATE_IDLE; |
| 173 } |
| 174 |
| 153 virtual void CancelSetPacScript() OVERRIDE { | 175 virtual void CancelSetPacScript() OVERRIDE { |
| 154 NOTREACHED(); | 176 NOTREACHED(); |
| 155 } | 177 } |
| 156 | 178 |
| 157 virtual int SetPacScript( | 179 virtual int SetPacScript( |
| 158 const scoped_refptr<ProxyResolverScriptData>& pac_script, | 180 const scoped_refptr<ProxyResolverScriptData>& pac_script, |
| 159 OldCompletionCallback* callback) OVERRIDE { | 181 OldCompletionCallback* callback) OVERRIDE { |
| 160 return OK; | 182 return OK; |
| 161 } | 183 } |
| 162 | 184 |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 | 397 |
| 376 // Reset the state associated with in-progress-resolve. | 398 // Reset the state associated with in-progress-resolve. |
| 377 resolve_job_ = NULL; | 399 resolve_job_ = NULL; |
| 378 config_id_ = ProxyConfig::kInvalidConfigID; | 400 config_id_ = ProxyConfig::kInvalidConfigID; |
| 379 | 401 |
| 380 return service_->DidFinishResolvingProxy(results_, result_code, net_log_); | 402 return service_->DidFinishResolvingProxy(results_, result_code, net_log_); |
| 381 } | 403 } |
| 382 | 404 |
| 383 BoundNetLog* net_log() { return &net_log_; } | 405 BoundNetLog* net_log() { return &net_log_; } |
| 384 | 406 |
| 407 LoadState GetLoadState() const { |
| 408 if (is_started()) |
| 409 return resolver()->GetLoadState(resolve_job_); |
| 410 return LOAD_STATE_RESOLVING_PROXY_FOR_URL; |
| 411 } |
| 412 |
| 385 private: | 413 private: |
| 386 friend class base::RefCounted<ProxyService::PacRequest>; | 414 friend class base::RefCounted<ProxyService::PacRequest>; |
| 387 | 415 |
| 388 ~PacRequest() {} | 416 ~PacRequest() {} |
| 389 | 417 |
| 390 // Callback for when the ProxyResolver request has completed. | 418 // Callback for when the ProxyResolver request has completed. |
| 391 void QueryComplete(int result_code) { | 419 void QueryComplete(int result_code) { |
| 392 result_code = QueryDidComplete(result_code); | 420 result_code = QueryDidComplete(result_code); |
| 393 | 421 |
| 394 // Remove this completed PacRequest from the service's pending list. | 422 // Remove this completed PacRequest from the service's pending list. |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 } | 800 } |
| 773 } | 801 } |
| 774 | 802 |
| 775 void ProxyService::CancelPacRequest(PacRequest* req) { | 803 void ProxyService::CancelPacRequest(PacRequest* req) { |
| 776 DCHECK(CalledOnValidThread()); | 804 DCHECK(CalledOnValidThread()); |
| 777 DCHECK(req); | 805 DCHECK(req); |
| 778 req->Cancel(); | 806 req->Cancel(); |
| 779 RemovePendingRequest(req); | 807 RemovePendingRequest(req); |
| 780 } | 808 } |
| 781 | 809 |
| 810 LoadState ProxyService::GetLoadState(const PacRequest* req) const { |
| 811 CHECK(req); |
| 812 return req->GetLoadState(); |
| 813 } |
| 814 |
| 782 bool ProxyService::ContainsPendingRequest(PacRequest* req) { | 815 bool ProxyService::ContainsPendingRequest(PacRequest* req) { |
| 783 PendingRequests::iterator it = std::find( | 816 PendingRequests::iterator it = std::find( |
| 784 pending_requests_.begin(), pending_requests_.end(), req); | 817 pending_requests_.begin(), pending_requests_.end(), req); |
| 785 return pending_requests_.end() != it; | 818 return pending_requests_.end() != it; |
| 786 } | 819 } |
| 787 | 820 |
| 788 void ProxyService::RemovePendingRequest(PacRequest* req) { | 821 void ProxyService::RemovePendingRequest(PacRequest* req) { |
| 789 DCHECK(ContainsPendingRequest(req)); | 822 DCHECK(ContainsPendingRequest(req)); |
| 790 PendingRequests::iterator it = std::find( | 823 PendingRequests::iterator it = std::find( |
| 791 pending_requests_.begin(), pending_requests_.end(), req); | 824 pending_requests_.begin(), pending_requests_.end(), req); |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1071 OnCompletion(result_); | 1104 OnCompletion(result_); |
| 1072 } | 1105 } |
| 1073 } | 1106 } |
| 1074 | 1107 |
| 1075 void SyncProxyServiceHelper::OnCompletion(int rv) { | 1108 void SyncProxyServiceHelper::OnCompletion(int rv) { |
| 1076 result_ = rv; | 1109 result_ = rv; |
| 1077 event_.Signal(); | 1110 event_.Signal(); |
| 1078 } | 1111 } |
| 1079 | 1112 |
| 1080 } // namespace net | 1113 } // namespace net |
| OLD | NEW |