| 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_picker.h" | 5 #include "components/offline_pages/background/pick_request_task.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/time/time.h" |
| 10 #include "components/offline_pages/background/device_conditions.h" |
| 11 #include "components/offline_pages/background/offliner_policy.h" |
| 12 #include "components/offline_pages/background/request_coordinator_event_logger.h
" |
| 13 #include "components/offline_pages/background/request_notifier.h" |
| 14 #include "components/offline_pages/background/request_queue_store.h" |
| 9 #include "components/offline_pages/background/save_page_request.h" | 15 #include "components/offline_pages/background/save_page_request.h" |
| 10 | 16 |
| 11 namespace { | 17 namespace { |
| 12 template <typename T> | 18 template <typename T> |
| 13 int signum(T t) { | 19 int signum(T t) { |
| 14 return (T(0) < t) - (t < T(0)); | 20 return (T(0) < t) - (t < T(0)); |
| 15 } | 21 } |
| 16 | 22 |
| 17 #define CALL_MEMBER_FUNCTION(object, ptrToMember) ((object)->*(ptrToMember)) | 23 #define CALL_MEMBER_FUNCTION(object, ptrToMember) ((object)->*(ptrToMember)) |
| 18 } // namespace | 24 } // namespace |
| 19 | 25 |
| 20 namespace offline_pages { | 26 namespace offline_pages { |
| 21 | 27 |
| 22 RequestPicker::RequestPicker(RequestQueue* requestQueue, | 28 PickRequestTask::PickRequestTask(RequestQueueStore* store, |
| 23 OfflinerPolicy* policy, | 29 OfflinerPolicy* policy, |
| 24 RequestNotifier* notifier, | 30 RequestNotifier* notifier, |
| 25 RequestCoordinatorEventLogger* event_logger) | 31 RequestCoordinatorEventLogger* event_logger, |
| 26 : queue_(requestQueue), | 32 RequestPickedCallback picked_callback, |
| 33 RequestNotPickedCallback not_picked_callback, |
| 34 DeviceConditions& device_conditions, |
| 35 const std::set<int64_t>& disabled_requests) |
| 36 : store_(store), |
| 27 policy_(policy), | 37 policy_(policy), |
| 28 notifier_(notifier), | 38 notifier_(notifier), |
| 29 event_logger_(event_logger), | 39 event_logger_(event_logger), |
| 30 fewer_retries_better_(false), | 40 picked_callback_(picked_callback), |
| 31 earlier_requests_better_(false), | 41 not_picked_callback_(not_picked_callback), |
| 32 weak_ptr_factory_(this) {} | 42 disabled_requests_(disabled_requests), |
| 33 | 43 weak_ptr_factory_(this) { |
| 34 RequestPicker::~RequestPicker() {} | 44 device_conditions_.reset(new DeviceConditions(device_conditions)); |
| 35 | |
| 36 // Entry point for the async operation to choose the next request. | |
| 37 void RequestPicker::ChooseNextRequest( | |
| 38 RequestCoordinator::RequestPickedCallback picked_callback, | |
| 39 RequestCoordinator::RequestNotPickedCallback not_picked_callback, | |
| 40 DeviceConditions* device_conditions, | |
| 41 const std::set<int64_t>& disabled_requests) { | |
| 42 picked_callback_ = picked_callback; | |
| 43 not_picked_callback_ = not_picked_callback; | |
| 44 fewer_retries_better_ = policy_->ShouldPreferUntriedRequests(); | |
| 45 earlier_requests_better_ = policy_->ShouldPreferEarlierRequests(); | |
| 46 current_conditions_.reset(new DeviceConditions(*device_conditions)); | |
| 47 // Get all requests from queue (there is no filtering mechanism). | |
| 48 queue_->GetRequests(base::Bind(&RequestPicker::GetRequestResultCallback, | |
| 49 weak_ptr_factory_.GetWeakPtr(), | |
| 50 disabled_requests)); | |
| 51 } | 45 } |
| 52 | 46 |
| 53 // When we get contents from the queue, use them to pick the next | 47 PickRequestTask::~PickRequestTask() {} |
| 54 // request to operate on (if any). | 48 |
| 55 void RequestPicker::GetRequestResultCallback( | 49 void PickRequestTask::Run() { |
| 56 const std::set<int64_t>& disabled_requests, | 50 // Get all the requests from the queue, we will classify them in the callback. |
| 57 RequestQueue::GetRequestsResult, | 51 store_->GetRequests(base::Bind(&PickRequestTask::ChooseAndPrune, |
| 52 weak_ptr_factory_.GetWeakPtr())); |
| 53 } |
| 54 |
| 55 void PickRequestTask::ChooseAndPrune( |
| 56 bool success, |
| 58 std::vector<std::unique_ptr<SavePageRequest>> requests) { | 57 std::vector<std::unique_ptr<SavePageRequest>> requests) { |
| 59 // If there is nothing to do, return right away. | 58 // If there is nothing to do, return right away. |
| 60 if (requests.size() == 0) { | 59 if (requests.size() == 0) { |
| 61 not_picked_callback_.Run(false); | 60 not_picked_callback_.Run(false); |
| 61 TaskComplete(); |
| 62 return; | 62 return; |
| 63 } | 63 } |
| 64 | 64 |
| 65 // Get the expired requests to be removed from the queue, and the valid ones | 65 // Get the expired requests to be removed from the queue, and the valid ones |
| 66 // from which to pick the next request. | 66 // from which to pick the next request. |
| 67 std::vector<std::unique_ptr<SavePageRequest>> valid_requests; | 67 std::vector<std::unique_ptr<SavePageRequest>> valid_requests; |
| 68 std::vector<std::unique_ptr<SavePageRequest>> expired_requests; | |
| 69 SplitRequests(std::move(requests), &valid_requests, &expired_requests); | |
| 70 std::vector<int64_t> expired_request_ids; | 68 std::vector<int64_t> expired_request_ids; |
| 71 for (const auto& request : expired_requests) | 69 SplitRequests(std::move(requests), &valid_requests, &expired_request_ids); |
| 72 expired_request_ids.push_back(request->request_id()); | |
| 73 | 70 |
| 74 queue_->RemoveRequests(expired_request_ids, | 71 // Continue processing by choosing a request. |
| 75 base::Bind(&RequestPicker::OnRequestExpired, | 72 ChooseRequestAndCallback(std::move(valid_requests)); |
| 76 weak_ptr_factory_.GetWeakPtr())); | |
| 77 | 73 |
| 74 // Continue processing by handling expired requests, if any. |
| 75 if (expired_request_ids.size() == 0) { |
| 76 TaskComplete(); |
| 77 return; |
| 78 } |
| 79 |
| 80 RemoveStaleRequests(std::move(expired_request_ids)); |
| 81 } |
| 82 |
| 83 void PickRequestTask::ChooseRequestAndCallback( |
| 84 std::vector<std::unique_ptr<SavePageRequest>> valid_requests) { |
| 78 // Pick the most deserving request for our conditions. | 85 // Pick the most deserving request for our conditions. |
| 79 const SavePageRequest* picked_request = nullptr; | 86 const SavePageRequest* picked_request = nullptr; |
| 80 | 87 |
| 81 RequestCompareFunction comparator = nullptr; | 88 RequestCompareFunction comparator = nullptr; |
| 82 | 89 |
| 83 // Choose which comparison function to use based on policy. | 90 // Choose which comparison function to use based on policy. |
| 84 if (policy_->RetryCountIsMoreImportantThanRecency()) | 91 if (policy_->RetryCountIsMoreImportantThanRecency()) |
| 85 comparator = &RequestPicker::RetryCountFirstCompareFunction; | 92 comparator = &PickRequestTask::RetryCountFirstCompareFunction; |
| 86 else | 93 else |
| 87 comparator = &RequestPicker::RecencyFirstCompareFunction; | 94 comparator = &PickRequestTask::RecencyFirstCompareFunction; |
| 95 |
| 96 // TODO(petewil): Consider replacing this bool with a better named enum. |
| 97 bool non_user_requested_tasks_remaining = false; |
| 88 | 98 |
| 89 // Iterate once through the requests, keeping track of best candidate. | 99 // Iterate once through the requests, keeping track of best candidate. |
| 90 bool non_user_requested_tasks_remaining = false; | |
| 91 for (unsigned i = 0; i < valid_requests.size(); ++i) { | 100 for (unsigned i = 0; i < valid_requests.size(); ++i) { |
| 92 // If the request is on the disabled list, skip it. | 101 // If the request is on the disabled list, skip it. |
| 93 auto search = disabled_requests.find(valid_requests[i]->request_id()); | 102 auto search = disabled_requests_.find(valid_requests[i]->request_id()); |
| 94 if (search != disabled_requests.end()) { | 103 if (search != disabled_requests_.end()) |
| 95 continue; | 104 continue; |
| 96 } | 105 // If there are non-user-requested tasks remaining, we need to make sure |
| 106 // that they are scheduled after we run out of user requested tasks. Here we |
| 107 // detect if any exist. If we don't find any user-requested tasks, we will |
| 108 // inform the "not_picked_callback_" that it needs to schedule a task for |
| 109 // non-user-requested items, which have different network and power needs. |
| 97 if (!valid_requests[i]->user_requested()) | 110 if (!valid_requests[i]->user_requested()) |
| 98 non_user_requested_tasks_remaining = true; | 111 non_user_requested_tasks_remaining = true; |
| 99 if (!RequestConditionsSatisfied(valid_requests[i].get())) | 112 if (!RequestConditionsSatisfied(valid_requests[i].get())) |
| 100 continue; | 113 continue; |
| 101 if (IsNewRequestBetter(picked_request, valid_requests[i].get(), comparator)) | 114 if (IsNewRequestBetter(picked_request, valid_requests[i].get(), comparator)) |
| 102 picked_request = valid_requests[i].get(); | 115 picked_request = valid_requests[i].get(); |
| 103 } | 116 } |
| 104 | 117 |
| 105 // If we have a best request to try next, get the request coodinator to | 118 // If we have a best request to try next, get the request coodinator to |
| 106 // start it. Otherwise return that we have no candidates. | 119 // start it. Otherwise return that we have no candidates. |
| 107 if (picked_request != nullptr) { | 120 if (picked_request != nullptr) |
| 108 picked_callback_.Run(*picked_request); | 121 picked_callback_.Run(*picked_request); |
| 109 } else { | 122 else |
| 110 not_picked_callback_.Run(non_user_requested_tasks_remaining); | 123 not_picked_callback_.Run(non_user_requested_tasks_remaining); |
| 124 } |
| 125 |
| 126 // Continue the async part of the processing by deleting the expired requests. |
| 127 // TODO(petewil): Does that really need to be done on the task queue? Hard to |
| 128 // see how we need to wait for it before starting the next task. OTOH, we'd hate |
| 129 // to do a second slow DB operation to get entries a second time, and waiting |
| 130 // until this is done will make sure other gets don't see these old entries. |
| 131 // Consider moving this to a fresh task type to clean the queue. |
| 132 void PickRequestTask::RemoveStaleRequests( |
| 133 std::vector<int64_t> stale_request_ids) { |
| 134 store_->RemoveRequests(stale_request_ids, |
| 135 base::Bind(&PickRequestTask::OnRequestsExpired, |
| 136 weak_ptr_factory_.GetWeakPtr())); |
| 137 } |
| 138 |
| 139 void PickRequestTask::OnRequestsExpired( |
| 140 std::unique_ptr<UpdateRequestsResult> result) { |
| 141 RequestNotifier::BackgroundSavePageResult save_page_result( |
| 142 RequestNotifier::BackgroundSavePageResult::EXPIRED); |
| 143 for (const auto& request : result->updated_items) { |
| 144 event_logger_->RecordDroppedSavePageRequest( |
| 145 request.client_id().name_space, save_page_result, request.request_id()); |
| 146 notifier_->NotifyCompleted(request, save_page_result); |
| 147 } |
| 148 |
| 149 // The task is now done, return control to the task queue. |
| 150 TaskComplete(); |
| 151 } |
| 152 |
| 153 void PickRequestTask::SplitRequests( |
| 154 std::vector<std::unique_ptr<SavePageRequest>> requests, |
| 155 std::vector<std::unique_ptr<SavePageRequest>>* valid_requests, |
| 156 std::vector<int64_t>* expired_request_ids) { |
| 157 for (auto& request : requests) { |
| 158 if (base::Time::Now() - request->creation_time() >= |
| 159 base::TimeDelta::FromSeconds(kRequestExpirationTimeInSeconds)) { |
| 160 expired_request_ids->push_back(request->request_id()); |
| 161 } else { |
| 162 valid_requests->push_back(std::move(request)); |
| 163 } |
| 111 } | 164 } |
| 112 } | 165 } |
| 113 | 166 |
| 114 // Filter out requests that don't meet the current conditions. For instance, if | 167 // Filter out requests that don't meet the current conditions. For instance, if |
| 115 // this is a predictive request, and we are not on WiFi, it should be ignored | 168 // this is a predictive request, and we are not on WiFi, it should be ignored |
| 116 // this round. | 169 // this round. |
| 117 bool RequestPicker::RequestConditionsSatisfied(const SavePageRequest* request) { | 170 bool PickRequestTask::RequestConditionsSatisfied( |
| 171 const SavePageRequest* request) { |
| 118 // If the user did not request the page directly, make sure we are connected | 172 // If the user did not request the page directly, make sure we are connected |
| 119 // to power and have WiFi and sufficient battery remaining before we take this | 173 // to power and have WiFi and sufficient battery remaining before we take this |
| 120 // request. | 174 // request. |
| 121 | 175 if (!device_conditions_->IsPowerConnected() && |
| 122 if (!current_conditions_->IsPowerConnected() && | |
| 123 policy_->PowerRequired(request->user_requested())) { | 176 policy_->PowerRequired(request->user_requested())) { |
| 124 return false; | 177 return false; |
| 125 } | 178 } |
| 126 | 179 |
| 127 if (current_conditions_->GetNetConnectionType() != | 180 if (device_conditions_->GetNetConnectionType() != |
| 128 net::NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI && | 181 net::NetworkChangeNotifier::ConnectionType::CONNECTION_WIFI && |
| 129 policy_->UnmeteredNetworkRequired(request->user_requested())) { | 182 policy_->UnmeteredNetworkRequired(request->user_requested())) { |
| 130 return false; | 183 return false; |
| 131 } | 184 } |
| 132 | 185 |
| 133 if (current_conditions_->GetBatteryPercentage() < | 186 if (device_conditions_->GetBatteryPercentage() < |
| 134 policy_->BatteryPercentageRequired(request->user_requested())) { | 187 policy_->BatteryPercentageRequired(request->user_requested())) { |
| 135 return false; | 188 return false; |
| 136 } | 189 } |
| 137 | 190 |
| 138 // If we have already started this page the max number of times, it is not | 191 // If we have already started this page the max number of times, it is not |
| 139 // eligible to try again. | 192 // eligible to try again. |
| 140 if (request->started_attempt_count() >= policy_->GetMaxStartedTries()) | 193 if (request->started_attempt_count() >= policy_->GetMaxStartedTries()) |
| 141 return false; | 194 return false; |
| 142 | 195 |
| 143 // If we have already completed trying this page the max number of times, it | 196 // If we have already completed trying this page the max number of times, it |
| 144 // is not eligible to try again. | 197 // is not eligible to try again. |
| 145 if (request->completed_attempt_count() >= policy_->GetMaxCompletedTries()) | 198 if (request->completed_attempt_count() >= policy_->GetMaxCompletedTries()) |
| 146 return false; | 199 return false; |
| 147 | 200 |
| 148 // If the request is paused, do not consider it. | 201 // If the request is paused, do not consider it. |
| 149 if (request->request_state() == SavePageRequest::RequestState::PAUSED) | 202 if (request->request_state() == SavePageRequest::RequestState::PAUSED) |
| 150 return false; | 203 return false; |
| 151 | 204 |
| 152 // If the request is expired, do not consider it. | 205 // If the request is expired, do not consider it. |
| 153 base::TimeDelta requestAge = base::Time::Now() - request->creation_time(); | 206 base::TimeDelta requestAge = base::Time::Now() - request->creation_time(); |
| 154 if (requestAge > | 207 if (requestAge > base::TimeDelta::FromSeconds( |
| 155 base::TimeDelta::FromSeconds( | 208 policy_->GetRequestExpirationTimeInSeconds())) |
| 156 policy_->GetRequestExpirationTimeInSeconds())) | |
| 157 return false; | 209 return false; |
| 158 | 210 |
| 159 // If this request is not active yet, return false. | 211 // If this request is not active yet, return false. |
| 160 // TODO(petewil): If the only reason we return nothing to do is that we have | 212 // TODO(petewil): If the only reason we return nothing to do is that we have |
| 161 // inactive requests, we still want to try again later after their activation | 213 // inactive requests, we still want to try again later after their activation |
| 162 // time elapses, we shouldn't take ourselves completely off the scheduler. | 214 // time elapses, we shouldn't take ourselves completely off the scheduler. |
| 163 if (request->activation_time() > base::Time::Now()) | 215 if (request->activation_time() > base::Time::Now()) |
| 164 return false; | 216 return false; |
| 165 | 217 |
| 166 return true; | 218 return true; |
| 167 } | 219 } |
| 168 | 220 |
| 169 // Look at policies to decide which requests to prefer. | 221 // Look at policies to decide which requests to prefer. |
| 170 bool RequestPicker::IsNewRequestBetter(const SavePageRequest* oldRequest, | 222 bool PickRequestTask::IsNewRequestBetter(const SavePageRequest* oldRequest, |
| 171 const SavePageRequest* newRequest, | 223 const SavePageRequest* newRequest, |
| 172 RequestCompareFunction comparator) { | 224 RequestCompareFunction comparator) { |
| 173 | |
| 174 // If there is no old request, the new one is better. | 225 // If there is no old request, the new one is better. |
| 175 if (oldRequest == nullptr) | 226 if (oldRequest == nullptr) |
| 176 return true; | 227 return true; |
| 177 | 228 |
| 178 // User requested pages get priority. | 229 // User requested pages get priority. |
| 179 if (newRequest->user_requested() && !oldRequest->user_requested()) | 230 if (newRequest->user_requested() && !oldRequest->user_requested()) |
| 180 return true; | 231 return true; |
| 181 | 232 |
| 182 // Otherwise, use the comparison function for the current policy, which | 233 // Otherwise, use the comparison function for the current policy, which |
| 183 // returns true if the older request is better. | 234 // returns true if the older request is better. |
| 184 return !(CALL_MEMBER_FUNCTION(this, comparator)(oldRequest, newRequest)); | 235 return !(CALL_MEMBER_FUNCTION(this, comparator)(oldRequest, newRequest)); |
| 185 } | 236 } |
| 186 | 237 |
| 187 // Compare the results, checking request count before recency. Returns true if | 238 // Compare the results, checking request count before recency. Returns true if |
| 188 // left hand side is better, false otherwise. | 239 // left hand side is better, false otherwise. |
| 189 bool RequestPicker::RetryCountFirstCompareFunction( | 240 bool PickRequestTask::RetryCountFirstCompareFunction( |
| 190 const SavePageRequest* left, const SavePageRequest* right) { | 241 const SavePageRequest* left, |
| 242 const SavePageRequest* right) { |
| 191 // Check the attempt count. | 243 // Check the attempt count. |
| 192 int result = CompareRetryCount(left, right); | 244 int result = CompareRetryCount(left, right); |
| 193 | 245 |
| 194 if (result != 0) | 246 if (result != 0) |
| 195 return (result > 0); | 247 return (result > 0); |
| 196 | 248 |
| 197 // If we get here, the attempt counts were the same, so check recency. | 249 // If we get here, the attempt counts were the same, so check recency. |
| 198 result = CompareCreationTime(left, right); | 250 result = CompareCreationTime(left, right); |
| 199 | 251 |
| 200 return (result > 0); | 252 return (result > 0); |
| 201 } | 253 } |
| 202 | 254 |
| 203 // Compare the results, checking recency before request count. Returns true if | 255 // Compare the results, checking recency before request count. Returns true if |
| 204 // left hand side is better, false otherwise. | 256 // left hand side is better, false otherwise. |
| 205 bool RequestPicker::RecencyFirstCompareFunction( | 257 bool PickRequestTask::RecencyFirstCompareFunction( |
| 206 const SavePageRequest* left, const SavePageRequest* right) { | 258 const SavePageRequest* left, |
| 259 const SavePageRequest* right) { |
| 207 // Check the recency. | 260 // Check the recency. |
| 208 int result = CompareCreationTime(left, right); | 261 int result = CompareCreationTime(left, right); |
| 209 | 262 |
| 210 if (result != 0) | 263 if (result != 0) |
| 211 return (result > 0); | 264 return (result > 0); |
| 212 | 265 |
| 213 // If we get here, the recency was the same, so check the attempt count. | 266 // If we get here, the recency was the same, so check the attempt count. |
| 214 result = CompareRetryCount(left, right); | 267 result = CompareRetryCount(left, right); |
| 215 | 268 |
| 216 return (result > 0); | 269 return (result > 0); |
| 217 } | 270 } |
| 218 | 271 |
| 219 // Compare left and right side, returning 1 if the left side is better | 272 // Compare left and right side, returning 1 if the left side is better |
| 220 // (preferred by policy), 0 if the same, and -1 if the right side is better. | 273 // (preferred by policy), 0 if the same, and -1 if the right side is better. |
| 221 int RequestPicker::CompareRetryCount( | 274 int PickRequestTask::CompareRetryCount(const SavePageRequest* left, |
| 222 const SavePageRequest* left, const SavePageRequest* right) { | 275 const SavePageRequest* right) { |
| 223 // Check the attempt count. | 276 // Check the attempt count. |
| 224 int result = signum(left->completed_attempt_count() - | 277 int result = signum(left->completed_attempt_count() - |
| 225 right->completed_attempt_count()); | 278 right->completed_attempt_count()); |
| 226 | 279 |
| 227 // Flip the direction of comparison if policy prefers fewer retries. | 280 // Flip the direction of comparison if policy prefers fewer retries. |
| 228 if (fewer_retries_better_) | 281 if (policy_->ShouldPreferUntriedRequests()) |
| 229 result *= -1; | 282 result *= -1; |
| 230 | 283 |
| 231 return result; | 284 return result; |
| 232 } | 285 } |
| 233 | 286 |
| 234 // Compare left and right side, returning 1 if the left side is better | 287 // Compare left and right side, returning 1 if the left side is better |
| 235 // (preferred by policy), 0 if the same, and -1 if the right side is better. | 288 // (preferred by policy), 0 if the same, and -1 if the right side is better. |
| 236 int RequestPicker::CompareCreationTime( | 289 int PickRequestTask::CompareCreationTime(const SavePageRequest* left, |
| 237 const SavePageRequest* left, const SavePageRequest* right) { | 290 const SavePageRequest* right) { |
| 238 // Check the recency. | 291 // Check the recency. |
| 239 base::TimeDelta difference = left->creation_time() - right->creation_time(); | 292 base::TimeDelta difference = left->creation_time() - right->creation_time(); |
| 240 int result = signum(difference.InMilliseconds()); | 293 int result = signum(difference.InMilliseconds()); |
| 241 | 294 |
| 242 // Flip the direction of comparison if policy prefers fewer retries. | 295 // Flip the direction of comparison if policy prefers fewer retries. |
| 243 if (earlier_requests_better_) | 296 if (policy_->ShouldPreferEarlierRequests()) |
| 244 result *= -1; | 297 result *= -1; |
| 245 | 298 |
| 246 return result; | 299 return result; |
| 247 } | 300 } |
| 248 | 301 |
| 249 void RequestPicker::SplitRequests( | |
| 250 std::vector<std::unique_ptr<SavePageRequest>> requests, | |
| 251 std::vector<std::unique_ptr<SavePageRequest>>* valid_requests, | |
| 252 std::vector<std::unique_ptr<SavePageRequest>>* expired_requests) { | |
| 253 for (auto& request : requests) { | |
| 254 if (base::Time::Now() - request->creation_time() >= | |
| 255 base::TimeDelta::FromSeconds(kRequestExpirationTimeInSeconds)) { | |
| 256 expired_requests->push_back(std::move(request)); | |
| 257 } else { | |
| 258 valid_requests->push_back(std::move(request)); | |
| 259 } | |
| 260 } | |
| 261 } | |
| 262 | |
| 263 // Callback used after expired requests are deleted from the queue and notifies | |
| 264 // the coordinator. | |
| 265 void RequestPicker::OnRequestExpired( | |
| 266 std::unique_ptr<UpdateRequestsResult> result) { | |
| 267 const RequestCoordinator::BackgroundSavePageResult save_page_result( | |
| 268 RequestCoordinator::BackgroundSavePageResult::EXPIRED); | |
| 269 for (const auto& request : result->updated_items) { | |
| 270 event_logger_->RecordDroppedSavePageRequest( | |
| 271 request.client_id().name_space, save_page_result, request.request_id()); | |
| 272 notifier_->NotifyCompleted(request, save_page_result); | |
| 273 } | |
| 274 } | |
| 275 | |
| 276 } // namespace offline_pages | 302 } // namespace offline_pages |
| OLD | NEW |