| 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 "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 DCHECK(policy_ != nullptr); | 55 DCHECK(policy_ != nullptr); |
| 56 picker_.reset(new RequestPicker(queue_.get(), policy_.get())); | 56 picker_.reset(new RequestPicker(queue_.get(), policy_.get())); |
| 57 } | 57 } |
| 58 | 58 |
| 59 RequestCoordinator::~RequestCoordinator() {} | 59 RequestCoordinator::~RequestCoordinator() {} |
| 60 | 60 |
| 61 bool RequestCoordinator::SavePageLater( | 61 bool RequestCoordinator::SavePageLater( |
| 62 const GURL& url, const ClientId& client_id, bool was_user_requested) { | 62 const GURL& url, const ClientId& client_id, bool was_user_requested) { |
| 63 DVLOG(2) << "URL is " << url << " " << __FUNCTION__; | 63 DVLOG(2) << "URL is " << url << " " << __FUNCTION__; |
| 64 | 64 |
| 65 // TODO(petewil): We need a robust scheme for allocating new IDs. We may need | 65 // TODO(petewil): We need a robust scheme for allocating new IDs. |
| 66 // GUIDS for the downloads home design. | |
| 67 static int64_t id = 0; | 66 static int64_t id = 0; |
| 68 | 67 |
| 69 // Build a SavePageRequest. | 68 // Build a SavePageRequest. |
| 70 // TODO(petewil): Use something like base::Clock to help in testing. | 69 // TODO(petewil): Use something like base::Clock to help in testing. |
| 71 offline_pages::SavePageRequest request( | 70 offline_pages::SavePageRequest request( |
| 72 id++, url, client_id, base::Time::Now(), was_user_requested); | 71 id++, url, client_id, base::Time::Now(), was_user_requested); |
| 73 | 72 |
| 74 // Put the request on the request queue. | 73 // Put the request on the request queue. |
| 75 queue_->AddRequest(request, | 74 queue_->AddRequest(request, |
| 76 base::Bind(&RequestCoordinator::AddRequestResultCallback, | 75 base::Bind(&RequestCoordinator::AddRequestResultCallback, |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 return trigger_conditions; | 235 return trigger_conditions; |
| 237 } | 236 } |
| 238 | 237 |
| 239 void RequestCoordinator::GetOffliner() { | 238 void RequestCoordinator::GetOffliner() { |
| 240 if (!offliner_) { | 239 if (!offliner_) { |
| 241 offliner_ = factory_->GetOffliner(policy_.get()); | 240 offliner_ = factory_->GetOffliner(policy_.get()); |
| 242 } | 241 } |
| 243 } | 242 } |
| 244 | 243 |
| 245 } // namespace offline_pages | 244 } // namespace offline_pages |
| OLD | NEW |