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" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 NOTREACHED(); | 57 NOTREACHED(); |
58 return NetLog::TYPE_CANCELLED; | 58 return NetLog::TYPE_CANCELLED; |
59 } | 59 } |
60 } | 60 } |
61 | 61 |
62 } // namespace | 62 } // namespace |
63 | 63 |
64 int HttpAuthHandler::GenerateAuthToken( | 64 int HttpAuthHandler::GenerateAuthToken( |
65 const AuthCredentials* credentials, const HttpRequestInfo* request, | 65 const AuthCredentials* credentials, const HttpRequestInfo* request, |
66 const CompletionCallback& callback, std::string* auth_token) { | 66 const CompletionCallback& callback, std::string* auth_token) { |
67 // TODO(cbentzel): Enforce non-NULL callback after cleaning up SocketStream. | 67 DCHECK(!callback.is_null()); |
68 DCHECK(request); | 68 DCHECK(request); |
69 DCHECK(credentials != NULL || AllowsDefaultCredentials()); | 69 DCHECK(credentials != NULL || AllowsDefaultCredentials()); |
70 DCHECK(auth_token != NULL); | 70 DCHECK(auth_token != NULL); |
71 DCHECK(callback_.is_null()); | 71 DCHECK(callback_.is_null()); |
72 callback_ = callback; | 72 callback_ = callback; |
73 net_log_.BeginEvent(EventTypeFromAuthTarget(target_)); | 73 net_log_.BeginEvent(EventTypeFromAuthTarget(target_)); |
74 int rv = GenerateAuthTokenImpl( | 74 int rv = GenerateAuthTokenImpl( |
75 credentials, request, | 75 credentials, request, |
76 base::Bind(&HttpAuthHandler::OnGenerateAuthTokenComplete, | 76 base::Bind(&HttpAuthHandler::OnGenerateAuthTokenComplete, |
77 base::Unretained(this)), | 77 base::Unretained(this)), |
(...skipping 11 matching lines...) Expand all Loading... |
89 return false; | 89 return false; |
90 } | 90 } |
91 | 91 |
92 bool HttpAuthHandler::AllowsExplicitCredentials() { | 92 bool HttpAuthHandler::AllowsExplicitCredentials() { |
93 return true; | 93 return true; |
94 } | 94 } |
95 | 95 |
96 void HttpAuthHandler::OnGenerateAuthTokenComplete(int rv) { | 96 void HttpAuthHandler::OnGenerateAuthTokenComplete(int rv) { |
97 CompletionCallback callback = callback_; | 97 CompletionCallback callback = callback_; |
98 FinishGenerateAuthToken(); | 98 FinishGenerateAuthToken(); |
99 if (!callback.is_null()) | 99 DCHECK(!callback.is_null()); |
100 callback.Run(rv); | 100 callback.Run(rv); |
101 } | 101 } |
102 | 102 |
103 void HttpAuthHandler::FinishGenerateAuthToken() { | 103 void HttpAuthHandler::FinishGenerateAuthToken() { |
104 // TOOD(cbentzel): Should this be done in OK case only? | 104 // TOOD(cbentzel): Should this be done in OK case only? |
105 net_log_.EndEvent(EventTypeFromAuthTarget(target_)); | 105 net_log_.EndEvent(EventTypeFromAuthTarget(target_)); |
106 callback_.Reset(); | 106 callback_.Reset(); |
107 } | 107 } |
108 | 108 |
109 } // namespace net | 109 } // namespace net |
OLD | NEW |