| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 "chrome/browser/chromeos/policy/upload_job.h" | 5 #include "chrome/browser/chromeos/policy/upload_job.h" |
| 6 | 6 |
| 7 #include <queue> | 7 #include <queue> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 65 |
| 66 // OAuth2TokenService: | 66 // OAuth2TokenService: |
| 67 void FetchOAuth2Token(RequestImpl* request, | 67 void FetchOAuth2Token(RequestImpl* request, |
| 68 const std::string& account_id, | 68 const std::string& account_id, |
| 69 net::URLRequestContextGetter* getter, | 69 net::URLRequestContextGetter* getter, |
| 70 const std::string& client_id, | 70 const std::string& client_id, |
| 71 const std::string& client_secret, | 71 const std::string& client_secret, |
| 72 const ScopeSet& scopes) override; | 72 const ScopeSet& scopes) override; |
| 73 | 73 |
| 74 // OAuth2TokenService: | 74 // OAuth2TokenService: |
| 75 void InvalidateOAuth2Token(const std::string& account_id, | 75 void InvalidateAccessTokenImpl(const std::string& account_id, |
| 76 const std::string& client_id, | 76 const std::string& client_id, |
| 77 const ScopeSet& scopes, | 77 const ScopeSet& scopes, |
| 78 const std::string& access_token) override; | 78 const std::string& access_token) override; |
| 79 | 79 |
| 80 void AddTokenToQueue(const std::string& token); | 80 void AddTokenToQueue(const std::string& token); |
| 81 bool IsTokenValid(const std::string& token) const; | 81 bool IsTokenValid(const std::string& token) const; |
| 82 void SetTokenValid(const std::string& token); | 82 void SetTokenValid(const std::string& token); |
| 83 void SetTokenInvalid(const std::string& token); | 83 void SetTokenInvalid(const std::string& token); |
| 84 | 84 |
| 85 private: | 85 private: |
| 86 std::queue<std::string> token_replies_; | 86 std::queue<std::string> token_replies_; |
| 87 std::set<std::string> valid_tokens_; | 87 std::set<std::string> valid_tokens_; |
| 88 | 88 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 } | 128 } |
| 129 | 129 |
| 130 void MockOAuth2TokenService::SetTokenValid(const std::string& token) { | 130 void MockOAuth2TokenService::SetTokenValid(const std::string& token) { |
| 131 valid_tokens_.insert(token); | 131 valid_tokens_.insert(token); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void MockOAuth2TokenService::SetTokenInvalid(const std::string& token) { | 134 void MockOAuth2TokenService::SetTokenInvalid(const std::string& token) { |
| 135 valid_tokens_.erase(token); | 135 valid_tokens_.erase(token); |
| 136 } | 136 } |
| 137 | 137 |
| 138 void MockOAuth2TokenService::InvalidateOAuth2Token( | 138 void MockOAuth2TokenService::InvalidateAccessTokenImpl( |
| 139 const std::string& account_id, | 139 const std::string& account_id, |
| 140 const std::string& client_id, | 140 const std::string& client_id, |
| 141 const ScopeSet& scopes, | 141 const ScopeSet& scopes, |
| 142 const std::string& access_token) { | 142 const std::string& access_token) { |
| 143 SetTokenInvalid(access_token); | 143 SetTokenInvalid(access_token); |
| 144 } | 144 } |
| 145 | 145 |
| 146 } // namespace | 146 } // namespace |
| 147 | 147 |
| 148 class UploadJobTestBase : public testing::Test, public UploadJob::Delegate { | 148 class UploadJobTestBase : public testing::Test, public UploadJob::Delegate { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 170 const GURL GetServerURL() const { return test_server_.GetURL(kUploadPath); } | 170 const GURL GetServerURL() const { return test_server_.GetURL(kUploadPath); } |
| 171 | 171 |
| 172 void SetExpectedError(scoped_ptr<UploadJob::ErrorCode> expected_error) { | 172 void SetExpectedError(scoped_ptr<UploadJob::ErrorCode> expected_error) { |
| 173 expected_error_ = expected_error.Pass(); | 173 expected_error_ = expected_error.Pass(); |
| 174 } | 174 } |
| 175 | 175 |
| 176 // testing::Test: | 176 // testing::Test: |
| 177 void SetUp() override { | 177 void SetUp() override { |
| 178 request_context_getter_ = new net::TestURLRequestContextGetter( | 178 request_context_getter_ = new net::TestURLRequestContextGetter( |
| 179 base::ThreadTaskRunnerHandle::Get()); | 179 base::ThreadTaskRunnerHandle::Get()); |
| 180 oauth2_service_.AddAccount("robot@gmail.com"); | 180 oauth2_service_.GetDelegate()->UpdateCredentials("robot@gmail.com", |
| 181 "refresh_token"); |
| 181 ASSERT_TRUE(test_server_.InitializeAndWaitUntilReady()); | 182 ASSERT_TRUE(test_server_.InitializeAndWaitUntilReady()); |
| 182 } | 183 } |
| 183 | 184 |
| 184 // testing::Test: | 185 // testing::Test: |
| 185 void TearDown() override { | 186 void TearDown() override { |
| 186 ASSERT_TRUE(test_server_.ShutdownAndWaitUntilComplete()); | 187 ASSERT_TRUE(test_server_.ShutdownAndWaitUntilComplete()); |
| 187 } | 188 } |
| 188 | 189 |
| 189 protected: | 190 protected: |
| 190 scoped_ptr<UploadJob> PrepareUploadJob(scoped_ptr< | 191 scoped_ptr<UploadJob> PrepareUploadJob(scoped_ptr< |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 "customfield2: CUSTOM2\r\n" | 334 "customfield2: CUSTOM2\r\n" |
| 334 "\r\n" | 335 "\r\n" |
| 335 "**||--||PAYLOAD2||--||**\r\n--" | 336 "**||--||PAYLOAD2||--||**\r\n--" |
| 336 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA--\r\n"); | 337 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA--\r\n"); |
| 337 | 338 |
| 338 upload_job->Start(); | 339 upload_job->Start(); |
| 339 run_loop_.Run(); | 340 run_loop_.Run(); |
| 340 } | 341 } |
| 341 | 342 |
| 342 } // namespace policy | 343 } // namespace policy |
| OLD | NEW |