| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "remoting/client/jni/chromoting_jni_instance.h" | 5 #include "remoting/client/jni/chromoting_jni_instance.h" |
| 6 | 6 |
| 7 #include <android/log.h> | 7 #include <android/log.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 xmpp_config_.host = kXmppServer; | 76 xmpp_config_.host = kXmppServer; |
| 77 xmpp_config_.port = kXmppPort; | 77 xmpp_config_.port = kXmppPort; |
| 78 xmpp_config_.use_tls = kXmppUseTls; | 78 xmpp_config_.use_tls = kXmppUseTls; |
| 79 xmpp_config_.username = username; | 79 xmpp_config_.username = username; |
| 80 xmpp_config_.auth_token = auth_token; | 80 xmpp_config_.auth_token = auth_token; |
| 81 | 81 |
| 82 client_auth_config_.host_id = host_id; | 82 client_auth_config_.host_id = host_id; |
| 83 client_auth_config_.pairing_client_id = pairing_id; | 83 client_auth_config_.pairing_client_id = pairing_id; |
| 84 client_auth_config_.pairing_secret = pairing_secret; | 84 client_auth_config_.pairing_secret = pairing_secret; |
| 85 client_auth_config_.fetch_secret_callback = | 85 client_auth_config_.fetch_secret_callback = |
| 86 base::Bind(&ChromotingJniInstance::FetchSecret, GetWeakPtr()); | 86 base::Bind(&JniPairingSecretFetcher::FetchSecret, secret_fetcher); |
| 87 client_auth_config_.fetch_third_party_token_callback = base::Bind( | 87 client_auth_config_.fetch_third_party_token_callback = base::Bind( |
| 88 &ChromotingJniInstance::FetchThirdPartyToken, GetWeakPtr(), host_pubkey); | 88 &ChromotingJniInstance::FetchThirdPartyToken, GetWeakPtr(), host_pubkey); |
| 89 | 89 |
| 90 // Post a task to start connection | 90 // Post a task to start connection |
| 91 jni_runtime_->network_task_runner()->PostTask( | 91 jni_runtime_->network_task_runner()->PostTask( |
| 92 FROM_HERE, | 92 FROM_HERE, |
| 93 base::Bind(&ChromotingJniInstance::ConnectToHostOnNetworkThread, | 93 base::Bind(&ChromotingJniInstance::ConnectToHostOnNetworkThread, |
| 94 GetWeakPtr())); | 94 GetWeakPtr())); |
| 95 } | 95 } |
| 96 | 96 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 "ThirdPartyAuth", | 170 "ThirdPartyAuth", |
| 171 "Ignored OnThirdPartyTokenFetched() without a pending fetch."); | 171 "Ignored OnThirdPartyTokenFetched() without a pending fetch."); |
| 172 } | 172 } |
| 173 } | 173 } |
| 174 | 174 |
| 175 void ChromotingJniInstance::ProvideSecret(const std::string& pin, | 175 void ChromotingJniInstance::ProvideSecret(const std::string& pin, |
| 176 bool create_pairing, | 176 bool create_pairing, |
| 177 const std::string& device_name) { | 177 const std::string& device_name) { |
| 178 DCHECK(jni_runtime_->ui_task_runner()->BelongsToCurrentThread()); | 178 DCHECK(jni_runtime_->ui_task_runner()->BelongsToCurrentThread()); |
| 179 | 179 |
| 180 if (!secret_fetcher_) { | |
| 181 return; | |
| 182 } | |
| 183 | |
| 184 create_pairing_ = create_pairing; | 180 create_pairing_ = create_pairing; |
| 185 | 181 |
| 186 if (create_pairing) | 182 if (create_pairing) |
| 187 SetDeviceName(device_name); | 183 SetDeviceName(device_name); |
| 188 | 184 |
| 189 secret_fetcher_->ProvideSecret(pin); | 185 jni_runtime_->network_task_runner()->PostTask( |
| 186 FROM_HERE, base::Bind(&JniPairingSecretFetcher::ProvideSecret, |
| 187 secret_fetcher_, pin)); |
| 190 } | 188 } |
| 191 | 189 |
| 192 void ChromotingJniInstance::SendMouseEvent( | 190 void ChromotingJniInstance::SendMouseEvent( |
| 193 int x, int y, | 191 int x, int y, |
| 194 protocol::MouseEvent_MouseButton button, | 192 protocol::MouseEvent_MouseButton button, |
| 195 bool button_down) { | 193 bool button_down) { |
| 196 if (!jni_runtime_->network_task_runner()->BelongsToCurrentThread()) { | 194 if (!jni_runtime_->network_task_runner()->BelongsToCurrentThread()) { |
| 197 jni_runtime_->network_task_runner()->PostTask( | 195 jni_runtime_->network_task_runner()->PostTask( |
| 198 FROM_HERE, base::Bind(&ChromotingJniInstance::SendMouseEvent, | 196 FROM_HERE, base::Bind(&ChromotingJniInstance::SendMouseEvent, |
| 199 GetWeakPtr(), x, y, button, button_down)); | 197 GetWeakPtr(), x, y, button, button_down)); |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 protocol::CandidateSessionConfig::CreateEmpty(); | 425 protocol::CandidateSessionConfig::CreateEmpty(); |
| 428 protocol_config->set_webrtc_supported(true); | 426 protocol_config->set_webrtc_supported(true); |
| 429 protocol_config->set_ice_supported(false); | 427 protocol_config->set_ice_supported(false); |
| 430 client_->set_protocol_config(std::move(protocol_config)); | 428 client_->set_protocol_config(std::move(protocol_config)); |
| 431 } | 429 } |
| 432 #endif // defined(ENABLE_WEBRTC_REMOTING_CLIENT) | 430 #endif // defined(ENABLE_WEBRTC_REMOTING_CLIENT) |
| 433 client_->Start(signaling_.get(), client_auth_config_, transport_context, | 431 client_->Start(signaling_.get(), client_auth_config_, transport_context, |
| 434 host_jid_, capabilities_); | 432 host_jid_, capabilities_); |
| 435 } | 433 } |
| 436 | 434 |
| 437 void ChromotingJniInstance::FetchSecret( | |
| 438 bool pairable, | |
| 439 const protocol::SecretFetchedCallback& callback) { | |
| 440 if (!jni_runtime_->ui_task_runner()->BelongsToCurrentThread()) { | |
| 441 jni_runtime_->ui_task_runner()->PostTask( | |
| 442 FROM_HERE, base::Bind(&JniPairingSecretFetcher::FetchSecret, | |
| 443 secret_fetcher_, pairable, callback)); | |
| 444 } else if (secret_fetcher_) { | |
| 445 secret_fetcher_->FetchSecret(pairable, callback); | |
| 446 } | |
| 447 } | |
| 448 | |
| 449 void ChromotingJniInstance::SetDeviceName(const std::string& device_name) { | 435 void ChromotingJniInstance::SetDeviceName(const std::string& device_name) { |
| 450 if (!jni_runtime_->network_task_runner()->BelongsToCurrentThread()) { | 436 if (!jni_runtime_->network_task_runner()->BelongsToCurrentThread()) { |
| 451 jni_runtime_->network_task_runner()->PostTask( | 437 jni_runtime_->network_task_runner()->PostTask( |
| 452 FROM_HERE, base::Bind(&ChromotingJniInstance::SetDeviceName, | 438 FROM_HERE, base::Bind(&ChromotingJniInstance::SetDeviceName, |
| 453 GetWeakPtr(), device_name)); | 439 GetWeakPtr(), device_name)); |
| 454 return; | 440 return; |
| 455 } | 441 } |
| 456 | 442 |
| 457 device_name_ = device_name; | 443 device_name_ = device_name; |
| 458 } | 444 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 video_renderer_.reset(); | 506 video_renderer_.reset(); |
| 521 view_.reset(); | 507 view_.reset(); |
| 522 signaling_.reset(); | 508 signaling_.reset(); |
| 523 perf_tracker_.reset(); | 509 perf_tracker_.reset(); |
| 524 client_context_.reset(); | 510 client_context_.reset(); |
| 525 | 511 |
| 526 weak_factory_.InvalidateWeakPtrs(); | 512 weak_factory_.InvalidateWeakPtrs(); |
| 527 } | 513 } |
| 528 | 514 |
| 529 } // namespace remoting | 515 } // namespace remoting |
| OLD | NEW |