| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/offline_pages/background/request_coordinator.h" | 5 #include "components/offline_pages/background/request_coordinator.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> |
| 9 | 10 |
| 10 #include "base/bind.h" | 11 #include "base/bind.h" |
| 11 #include "base/location.h" | 12 #include "base/location.h" |
| 12 #include "base/test/test_simple_task_runner.h" | 13 #include "base/test/test_simple_task_runner.h" |
| 13 #include "base/threading/thread_task_runner_handle.h" | 14 #include "base/threading/thread_task_runner_handle.h" |
| 14 #include "components/offline_pages/background/offliner.h" | 15 #include "components/offline_pages/background/offliner.h" |
| 15 #include "components/offline_pages/background/offliner_factory.h" | 16 #include "components/offline_pages/background/offliner_factory.h" |
| 16 #include "components/offline_pages/background/offliner_policy.h" | 17 #include "components/offline_pages/background/offliner_policy.h" |
| 17 #include "components/offline_pages/background/request_queue.h" | 18 #include "components/offline_pages/background/request_queue.h" |
| 18 #include "components/offline_pages/background/request_queue_in_memory_store.h" | 19 #include "components/offline_pages/background/request_queue_in_memory_store.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 48 private: | 49 private: |
| 49 bool schedule_called_; | 50 bool schedule_called_; |
| 50 bool unschedule_called_; | 51 bool unschedule_called_; |
| 51 }; | 52 }; |
| 52 | 53 |
| 53 class OfflinerStub : public Offliner { | 54 class OfflinerStub : public Offliner { |
| 54 bool LoadAndSave(const SavePageRequest& request, | 55 bool LoadAndSave(const SavePageRequest& request, |
| 55 const CompletionCallback& callback) override { | 56 const CompletionCallback& callback) override { |
| 56 // Post the callback on the run loop. | 57 // Post the callback on the run loop. |
| 57 base::ThreadTaskRunnerHandle::Get()->PostTask( | 58 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 58 FROM_HERE, base::Bind(callback, request, Offliner::SAVED)); | 59 FROM_HERE, |
| 60 base::Bind(callback, request, Offliner::RequestStatus::SAVED)); |
| 59 return true; | 61 return true; |
| 60 } | 62 } |
| 61 | 63 |
| 62 // Clears the currently processing request, if any. | 64 // Clears the currently processing request, if any. |
| 63 void Cancel() override {} | 65 void Cancel() override {} |
| 64 }; | 66 }; |
| 65 | 67 |
| 66 class OfflinerFactoryStub : public OfflinerFactory { | 68 class OfflinerFactoryStub : public OfflinerFactory { |
| 67 public: | 69 public: |
| 68 Offliner* GetOffliner(const OfflinerPolicy* policy) override { | 70 Offliner* GetOffliner(const OfflinerPolicy* policy) override { |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 EXPECT_EQ(1UL, last_requests().size()); | 167 EXPECT_EQ(1UL, last_requests().size()); |
| 166 EXPECT_EQ(kUrl, last_requests()[0].url()); | 168 EXPECT_EQ(kUrl, last_requests()[0].url()); |
| 167 EXPECT_EQ(kClientId, last_requests()[0].client_id()); | 169 EXPECT_EQ(kClientId, last_requests()[0].client_id()); |
| 168 | 170 |
| 169 // Expect that the scheduler got notified. | 171 // Expect that the scheduler got notified. |
| 170 SchedulerStub* scheduler_stub = reinterpret_cast<SchedulerStub*>( | 172 SchedulerStub* scheduler_stub = reinterpret_cast<SchedulerStub*>( |
| 171 coordinator()->GetSchedulerForTesting()); | 173 coordinator()->GetSchedulerForTesting()); |
| 172 EXPECT_TRUE(scheduler_stub->schedule_called()); | 174 EXPECT_TRUE(scheduler_stub->schedule_called()); |
| 173 | 175 |
| 174 // Check that the offliner callback got a response. | 176 // Check that the offliner callback got a response. |
| 175 EXPECT_EQ(Offliner::SAVED, coordinator()->last_offlining_status()); | 177 EXPECT_EQ(Offliner::RequestStatus::SAVED, |
| 178 coordinator()->last_offlining_status()); |
| 176 | 179 |
| 177 // TODO(petewil): Expect that the scheduler got notified. | 180 // TODO(petewil): Expect that the scheduler got notified. |
| 178 } | 181 } |
| 179 | 182 |
| 180 } // namespace offline_pages | 183 } // namespace offline_pages |
| OLD | NEW |