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

Unified Diff: android_webview/native/aw_http_auth_handler.cc

Issue 11661013: Tell java side when the native auth handler is gone (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix2 Created 8 years 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 | « android_webview/java/src/org/chromium/android_webview/AwHttpAuthHandler.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/native/aw_http_auth_handler.cc
diff --git a/android_webview/native/aw_http_auth_handler.cc b/android_webview/native/aw_http_auth_handler.cc
index be696dedcb5ea12f07f5fa9f88b7edf7a2c836d3..b926a6a31276cc0b115cd99730437f6052266568 100644
--- a/android_webview/native/aw_http_auth_handler.cc
+++ b/android_webview/native/aw_http_auth_handler.cc
@@ -8,6 +8,7 @@
#include "android_webview/native/aw_contents.h"
#include "base/android/jni_android.h"
#include "base/android/jni_string.h"
+#include "content/public/browser/browser_thread.h"
#include "jni/AwHttpAuthHandler_jni.h"
#include "net/base/auth.h"
#include "content/public/browser/web_contents.h"
@@ -19,9 +20,10 @@ namespace android_webview {
AwHttpAuthHandler::AwHttpAuthHandler(AwLoginDelegate* login_delegate,
net::AuthChallengeInfo* auth_info,
bool first_auth_attempt)
- : login_delegate_(make_scoped_refptr(login_delegate)),
+ : login_delegate_(login_delegate),
host_(auth_info->challenger.host()),
realm_(auth_info->realm) {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
JNIEnv* env = base::android::AttachCurrentThread();
http_auth_handler_.Reset(
Java_AwHttpAuthHandler_create(
@@ -29,23 +31,34 @@ AwHttpAuthHandler::AwHttpAuthHandler(AwLoginDelegate* login_delegate,
}
AwHttpAuthHandler:: ~AwHttpAuthHandler() {
- // TODO(joth): tell java counterpart, so it can null its native back-pointer.
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ Java_AwHttpAuthHandler_handlerDestroyed(base::android::AttachCurrentThread(),
+ http_auth_handler_.obj());
}
void AwHttpAuthHandler::Proceed(JNIEnv* env,
jobject obj,
jstring user,
jstring password) {
- login_delegate_->Proceed(ConvertJavaStringToUTF16(env, user),
- ConvertJavaStringToUTF16(env, password));
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ if (login_delegate_) {
+ login_delegate_->Proceed(ConvertJavaStringToUTF16(env, user),
+ ConvertJavaStringToUTF16(env, password));
+ login_delegate_ = NULL;
+ }
}
void AwHttpAuthHandler::Cancel(JNIEnv* env, jobject obj) {
- login_delegate_->Cancel();
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ if (login_delegate_) {
+ login_delegate_->Cancel();
+ login_delegate_ = NULL;
+ }
}
void AwHttpAuthHandler::HandleOnUIThread(content::WebContents* web_contents) {
DCHECK(web_contents);
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
AwContents* aw_contents = AwContents::FromWebContents(web_contents);
aw_contents->onReceivedHttpAuthRequest(
« no previous file with comments | « android_webview/java/src/org/chromium/android_webview/AwHttpAuthHandler.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698