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

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

Issue 2066593003: Add a general purpose facility for letting background tasks wait until (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: logical merge fix Created 4 years, 6 months 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
« no previous file with comments | « chrome/android/java_sources.gni ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 Scheduler::TriggerCondition conditions; 67 Scheduler::TriggerCondition conditions;
68 scheduler_->Schedule(conditions); 68 scheduler_->Schedule(conditions);
69 } 69 }
70 70
71 // Called in response to updating a request in the request queue. 71 // Called in response to updating a request in the request queue.
72 void RequestCoordinator::UpdateRequestCallback( 72 void RequestCoordinator::UpdateRequestCallback(
73 RequestQueue::UpdateRequestResult result) {} 73 RequestQueue::UpdateRequestResult result) {}
74 74
75 // Called by the request picker when a request has been picked. 75 // Called by the request picker when a request has been picked.
76 void RequestCoordinator::RequestPicked(const SavePageRequest& request) { 76 void RequestCoordinator::RequestPicked(const SavePageRequest& request) {
77 Scheduler::TriggerCondition conditions;
78
79 // Ensure that the scheduler has actively scheduled a task.
80 scheduler_->Schedule(conditions);
81
82 // Send the request on to the offliner. 77 // Send the request on to the offliner.
83 SendRequestToOffliner(request); 78 SendRequestToOffliner(request);
84 } 79 }
85 80
86 void RequestCoordinator::RequestQueueEmpty() { 81 void RequestCoordinator::RequestQueueEmpty() {
87 // Clear the outstanding "safety" task in the scheduler. 82 // Clear the outstanding "safety" task in the scheduler.
88 scheduler_->Unschedule(); 83 scheduler_->Unschedule();
89 // Return control to the scheduler when there is no more to do. 84 // Return control to the scheduler when there is no more to do.
90 scheduler_callback_.Run(true); 85 scheduler_callback_.Run(true);
91 } 86 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 queue_->RemoveRequest(request.request_id(), 141 queue_->RemoveRequest(request.request_id(),
147 base::Bind(&RequestCoordinator::UpdateRequestCallback, 142 base::Bind(&RequestCoordinator::UpdateRequestCallback,
148 weak_ptr_factory_.GetWeakPtr())); 143 weak_ptr_factory_.GetWeakPtr()));
149 } 144 }
150 145
151 // TODO(petewil): Check time budget. Return to the scheduler if we are out. 146 // TODO(petewil): Check time budget. Return to the scheduler if we are out.
152 147
153 148
154 // Start a request if we have time. 149 // Start a request if we have time.
155 TryNextRequest(); 150 TryNextRequest();
156
157 } 151 }
158 152
159 } // namespace offline_pages 153 } // namespace offline_pages
OLDNEW
« no previous file with comments | « chrome/android/java_sources.gni ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698