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

Unified Diff: components/offline_pages/core/background/offliner_stub.cc

Issue 2836863002: [Offline pages] Removing active_request_ from request coordinator (Closed)
Patch Set: Addressing code review feedback and fixing app status change bug Created 3 years, 8 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/core/background/offliner_stub.cc
diff --git a/components/offline_pages/core/background/offliner_stub.cc b/components/offline_pages/core/background/offliner_stub.cc
index 04fe6eae1341d75923a1ecc128c7323266869d3c..58b80a159286601b889932e8cecc78754d00f547 100644
--- a/components/offline_pages/core/background/offliner_stub.cc
+++ b/components/offline_pages/core/background/offliner_stub.cc
@@ -24,31 +24,37 @@ bool OfflinerStub::LoadAndSave(const SavePageRequest& request,
if (disable_loading_)
return false;
- completion_callback_ = completion_callback;
- progress_callback_ = progress_callback;
+ pending_request_.reset(new SavePageRequest(request));
+ completion_callback_ =
+ base::Bind(completion_callback, request, Offliner::RequestStatus::SAVED);
// Post the callback on the run loop.
if (enable_callback_) {
const int64_t arbitrary_size = 153LL;
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(progress_callback_, request, arbitrary_size));
- base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(completion_callback_, request,
- Offliner::RequestStatus::SAVED));
+ FROM_HERE, base::Bind(progress_callback, request, arbitrary_size));
+ base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
+ completion_callback_);
}
return true;
}
-void OfflinerStub::Cancel(const CancelCallback& callback) {
+bool OfflinerStub::Cancel(const CancelCallback& callback) {
cancel_called_ = true;
- callback.Run(0LL);
+ if (!pending_request_)
+ return false;
+
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(callback, *pending_request_.get()));
+ pending_request_.reset();
+ return true;
}
-bool OfflinerStub::HandleTimeout(const SavePageRequest& request) {
+bool OfflinerStub::HandleTimeout(int64_t request_id) {
if (snapshot_on_last_retry_) {
- base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(completion_callback_, request,
- Offliner::RequestStatus::SAVED));
+ base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
+ completion_callback_);
+ pending_request_.reset();
return true;
}
return false;

Powered by Google App Engine
This is Rietveld 408576698