| 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 |
| 121 virtual void CancelSetPacScript() OVERRIDE { | 126 virtual void CancelSetPacScript() OVERRIDE { |
| 122 NOTREACHED(); | 127 NOTREACHED(); |
| 123 } | 128 } |
| 124 | 129 |
| 125 virtual int SetPacScript( | 130 virtual int SetPacScript( |
| 126 const scoped_refptr<ProxyResolverScriptData>& /*script_data*/, | 131 const scoped_refptr<ProxyResolverScriptData>& /*script_data*/, |
| 127 OldCompletionCallback* /*callback*/) OVERRIDE { | 132 OldCompletionCallback* /*callback*/) OVERRIDE { |
| 128 return ERR_NOT_IMPLEMENTED; | 133 return ERR_NOT_IMPLEMENTED; |
| 129 } | 134 } |
| 130 }; | 135 }; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 143 RequestHandle* request, | 148 RequestHandle* request, |
| 144 const BoundNetLog& net_log) OVERRIDE { | 149 const BoundNetLog& net_log) OVERRIDE { |
| 145 results->UsePacString(pac_string_); | 150 results->UsePacString(pac_string_); |
| 146 return OK; | 151 return OK; |
| 147 } | 152 } |
| 148 | 153 |
| 149 virtual void CancelRequest(RequestHandle request) OVERRIDE { | 154 virtual void CancelRequest(RequestHandle request) OVERRIDE { |
| 150 NOTREACHED(); | 155 NOTREACHED(); |
| 151 } | 156 } |
| 152 | 157 |
| 158 virtual LoadState GetLoadState(RequestHandle request) const OVERRIDE { |
| 159 NOTREACHED(); |
| 160 return LOAD_STATE_IDLE; |
| 161 } |
| 162 |
| 153 virtual void CancelSetPacScript() OVERRIDE { | 163 virtual void CancelSetPacScript() OVERRIDE { |
| 154 NOTREACHED(); | 164 NOTREACHED(); |
| 155 } | 165 } |
| 156 | 166 |
| 157 virtual int SetPacScript( | 167 virtual int SetPacScript( |
| 158 const scoped_refptr<ProxyResolverScriptData>& pac_script, | 168 const scoped_refptr<ProxyResolverScriptData>& pac_script, |
| 159 OldCompletionCallback* callback) OVERRIDE { | 169 OldCompletionCallback* callback) OVERRIDE { |
| 160 return OK; | 170 return OK; |
| 161 } | 171 } |
| 162 | 172 |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 | 385 |
| 376 // Reset the state associated with in-progress-resolve. | 386 // Reset the state associated with in-progress-resolve. |
| 377 resolve_job_ = NULL; | 387 resolve_job_ = NULL; |
| 378 config_id_ = ProxyConfig::kInvalidConfigID; | 388 config_id_ = ProxyConfig::kInvalidConfigID; |
| 379 | 389 |
| 380 return service_->DidFinishResolvingProxy(results_, result_code, net_log_); | 390 return service_->DidFinishResolvingProxy(results_, result_code, net_log_); |
| 381 } | 391 } |
| 382 | 392 |
| 383 BoundNetLog* net_log() { return &net_log_; } | 393 BoundNetLog* net_log() { return &net_log_; } |
| 384 | 394 |
| 395 LoadState GetLoadState() const { |
| 396 if (is_started()) |
| 397 return resolver()->GetLoadState(resolve_job_); |
| 398 return LOAD_STATE_RESOLVING_PROXY_FOR_URL; |
| 399 } |
| 400 |
| 385 private: | 401 private: |
| 386 friend class base::RefCounted<ProxyService::PacRequest>; | 402 friend class base::RefCounted<ProxyService::PacRequest>; |
| 387 | 403 |
| 388 ~PacRequest() {} | 404 ~PacRequest() {} |
| 389 | 405 |
| 390 // Callback for when the ProxyResolver request has completed. | 406 // Callback for when the ProxyResolver request has completed. |
| 391 void QueryComplete(int result_code) { | 407 void QueryComplete(int result_code) { |
| 392 result_code = QueryDidComplete(result_code); | 408 result_code = QueryDidComplete(result_code); |
| 393 | 409 |
| 394 // Remove this completed PacRequest from the service's pending list. | 410 // Remove this completed PacRequest from the service's pending list. |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 } | 788 } |
| 773 } | 789 } |
| 774 | 790 |
| 775 void ProxyService::CancelPacRequest(PacRequest* req) { | 791 void ProxyService::CancelPacRequest(PacRequest* req) { |
| 776 DCHECK(CalledOnValidThread()); | 792 DCHECK(CalledOnValidThread()); |
| 777 DCHECK(req); | 793 DCHECK(req); |
| 778 req->Cancel(); | 794 req->Cancel(); |
| 779 RemovePendingRequest(req); | 795 RemovePendingRequest(req); |
| 780 } | 796 } |
| 781 | 797 |
| 798 LoadState ProxyService::GetLoadState(const PacRequest* req) const { |
| 799 CHECK(req); |
| 800 return req->GetLoadState(); |
| 801 } |
| 802 |
| 782 bool ProxyService::ContainsPendingRequest(PacRequest* req) { | 803 bool ProxyService::ContainsPendingRequest(PacRequest* req) { |
| 783 PendingRequests::iterator it = std::find( | 804 PendingRequests::iterator it = std::find( |
| 784 pending_requests_.begin(), pending_requests_.end(), req); | 805 pending_requests_.begin(), pending_requests_.end(), req); |
| 785 return pending_requests_.end() != it; | 806 return pending_requests_.end() != it; |
| 786 } | 807 } |
| 787 | 808 |
| 788 void ProxyService::RemovePendingRequest(PacRequest* req) { | 809 void ProxyService::RemovePendingRequest(PacRequest* req) { |
| 789 DCHECK(ContainsPendingRequest(req)); | 810 DCHECK(ContainsPendingRequest(req)); |
| 790 PendingRequests::iterator it = std::find( | 811 PendingRequests::iterator it = std::find( |
| 791 pending_requests_.begin(), pending_requests_.end(), req); | 812 pending_requests_.begin(), pending_requests_.end(), req); |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1071 OnCompletion(result_); | 1092 OnCompletion(result_); |
| 1072 } | 1093 } |
| 1073 } | 1094 } |
| 1074 | 1095 |
| 1075 void SyncProxyServiceHelper::OnCompletion(int rv) { | 1096 void SyncProxyServiceHelper::OnCompletion(int rv) { |
| 1076 result_ = rv; | 1097 result_ = rv; |
| 1077 event_.Signal(); | 1098 event_.Signal(); |
| 1078 } | 1099 } |
| 1079 | 1100 |
| 1080 } // namespace net | 1101 } // namespace net |
| OLD | NEW |