| 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 <utility> | 10 #include <utility> |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 xmpp_config_.auth_token = auth_token; | 72 xmpp_config_.auth_token = auth_token; |
| 73 | 73 |
| 74 client_auth_config_.host_id = host_id; | 74 client_auth_config_.host_id = host_id; |
| 75 client_auth_config_.pairing_client_id = pairing_id; | 75 client_auth_config_.pairing_client_id = pairing_id; |
| 76 client_auth_config_.pairing_secret = pairing_secret; | 76 client_auth_config_.pairing_secret = pairing_secret; |
| 77 client_auth_config_.fetch_secret_callback = base::Bind( | 77 client_auth_config_.fetch_secret_callback = base::Bind( |
| 78 &ChromotingJniInstance::FetchSecret, weak_factory_.GetWeakPtr()); | 78 &ChromotingJniInstance::FetchSecret, weak_factory_.GetWeakPtr()); |
| 79 client_auth_config_.fetch_third_party_token_callback = | 79 client_auth_config_.fetch_third_party_token_callback = |
| 80 base::Bind(&ChromotingJniInstance::FetchThirdPartyToken, | 80 base::Bind(&ChromotingJniInstance::FetchThirdPartyToken, |
| 81 weak_factory_.GetWeakPtr(), host_pubkey); | 81 weak_factory_.GetWeakPtr(), host_pubkey); |
| 82 | |
| 83 // Post a task to start connection | |
| 84 jni_runtime_->network_task_runner()->PostTask( | |
| 85 FROM_HERE, | |
| 86 base::Bind(&ChromotingJniInstance::ConnectToHostOnNetworkThread, this)); | |
| 87 } | 82 } |
| 88 | 83 |
| 89 ChromotingJniInstance::~ChromotingJniInstance() { | 84 ChromotingJniInstance::~ChromotingJniInstance() { |
| 90 // This object is ref-counted, so this dtor can execute on any thread. | 85 // This object is ref-counted, so this dtor can execute on any thread. |
| 91 // Ensure that all these objects have been freed already, so they are not | 86 // Ensure that all these objects have been freed already, so they are not |
| 92 // destroyed on some random thread. | 87 // destroyed on some random thread. |
| 93 DCHECK(!view_); | 88 DCHECK(!view_); |
| 94 DCHECK(!client_context_); | 89 DCHECK(!client_context_); |
| 95 DCHECK(!video_renderer_); | 90 DCHECK(!video_renderer_); |
| 96 DCHECK(!client_); | 91 DCHECK(!client_); |
| 97 DCHECK(!signaling_); | 92 DCHECK(!signaling_); |
| 98 } | 93 } |
| 99 | 94 |
| 95 void ChromotingJniInstance::Connect() { |
| 96 if (jni_runtime_->network_task_runner()->BelongsToCurrentThread()) { |
| 97 ConnectToHostOnNetworkThread(); |
| 98 } else { |
| 99 jni_runtime_->network_task_runner()->PostTask( |
| 100 FROM_HERE, |
| 101 base::Bind(&ChromotingJniInstance::ConnectToHostOnNetworkThread, this)); |
| 102 } |
| 103 } |
| 104 |
| 100 void ChromotingJniInstance::Disconnect() { | 105 void ChromotingJniInstance::Disconnect() { |
| 101 if (!jni_runtime_->network_task_runner()->BelongsToCurrentThread()) { | 106 if (!jni_runtime_->network_task_runner()->BelongsToCurrentThread()) { |
| 102 jni_runtime_->network_task_runner()->PostTask( | 107 jni_runtime_->network_task_runner()->PostTask( |
| 103 FROM_HERE, | 108 FROM_HERE, |
| 104 base::Bind(&ChromotingJniInstance::Disconnect, this)); | 109 base::Bind(&ChromotingJniInstance::Disconnect, this)); |
| 105 return; | 110 return; |
| 106 } | 111 } |
| 107 | 112 |
| 108 stats_logging_enabled_ = false; | 113 stats_logging_enabled_ = false; |
| 109 | 114 |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 perf_tracker_->round_trip_ms().Max()); | 522 perf_tracker_->round_trip_ms().Max()); |
| 518 | 523 |
| 519 jni_runtime_->logger()->LogStatistics(perf_tracker_.get()); | 524 jni_runtime_->logger()->LogStatistics(perf_tracker_.get()); |
| 520 | 525 |
| 521 jni_runtime_->network_task_runner()->PostDelayedTask( | 526 jni_runtime_->network_task_runner()->PostDelayedTask( |
| 522 FROM_HERE, base::Bind(&ChromotingJniInstance::LogPerfStats, this), | 527 FROM_HERE, base::Bind(&ChromotingJniInstance::LogPerfStats, this), |
| 523 base::TimeDelta::FromMilliseconds(kPerfStatsIntervalMs)); | 528 base::TimeDelta::FromMilliseconds(kPerfStatsIntervalMs)); |
| 524 } | 529 } |
| 525 | 530 |
| 526 } // namespace remoting | 531 } // namespace remoting |
| OLD | NEW |