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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 ProxyInfo* results, | 276 ProxyInfo* results, |
277 CompletionCallback* user_callback, | 277 CompletionCallback* user_callback, |
278 const BoundNetLog& net_log) | 278 const BoundNetLog& net_log) |
279 : service_(service), | 279 : service_(service), |
280 user_callback_(user_callback), | 280 user_callback_(user_callback), |
281 ALLOW_THIS_IN_INITIALIZER_LIST(io_callback_( | 281 ALLOW_THIS_IN_INITIALIZER_LIST(io_callback_( |
282 this, &PacRequest::QueryComplete)), | 282 this, &PacRequest::QueryComplete)), |
283 results_(results), | 283 results_(results), |
284 url_(url), | 284 url_(url), |
285 resolve_job_(NULL), | 285 resolve_job_(NULL), |
286 config_id_(ProxyConfig::INVALID_ID), | 286 config_id_(ProxyConfig::kInvalidConfigID), |
287 net_log_(net_log) { | 287 net_log_(net_log) { |
288 DCHECK(user_callback); | 288 DCHECK(user_callback); |
289 } | 289 } |
290 | 290 |
291 // Starts the resolve proxy request. | 291 // Starts the resolve proxy request. |
292 int Start() { | 292 int Start() { |
293 DCHECK(!was_cancelled()); | 293 DCHECK(!was_cancelled()); |
294 DCHECK(!is_started()); | 294 DCHECK(!is_started()); |
295 | 295 |
296 DCHECK(service_->config_.is_valid()); | 296 DCHECK(service_->config_.is_valid()); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 // asynchronous). Fixes up the result that is to be returned to user. | 343 // asynchronous). Fixes up the result that is to be returned to user. |
344 int QueryDidComplete(int result_code) { | 344 int QueryDidComplete(int result_code) { |
345 DCHECK(!was_cancelled()); | 345 DCHECK(!was_cancelled()); |
346 | 346 |
347 // Make a note in the results which configuration was in use at the | 347 // Make a note in the results which configuration was in use at the |
348 // time of the resolve. | 348 // time of the resolve. |
349 results_->config_id_ = config_id_; | 349 results_->config_id_ = config_id_; |
350 | 350 |
351 // Reset the state associated with in-progress-resolve. | 351 // Reset the state associated with in-progress-resolve. |
352 resolve_job_ = NULL; | 352 resolve_job_ = NULL; |
353 config_id_ = ProxyConfig::INVALID_ID; | 353 config_id_ = ProxyConfig::kInvalidConfigID; |
354 | 354 |
355 return service_->DidFinishResolvingProxy(results_, result_code, net_log_); | 355 return service_->DidFinishResolvingProxy(results_, result_code, net_log_); |
356 } | 356 } |
357 | 357 |
358 BoundNetLog* net_log() { return &net_log_; } | 358 BoundNetLog* net_log() { return &net_log_; } |
359 | 359 |
360 private: | 360 private: |
361 friend class base::RefCounted<ProxyService::PacRequest>; | 361 friend class base::RefCounted<ProxyService::PacRequest>; |
362 | 362 |
363 ~PacRequest() {} | 363 ~PacRequest() {} |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 return rv; // ERR_IO_PENDING | 567 return rv; // ERR_IO_PENDING |
568 } | 568 } |
569 | 569 |
570 int ProxyService::TryToCompleteSynchronously(const GURL& url, | 570 int ProxyService::TryToCompleteSynchronously(const GURL& url, |
571 ProxyInfo* result) { | 571 ProxyInfo* result) { |
572 DCHECK_NE(STATE_NONE, current_state_); | 572 DCHECK_NE(STATE_NONE, current_state_); |
573 | 573 |
574 if (current_state_ != STATE_READY) | 574 if (current_state_ != STATE_READY) |
575 return ERR_IO_PENDING; // Still initializing. | 575 return ERR_IO_PENDING; // Still initializing. |
576 | 576 |
577 DCHECK_NE(config_.id(), ProxyConfig::INVALID_ID); | 577 DCHECK_NE(config_.id(), ProxyConfig::kInvalidConfigID); |
578 | 578 |
579 // If it was impossible to fetch or parse the PAC script, we cannot complete | 579 // If it was impossible to fetch or parse the PAC script, we cannot complete |
580 // the request here and bail out. | 580 // the request here and bail out. |
581 if (permanent_error_ != OK) | 581 if (permanent_error_ != OK) |
582 return permanent_error_; | 582 return permanent_error_; |
583 | 583 |
584 if (config_.HasAutomaticSettings()) | 584 if (config_.HasAutomaticSettings()) |
585 return ERR_IO_PENDING; // Must submit the request to the proxy resolver. | 585 return ERR_IO_PENDING; // Must submit the request to the proxy resolver. |
586 | 586 |
587 // Use the manual proxy settings. | 587 // Use the manual proxy settings. |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1021 OnCompletion(result_); | 1021 OnCompletion(result_); |
1022 } | 1022 } |
1023 } | 1023 } |
1024 | 1024 |
1025 void SyncProxyServiceHelper::OnCompletion(int rv) { | 1025 void SyncProxyServiceHelper::OnCompletion(int rv) { |
1026 result_ = rv; | 1026 result_ = rv; |
1027 event_.Signal(); | 1027 event_.Signal(); |
1028 } | 1028 } |
1029 | 1029 |
1030 } // namespace net | 1030 } // namespace net |
OLD | NEW |