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

Unified Diff: remoting/client/jni/jni_pairing_secret_fetcher.cc

Issue 2047613002: [Remoting Android] Move pairing secret fetcher to the network thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reviewer's Feedback Created 4 years, 6 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 | « remoting/client/jni/jni_pairing_secret_fetcher.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/client/jni/jni_pairing_secret_fetcher.cc
diff --git a/remoting/client/jni/jni_pairing_secret_fetcher.cc b/remoting/client/jni/jni_pairing_secret_fetcher.cc
index 3dc5a4e8e80bcf4d98d050008231b6b9a087348c..f6593271c12120bf3108fedb6896d70cac1d0f6e 100644
--- a/remoting/client/jni/jni_pairing_secret_fetcher.cc
+++ b/remoting/client/jni/jni_pairing_secret_fetcher.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <remoting/client/jni/jni_pairing_secret_fetcher.h>
+#include "remoting/client/jni/jni_pairing_secret_fetcher.h"
#include "base/bind.h"
#include "base/location.h"
#include "remoting/client/jni/chromoting_jni_runtime.h"
@@ -19,35 +19,45 @@ JniPairingSecretFetcher::JniPairingSecretFetcher(ChromotingJniRuntime* runtime,
weak_factory_(this) {}
JniPairingSecretFetcher::~JniPairingSecretFetcher() {
- DCHECK(jni_runtime_->ui_task_runner()->BelongsToCurrentThread());
+ DCHECK(jni_runtime_->network_task_runner()->BelongsToCurrentThread());
}
void JniPairingSecretFetcher::FetchSecret(
bool pairable,
const protocol::SecretFetchedCallback& callback) {
- DCHECK (jni_runtime_->ui_task_runner()->BelongsToCurrentThread());
-
- if (!jni_client_) {
- return;
- }
-
- // Delete pairing credentials if they exist.
- jni_client_->CommitPairingCredentials(host_id_, "", "");
+ DCHECK (jni_runtime_->network_task_runner()->BelongsToCurrentThread());
callback_ = callback;
- jni_client_->DisplayAuthenticationPrompt(pairable);
+ jni_runtime_->ui_task_runner()->PostTask(
+ FROM_HERE,
+ base::Bind(&JniPairingSecretFetcher::FetchSecretOnUiThread, jni_client_,
+ host_id_, pairable));
}
void JniPairingSecretFetcher::ProvideSecret(const std::string& pin) {
- DCHECK(jni_runtime_->ui_task_runner()->BelongsToCurrentThread());
+ DCHECK(jni_runtime_->network_task_runner()->BelongsToCurrentThread());
DCHECK(!callback_.is_null());
- jni_runtime_->network_task_runner()->PostTask(FROM_HERE,
- base::Bind(callback_, pin));
+ callback_.Run(pin);
}
base::WeakPtr<JniPairingSecretFetcher> JniPairingSecretFetcher::GetWeakPtr() {
return weak_factory_.GetWeakPtr();
}
+// static
+void JniPairingSecretFetcher::FetchSecretOnUiThread(
+ base::WeakPtr<JniClient> client,
+ const std::string& host_id,
+ bool pairable) {
+ if (!client) {
+ return;
+ }
+
+ // Delete pairing credentials if they exist.
+ client->CommitPairingCredentials(host_id, "", "");
+
+ client->DisplayAuthenticationPrompt(pairable);
+}
+
} // namespace remoting
« no previous file with comments | « remoting/client/jni/jni_pairing_secret_fetcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698