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

Unified Diff: components/offline_pages/background/request_coordinator.cc

Issue 1971923004: Add calls to the offliner and unit tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix memory leak Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: components/offline_pages/background/request_coordinator.cc
diff --git a/components/offline_pages/background/request_coordinator.cc b/components/offline_pages/background/request_coordinator.cc
index 37fa98ccb73c5ef715491808fb0733a3fadd63f2..c73738d2607089c3f5864df3bdbe4ed9e34ed0e1 100644
--- a/components/offline_pages/background/request_coordinator.cc
+++ b/components/offline_pages/background/request_coordinator.cc
@@ -15,13 +15,15 @@
namespace offline_pages {
-RequestCoordinator::RequestCoordinator(
- std::unique_ptr<OfflinerPolicy> policy,
- std::unique_ptr<OfflinerFactory> factory,
- std::unique_ptr<RequestQueue> queue,
- std::unique_ptr<Scheduler> scheduler)
- : policy_(std::move(policy)), factory_(std::move(factory)),
- queue_(std::move(queue)), scheduler_(std::move(scheduler)) {
+RequestCoordinator::RequestCoordinator(std::unique_ptr<OfflinerPolicy> policy,
+ std::unique_ptr<OfflinerFactory> factory,
+ std::unique_ptr<RequestQueue> queue,
+ std::unique_ptr<Scheduler> scheduler)
+ : policy_(std::move(policy)),
+ factory_(std::move(factory)),
+ queue_(std::move(queue)),
+ scheduler_(std::move(scheduler)),
+ last_offlining_status_(Offliner::NO_STATUS_YET) {
dougarnett 2016/05/13 19:33:00 suggesting Offliner::UNKNOWN
Pete Williamson 2016/05/13 22:28:24 Done.
DCHECK(policy_ != nullptr);
}
@@ -45,6 +47,10 @@ bool RequestCoordinator::SavePageLater(
AsWeakPtr()));
// TODO: Do I need to persist the request in case the add fails?
+ // TODO(petewil): Eventually we will wait for the StartProcessing callback,
+ // but for now just kick start the request so we can test the wiring.
+ SendRequestToOffliner(request);
+
return true;
}
@@ -67,4 +73,26 @@ bool RequestCoordinator::StartProcessing(
void RequestCoordinator::StopProcessing() {
}
+void RequestCoordinator::SendRequestToOffliner(SavePageRequest& request) {
+ // TODO(petewil): When we have multiple offliners, we need to pick one.
+ Offliner* prerendererOffliner = factory_->GetOffliner(policy_.get());
dougarnett 2016/05/13 19:33:00 just name as "offliner" here?
Pete Williamson 2016/05/13 22:28:24 Done. However, eventually we will have two factor
dougarnett 2016/05/13 22:56:28 I expect so but I'm not confident at this point wh
+ if (!prerendererOffliner) {
+ LOG(ERROR) << "Unable to create Prerendering Offliner. "
+ << "Cannot background offline page.";
+ return;
+ }
+
+ // Start the load and save process in the prerenderer (Async).
dougarnett 2016/05/13 19:33:00 ... by the offliner
Pete Williamson 2016/05/13 22:28:24 Done.
+ prerendererOffliner->LoadAndSave(
+ request,
+ base::Bind(&RequestCoordinator::PrerendererDoneCallback, AsWeakPtr()));
+}
+
+void RequestCoordinator::PrerendererDoneCallback(
+ const SavePageRequest& request,
+ Offliner::CompletionStatus status) {
+ DVLOG(2) << "prerenderer finished, status " << status << ", " << __FUNCTION__;
+ last_offlining_status_ = status;
+}
+
} // namespace offline_pages

Powered by Google App Engine
This is Rietveld 408576698