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

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

Issue 2023113002: Fix bug of posting task inside constructor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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/chromoting_jni_instance.h ('k') | remoting/client/jni/chromoting_jni_runtime.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/client/jni/chromoting_jni_instance.cc
diff --git a/remoting/client/jni/chromoting_jni_instance.cc b/remoting/client/jni/chromoting_jni_instance.cc
index e63e2b4c31c0a962dcc2b1593002cd8596db0544..20f286b33072915f62e2f6c13fd4a5ff8b437548 100644
--- a/remoting/client/jni/chromoting_jni_instance.cc
+++ b/remoting/client/jni/chromoting_jni_instance.cc
@@ -79,11 +79,6 @@ ChromotingJniInstance::ChromotingJniInstance(ChromotingJniRuntime* jni_runtime,
client_auth_config_.fetch_third_party_token_callback =
base::Bind(&ChromotingJniInstance::FetchThirdPartyToken,
weak_factory_.GetWeakPtr(), host_pubkey);
-
- // Post a task to start connection
- jni_runtime_->network_task_runner()->PostTask(
- FROM_HERE,
- base::Bind(&ChromotingJniInstance::ConnectToHostOnNetworkThread, this));
}
ChromotingJniInstance::~ChromotingJniInstance() {
@@ -97,6 +92,16 @@ ChromotingJniInstance::~ChromotingJniInstance() {
DCHECK(!signaling_);
}
+void ChromotingJniInstance::Connect() {
+ if (jni_runtime_->network_task_runner()->BelongsToCurrentThread()) {
+ ConnectToHostOnNetworkThread();
+ } else {
+ jni_runtime_->network_task_runner()->PostTask(
+ FROM_HERE,
+ base::Bind(&ChromotingJniInstance::ConnectToHostOnNetworkThread, this));
+ }
+}
+
void ChromotingJniInstance::Disconnect() {
if (!jni_runtime_->network_task_runner()->BelongsToCurrentThread()) {
jni_runtime_->network_task_runner()->PostTask(
« no previous file with comments | « remoting/client/jni/chromoting_jni_instance.h ('k') | remoting/client/jni/chromoting_jni_runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698