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

Side by Side Diff: sync/internal_api/attachments/attachment_downloader_impl_unittest.cc

Issue 1143323005: Refactor AO2TS to make it easier to componentize. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: debug Created 5 years, 5 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
OLDNEW
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
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698