Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "remoting/host/token_validator_base.h" | 5 #include "remoting/host/token_validator_base.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 const std::string& TokenValidatorBase::token_scope() const { | 120 const std::string& TokenValidatorBase::token_scope() const { |
| 121 return token_scope_; | 121 return token_scope_; |
| 122 } | 122 } |
| 123 | 123 |
| 124 // URLFetcherDelegate interface. | 124 // URLFetcherDelegate interface. |
| 125 void TokenValidatorBase::OnResponseStarted(net::URLRequest* source, | 125 void TokenValidatorBase::OnResponseStarted(net::URLRequest* source, |
| 126 int net_result) { | 126 int net_result) { |
| 127 DCHECK_NE(net_result, net::ERR_IO_PENDING); | 127 DCHECK_NE(net_result, net::ERR_IO_PENDING); |
| 128 DCHECK_EQ(request_.get(), source); | 128 DCHECK_EQ(request_.get(), source); |
| 129 | 129 |
| 130 if (net_result != net::OK) | 130 if (net_result != net::OK) { |
| 131 // Treat all network errors read errors. | |
| 132 OnReadCompleted(request_.get(), net_result); | |
|
mmenke
2016/12/02 15:20:08
This is a bug fix.
| |
| 131 return; | 133 return; |
| 134 } | |
| 132 | 135 |
| 133 int bytes_read = request_->Read(buffer_.get(), kBufferSize); | 136 int bytes_read = request_->Read(buffer_.get(), kBufferSize); |
| 134 if (bytes_read > 0) | 137 if (bytes_read != net::ERR_IO_PENDING) |
|
mmenke
2016/12/02 15:20:08
Note that doing this in the bytes_read == 0 case i
| |
| 135 OnReadCompleted(request_.get(), bytes_read); | 138 OnReadCompleted(request_.get(), bytes_read); |
| 136 } | 139 } |
| 137 | 140 |
| 138 void TokenValidatorBase::OnReadCompleted(net::URLRequest* source, | 141 void TokenValidatorBase::OnReadCompleted(net::URLRequest* source, |
| 139 int net_result) { | 142 int net_result) { |
| 140 DCHECK_NE(net_result, net::ERR_IO_PENDING); | 143 DCHECK_NE(net_result, net::ERR_IO_PENDING); |
| 141 DCHECK_EQ(request_.get(), source); | 144 DCHECK_EQ(request_.get(), source); |
| 142 | 145 |
| 143 while (net_result > 0) { | 146 while (net_result > 0) { |
| 144 data_.append(buffer_->data(), net_result); | 147 data_.append(buffer_->data(), net_result); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 272 return std::string(); | 275 return std::string(); |
| 273 } | 276 } |
| 274 | 277 |
| 275 std::string shared_secret; | 278 std::string shared_secret; |
| 276 // Everything is valid, so return the shared secret to the caller. | 279 // Everything is valid, so return the shared secret to the caller. |
| 277 dict->GetStringWithoutPathExpansion("access_token", &shared_secret); | 280 dict->GetStringWithoutPathExpansion("access_token", &shared_secret); |
| 278 return shared_secret; | 281 return shared_secret; |
| 279 } | 282 } |
| 280 | 283 |
| 281 } // namespace remoting | 284 } // namespace remoting |
| OLD | NEW |