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 "components/sync/engine_impl/attachments/attachment_downloader_impl.h" | 5 #include "components/sync/engine_impl/attachments/attachment_downloader_impl.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/memory/ptr_util.h" |
12 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
13 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
14 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
15 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
16 #include "base/test/histogram_tester.h" | 17 #include "base/test/histogram_tester.h" |
17 #include "base/threading/thread_task_runner_handle.h" | 18 #include "base/threading/thread_task_runner_handle.h" |
18 #include "components/sync/engine/attachments/attachment_util.h" | 19 #include "components/sync/engine/attachments/attachment_util.h" |
19 #include "components/sync/engine_impl/attachments/attachment_uploader_impl.h" | 20 #include "components/sync/engine_impl/attachments/attachment_uploader_impl.h" |
20 #include "components/sync/model/attachments/attachment.h" | 21 #include "components/sync/model/attachments/attachment.h" |
21 #include "google_apis/gaia/fake_oauth2_token_service.h" | 22 #include "google_apis/gaia/fake_oauth2_token_service.h" |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 std::unique_ptr<AttachmentDownloader> attachment_downloader_; | 200 std::unique_ptr<AttachmentDownloader> attachment_downloader_; |
200 ResultsMap download_results_; | 201 ResultsMap download_results_; |
201 int num_completed_downloads_; | 202 int num_completed_downloads_; |
202 const AttachmentId attachment_id_; | 203 const AttachmentId attachment_id_; |
203 }; | 204 }; |
204 | 205 |
205 void AttachmentDownloaderImplTest::SetUp() { | 206 void AttachmentDownloaderImplTest::SetUp() { |
206 url_request_context_getter_ = | 207 url_request_context_getter_ = |
207 new net::TestURLRequestContextGetter(message_loop_.task_runner()); | 208 new net::TestURLRequestContextGetter(message_loop_.task_runner()); |
208 url_fetcher_factory_.set_remove_fetcher_on_delete(true); | 209 url_fetcher_factory_.set_remove_fetcher_on_delete(true); |
209 token_service_.reset(new MockOAuth2TokenService()); | 210 token_service_ = base::MakeUnique<MockOAuth2TokenService>(); |
210 token_service_->AddAccount(kAccountId); | 211 token_service_->AddAccount(kAccountId); |
211 scoped_refptr<OAuth2TokenServiceRequest::TokenServiceProvider> | 212 scoped_refptr<OAuth2TokenServiceRequest::TokenServiceProvider> |
212 token_service_provider(new TokenServiceProvider(token_service_.get())); | 213 token_service_provider(new TokenServiceProvider(token_service_.get())); |
213 | 214 |
214 OAuth2TokenService::ScopeSet scopes; | 215 OAuth2TokenService::ScopeSet scopes; |
215 scopes.insert(GaiaConstants::kChromeSyncOAuth2Scope); | 216 scopes.insert(GaiaConstants::kChromeSyncOAuth2Scope); |
216 attachment_downloader_ = AttachmentDownloader::Create( | 217 attachment_downloader_ = AttachmentDownloader::Create( |
217 GURL(kAttachmentServerUrl), url_request_context_getter_, kAccountId, | 218 GURL(kAttachmentServerUrl), url_request_context_getter_, kAccountId, |
218 scopes, token_service_provider, std::string(kStoreBirthday), kModelType); | 219 scopes, token_service_provider, std::string(kStoreBirthday), kModelType); |
219 } | 220 } |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 raw += "\n"; | 527 raw += "\n"; |
527 std::replace(raw.begin(), raw.end(), '\n', '\0'); | 528 std::replace(raw.begin(), raw.end(), '\n', '\0'); |
528 scoped_refptr<net::HttpResponseHeaders> headers( | 529 scoped_refptr<net::HttpResponseHeaders> headers( |
529 new net::HttpResponseHeaders(raw)); | 530 new net::HttpResponseHeaders(raw)); |
530 uint32_t extracted; | 531 uint32_t extracted; |
531 ASSERT_FALSE( | 532 ASSERT_FALSE( |
532 AttachmentDownloaderImpl::ExtractCrc32c(headers.get(), &extracted)); | 533 AttachmentDownloaderImpl::ExtractCrc32c(headers.get(), &extracted)); |
533 } | 534 } |
534 | 535 |
535 } // namespace syncer | 536 } // namespace syncer |
OLD | NEW |