| 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 "sync/internal_api/public/attachments/attachment_downloader_impl.h" | 5 #include "sync/internal_api/public/attachments/attachment_downloader_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 int num_invalidate_token() const { return num_invalidate_token_; } | 47 int num_invalidate_token() const { return num_invalidate_token_; } |
| 48 | 48 |
| 49 protected: | 49 protected: |
| 50 void FetchOAuth2Token(RequestImpl* request, | 50 void FetchOAuth2Token(RequestImpl* request, |
| 51 const std::string& account_id, | 51 const std::string& account_id, |
| 52 net::URLRequestContextGetter* getter, | 52 net::URLRequestContextGetter* getter, |
| 53 const std::string& client_id, | 53 const std::string& client_id, |
| 54 const std::string& client_secret, | 54 const std::string& client_secret, |
| 55 const ScopeSet& scopes) override; | 55 const ScopeSet& scopes) override; |
| 56 | 56 |
| 57 void InvalidateOAuth2Token(const std::string& account_id, | 57 void InvalidateAccessTokenImpl(const std::string& account_id, |
| 58 const std::string& client_id, | 58 const std::string& client_id, |
| 59 const ScopeSet& scopes, | 59 const ScopeSet& scopes, |
| 60 const std::string& access_token) override; | 60 const std::string& access_token) override; |
| 61 | 61 |
| 62 private: | 62 private: |
| 63 base::WeakPtr<RequestImpl> last_request_; | 63 base::WeakPtr<RequestImpl> last_request_; |
| 64 int num_invalidate_token_; | 64 int num_invalidate_token_; |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 void MockOAuth2TokenService::RespondToAccessTokenRequest( | 67 void MockOAuth2TokenService::RespondToAccessTokenRequest( |
| 68 GoogleServiceAuthError error) { | 68 GoogleServiceAuthError error) { |
| 69 EXPECT_TRUE(last_request_ != NULL); | 69 EXPECT_TRUE(last_request_ != NULL); |
| 70 std::string access_token; | 70 std::string access_token; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 87 const std::string& account_id, | 87 const std::string& account_id, |
| 88 net::URLRequestContextGetter* getter, | 88 net::URLRequestContextGetter* getter, |
| 89 const std::string& client_id, | 89 const std::string& client_id, |
| 90 const std::string& client_secret, | 90 const std::string& client_secret, |
| 91 const ScopeSet& scopes) { | 91 const ScopeSet& scopes) { |
| 92 // Only one request at a time is allowed. | 92 // Only one request at a time is allowed. |
| 93 EXPECT_TRUE(last_request_ == NULL); | 93 EXPECT_TRUE(last_request_ == NULL); |
| 94 last_request_ = request->AsWeakPtr(); | 94 last_request_ = request->AsWeakPtr(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void MockOAuth2TokenService::InvalidateOAuth2Token( | 97 void MockOAuth2TokenService::InvalidateAccessTokenImpl( |
| 98 const std::string& account_id, | 98 const std::string& account_id, |
| 99 const std::string& client_id, | 99 const std::string& client_id, |
| 100 const ScopeSet& scopes, | 100 const ScopeSet& scopes, |
| 101 const std::string& access_token) { | 101 const std::string& access_token) { |
| 102 ++num_invalidate_token_; | 102 ++num_invalidate_token_; |
| 103 } | 103 } |
| 104 | 104 |
| 105 class TokenServiceProvider | 105 class TokenServiceProvider |
| 106 : public OAuth2TokenServiceRequest::TokenServiceProvider, | 106 : public OAuth2TokenServiceRequest::TokenServiceProvider, |
| 107 base::NonThreadSafe { | 107 base::NonThreadSafe { |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 raw += "\n"; | 528 raw += "\n"; |
| 529 std::replace(raw.begin(), raw.end(), '\n', '\0'); | 529 std::replace(raw.begin(), raw.end(), '\n', '\0'); |
| 530 scoped_refptr<net::HttpResponseHeaders> headers( | 530 scoped_refptr<net::HttpResponseHeaders> headers( |
| 531 new net::HttpResponseHeaders(raw)); | 531 new net::HttpResponseHeaders(raw)); |
| 532 uint32_t extracted; | 532 uint32_t extracted; |
| 533 ASSERT_FALSE( | 533 ASSERT_FALSE( |
| 534 AttachmentDownloaderImpl::ExtractCrc32c(headers.get(), &extracted)); | 534 AttachmentDownloaderImpl::ExtractCrc32c(headers.get(), &extracted)); |
| 535 } | 535 } |
| 536 | 536 |
| 537 } // namespace syncer | 537 } // namespace syncer |
| OLD | NEW |