Chromium Code Reviews| 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 df6583d7a87e744b158b3562ba1035d4e34ecbfe..d8c992497edabbd802899a989e4757d5382aa86d 100644 |
| --- a/remoting/client/jni/chromoting_jni_instance.cc |
| +++ b/remoting/client/jni/chromoting_jni_instance.cc |
| @@ -40,7 +40,10 @@ ChromotingJniInstance::ChromotingJniInstance(const char* username, |
| this)); |
| } |
| -ChromotingJniInstance::~ChromotingJniInstance() {} |
| +ChromotingJniInstance::~ChromotingJniInstance() { |
| + // Invalidate weak pointers to |view_| before it is destroyed. |
| + view_weak_factory_->InvalidateWeakPtrs(); |
|
Wez
2013/07/16 18:45:53
nit: Since you only grab a WeakPtr to the view at
solb
2013/07/16 21:35:41
Done.
|
| +} |
| void ChromotingJniInstance::Cleanup() { |
| if (!ChromotingJni::GetInstance()-> |
| @@ -57,7 +60,8 @@ void ChromotingJniInstance::Cleanup() { |
| host_id_ = ""; |
| host_pubkey_ = ""; |
| - // |client_| must be torn down before |signaling_|. |
| + // We reset these manually because they must be destroyed on the network |
| + // thread. |client_| must be torn down before |signaling_|. |
| pin_callback_.Reset(); |
| client_.reset(); |
| connection_.reset(); |
| @@ -79,6 +83,19 @@ void ChromotingJniInstance::ProvideSecret(const char* pin) { |
| base::Bind(pin_callback_, pin)); |
| } |
| +void ChromotingJniInstance::RedrawDesktop() { |
| + if (!ChromotingJni::GetInstance()-> |
| + display_task_runner()->BelongsToCurrentThread()) { |
| + ChromotingJni::GetInstance()->display_task_runner()->PostTask( |
| + FROM_HERE, |
| + base::Bind(&ChromotingJniInstance::RedrawDesktop, |
| + this)); |
| + return; |
| + } |
| + |
| + ChromotingJni::GetInstance()->RedrawCanvas(); |
| +} |
| + |
| void ChromotingJniInstance::OnConnectionState( |
| protocol::ConnectionToHost::State state, |
| protocol::ErrorCode error) { |
| @@ -128,11 +145,12 @@ void ChromotingJniInstance::ConnectToHostOnDisplayThread() { |
| DCHECK(ChromotingJni::GetInstance()-> |
| display_task_runner()->BelongsToCurrentThread()); |
| - if (!frame_consumer_.get()) { |
| - frame_consumer_ = new FrameConsumerProxy( |
| - ChromotingJni::GetInstance()->display_task_runner()); |
| - // TODO(solb) Instantiate some FrameConsumer implementation and attach it. |
| - } |
| + frame_consumer_ = new FrameConsumerProxy( |
| + ChromotingJni::GetInstance()->display_task_runner()); |
| + view_.reset(new JniFrameConsumer()); |
| + view_weak_factory_.reset(new base::WeakPtrFactory<JniFrameConsumer>( |
| + view_.get())); |
| + frame_consumer_->Attach(view_weak_factory_->GetWeakPtr()); |
| ChromotingJni::GetInstance()->network_task_runner()->PostTask( |
| FROM_HERE, |
| @@ -172,6 +190,8 @@ void ChromotingJniInstance::ConnectToHostOnNetworkThread() { |
| frame_consumer_, |
| scoped_ptr<AudioPlayer>())); |
| + view_->set_frame_producer(client_->GetFrameProducer()); |
| + |
| signaling_config_.reset(new XmppSignalStrategy::XmppServerConfig()); |
| signaling_config_->host = CHAT_SERVER; |
| signaling_config_->port = CHAT_PORT; |