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())); | 63 picker_.reset(new RequestPicker(queue_.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) { | 69 const GURL& url, const ClientId& client_id) { |
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. | 72 // TODO(petewil): We need a robust scheme for allocating new IDs. |
73 static int64_t id = 0; | 73 static int64_t id = 0; |
74 | 74 |
75 // Build a SavePageRequest. | 75 // Build a SavePageRequest. |
76 // TODO(petewil): Use something like base::Clock to help in testing. | 76 // TODO(petewil): Use something like base::Clock to help in testing. |
77 offline_pages::SavePageRequest request( | 77 offline_pages::SavePageRequest request( |
78 id++, url, client_id, base::Time::Now()); | 78 id++, url, client_id, base::Time::Now()); |
79 | 79 |
80 // Put the request on the request queue. | 80 // Put the request on the request queue. |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 weak_ptr_factory_.GetWeakPtr())); | 173 weak_ptr_factory_.GetWeakPtr())); |
174 | 174 |
175 // Start a watchdog timer to catch pre-renders running too long | 175 // Start a watchdog timer to catch pre-renders running too long |
176 watchdog_timer_.Start(FROM_HERE, offliner_timeout_, this, | 176 watchdog_timer_.Start(FROM_HERE, offliner_timeout_, this, |
177 &RequestCoordinator::StopProcessing); | 177 &RequestCoordinator::StopProcessing); |
178 } | 178 } |
179 | 179 |
180 void RequestCoordinator::OfflinerDoneCallback(const SavePageRequest& request, | 180 void RequestCoordinator::OfflinerDoneCallback(const SavePageRequest& request, |
181 Offliner::RequestStatus status) { | 181 Offliner::RequestStatus status) { |
182 DVLOG(2) << "offliner finished, saved: " | 182 DVLOG(2) << "offliner finished, saved: " |
183 << (status == Offliner::RequestStatus::SAVED) << ", status: " | 183 << (status == Offliner::RequestStatus::SAVED) |
184 << (int) status << ", " << __FUNCTION__; | 184 << ", status: " << static_cast<int>(status) << ", " << __func__; |
185 DCHECK_NE(status, Offliner::RequestStatus::UNKNOWN); | 185 DCHECK_NE(status, Offliner::RequestStatus::UNKNOWN); |
186 DCHECK_NE(status, Offliner::RequestStatus::LOADED); | 186 DCHECK_NE(status, Offliner::RequestStatus::LOADED); |
187 event_logger_.RecordSavePageRequestUpdated( | 187 event_logger_.RecordSavePageRequestUpdated( |
188 request.client_id().name_space, | 188 request.client_id().name_space, |
189 "Saved", | 189 "Saved", |
190 request.request_id()); | 190 request.request_id()); |
191 last_offlining_status_ = status; | 191 last_offlining_status_ = status; |
192 RecordOfflinerResultUMA(last_offlining_status_); | 192 RecordOfflinerResultUMA(last_offlining_status_); |
193 watchdog_timer_.Stop(); | 193 watchdog_timer_.Stop(); |
194 | 194 |
(...skipping 18 matching lines...) Expand all Loading... |
213 return kUserRequestTriggerConditions; | 213 return kUserRequestTriggerConditions; |
214 } | 214 } |
215 | 215 |
216 void RequestCoordinator::GetOffliner() { | 216 void RequestCoordinator::GetOffliner() { |
217 if (!offliner_) { | 217 if (!offliner_) { |
218 offliner_ = factory_->GetOffliner(policy_.get()); | 218 offliner_ = factory_->GetOffliner(policy_.get()); |
219 } | 219 } |
220 } | 220 } |
221 | 221 |
222 } // namespace offline_pages | 222 } // namespace offline_pages |
OLD | NEW |