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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 last_offlining_status_(Offliner::RequestStatus::UNKNOWN), | 60 last_offlining_status_(Offliner::RequestStatus::UNKNOWN), |
61 weak_ptr_factory_(this) { | 61 weak_ptr_factory_(this) { |
62 DCHECK(policy_ != nullptr); | 62 DCHECK(policy_ != nullptr); |
63 picker_.reset(new RequestPicker(queue_.get(), policy_.get())); | 63 picker_.reset(new RequestPicker(queue_.get(), policy_.get())); |
64 } | 64 } |
65 | 65 |
66 RequestCoordinator::~RequestCoordinator() {} | 66 RequestCoordinator::~RequestCoordinator() {} |
67 | 67 |
68 bool RequestCoordinator::SavePageLater( | 68 bool RequestCoordinator::SavePageLater( |
69 const GURL& url, const ClientId& client_id, bool was_user_requested) { | 69 const GURL& url, const ClientId& client_id, bool was_user_requested) { |
70 DVLOG(2) << "URL is " << url << " " << __FUNCTION__; | 70 DVLOG(2) << "URL is " << url << " " << __func__; |
71 | 71 |
72 // TODO(petewil): We need a robust scheme for allocating new IDs. We may need | 72 // TODO(petewil): We need a robust scheme for allocating new IDs. We may need |
73 // GUIDS for the downloads home design. | 73 // GUIDS for the downloads home design. |
74 static int64_t id = 0; | 74 static int64_t id = 0; |
75 | 75 |
76 // Build a SavePageRequest. | 76 // Build a SavePageRequest. |
77 // TODO(petewil): Use something like base::Clock to help in testing. | 77 // TODO(petewil): Use something like base::Clock to help in testing. |
78 offline_pages::SavePageRequest request( | 78 offline_pages::SavePageRequest request( |
79 id++, url, client_id, base::Time::Now(), was_user_requested); | 79 id++, url, client_id, base::Time::Now(), was_user_requested); |
80 | 80 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 weak_ptr_factory_.GetWeakPtr())); | 184 weak_ptr_factory_.GetWeakPtr())); |
185 | 185 |
186 // Start a watchdog timer to catch pre-renders running too long | 186 // Start a watchdog timer to catch pre-renders running too long |
187 watchdog_timer_.Start(FROM_HERE, offliner_timeout_, this, | 187 watchdog_timer_.Start(FROM_HERE, offliner_timeout_, this, |
188 &RequestCoordinator::StopProcessing); | 188 &RequestCoordinator::StopProcessing); |
189 } | 189 } |
190 | 190 |
191 void RequestCoordinator::OfflinerDoneCallback(const SavePageRequest& request, | 191 void RequestCoordinator::OfflinerDoneCallback(const SavePageRequest& request, |
192 Offliner::RequestStatus status) { | 192 Offliner::RequestStatus status) { |
193 DVLOG(2) << "offliner finished, saved: " | 193 DVLOG(2) << "offliner finished, saved: " |
194 << (status == Offliner::RequestStatus::SAVED) << ", status: " | 194 << (status == Offliner::RequestStatus::SAVED) |
195 << (int) status << ", " << __FUNCTION__; | 195 << ", status: " << static_cast<int>(status) << ", " << __func__; |
196 DCHECK_NE(status, Offliner::RequestStatus::UNKNOWN); | 196 DCHECK_NE(status, Offliner::RequestStatus::UNKNOWN); |
197 DCHECK_NE(status, Offliner::RequestStatus::LOADED); | 197 DCHECK_NE(status, Offliner::RequestStatus::LOADED); |
198 event_logger_.RecordSavePageRequestUpdated( | 198 event_logger_.RecordSavePageRequestUpdated( |
199 request.client_id().name_space, | 199 request.client_id().name_space, |
200 "Saved", | 200 "Saved", |
201 request.request_id()); | 201 request.request_id()); |
202 last_offlining_status_ = status; | 202 last_offlining_status_ = status; |
203 RecordOfflinerResultUMA(last_offlining_status_); | 203 RecordOfflinerResultUMA(last_offlining_status_); |
204 watchdog_timer_.Stop(); | 204 watchdog_timer_.Stop(); |
205 | 205 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 return kUserRequestTriggerConditions; | 239 return kUserRequestTriggerConditions; |
240 } | 240 } |
241 | 241 |
242 void RequestCoordinator::GetOffliner() { | 242 void RequestCoordinator::GetOffliner() { |
243 if (!offliner_) { | 243 if (!offliner_) { |
244 offliner_ = factory_->GetOffliner(policy_.get()); | 244 offliner_ = factory_->GetOffliner(policy_.get()); |
245 } | 245 } |
246 } | 246 } |
247 | 247 |
248 } // namespace offline_pages | 248 } // namespace offline_pages |
OLD | NEW |