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

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 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 DCHECK(so != NULL); 392 DCHECK(so != NULL);
390 return static_cast<ChromotingScriptableObject*>(so); 393 return static_cast<ChromotingScriptableObject*>(so);
391 } 394 }
392 LOG(ERROR) << "Unable to get ScriptableObject for Chromoting plugin."; 395 LOG(ERROR) << "Unable to get ScriptableObject for Chromoting plugin.";
393 return NULL; 396 return NULL;
394 } 397 }
395 398
396 void ChromotingInstance::Connect(const ClientConfig& config) { 399 void ChromotingInstance::Connect(const ClientConfig& config) {
397 DCHECK(plugin_message_loop_->BelongsToCurrentThread()); 400 DCHECK(plugin_message_loop_->BelongsToCurrentThread());
398 401
402 jingle_glue::JingleThreadWrapper::EnsureForCurrentThread();
403
399 host_connection_.reset(new protocol::ConnectionToHost( 404 host_connection_.reset(new protocol::ConnectionToHost(
400 context_.network_message_loop(), this, true)); 405 context_.network_message_loop(), true));
401 client_.reset(new ChromotingClient(config, &context_, host_connection_.get(), 406 client_.reset(new ChromotingClient(config, &context_, host_connection_.get(),
402 view_.get(), rectangle_decoder_.get(), 407 view_.get(), rectangle_decoder_.get(),
403 base::Closure())); 408 base::Closure()));
404 409
405 // Construct the input pipeline 410 // Construct the input pipeline
406 mouse_input_filter_.reset( 411 mouse_input_filter_.reset(
407 new protocol::MouseInputFilter(host_connection_->input_stub())); 412 new protocol::MouseInputFilter(host_connection_->input_stub()));
408 mouse_input_filter_->set_input_size(view_->get_view_size()); 413 mouse_input_filter_->set_input_size(view_->get_view_size());
409 input_tracker_.reset( 414 input_tracker_.reset(
410 new protocol::InputEventTracker(mouse_input_filter_.get())); 415 new protocol::InputEventTracker(mouse_input_filter_.get()));
(...skipping 12 matching lines...) Expand all
423 428
424 LOG(INFO) << "Connecting to " << config.host_jid 429 LOG(INFO) << "Connecting to " << config.host_jid
425 << ". Local jid: " << config.local_jid << "."; 430 << ". Local jid: " << config.local_jid << ".";
426 431
427 // Setup the XMPP Proxy. 432 // Setup the XMPP Proxy.
428 xmpp_proxy_ = new PepperXmppProxy( 433 xmpp_proxy_ = new PepperXmppProxy(
429 base::Bind(&ChromotingInstance::SendOutgoingIq, AsWeakPtr()), 434 base::Bind(&ChromotingInstance::SendOutgoingIq, AsWeakPtr()),
430 plugin_message_loop_, 435 plugin_message_loop_,
431 context_.network_message_loop()); 436 context_.network_message_loop());
432 437
438 scoped_ptr<cricket::HttpPortAllocatorBase> port_allocator(
439 PepperPortAllocator::Create(this));
440 scoped_ptr<protocol::TransportFactory> transport_factory(
441 new protocol::LibjingleTransportFactory(port_allocator.Pass(), false));
442
433 // Kick off the connection. 443 // Kick off the connection.
434 client_->Start(xmpp_proxy_); 444 client_->Start(xmpp_proxy_, transport_factory.Pass());
435 445
436 // Start timer that periodically sends perf stats. 446 // Start timer that periodically sends perf stats.
437 plugin_message_loop_->PostDelayedTask( 447 plugin_message_loop_->PostDelayedTask(
438 FROM_HERE, base::Bind(&ChromotingInstance::SendPerfStats, AsWeakPtr()), 448 FROM_HERE, base::Bind(&ChromotingInstance::SendPerfStats, AsWeakPtr()),
439 base::TimeDelta::FromMilliseconds(kPerfStatsIntervalMs)); 449 base::TimeDelta::FromMilliseconds(kPerfStatsIntervalMs));
440 450
441 VLOG(1) << "Connection status: Initializing"; 451 VLOG(1) << "Connection status: Initializing";
442 SetConnectionState(STATE_INITIALIZING, ERROR_NONE); 452 SetConnectionState(STATE_INITIALIZING, ERROR_NONE);
443 } 453 }
444 454
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 } 688 }
679 g_logging_to_plugin = false; 689 g_logging_to_plugin = false;
680 } 690 }
681 691
682 bool ChromotingInstance::IsConnected() { 692 bool ChromotingInstance::IsConnected() {
683 return host_connection_.get() && 693 return host_connection_.get() &&
684 (host_connection_->state() == protocol::ConnectionToHost::CONNECTED); 694 (host_connection_->state() == protocol::ConnectionToHost::CONNECTED);
685 } 695 }
686 696
687 } // namespace remoting 697 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/chromoting_client.cc ('k') | remoting/client/plugin/pepper_packet_socket_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698