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

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

Issue 2030773002: Add unit tests for the Background Scheduler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR feedback per DougArnett 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
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/logging.h" 10 #include "base/logging.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 weak_ptr_factory_.GetWeakPtr()), 89 weak_ptr_factory_.GetWeakPtr()),
90 base::Bind(&RequestCoordinator::RequestQueueEmpty, 90 base::Bind(&RequestCoordinator::RequestQueueEmpty,
91 weak_ptr_factory_.GetWeakPtr())); 91 weak_ptr_factory_.GetWeakPtr()));
92 return false; 92 return false;
93 } 93 }
94 94
95 void RequestCoordinator::StopProcessing() { 95 void RequestCoordinator::StopProcessing() {
96 } 96 }
97 97
98 void RequestCoordinator::SendRequestToOffliner(const SavePageRequest& request) { 98 void RequestCoordinator::SendRequestToOffliner(const SavePageRequest& request) {
99 // TODO(petewil): Ensure only one offliner at a time is used.
99 // TODO(petewil): When we have multiple offliners, we need to pick one. 100 // TODO(petewil): When we have multiple offliners, we need to pick one.
100 Offliner* offliner = factory_->GetOffliner(policy_.get()); 101 Offliner* offliner = factory_->GetOffliner(policy_.get());
101 if (!offliner) { 102 if (!offliner) {
102 DVLOG(0) << "Unable to create Offliner. " 103 DVLOG(0) << "Unable to create Offliner. "
103 << "Cannot background offline page."; 104 << "Cannot background offline page.";
104 return; 105 return;
105 } 106 }
106 107
107 // Start the load and save process in the offliner (Async). 108 // Start the load and save process in the offliner (Async).
108 offliner->LoadAndSave(request, 109 offliner->LoadAndSave(request,
109 base::Bind(&RequestCoordinator::OfflinerDoneCallback, 110 base::Bind(&RequestCoordinator::OfflinerDoneCallback,
110 weak_ptr_factory_.GetWeakPtr())); 111 weak_ptr_factory_.GetWeakPtr()));
111 } 112 }
112 113
113 void RequestCoordinator::OfflinerDoneCallback(const SavePageRequest& request, 114 void RequestCoordinator::OfflinerDoneCallback(const SavePageRequest& request,
114 Offliner::RequestStatus status) { 115 Offliner::RequestStatus status) {
115 DVLOG(2) << "offliner finished, saved: " 116 DVLOG(2) << "offliner finished, saved: "
116 << (status == Offliner::RequestStatus::SAVED) << ", " 117 << (status == Offliner::RequestStatus::SAVED) << ", "
117 << __FUNCTION__; 118 << __FUNCTION__;
118 last_offlining_status_ = status; 119 last_offlining_status_ = status;
119 120
120 // TODO(petewil): Check time budget. Start a request if we have time, return 121 // TODO(petewil): Check time budget. Start a request if we have time, return
121 // to the scheduler if we are out of time. 122 // to the scheduler if we are out of time.
122 123
123 // TODO(petewil): If the request succeeded, remove it from the Queue. 124 // TODO(petewil): If the request succeeded, remove it from the Queue.
124 } 125 }
125 126
126 } // namespace offline_pages 127 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698