Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: remoting/client/plugin/chromoting_instance.cc

Issue 10284008: Switch client to Pepper UDP API instead of Transport API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/json/json_reader.h" 12 #include "base/json/json_reader.h"
13 #include "base/json/json_writer.h" 13 #include "base/json/json_writer.h"
14 #include "base/lazy_instance.h" 14 #include "base/lazy_instance.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/stringprintf.h" 16 #include "base/stringprintf.h"
17 #include "base/string_split.h" 17 #include "base/string_split.h"
18 #include "base/synchronization/lock.h" 18 #include "base/synchronization/lock.h"
19 #include "base/synchronization/waitable_event.h" 19 #include "base/synchronization/waitable_event.h"
20 #include "base/threading/thread.h" 20 #include "base/threading/thread.h"
21 #include "base/values.h" 21 #include "base/values.h"
22 #include "jingle/glue/thread_wrapper.h"
22 #include "media/base/media.h" 23 #include "media/base/media.h"
23 #include "ppapi/cpp/completion_callback.h" 24 #include "ppapi/cpp/completion_callback.h"
24 #include "ppapi/cpp/input_event.h" 25 #include "ppapi/cpp/input_event.h"
25 #include "ppapi/cpp/rect.h" 26 #include "ppapi/cpp/rect.h"
26 // TODO(wez): Remove this when crbug.com/86353 is complete. 27 // TODO(wez): Remove this when crbug.com/86353 is complete.
27 #include "ppapi/cpp/private/var_private.h" 28 #include "ppapi/cpp/private/var_private.h"
28 #include "remoting/base/constants.h" 29 #include "remoting/base/constants.h"
29 #include "remoting/base/util.h" 30 #include "remoting/base/util.h"
30 #include "remoting/client/client_config.h" 31 #include "remoting/client/client_config.h"
31 #include "remoting/client/chromoting_client.h" 32 #include "remoting/client/chromoting_client.h"
32 #include "remoting/client/frame_consumer_proxy.h" 33 #include "remoting/client/frame_consumer_proxy.h"
33 #include "remoting/client/plugin/chromoting_scriptable_object.h" 34 #include "remoting/client/plugin/chromoting_scriptable_object.h"
34 #include "remoting/client/plugin/pepper_input_handler.h" 35 #include "remoting/client/plugin/pepper_input_handler.h"
36 #include "remoting/client/plugin/pepper_port_allocator.h"
35 #include "remoting/client/plugin/pepper_view.h" 37 #include "remoting/client/plugin/pepper_view.h"
36 #include "remoting/client/plugin/pepper_xmpp_proxy.h" 38 #include "remoting/client/plugin/pepper_xmpp_proxy.h"
37 #include "remoting/client/rectangle_update_decoder.h" 39 #include "remoting/client/rectangle_update_decoder.h"
38 #include "remoting/protocol/connection_to_host.h" 40 #include "remoting/protocol/connection_to_host.h"
39 #include "remoting/protocol/host_stub.h" 41 #include "remoting/protocol/host_stub.h"
40 #include "remoting/protocol/input_event_tracker.h" 42 #include "remoting/protocol/input_event_tracker.h"
43 #include "remoting/protocol/libjingle_transport_factory.h"
41 #include "remoting/protocol/mouse_input_filter.h" 44 #include "remoting/protocol/mouse_input_filter.h"
42 45
43 // Windows defines 'PostMessage', so we have to undef it. 46 // Windows defines 'PostMessage', so we have to undef it.
44 #if defined(PostMessage) 47 #if defined(PostMessage)
45 #undef PostMessage 48 #undef PostMessage
46 #endif 49 #endif
47 50
48 namespace remoting { 51 namespace remoting {
49 52
50 namespace { 53 namespace {
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 DCHECK(so != NULL); 385 DCHECK(so != NULL);
383 return static_cast<ChromotingScriptableObject*>(so); 386 return static_cast<ChromotingScriptableObject*>(so);
384 } 387 }
385 LOG(ERROR) << "Unable to get ScriptableObject for Chromoting plugin."; 388 LOG(ERROR) << "Unable to get ScriptableObject for Chromoting plugin.";
386 return NULL; 389 return NULL;
387 } 390 }
388 391
389 void ChromotingInstance::Connect(const ClientConfig& config) { 392 void ChromotingInstance::Connect(const ClientConfig& config) {
390 DCHECK(plugin_message_loop_->BelongsToCurrentThread()); 393 DCHECK(plugin_message_loop_->BelongsToCurrentThread());
391 394
395 jingle_glue::JingleThreadWrapper::EnsureForCurrentThread();
396
392 host_connection_.reset(new protocol::ConnectionToHost( 397 host_connection_.reset(new protocol::ConnectionToHost(
393 context_.network_message_loop(), this, true)); 398 context_.network_message_loop(), this, true));
394 client_.reset(new ChromotingClient(config, &context_, host_connection_.get(), 399 client_.reset(new ChromotingClient(config, &context_, host_connection_.get(),
395 view_.get(), rectangle_decoder_.get(), 400 view_.get(), rectangle_decoder_.get(),
396 base::Closure())); 401 base::Closure()));
397 402
398 // Construct the input pipeline 403 // Construct the input pipeline
399 mouse_input_filter_.reset( 404 mouse_input_filter_.reset(
400 new protocol::MouseInputFilter(host_connection_->input_stub())); 405 new protocol::MouseInputFilter(host_connection_->input_stub()));
401 mouse_input_filter_->set_input_size(view_->get_view_size()); 406 mouse_input_filter_->set_input_size(view_->get_view_size());
402 input_tracker_.reset( 407 input_tracker_.reset(
403 new protocol::InputEventTracker(mouse_input_filter_.get())); 408 new protocol::InputEventTracker(mouse_input_filter_.get()));
404 key_mapper_.set_input_stub(input_tracker_.get()); 409 key_mapper_.set_input_stub(input_tracker_.get());
405 input_handler_.reset( 410 input_handler_.reset(
406 new PepperInputHandler(&key_mapper_)); 411 new PepperInputHandler(&key_mapper_));
407 412
408 LOG(INFO) << "Connecting to " << config.host_jid 413 LOG(INFO) << "Connecting to " << config.host_jid
409 << ". Local jid: " << config.local_jid << "."; 414 << ". Local jid: " << config.local_jid << ".";
410 415
411 // Setup the XMPP Proxy. 416 // Setup the XMPP Proxy.
412 xmpp_proxy_ = new PepperXmppProxy( 417 xmpp_proxy_ = new PepperXmppProxy(
413 base::Bind(&ChromotingInstance::SendOutgoingIq, AsWeakPtr()), 418 base::Bind(&ChromotingInstance::SendOutgoingIq, AsWeakPtr()),
414 plugin_message_loop_, 419 plugin_message_loop_,
415 context_.network_message_loop()); 420 context_.network_message_loop());
416 421
422 scoped_ptr<cricket::HttpPortAllocatorBase> port_allocator(
423 PepperPortAllocator::Create(this));
424 scoped_ptr<protocol::TransportFactory> transport_factory(
425 new protocol::LibjingleTransportFactory(port_allocator.Pass(), false));
426
417 // Kick off the connection. 427 // Kick off the connection.
418 client_->Start(xmpp_proxy_); 428 client_->Start(xmpp_proxy_, transport_factory.Pass());
419 429
420 // Start timer that periodically sends perf stats. 430 // Start timer that periodically sends perf stats.
421 plugin_message_loop_->PostDelayedTask( 431 plugin_message_loop_->PostDelayedTask(
422 FROM_HERE, base::Bind(&ChromotingInstance::SendPerfStats, AsWeakPtr()), 432 FROM_HERE, base::Bind(&ChromotingInstance::SendPerfStats, AsWeakPtr()),
423 base::TimeDelta::FromMilliseconds(kPerfStatsIntervalMs)); 433 base::TimeDelta::FromMilliseconds(kPerfStatsIntervalMs));
424 434
425 VLOG(1) << "Connection status: Initializing"; 435 VLOG(1) << "Connection status: Initializing";
426 SetConnectionState(STATE_INITIALIZING, ERROR_NONE); 436 SetConnectionState(STATE_INITIALIZING, ERROR_NONE);
427 } 437 }
428 438
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); 658 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue());
649 data->SetString("message", message); 659 data->SetString("message", message);
650 PostChromotingMessage("logDebugMessage", data.Pass()); 660 PostChromotingMessage("logDebugMessage", data.Pass());
651 661
652 scriptable_object->LogDebugInfo(message); 662 scriptable_object->LogDebugInfo(message);
653 } 663 }
654 g_logging_to_plugin = false; 664 g_logging_to_plugin = false;
655 } 665 }
656 666
657 } // namespace remoting 667 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698