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

Unified Diff: chrome/browser/android/offline_pages/downloads/offline_page_download_bridge.cc

Issue 2271753002: [Offline pages] Making sure that destroying the bridge does not leave notification hanging (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « chrome/browser/android/offline_pages/downloads/offline_page_download_bridge.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/offline_pages/downloads/offline_page_download_bridge.cc
diff --git a/chrome/browser/android/offline_pages/downloads/offline_page_download_bridge.cc b/chrome/browser/android/offline_pages/downloads/offline_page_download_bridge.cc
index 587040e89f26d8bd39a11b9e80d90ae993fb8a9d..ce4eaa611c9d91bd407b31222c7ae182d1b31c72 100644
--- a/chrome/browser/android/offline_pages/downloads/offline_page_download_bridge.cc
+++ b/chrome/browser/android/offline_pages/downloads/offline_page_download_bridge.cc
@@ -67,8 +67,7 @@ OfflinePageDownloadBridge::OfflinePageDownloadBridge(
const JavaParamRef<jobject>& obj,
DownloadUIAdapter* download_ui_adapter)
: weak_java_ref_(env, obj),
- download_ui_adapter_(download_ui_adapter),
- weak_ptr_factory_(this) {
+ download_ui_adapter_(download_ui_adapter) {
DCHECK(download_ui_adapter_);
download_ui_adapter_->AddObserver(this);
}
@@ -80,6 +79,18 @@ bool OfflinePageDownloadBridge::Register(JNIEnv* env) {
return RegisterNativesImpl(env);
}
+// static
+void OfflinePageDownloadBridge::SavePageCallback(
+ const DownloadUIItem& item,
+ OfflinePageModel::SavePageResult result,
+ int64_t offline_id) {
+ OfflinePageNotificationBridge notification_bridge;
+ if (result == SavePageResult::SUCCESS)
+ notification_bridge.NotifyDownloadSuccessful(item);
+ else
+ notification_bridge.NotifyDownloadFailed(item);
+}
+
void OfflinePageDownloadBridge::Destroy(JNIEnv* env,
const JavaParamRef<jobject>&) {
download_ui_adapter_->RemoveObserver(this);
@@ -160,8 +171,7 @@ void OfflinePageDownloadBridge::StartDownload(
offline_page_model->SavePage(
url, client_id, 0ul, std::move(archiver),
- base::Bind(&OfflinePageDownloadBridge::SavePageCallback,
- weak_ptr_factory_.GetWeakPtr(), item));
+ base::Bind(&OfflinePageDownloadBridge::SavePageCallback, item));
}
void OfflinePageDownloadBridge::ItemsLoaded() {
@@ -199,17 +209,6 @@ void OfflinePageDownloadBridge::ItemUpdated(const DownloadUIItem& item) {
env, obj, ToJavaOfflinePageDownloadItem(env, item));
}
-void OfflinePageDownloadBridge::SavePageCallback(
- const DownloadUIItem& item,
- OfflinePageModel::SavePageResult result,
- int64_t offline_id) {
- OfflinePageNotificationBridge notification_bridge;
- if (result == SavePageResult::SUCCESS)
- notification_bridge.NotifyDownloadSuccessful(item);
- else
- notification_bridge.NotifyDownloadFailed(item);
-}
-
static jlong Init(JNIEnv* env,
const JavaParamRef<jobject>& obj,
const JavaParamRef<jobject>& j_profile) {
« no previous file with comments | « chrome/browser/android/offline_pages/downloads/offline_page_download_bridge.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698