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_service_impl.h" | 5 #include "components/sync/core/attachments/attachment_service_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/location.h" | 13 #include "base/location.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
18 #include "base/run_loop.h" | 18 #include "base/run_loop.h" |
19 #include "base/single_thread_task_runner.h" | 19 #include "base/single_thread_task_runner.h" |
20 #include "base/threading/thread_task_runner_handle.h" | 20 #include "base/threading/thread_task_runner_handle.h" |
21 #include "base/timer/mock_timer.h" | 21 #include "base/timer/mock_timer.h" |
22 #include "sync/api/attachments/attachment_store_backend.h" | 22 #include "components/sync/api/attachments/attachment_store_backend.h" |
23 #include "sync/internal_api/public/attachments/attachment_util.h" | 23 #include "components/sync/core/attachments/attachment_util.h" |
24 #include "sync/internal_api/public/attachments/fake_attachment_downloader.h" | 24 #include "components/sync/core/attachments/fake_attachment_downloader.h" |
25 #include "sync/internal_api/public/attachments/fake_attachment_uploader.h" | 25 #include "components/sync/core/attachments/fake_attachment_uploader.h" |
26 #include "testing/gmock/include/gmock/gmock-matchers.h" | 26 #include "testing/gmock/include/gmock/gmock-matchers.h" |
27 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
28 | 28 |
29 namespace syncer { | 29 namespace syncer { |
30 | 30 |
31 namespace { | 31 namespace { |
32 | 32 |
33 class MockAttachmentStoreBackend | 33 class MockAttachmentStoreBackend |
34 : public AttachmentStoreBackend, | 34 : public AttachmentStoreBackend, |
35 public base::SupportsWeakPtr<MockAttachmentStoreBackend> { | 35 public base::SupportsWeakPtr<MockAttachmentStoreBackend> { |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 } | 280 } |
281 | 281 |
282 static AttachmentIdSet AttachmentIdSetFromList( | 282 static AttachmentIdSet AttachmentIdSetFromList( |
283 const AttachmentIdList& id_list) { | 283 const AttachmentIdList& id_list) { |
284 AttachmentIdSet id_set; | 284 AttachmentIdSet id_set; |
285 std::copy(id_list.begin(), id_list.end(), | 285 std::copy(id_list.begin(), id_list.end(), |
286 std::inserter(id_set, id_set.end())); | 286 std::inserter(id_set, id_set.end())); |
287 return id_set; | 287 return id_set; |
288 } | 288 } |
289 | 289 |
290 const std::vector<AttachmentService::GetOrDownloadResult>& | 290 const std::vector<AttachmentService::GetOrDownloadResult>& download_results() |
291 download_results() const { | 291 const { |
292 return download_results_; | 292 return download_results_; |
293 } | 293 } |
294 | 294 |
295 const AttachmentMap& last_download_attachments() const { | 295 const AttachmentMap& last_download_attachments() const { |
296 return *last_download_attachments_.get(); | 296 return *last_download_attachments_.get(); |
297 } | 297 } |
298 | 298 |
299 net::NetworkChangeNotifier* network_change_notifier() { | 299 net::NetworkChangeNotifier* network_change_notifier() { |
300 return network_change_notifier_.get(); | 300 return network_change_notifier_.get(); |
301 } | 301 } |
302 | 302 |
303 MockAttachmentStoreBackend* store() { | 303 MockAttachmentStoreBackend* store() { |
304 return attachment_store_backend_.get(); | 304 return attachment_store_backend_.get(); |
305 } | 305 } |
306 | 306 |
307 MockAttachmentDownloader* downloader() { | 307 MockAttachmentDownloader* downloader() { |
308 return attachment_downloader_.get(); | 308 return attachment_downloader_.get(); |
309 } | 309 } |
310 | 310 |
311 MockAttachmentUploader* uploader() { | 311 MockAttachmentUploader* uploader() { return attachment_uploader_.get(); } |
312 return attachment_uploader_.get(); | |
313 } | |
314 | 312 |
315 const std::vector<AttachmentId>& on_attachment_uploaded_list() const { | 313 const std::vector<AttachmentId>& on_attachment_uploaded_list() const { |
316 return on_attachment_uploaded_list_; | 314 return on_attachment_uploaded_list_; |
317 } | 315 } |
318 | 316 |
319 private: | 317 private: |
320 base::MessageLoop message_loop_; | 318 base::MessageLoop message_loop_; |
321 std::unique_ptr<net::NetworkChangeNotifier> network_change_notifier_; | 319 std::unique_ptr<net::NetworkChangeNotifier> network_change_notifier_; |
322 base::WeakPtr<MockAttachmentStoreBackend> attachment_store_backend_; | 320 base::WeakPtr<MockAttachmentStoreBackend> attachment_store_backend_; |
323 base::WeakPtr<MockAttachmentDownloader> attachment_downloader_; | 321 base::WeakPtr<MockAttachmentDownloader> attachment_downloader_; |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 net::NetworkChangeNotifier::NotifyObserversOfNetworkChangeForTests( | 629 net::NetworkChangeNotifier::NotifyObserversOfNetworkChangeForTests( |
632 net::NetworkChangeNotifier::CONNECTION_WIFI); | 630 net::NetworkChangeNotifier::CONNECTION_WIFI); |
633 RunLoop(); | 631 RunLoop(); |
634 | 632 |
635 // No longer in backoff. | 633 // No longer in backoff. |
636 ASSERT_TRUE(mock_timer()->IsRunning()); | 634 ASSERT_TRUE(mock_timer()->IsRunning()); |
637 ASSERT_EQ(base::TimeDelta(), mock_timer()->GetCurrentDelay()); | 635 ASSERT_EQ(base::TimeDelta(), mock_timer()->GetCurrentDelay()); |
638 } | 636 } |
639 | 637 |
640 } // namespace syncer | 638 } // namespace syncer |
OLD | NEW |