| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/plugin/chromoting_instance.h" | 5 #include "remoting/client/plugin/chromoting_instance.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 | 189 |
| 190 // Start all the threads. | 190 // Start all the threads. |
| 191 context_.Start(); | 191 context_.Start(); |
| 192 | 192 |
| 193 // Create the chromoting objects that don't depend on the network connection. | 193 // Create the chromoting objects that don't depend on the network connection. |
| 194 // RectangleUpdateDecoder runs on a separate thread so for now we wrap | 194 // RectangleUpdateDecoder runs on a separate thread so for now we wrap |
| 195 // PepperView with a ref-counted proxy object. | 195 // PepperView with a ref-counted proxy object. |
| 196 scoped_refptr<FrameConsumerProxy> consumer_proxy = | 196 scoped_refptr<FrameConsumerProxy> consumer_proxy = |
| 197 new FrameConsumerProxy(plugin_message_loop_); | 197 new FrameConsumerProxy(plugin_message_loop_); |
| 198 rectangle_decoder_ = new RectangleUpdateDecoder( | 198 rectangle_decoder_ = new RectangleUpdateDecoder( |
| 199 context_.decode_message_loop(), consumer_proxy); | 199 context_.decode_task_runner(), consumer_proxy); |
| 200 view_.reset(new PepperView(this, &context_, rectangle_decoder_.get())); | 200 view_.reset(new PepperView(this, &context_, rectangle_decoder_.get())); |
| 201 consumer_proxy->Attach(view_->AsWeakPtr()); | 201 consumer_proxy->Attach(view_->AsWeakPtr()); |
| 202 | 202 |
| 203 return true; | 203 return true; |
| 204 } | 204 } |
| 205 | 205 |
| 206 void ChromotingInstance::HandleMessage(const pp::Var& message) { | 206 void ChromotingInstance::HandleMessage(const pp::Var& message) { |
| 207 if (!message.is_string()) { | 207 if (!message.is_string()) { |
| 208 LOG(ERROR) << "Received a message that is not a string."; | 208 LOG(ERROR) << "Received a message that is not a string."; |
| 209 return; | 209 return; |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 362 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
| 363 PostChromotingMessage("onFirstFrameReceived", data.Pass()); | 363 PostChromotingMessage("onFirstFrameReceived", data.Pass()); |
| 364 } | 364 } |
| 365 | 365 |
| 366 void ChromotingInstance::Connect(const ClientConfig& config) { | 366 void ChromotingInstance::Connect(const ClientConfig& config) { |
| 367 DCHECK(plugin_message_loop_->BelongsToCurrentThread()); | 367 DCHECK(plugin_message_loop_->BelongsToCurrentThread()); |
| 368 | 368 |
| 369 jingle_glue::JingleThreadWrapper::EnsureForCurrentThread(); | 369 jingle_glue::JingleThreadWrapper::EnsureForCurrentThread(); |
| 370 | 370 |
| 371 host_connection_.reset(new protocol::ConnectionToHost(true)); | 371 host_connection_.reset(new protocol::ConnectionToHost(true)); |
| 372 client_.reset(new ChromotingClient(config, &context_, host_connection_.get(), | 372 client_.reset(new ChromotingClient(config, context_.main_task_runner(), |
| 373 view_.get(), rectangle_decoder_.get(), | 373 host_connection_.get(), view_.get(), |
| 374 base::Closure())); | 374 rectangle_decoder_.get())); |
| 375 | 375 |
| 376 // Construct the input pipeline | 376 // Construct the input pipeline |
| 377 mouse_input_filter_.reset( | 377 mouse_input_filter_.reset( |
| 378 new protocol::MouseInputFilter(host_connection_->input_stub())); | 378 new protocol::MouseInputFilter(host_connection_->input_stub())); |
| 379 mouse_input_filter_->set_input_size(view_->get_view_size()); | 379 mouse_input_filter_->set_input_size(view_->get_view_size()); |
| 380 input_tracker_.reset( | 380 input_tracker_.reset( |
| 381 new protocol::InputEventTracker(mouse_input_filter_.get())); | 381 new protocol::InputEventTracker(mouse_input_filter_.get())); |
| 382 | 382 |
| 383 #if defined(OS_MACOSX) | 383 #if defined(OS_MACOSX) |
| 384 // On Mac we need an extra filter to inject missing keyup events. | 384 // On Mac we need an extra filter to inject missing keyup events. |
| 385 // See remoting/client/plugin/mac_key_event_processor.h for more details. | 385 // See remoting/client/plugin/mac_key_event_processor.h for more details. |
| 386 mac_key_event_processor_.reset( | 386 mac_key_event_processor_.reset( |
| 387 new MacKeyEventProcessor(input_tracker_.get())); | 387 new MacKeyEventProcessor(input_tracker_.get())); |
| 388 key_mapper_.set_input_stub(mac_key_event_processor_.get()); | 388 key_mapper_.set_input_stub(mac_key_event_processor_.get()); |
| 389 #else | 389 #else |
| 390 key_mapper_.set_input_stub(input_tracker_.get()); | 390 key_mapper_.set_input_stub(input_tracker_.get()); |
| 391 #endif | 391 #endif |
| 392 input_handler_.reset( | 392 input_handler_.reset( |
| 393 new PepperInputHandler(&key_mapper_)); | 393 new PepperInputHandler(&key_mapper_)); |
| 394 | 394 |
| 395 LOG(INFO) << "Connecting to " << config.host_jid | 395 LOG(INFO) << "Connecting to " << config.host_jid |
| 396 << ". Local jid: " << config.local_jid << "."; | 396 << ". Local jid: " << config.local_jid << "."; |
| 397 | 397 |
| 398 // Setup the XMPP Proxy. | 398 // Setup the XMPP Proxy. |
| 399 xmpp_proxy_ = new PepperXmppProxy( | 399 xmpp_proxy_ = new PepperXmppProxy( |
| 400 base::Bind(&ChromotingInstance::SendOutgoingIq, AsWeakPtr()), | 400 base::Bind(&ChromotingInstance::SendOutgoingIq, AsWeakPtr()), |
| 401 plugin_message_loop_, | 401 plugin_message_loop_, context_.main_task_runner()); |
| 402 context_.network_message_loop()); | |
| 403 | 402 |
| 404 scoped_ptr<cricket::HttpPortAllocatorBase> port_allocator( | 403 scoped_ptr<cricket::HttpPortAllocatorBase> port_allocator( |
| 405 PepperPortAllocator::Create(this)); | 404 PepperPortAllocator::Create(this)); |
| 406 scoped_ptr<protocol::TransportFactory> transport_factory( | 405 scoped_ptr<protocol::TransportFactory> transport_factory( |
| 407 new protocol::LibjingleTransportFactory(port_allocator.Pass(), false)); | 406 new protocol::LibjingleTransportFactory(port_allocator.Pass(), false)); |
| 408 | 407 |
| 409 // Kick off the connection. | 408 // Kick off the connection. |
| 410 client_->Start(xmpp_proxy_, transport_factory.Pass()); | 409 client_->Start(xmpp_proxy_, transport_factory.Pass()); |
| 411 | 410 |
| 412 // Start timer that periodically sends perf stats. | 411 // Start timer that periodically sends perf stats. |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 PostChromotingMessage("logDebugMessage", data.Pass()); | 699 PostChromotingMessage("logDebugMessage", data.Pass()); |
| 701 g_logging_to_plugin = false; | 700 g_logging_to_plugin = false; |
| 702 } | 701 } |
| 703 | 702 |
| 704 bool ChromotingInstance::IsConnected() { | 703 bool ChromotingInstance::IsConnected() { |
| 705 return host_connection_.get() && | 704 return host_connection_.get() && |
| 706 (host_connection_->state() == protocol::ConnectionToHost::CONNECTED); | 705 (host_connection_->state() == protocol::ConnectionToHost::CONNECTED); |
| 707 } | 706 } |
| 708 | 707 |
| 709 } // namespace remoting | 708 } // namespace remoting |
| OLD | NEW |