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_uploader_impl.h" | 5 #include "sync/internal_api/public/attachments/attachment_uploader_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/location.h" |
13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
14 #include "base/memory/ref_counted_memory.h" | 15 #include "base/memory/ref_counted_memory.h" |
15 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
16 #include "base/run_loop.h" | 17 #include "base/run_loop.h" |
| 18 #include "base/single_thread_task_runner.h" |
17 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
18 #include "base/strings/stringprintf.h" | 20 #include "base/strings/stringprintf.h" |
19 #include "base/synchronization/lock.h" | 21 #include "base/synchronization/lock.h" |
20 #include "base/test/histogram_tester.h" | 22 #include "base/test/histogram_tester.h" |
21 #include "base/threading/non_thread_safe.h" | 23 #include "base/threading/non_thread_safe.h" |
22 #include "base/threading/thread.h" | 24 #include "base/threading/thread.h" |
23 #include "base/threading/thread_task_runner_handle.h" | 25 #include "base/threading/thread_task_runner_handle.h" |
24 #include "google_apis/gaia/fake_oauth2_token_service.h" | 26 #include "google_apis/gaia/fake_oauth2_token_service.h" |
25 #include "google_apis/gaia/gaia_constants.h" | 27 #include "google_apis/gaia/gaia_constants.h" |
26 #include "google_apis/gaia/oauth2_token_service_request.h" | 28 #include "google_apis/gaia/oauth2_token_service_request.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 response_expiration_ = expiration; | 126 response_expiration_ = expiration; |
125 } | 127 } |
126 | 128 |
127 void MockOAuth2TokenService::FetchOAuth2Token( | 129 void MockOAuth2TokenService::FetchOAuth2Token( |
128 RequestImpl* request, | 130 RequestImpl* request, |
129 const std::string& account_id, | 131 const std::string& account_id, |
130 net::URLRequestContextGetter* getter, | 132 net::URLRequestContextGetter* getter, |
131 const std::string& client_id, | 133 const std::string& client_id, |
132 const std::string& client_secret, | 134 const std::string& client_secret, |
133 const ScopeSet& scopes) { | 135 const ScopeSet& scopes) { |
134 base::MessageLoop::current()->PostTask( | 136 base::ThreadTaskRunnerHandle::Get()->PostTask( |
135 FROM_HERE, | 137 FROM_HERE, base::Bind(&OAuth2TokenService::RequestImpl::InformConsumer, |
136 base::Bind(&OAuth2TokenService::RequestImpl::InformConsumer, | 138 request->AsWeakPtr(), response_error_, |
137 request->AsWeakPtr(), | 139 response_access_token_, response_expiration_)); |
138 response_error_, | |
139 response_access_token_, | |
140 response_expiration_)); | |
141 } | 140 } |
142 | 141 |
143 void MockOAuth2TokenService::InvalidateAccessTokenImpl( | 142 void MockOAuth2TokenService::InvalidateAccessTokenImpl( |
144 const std::string& account_id, | 143 const std::string& account_id, |
145 const std::string& client_id, | 144 const std::string& client_id, |
146 const ScopeSet& scopes, | 145 const ScopeSet& scopes, |
147 const std::string& access_token) { | 146 const std::string& access_token) { |
148 ++num_invalidate_token_; | 147 ++num_invalidate_token_; |
149 last_token_invalidated_ = access_token; | 148 last_token_invalidated_ = access_token; |
150 } | 149 } |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 scoped_refptr<base::RefCountedString> hello_world(new base::RefCountedString); | 673 scoped_refptr<base::RefCountedString> hello_world(new base::RefCountedString); |
675 hello_world->data() = "hello world"; | 674 hello_world->data() = "hello world"; |
676 EXPECT_EQ("yZRlqg==", AttachmentUploaderImpl::FormatCrc32cHash( | 675 EXPECT_EQ("yZRlqg==", AttachmentUploaderImpl::FormatCrc32cHash( |
677 ComputeCrc32c(hello_world))); | 676 ComputeCrc32c(hello_world))); |
678 } | 677 } |
679 | 678 |
680 // TODO(maniscalco): Add test case for when we are uploading an attachment that | 679 // TODO(maniscalco): Add test case for when we are uploading an attachment that |
681 // already exists. 409 Conflict? (bug 379825) | 680 // already exists. 409 Conflict? (bug 379825) |
682 | 681 |
683 } // namespace syncer | 682 } // namespace syncer |
OLD | NEW |