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

Side by Side Diff: chrome/browser/android/feedback/connectivity_checker.cc

Issue 1312153003: jni_generator: Pass object parameters as JavaParamRef. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chrome/browser/android/feedback/connectivity_checker.h" 5 #include "chrome/browser/android/feedback/connectivity_checker.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/android/scoped_java_ref.h" 9 #include "base/android/scoped_java_ref.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 return; 157 return;
158 is_being_destroyed_ = true; 158 is_being_destroyed_ = true;
159 url_fetcher_.reset(); 159 url_fetcher_.reset();
160 ExecuteCallback(java_callback_.obj(), CONNECTIVITY_CHECK_RESULT_TIMEOUT); 160 ExecuteCallback(java_callback_.obj(), CONNECTIVITY_CHECK_RESULT_TIMEOUT);
161 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); 161 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
162 } 162 }
163 163
164 } // namespace 164 } // namespace
165 165
166 void CheckConnectivity(JNIEnv* env, 166 void CheckConnectivity(JNIEnv* env,
167 jclass clazz, 167 const JavaParamRef<jclass>& clazz,
168 jobject j_profile, 168 const JavaParamRef<jobject>& j_profile,
169 jstring j_url, 169 const JavaParamRef<jstring>& j_url,
170 jlong j_timeout_ms, 170 jlong j_timeout_ms,
171 jobject j_callback) { 171 const JavaParamRef<jobject>& j_callback) {
172 Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile); 172 Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile);
173 if (!profile) { 173 if (!profile) {
174 PostCallback(env, j_callback, CONNECTIVITY_CHECK_RESULT_ERROR); 174 PostCallback(env, j_callback, CONNECTIVITY_CHECK_RESULT_ERROR);
175 return; 175 return;
176 } 176 }
177 GURL url(base::android::ConvertJavaStringToUTF8(env, j_url)); 177 GURL url(base::android::ConvertJavaStringToUTF8(env, j_url));
178 if (!url.is_valid()) { 178 if (!url.is_valid()) {
179 PostCallback(env, j_callback, CONNECTIVITY_CHECK_RESULT_ERROR); 179 PostCallback(env, j_callback, CONNECTIVITY_CHECK_RESULT_ERROR);
180 return; 180 return;
181 } 181 }
182 182
183 // This object will be deleted when the connectivity check has completed. 183 // This object will be deleted when the connectivity check has completed.
184 ConnectivityChecker* connectivity_checker = new ConnectivityChecker( 184 ConnectivityChecker* connectivity_checker = new ConnectivityChecker(
185 profile, url, base::TimeDelta::FromMilliseconds(j_timeout_ms), 185 profile, url, base::TimeDelta::FromMilliseconds(j_timeout_ms),
186 base::android::ScopedJavaLocalRef<jobject>(env, j_callback)); 186 base::android::ScopedJavaLocalRef<jobject>(env, j_callback));
187 connectivity_checker->StartAsyncCheck(); 187 connectivity_checker->StartAsyncCheck();
188 } 188 }
189 189
190 jboolean IsUrlValid(JNIEnv* env, jclass clazz, jstring j_url) { 190 jboolean IsUrlValid(JNIEnv* env,
191 const JavaParamRef<jclass>& clazz,
192 const JavaParamRef<jstring>& j_url) {
191 GURL url(base::android::ConvertJavaStringToUTF8(env, j_url)); 193 GURL url(base::android::ConvertJavaStringToUTF8(env, j_url));
192 return url.is_valid(); 194 return url.is_valid();
193 } 195 }
194 196
195 bool RegisterConnectivityChecker(JNIEnv* env) { 197 bool RegisterConnectivityChecker(JNIEnv* env) {
196 return RegisterNativesImpl(env); 198 return RegisterNativesImpl(env);
197 } 199 }
198 200
199 } // namespace android 201 } // namespace android
200 } // namespace chrome 202 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/android/feature_utilities.cc ('k') | chrome/browser/android/find_in_page/find_in_page_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698