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

Side by Side Diff: android_webview/native/aw_contents_statics.cc

Issue 2538463002: android: Don't pass ScopedJavaGlobalRef pointers. (Closed)
Patch Set: timeouts are very annoying Created 4 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 unified diff | Download patch
« no previous file with comments | « android_webview/native/aw_contents.cc ('k') | chrome/browser/android/favicon_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "android_webview/native/aw_contents_statics.h" 5 #include "android_webview/native/aw_contents_statics.h"
6 6
7 #include "android_webview/browser/aw_browser_context.h" 7 #include "android_webview/browser/aw_browser_context.h"
8 #include "android_webview/browser/net/aw_url_request_context_getter.h" 8 #include "android_webview/browser/net/aw_url_request_context_getter.h"
9 #include "android_webview/common/aw_version_info_values.h" 9 #include "android_webview/common/aw_version_info_values.h"
10 #include "android_webview/native/aw_contents_io_thread_client_impl.h" 10 #include "android_webview/native/aw_contents_io_thread_client_impl.h"
11 #include "base/android/jni_string.h" 11 #include "base/android/jni_string.h"
12 #include "base/android/scoped_java_ref.h" 12 #include "base/android/scoped_java_ref.h"
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
15 #include "content/public/browser/storage_partition.h" 15 #include "content/public/browser/storage_partition.h"
16 #include "content/public/common/url_constants.h" 16 #include "content/public/common/url_constants.h"
17 #include "jni/AwContentsStatics_jni.h" 17 #include "jni/AwContentsStatics_jni.h"
18 #include "net/cert/cert_database.h" 18 #include "net/cert/cert_database.h"
19 19
20 using base::android::AttachCurrentThread; 20 using base::android::AttachCurrentThread;
21 using base::android::ConvertJavaStringToUTF8; 21 using base::android::ConvertJavaStringToUTF8;
22 using base::android::JavaParamRef; 22 using base::android::JavaParamRef;
23 using base::android::JavaRef;
23 using base::android::ScopedJavaGlobalRef; 24 using base::android::ScopedJavaGlobalRef;
24 using base::android::ScopedJavaLocalRef; 25 using base::android::ScopedJavaLocalRef;
25 using content::BrowserThread; 26 using content::BrowserThread;
26 27
27 namespace android_webview { 28 namespace android_webview {
28 29
29 namespace { 30 namespace {
30 31
31 void ClientCertificatesCleared(ScopedJavaGlobalRef<jobject>* callback) { 32 void ClientCertificatesCleared(const JavaRef<jobject>& callback) {
32 DCHECK_CURRENTLY_ON(BrowserThread::UI); 33 DCHECK_CURRENTLY_ON(BrowserThread::UI);
33 JNIEnv* env = AttachCurrentThread(); 34 JNIEnv* env = AttachCurrentThread();
34 Java_AwContentsStatics_clientCertificatesCleared(env, *callback); 35 Java_AwContentsStatics_clientCertificatesCleared(env, callback);
35 } 36 }
36 37
37 void NotifyClientCertificatesChanged() { 38 void NotifyClientCertificatesChanged() {
38 DCHECK_CURRENTLY_ON(BrowserThread::IO); 39 DCHECK_CURRENTLY_ON(BrowserThread::IO);
39 net::CertDatabase::GetInstance()->OnAndroidKeyStoreChanged(); 40 net::CertDatabase::GetInstance()->OnAndroidKeyStoreChanged();
40 } 41 }
41 42
42 } // namespace 43 } // namespace
43 44
44 // static 45 // static
45 void ClearClientCertPreferences(JNIEnv* env, 46 void ClearClientCertPreferences(JNIEnv* env,
46 const JavaParamRef<jclass>&, 47 const JavaParamRef<jclass>&,
47 const JavaParamRef<jobject>& callback) { 48 const JavaParamRef<jobject>& callback) {
48 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 49 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
49 ScopedJavaGlobalRef<jobject>* j_callback = new ScopedJavaGlobalRef<jobject>();
50 j_callback->Reset(env, callback);
51 BrowserThread::PostTaskAndReply( 50 BrowserThread::PostTaskAndReply(
52 BrowserThread::IO, 51 BrowserThread::IO, FROM_HERE,
53 FROM_HERE,
54 base::Bind(&NotifyClientCertificatesChanged), 52 base::Bind(&NotifyClientCertificatesChanged),
55 base::Bind(&ClientCertificatesCleared, base::Owned(j_callback))); 53 base::Bind(&ClientCertificatesCleared,
54 ScopedJavaGlobalRef<jobject>(env, callback)));
56 } 55 }
57 56
58 // static 57 // static
59 ScopedJavaLocalRef<jstring> GetUnreachableWebDataUrl( 58 ScopedJavaLocalRef<jstring> GetUnreachableWebDataUrl(
60 JNIEnv* env, 59 JNIEnv* env,
61 const JavaParamRef<jclass>&) { 60 const JavaParamRef<jclass>&) {
62 return base::android::ConvertUTF8ToJavaString( 61 return base::android::ConvertUTF8ToJavaString(
63 env, content::kUnreachableWebDataURL); 62 env, content::kUnreachableWebDataURL);
64 } 63 }
65 64
(...skipping 19 matching lines...) Expand all
85 AwContentsIoThreadClientImpl::SetServiceWorkerIoThreadClient( 84 AwContentsIoThreadClientImpl::SetServiceWorkerIoThreadClient(
86 io_thread_client, browser_context); 85 io_thread_client, browser_context);
87 } 86 }
88 87
89 88
90 bool RegisterAwContentsStatics(JNIEnv* env) { 89 bool RegisterAwContentsStatics(JNIEnv* env) {
91 return RegisterNativesImpl(env); 90 return RegisterNativesImpl(env);
92 } 91 }
93 92
94 } // namespace android_webview 93 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/native/aw_contents.cc ('k') | chrome/browser/android/favicon_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698