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

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

Issue 2898393002: Split Android-specific dependency from BackgroundLoaderOffliner. Create a subfolder of c/b/offline_… (Closed)
Patch Set: more build fixes Created 3 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/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 58b80a159286601b889932e8cecc78754d00f547..92518428923195042815bed0ccd68d25d7b8f19b 100644
--- a/components/offline_pages/core/background/offliner_stub.cc
+++ b/components/offline_pages/core/background/offliner_stub.cc
@@ -25,16 +25,16 @@ bool OfflinerStub::LoadAndSave(const SavePageRequest& request,
return false;
pending_request_.reset(new SavePageRequest(request));
- completion_callback_ =
- base::Bind(completion_callback, request, Offliner::RequestStatus::SAVED);
+ completion_callback_ = completion_callback;
// 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,
- completion_callback_);
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(completion_callback, *pending_request_.get(),
+ Offliner::RequestStatus::SAVED));
}
return true;
}
@@ -50,10 +50,18 @@ bool OfflinerStub::Cancel(const CancelCallback& callback) {
return true;
}
+void OfflinerStub::TerminateLoadIfInProgress() {
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(completion_callback_, *pending_request_.get(),
+ Offliner::RequestStatus::FOREGROUND_CANCELED));
+ pending_request_.reset();
+}
+
bool OfflinerStub::HandleTimeout(int64_t request_id) {
if (snapshot_on_last_retry_) {
- base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
- completion_callback_);
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(completion_callback_, *pending_request_.get(),
+ Offliner::RequestStatus::SAVED));
pending_request_.reset();
return true;
}

Powered by Google App Engine
This is Rietveld 408576698