| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "components/offline_pages/background/offliner_factory.h" | 10 #include "components/offline_pages/background/offliner_factory.h" |
| 11 #include "components/offline_pages/background/offliner_policy.h" | 11 #include "components/offline_pages/background/offliner_policy.h" |
| 12 #include "components/offline_pages/background/save_page_request.h" | 12 #include "components/offline_pages/background/save_page_request.h" |
| 13 #include "components/offline_pages/background/scheduler.h" |
| 13 #include "components/offline_pages/offline_page_item.h" | 14 #include "components/offline_pages/offline_page_item.h" |
| 14 | 15 |
| 15 namespace offline_pages { | 16 namespace offline_pages { |
| 16 | 17 |
| 17 RequestCoordinator::RequestCoordinator(std::unique_ptr<OfflinerPolicy> policy, | 18 RequestCoordinator::RequestCoordinator( |
| 18 std::unique_ptr<OfflinerFactory> factory, | 19 std::unique_ptr<OfflinerPolicy> policy, |
| 19 std::unique_ptr<RequestQueue> queue) { | 20 std::unique_ptr<OfflinerFactory> factory, |
| 20 // Do setup as needed. | 21 std::unique_ptr<RequestQueue> queue, |
| 21 // TODO(petewil): Assert policy not null. | 22 std::unique_ptr<Scheduler> scheduler) |
| 22 policy_ = std::move(policy); | 23 : policy_(std::move(policy)), factory_(std::move(factory)), |
| 23 factory_ = std::move(factory); | 24 queue_(std::move(queue)), scheduler_(std::move(scheduler)) { |
| 24 queue_ = std::move(queue); | 25 DCHECK(policy_ != nullptr); |
| 25 } | 26 } |
| 26 | 27 |
| 27 RequestCoordinator::~RequestCoordinator() {} | 28 RequestCoordinator::~RequestCoordinator() {} |
| 28 | 29 |
| 29 bool RequestCoordinator::SavePageLater( | 30 bool RequestCoordinator::SavePageLater( |
| 30 const GURL& url, const ClientId& client_id) { | 31 const GURL& url, const ClientId& client_id) { |
| 31 DVLOG(2) << "URL is " << url << " " << __FUNCTION__; | 32 DVLOG(2) << "URL is " << url << " " << __FUNCTION__; |
| 32 | 33 |
| 33 // TODO(petewil): We need a robust scheme for allocating new IDs. | 34 // TODO(petewil): We need a robust scheme for allocating new IDs. |
| 34 static int64_t id = 0; | 35 static int64_t id = 0; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 46 | 47 |
| 47 return true; | 48 return true; |
| 48 } | 49 } |
| 49 | 50 |
| 50 void RequestCoordinator::AddRequestResultCallback( | 51 void RequestCoordinator::AddRequestResultCallback( |
| 51 RequestQueue::AddRequestResult result, | 52 RequestQueue::AddRequestResult result, |
| 52 const SavePageRequest& request) { | 53 const SavePageRequest& request) { |
| 53 DVLOG(2) << __FUNCTION__; | 54 DVLOG(2) << __FUNCTION__; |
| 54 | 55 |
| 55 // Inform the scheduler that we have an outstanding task. | 56 // Inform the scheduler that we have an outstanding task. |
| 56 // TODO(petewil): implement. | 57 // TODO(petewil): Define proper TriggerConditions and set them. |
| 58 Scheduler::TriggerCondition conditions; |
| 59 scheduler_->Schedule(conditions); |
| 57 } | 60 } |
| 58 | 61 |
| 59 bool RequestCoordinator::StartProcessing( | 62 bool RequestCoordinator::StartProcessing( |
| 60 const ProcessingDoneCallback& callback) { | 63 const ProcessingDoneCallback& callback) { |
| 61 return false; | 64 return false; |
| 62 } | 65 } |
| 63 | 66 |
| 64 void RequestCoordinator::StopProcessing() { | 67 void RequestCoordinator::StopProcessing() { |
| 65 } | 68 } |
| 66 | 69 |
| 67 } // namespace offline_pages | 70 } // namespace offline_pages |
| OLD | NEW |