Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(458)

Side by Side Diff: net/http/http_auth_handler.cc

Issue 1391053002: [net/http auth] Make HttpAuthHandler challenge handling asynchronous. Base URL: https://chromium.googlesource.com/chromium/src.git@auth-handler-init-split
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/http/http_auth_handler.h ('k') | net/http/http_auth_handler_basic.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "net/base/net_errors.h" 11 #include "net/base/net_errors.h"
12 #include "net/http/http_auth_challenge_tokenizer.h" 12 #include "net/http/http_auth_challenge_tokenizer.h"
13 13
14 namespace net { 14 namespace net {
15 15
16 HttpAuthHandler::HttpAuthHandler(const std::string& scheme) 16 HttpAuthHandler::HttpAuthHandler(const std::string& scheme)
17 : auth_scheme_(scheme), target_(HttpAuth::AUTH_NONE) {} 17 : auth_scheme_(scheme), target_(HttpAuth::AUTH_NONE) {}
18 18
19 HttpAuthHandler::~HttpAuthHandler() { 19 HttpAuthHandler::~HttpAuthHandler() {
20 } 20 }
21 21
22 int HttpAuthHandler::HandleInitialChallenge( 22 int HttpAuthHandler::HandleInitialChallenge(
23 const HttpAuthChallengeTokenizer& challenge, 23 const HttpAuthChallengeTokenizer& challenge,
24 const HttpResponseInfo& response_info,
24 HttpAuth::Target target, 25 HttpAuth::Target target,
25 const GURL& origin, 26 const GURL& origin,
26 const BoundNetLog& net_log) { 27 const BoundNetLog& net_log,
28 const CompletionCallback& callback) {
27 origin_ = origin; 29 origin_ = origin;
28 target_ = target; 30 target_ = target;
29 net_log_ = net_log; 31 net_log_ = net_log;
30 32
31 auth_challenge_ = challenge.challenge_text(); 33 auth_challenge_ = challenge.challenge_text();
32 return Init(challenge); 34 return InitializeFromChallengeInternal(challenge, response_info, callback);
35 }
36
37 int HttpAuthHandler::InitializeFromCacheEntry(HttpAuthCache::Entry* cache_entry,
38 HttpAuth::Target target,
39 const BoundNetLog& net_log) {
40 origin_ = cache_entry->origin();
41 target_ = target;
42 net_log_ = net_log;
43
44 auth_challenge_ = cache_entry->auth_challenge();
45 return InitializeFromCacheEntryInternal(cache_entry);
33 } 46 }
34 47
35 namespace { 48 namespace {
36 49
37 NetLog::EventType EventTypeFromAuthTarget(HttpAuth::Target target) { 50 NetLog::EventType EventTypeFromAuthTarget(HttpAuth::Target target) {
38 switch (target) { 51 switch (target) {
39 case HttpAuth::AUTH_PROXY: 52 case HttpAuth::AUTH_PROXY:
40 return NetLog::TYPE_AUTH_PROXY; 53 return NetLog::TYPE_AUTH_PROXY;
41 case HttpAuth::AUTH_SERVER: 54 case HttpAuth::AUTH_SERVER:
42 return NetLog::TYPE_AUTH_SERVER; 55 return NetLog::TYPE_AUTH_SERVER;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 callback.Run(rv); 100 callback.Run(rv);
88 } 101 }
89 102
90 void HttpAuthHandler::FinishGenerateAuthToken() { 103 void HttpAuthHandler::FinishGenerateAuthToken() {
91 // TOOD(cbentzel): Should this be done in OK case only? 104 // TOOD(cbentzel): Should this be done in OK case only?
92 net_log_.EndEvent(EventTypeFromAuthTarget(target_)); 105 net_log_.EndEvent(EventTypeFromAuthTarget(target_));
93 callback_.Reset(); 106 callback_.Reset();
94 } 107 }
95 108
96 } // namespace net 109 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_auth_handler.h ('k') | net/http/http_auth_handler_basic.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698