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> |
| 11 |
10 #include "base/bind.h" | 12 #include "base/bind.h" |
11 #include "base/logging.h" | 13 #include "base/logging.h" |
12 #include "jingle/glue/thread_wrapper.h" | 14 #include "jingle/glue/thread_wrapper.h" |
13 #include "net/socket/client_socket_factory.h" | 15 #include "net/socket/client_socket_factory.h" |
14 #include "remoting/base/service_urls.h" | 16 #include "remoting/base/service_urls.h" |
15 #include "remoting/client/audio_player.h" | 17 #include "remoting/client/audio_player.h" |
16 #include "remoting/client/client_status_logger.h" | 18 #include "remoting/client/client_status_logger.h" |
17 #include "remoting/client/jni/android_keymap.h" | 19 #include "remoting/client/jni/android_keymap.h" |
18 #include "remoting/client/jni/chromoting_jni_runtime.h" | 20 #include "remoting/client/jni/chromoting_jni_runtime.h" |
19 #include "remoting/client/jni/jni_frame_consumer.h" | 21 #include "remoting/client/jni/jni_frame_consumer.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 auth_methods.push_back(protocol::AuthenticationMethod::Spake2Pair()); | 81 auth_methods.push_back(protocol::AuthenticationMethod::Spake2Pair()); |
80 auth_methods.push_back(protocol::AuthenticationMethod::Spake2( | 82 auth_methods.push_back(protocol::AuthenticationMethod::Spake2( |
81 protocol::AuthenticationMethod::HMAC_SHA256)); | 83 protocol::AuthenticationMethod::HMAC_SHA256)); |
82 auth_methods.push_back(protocol::AuthenticationMethod::Spake2( | 84 auth_methods.push_back(protocol::AuthenticationMethod::Spake2( |
83 protocol::AuthenticationMethod::NONE)); | 85 protocol::AuthenticationMethod::NONE)); |
84 auth_methods.push_back(protocol::AuthenticationMethod::ThirdParty()); | 86 auth_methods.push_back(protocol::AuthenticationMethod::ThirdParty()); |
85 | 87 |
86 authenticator_.reset(new protocol::NegotiatingClientAuthenticator( | 88 authenticator_.reset(new protocol::NegotiatingClientAuthenticator( |
87 pairing_id, pairing_secret, host_id_, | 89 pairing_id, pairing_secret, host_id_, |
88 base::Bind(&ChromotingJniInstance::FetchSecret, this), | 90 base::Bind(&ChromotingJniInstance::FetchSecret, this), |
89 token_fetcher.Pass(), auth_methods)); | 91 std::move(token_fetcher), auth_methods)); |
90 | 92 |
91 // Post a task to start connection | 93 // Post a task to start connection |
92 jni_runtime_->network_task_runner()->PostTask( | 94 jni_runtime_->network_task_runner()->PostTask( |
93 FROM_HERE, | 95 FROM_HERE, |
94 base::Bind(&ChromotingJniInstance::ConnectToHostOnNetworkThread, this)); | 96 base::Bind(&ChromotingJniInstance::ConnectToHostOnNetworkThread, this)); |
95 } | 97 } |
96 | 98 |
97 ChromotingJniInstance::~ChromotingJniInstance() { | 99 ChromotingJniInstance::~ChromotingJniInstance() { |
98 // This object is ref-counted, so this dtor can execute on any thread. | 100 // This object is ref-counted, so this dtor can execute on any thread. |
99 // Ensure that all these objects have been freed already, so they are not | 101 // Ensure that all these objects have been freed already, so they are not |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 protocol::NetworkSettings network_settings( | 425 protocol::NetworkSettings network_settings( |
424 protocol::NetworkSettings::NAT_TRAVERSAL_FULL); | 426 protocol::NetworkSettings::NAT_TRAVERSAL_FULL); |
425 | 427 |
426 // Use Chrome's network stack to allocate ports for peer-to-peer channels. | 428 // Use Chrome's network stack to allocate ports for peer-to-peer channels. |
427 scoped_ptr<protocol::ChromiumPortAllocatorFactory> port_allocator_factory( | 429 scoped_ptr<protocol::ChromiumPortAllocatorFactory> port_allocator_factory( |
428 new protocol::ChromiumPortAllocatorFactory( | 430 new protocol::ChromiumPortAllocatorFactory( |
429 jni_runtime_->url_requester())); | 431 jni_runtime_->url_requester())); |
430 | 432 |
431 scoped_refptr<protocol::TransportContext> transport_context = | 433 scoped_refptr<protocol::TransportContext> transport_context = |
432 new protocol::TransportContext( | 434 new protocol::TransportContext( |
433 signaling_.get(), port_allocator_factory.Pass(), network_settings, | 435 signaling_.get(), std::move(port_allocator_factory), network_settings, |
434 protocol::TransportRole::CLIENT); | 436 protocol::TransportRole::CLIENT); |
435 | 437 |
436 client_->Start(signaling_.get(), authenticator_.Pass(), transport_context, | 438 client_->Start(signaling_.get(), std::move(authenticator_), transport_context, |
437 host_jid_, capabilities_); | 439 host_jid_, capabilities_); |
438 } | 440 } |
439 | 441 |
440 void ChromotingJniInstance::FetchSecret( | 442 void ChromotingJniInstance::FetchSecret( |
441 bool pairable, | 443 bool pairable, |
442 const protocol::SecretFetchedCallback& callback) { | 444 const protocol::SecretFetchedCallback& callback) { |
443 if (!jni_runtime_->ui_task_runner()->BelongsToCurrentThread()) { | 445 if (!jni_runtime_->ui_task_runner()->BelongsToCurrentThread()) { |
444 jni_runtime_->ui_task_runner()->PostTask( | 446 jni_runtime_->ui_task_runner()->PostTask( |
445 FROM_HERE, base::Bind(&ChromotingJniInstance::FetchSecret, | 447 FROM_HERE, base::Bind(&ChromotingJniInstance::FetchSecret, |
446 this, pairable, callback)); | 448 this, pairable, callback)); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 perf_tracker_->round_trip_ms()); | 509 perf_tracker_->round_trip_ms()); |
508 | 510 |
509 client_status_logger_->LogStatistics(perf_tracker_.get()); | 511 client_status_logger_->LogStatistics(perf_tracker_.get()); |
510 | 512 |
511 jni_runtime_->network_task_runner()->PostDelayedTask( | 513 jni_runtime_->network_task_runner()->PostDelayedTask( |
512 FROM_HERE, base::Bind(&ChromotingJniInstance::LogPerfStats, this), | 514 FROM_HERE, base::Bind(&ChromotingJniInstance::LogPerfStats, this), |
513 base::TimeDelta::FromMilliseconds(kPerfStatsIntervalMs)); | 515 base::TimeDelta::FromMilliseconds(kPerfStatsIntervalMs)); |
514 } | 516 } |
515 | 517 |
516 } // namespace remoting | 518 } // namespace remoting |
OLD | NEW |