Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: components/offline_pages/background/request_coordinator.h

Issue 2493683002: [OfflinePages] Fixes RequestCoordinator bug not clearing state on timeout (Closed)
Patch Set: Broke out some OfflinerDoneCallback logic and reworked timeout handling Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ 5 #ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_
6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ 6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 // started. 295 // started.
296 void StartOffliner(int64_t request_id, 296 void StartOffliner(int64_t request_id,
297 const std::string& client_namespace, 297 const std::string& client_namespace,
298 std::unique_ptr<UpdateRequestsResult> update_result); 298 std::unique_ptr<UpdateRequestsResult> update_result);
299 299
300 // Called by the offliner when an offlining request is completed. (and by 300 // Called by the offliner when an offlining request is completed. (and by
301 // tests). 301 // tests).
302 void OfflinerDoneCallback(const SavePageRequest& request, 302 void OfflinerDoneCallback(const SavePageRequest& request,
303 Offliner::RequestStatus status); 303 Offliner::RequestStatus status);
304 304
305 // Records a completed attempt for the request and update it in the queue
306 // (possibly removing it).
307 void UpdateRequestForCompletedAttempt(const SavePageRequest& request,
308 Offliner::RequestStatus status);
309
310 // Returns whether we should try another request based on the outcome
311 // of the previous one.
312 bool ShouldTryNextRequest(Offliner::RequestStatus previous_request_status);
313
305 void TryNextRequest(); 314 void TryNextRequest();
306 315
307 // If there is an active request in the list, cancel that request. 316 // If there is an active request in the list, cancel that request.
308 bool CancelActiveRequestIfItMatches(const std::vector<int64_t>& request_ids); 317 bool CancelActiveRequestIfItMatches(const std::vector<int64_t>& request_ids);
309 318
310 // Records an aborted attempt for the request and update it in the queue 319 // Records an aborted attempt for the request and update it in the queue
311 // (possibly removing it). Returns the updated copy. 320 // (possibly removing it).
312 void AbortRequestAttempt(const SavePageRequest& request); 321 void UpdateRequestForAbortedAttempt(const SavePageRequest& request);
313 322
314 // Remove the attempted request from the queue with status to pass through to 323 // Remove the attempted request from the queue with status to pass through to
315 // any observers and UMA histogram. 324 // any observers and UMA histogram.
316 void RemoveAttemptedRequest(const SavePageRequest& request, 325 void RemoveAttemptedRequest(const SavePageRequest& request,
317 BackgroundSavePageResult status); 326 BackgroundSavePageResult status);
318 327
319 // Completes aborting the request, reports an error if it fails. 328 // Completes aborting the request, reports an error if it fails.
320 void MarkAttemptAbortedDone(int64_t request_id, 329 void MarkAttemptAbortedDone(int64_t request_id,
321 const ClientId& client_id, 330 const ClientId& client_id,
322 std::unique_ptr<UpdateRequestsResult> result); 331 std::unique_ptr<UpdateRequestsResult> result);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 base::Callback<void(bool)> immediate_schedule_callback_; 408 base::Callback<void(bool)> immediate_schedule_callback_;
400 // Allows us to pass a weak pointer to callbacks. 409 // Allows us to pass a weak pointer to callbacks.
401 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_; 410 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_;
402 411
403 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); 412 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator);
404 }; 413 };
405 414
406 } // namespace offline_pages 415 } // namespace offline_pages
407 416
408 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ 417 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698