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

Unified Diff: chrome/browser/android/feedback/connectivity_checker.cc

Issue 2538463002: android: Don't pass ScopedJavaGlobalRef pointers. (Closed)
Patch Set: timeouts are very annoying Created 4 years, 1 month 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/favicon_helper.cc ('k') | chrome/browser/android/feedback/screenshot_task.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/feedback/connectivity_checker.cc
diff --git a/chrome/browser/android/feedback/connectivity_checker.cc b/chrome/browser/android/feedback/connectivity_checker.cc
index a499401dcf99a37864264de8c14e4c7af584ead0..38d79b7a91c43889d2e4a498e7d3491db7dfde9a 100644
--- a/chrome/browser/android/feedback/connectivity_checker.cc
+++ b/chrome/browser/android/feedback/connectivity_checker.cc
@@ -41,27 +41,21 @@ enum ConnectivityCheckResult {
CONNECTIVITY_CHECK_RESULT_END = 5
};
-void ExecuteCallback(jobject callback, ConnectivityCheckResult result) {
+void ExecuteCallback(const base::android::JavaRef<jobject>& callback,
+ ConnectivityCheckResult result) {
CHECK(result >= CONNECTIVITY_CHECK_RESULT_UNKNOWN);
CHECK(result < CONNECTIVITY_CHECK_RESULT_END);
Java_ConnectivityChecker_executeCallback(base::android::AttachCurrentThread(),
callback, result);
}
-void ExecuteCallbackFromRef(
- base::android::ScopedJavaGlobalRef<jobject>* callback,
- ConnectivityCheckResult result) {
- ExecuteCallback(callback->obj(), result);
-}
-
void PostCallback(JNIEnv* env,
- jobject j_callback,
+ const base::android::JavaRef<jobject>& j_callback,
ConnectivityCheckResult result) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
- base::Bind(&ExecuteCallbackFromRef,
- base::Owned(new base::android::ScopedJavaGlobalRef<jobject>(
- env, j_callback)),
+ base::Bind(&ExecuteCallback,
+ base::android::ScopedJavaGlobalRef<jobject>(j_callback),
result));
}
@@ -119,10 +113,9 @@ void ConnectivityChecker::OnURLFetchComplete(const net::URLFetcher* source) {
bool connected = status.is_success() && response_code == net::HTTP_NO_CONTENT;
if (connected) {
- ExecuteCallback(java_callback_.obj(), CONNECTIVITY_CHECK_RESULT_CONNECTED);
+ ExecuteCallback(java_callback_, CONNECTIVITY_CHECK_RESULT_CONNECTED);
} else {
- ExecuteCallback(java_callback_.obj(),
- CONNECTIVITY_CHECK_RESULT_NOT_CONNECTED);
+ ExecuteCallback(java_callback_, CONNECTIVITY_CHECK_RESULT_NOT_CONNECTED);
}
base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this);
@@ -164,7 +157,7 @@ void ConnectivityChecker::OnTimeout() {
return;
is_being_destroyed_ = true;
url_fetcher_.reset();
- ExecuteCallback(java_callback_.obj(), CONNECTIVITY_CHECK_RESULT_TIMEOUT);
+ ExecuteCallback(java_callback_, CONNECTIVITY_CHECK_RESULT_TIMEOUT);
base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this);
}
« no previous file with comments | « chrome/browser/android/favicon_helper.cc ('k') | chrome/browser/android/feedback/screenshot_task.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698