| 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/http/http_auth_handler.h" | 5 #include "net/http/http_auth_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| 11 #include "net/http/http_auth_challenge_tokenizer.h" | 11 #include "net/http/http_auth_challenge_tokenizer.h" |
| 12 #include "net/log/net_log_event_type.h" |
| 12 | 13 |
| 13 namespace net { | 14 namespace net { |
| 14 | 15 |
| 15 HttpAuthHandler::HttpAuthHandler() | 16 HttpAuthHandler::HttpAuthHandler() |
| 16 : auth_scheme_(HttpAuth::AUTH_SCHEME_MAX), | 17 : auth_scheme_(HttpAuth::AUTH_SCHEME_MAX), |
| 17 score_(-1), | 18 score_(-1), |
| 18 target_(HttpAuth::AUTH_NONE), | 19 target_(HttpAuth::AUTH_NONE), |
| 19 properties_(-1) { | 20 properties_(-1) { |
| 20 } | 21 } |
| 21 | 22 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 40 // realm may be empty. | 41 // realm may be empty. |
| 41 DCHECK(!ok || score_ != -1); | 42 DCHECK(!ok || score_ != -1); |
| 42 DCHECK(!ok || properties_ != -1); | 43 DCHECK(!ok || properties_ != -1); |
| 43 DCHECK(!ok || auth_scheme_ != HttpAuth::AUTH_SCHEME_MAX); | 44 DCHECK(!ok || auth_scheme_ != HttpAuth::AUTH_SCHEME_MAX); |
| 44 | 45 |
| 45 return ok; | 46 return ok; |
| 46 } | 47 } |
| 47 | 48 |
| 48 namespace { | 49 namespace { |
| 49 | 50 |
| 50 NetLog::EventType EventTypeFromAuthTarget(HttpAuth::Target target) { | 51 NetLogEventType EventTypeFromAuthTarget(HttpAuth::Target target) { |
| 51 switch (target) { | 52 switch (target) { |
| 52 case HttpAuth::AUTH_PROXY: | 53 case HttpAuth::AUTH_PROXY: |
| 53 return NetLog::TYPE_AUTH_PROXY; | 54 return NetLogEventType::AUTH_PROXY; |
| 54 case HttpAuth::AUTH_SERVER: | 55 case HttpAuth::AUTH_SERVER: |
| 55 return NetLog::TYPE_AUTH_SERVER; | 56 return NetLogEventType::AUTH_SERVER; |
| 56 default: | 57 default: |
| 57 NOTREACHED(); | 58 NOTREACHED(); |
| 58 return NetLog::TYPE_CANCELLED; | 59 return NetLogEventType::CANCELLED; |
| 59 } | 60 } |
| 60 } | 61 } |
| 61 | 62 |
| 62 } // namespace | 63 } // namespace |
| 63 | 64 |
| 64 int HttpAuthHandler::GenerateAuthToken( | 65 int HttpAuthHandler::GenerateAuthToken( |
| 65 const AuthCredentials* credentials, const HttpRequestInfo* request, | 66 const AuthCredentials* credentials, const HttpRequestInfo* request, |
| 66 const CompletionCallback& callback, std::string* auth_token) { | 67 const CompletionCallback& callback, std::string* auth_token) { |
| 67 DCHECK(!callback.is_null()); | 68 DCHECK(!callback.is_null()); |
| 68 DCHECK(request); | 69 DCHECK(request); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 callback.Run(rv); | 101 callback.Run(rv); |
| 101 } | 102 } |
| 102 | 103 |
| 103 void HttpAuthHandler::FinishGenerateAuthToken() { | 104 void HttpAuthHandler::FinishGenerateAuthToken() { |
| 104 // TOOD(cbentzel): Should this be done in OK case only? | 105 // TOOD(cbentzel): Should this be done in OK case only? |
| 105 net_log_.EndEvent(EventTypeFromAuthTarget(target_)); | 106 net_log_.EndEvent(EventTypeFromAuthTarget(target_)); |
| 106 callback_.Reset(); | 107 callback_.Reset(); |
| 107 } | 108 } |
| 108 | 109 |
| 109 } // namespace net | 110 } // namespace net |
| OLD | NEW |