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

Unified Diff: content/browser/android/download_controller.cc

Issue 10827125: Use JavaObjectWeakGlobalRef in ContentViewCore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 | « content/browser/android/download_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/android/download_controller.cc
diff --git a/content/browser/android/download_controller.cc b/content/browser/android/download_controller.cc
index 13b75c7123b5b4e357a28a50bef71aaea5ed80c8..61bce0f703db029283bbfe5a9ee5f7d001615161 100644
--- a/content/browser/android/download_controller.cc
+++ b/content/browser/android/download_controller.cc
@@ -186,8 +186,9 @@ void DownloadController::StartAndroidDownload(
JNIEnv* env = AttachCurrentThread();
// Call newHttpGetDownload
- jobject view = GetContentView(render_process_id, render_view_id);
- if (!view) {
+ ScopedJavaLocalRef<jobject> view = GetContentView(render_process_id,
+ render_view_id);
+ if (view.is_null()) {
// The view went away. Can't proceed.
LOG(ERROR) << "Download failed on URL:" << info.url.spec();
return;
@@ -205,7 +206,7 @@ void DownloadController::StartAndroidDownload(
ConvertUTF8ToJavaString(env, info.cookie);
Java_DownloadController_newHttpGetDownload(
- env, GetJavaObject()->Controller(env).obj(), view, jurl.obj(),
+ env, GetJavaObject()->Controller(env).obj(), view.obj(), jurl.obj(),
juser_agent.obj(), jcontent_disposition.obj(), jmime_type.obj(),
jcookie.obj(), info.total_bytes);
}
@@ -219,14 +220,15 @@ void DownloadController::OnPostDownloadStarted(
// Register for updates to the DownloadItem.
download_item->AddObserver(this);
- jobject view = GetContentViewCoreFromWebContents(web_contents);
- if(!view) {
+ ScopedJavaLocalRef<jobject> view =
+ GetContentViewCoreFromWebContents(web_contents);
+ if(view.is_null()) {
// The view went away. Can't proceed.
return;
}
Java_DownloadController_onHttpPostDownloadStarted(
- env, GetJavaObject()->Controller(env).obj(), view);
+ env, GetJavaObject()->Controller(env).obj(), view.obj());
}
void DownloadController::OnDownloadUpdated(DownloadItem* item) {
@@ -246,14 +248,15 @@ void DownloadController::OnDownloadUpdated(DownloadItem* item) {
ScopedJavaLocalRef<jstring> jpath =
ConvertUTF8ToJavaString(env, item->GetFullPath().value());
- jobject view_core = GetContentViewCoreFromWebContents(item->GetWebContents());
- if (!view_core) {
+ ScopedJavaLocalRef<jobject> view_core = GetContentViewCoreFromWebContents(
+ item->GetWebContents());
+ if (view_core.is_null()) {
// We can get NULL WebContents from the DownloadItem.
return;
}
Java_DownloadController_onHttpPostDownloadCompleted(env,
- GetJavaObject()->Controller(env).obj(), view_core, jurl.obj(),
+ GetJavaObject()->Controller(env).obj(), view_core.obj(), jurl.obj(),
jcontent_disposition.obj(), jmime_type.obj(), jpath.obj(),
item->GetReceivedBytes(), true);
}
@@ -261,27 +264,31 @@ void DownloadController::OnDownloadUpdated(DownloadItem* item) {
void DownloadController::OnDownloadOpened(DownloadItem* item) {
}
-jobject DownloadController::GetContentView(int render_process_id,
- int render_view_id) {
+ScopedJavaLocalRef<jobject> DownloadController::GetContentView(
+ int render_process_id, int render_view_id) {
RenderViewHost* render_view_host =
RenderViewHost::FromID(render_process_id, render_view_id);
if (!render_view_host)
- return NULL;
+ return ScopedJavaLocalRef<jobject>();
WebContents* web_contents =
render_view_host->GetDelegate()->GetAsWebContents();
if (!web_contents)
- return NULL;
+ return ScopedJavaLocalRef<jobject>();
return GetContentViewCoreFromWebContents(web_contents);
}
-jobject DownloadController::GetContentViewCoreFromWebContents(
+ScopedJavaLocalRef<jobject>
+ DownloadController::GetContentViewCoreFromWebContents(
WebContents* web_contents) {
+ if (!web_contents)
+ return ScopedJavaLocalRef<jobject>();
+
NOTIMPLEMENTED();
- return NULL;
+ return ScopedJavaLocalRef<jobject>();
}
DownloadController::JavaObject* DownloadController::GetJavaObject() {
« no previous file with comments | « content/browser/android/download_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698