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

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

Issue 19579010: Remove unnecessary SupportsWeakPtr base from ChromotingInstance. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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
« no previous file with comments | « remoting/client/plugin/chromoting_instance.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 !ParseAuthMethods(auth_methods, &config) || 287 !ParseAuthMethods(auth_methods, &config) ||
288 !data->GetString("authenticationTag", &config.authentication_tag)) { 288 !data->GetString("authenticationTag", &config.authentication_tag)) {
289 LOG(ERROR) << "Invalid connect() data."; 289 LOG(ERROR) << "Invalid connect() data.";
290 return; 290 return;
291 } 291 }
292 data->GetString("clientPairingId", &config.client_pairing_id); 292 data->GetString("clientPairingId", &config.client_pairing_id);
293 data->GetString("clientPairedSecret", &config.client_paired_secret); 293 data->GetString("clientPairedSecret", &config.client_paired_secret);
294 if (use_async_pin_dialog_) { 294 if (use_async_pin_dialog_) {
295 config.fetch_secret_callback = 295 config.fetch_secret_callback =
296 base::Bind(&ChromotingInstance::FetchSecretFromDialog, 296 base::Bind(&ChromotingInstance::FetchSecretFromDialog,
297 this->AsWeakPtr()); 297 weak_factory_.GetWeakPtr());
298 } else { 298 } else {
299 std::string shared_secret; 299 std::string shared_secret;
300 if (!data->GetString("sharedSecret", &shared_secret)) { 300 if (!data->GetString("sharedSecret", &shared_secret)) {
301 LOG(ERROR) << "sharedSecret not specified in connect()."; 301 LOG(ERROR) << "sharedSecret not specified in connect().";
302 return; 302 return;
303 } 303 }
304 config.fetch_secret_callback = 304 config.fetch_secret_callback =
305 base::Bind(&ChromotingInstance::FetchSecretFromString, shared_secret); 305 base::Bind(&ChromotingInstance::FetchSecretFromString, shared_secret);
306 } 306 }
307 307
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 565
566 protocol::CursorShapeStub* ChromotingInstance::GetCursorShapeStub() { 566 protocol::CursorShapeStub* ChromotingInstance::GetCursorShapeStub() {
567 // TODO(sergeyu): Move cursor shape code to a separate class. 567 // TODO(sergeyu): Move cursor shape code to a separate class.
568 // crbug.com/138108 568 // crbug.com/138108
569 return this; 569 return this;
570 } 570 }
571 571
572 scoped_ptr<protocol::ThirdPartyClientAuthenticator::TokenFetcher> 572 scoped_ptr<protocol::ThirdPartyClientAuthenticator::TokenFetcher>
573 ChromotingInstance::GetTokenFetcher(const std::string& host_public_key) { 573 ChromotingInstance::GetTokenFetcher(const std::string& host_public_key) {
574 return scoped_ptr<protocol::ThirdPartyClientAuthenticator::TokenFetcher>( 574 return scoped_ptr<protocol::ThirdPartyClientAuthenticator::TokenFetcher>(
575 new PepperTokenFetcher(this->AsWeakPtr(), host_public_key)); 575 new PepperTokenFetcher(weak_factory_.GetWeakPtr(), host_public_key));
576 } 576 }
577 577
578 void ChromotingInstance::InjectClipboardEvent( 578 void ChromotingInstance::InjectClipboardEvent(
579 const protocol::ClipboardEvent& event) { 579 const protocol::ClipboardEvent& event) {
580 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); 580 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue());
581 data->SetString("mimeType", event.mime_type()); 581 data->SetString("mimeType", event.mime_type());
582 data->SetString("item", event.data()); 582 data->SetString("item", event.data());
583 PostChromotingMessage("injectClipboardItem", data.Pass()); 583 PostChromotingMessage("injectClipboardItem", data.Pass());
584 } 584 }
585 585
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 // Connect the input pipeline to the protocol stub & initialize components. 694 // Connect the input pipeline to the protocol stub & initialize components.
695 mouse_input_filter_.set_input_stub(host_connection_->input_stub()); 695 mouse_input_filter_.set_input_stub(host_connection_->input_stub());
696 mouse_input_filter_.set_input_size(view_->get_view_size_dips()); 696 mouse_input_filter_.set_input_size(view_->get_view_size_dips());
697 697
698 LOG(INFO) << "Connecting to " << config.host_jid 698 LOG(INFO) << "Connecting to " << config.host_jid
699 << ". Local jid: " << config.local_jid << "."; 699 << ". Local jid: " << config.local_jid << ".";
700 700
701 // Setup the PepperSignalStrategy. 701 // Setup the PepperSignalStrategy.
702 signal_strategy_.reset(new PepperSignalStrategy( 702 signal_strategy_.reset(new PepperSignalStrategy(
703 config.local_jid, 703 config.local_jid,
704 base::Bind(&ChromotingInstance::SendOutgoingIq, AsWeakPtr()))); 704 base::Bind(&ChromotingInstance::SendOutgoingIq,
705 weak_factory_.GetWeakPtr())));
705 706
706 scoped_ptr<cricket::HttpPortAllocatorBase> port_allocator( 707 scoped_ptr<cricket::HttpPortAllocatorBase> port_allocator(
707 PepperPortAllocator::Create(this)); 708 PepperPortAllocator::Create(this));
708 scoped_ptr<protocol::TransportFactory> transport_factory( 709 scoped_ptr<protocol::TransportFactory> transport_factory(
709 new protocol::LibjingleTransportFactory(port_allocator.Pass(), false)); 710 new protocol::LibjingleTransportFactory(port_allocator.Pass(), false));
710 711
711 // Kick off the connection. 712 // Kick off the connection.
712 client_->Start(signal_strategy_.get(), transport_factory.Pass()); 713 client_->Start(signal_strategy_.get(), transport_factory.Pass());
713 714
714 // Start timer that periodically sends perf stats. 715 // Start timer that periodically sends perf stats.
715 plugin_task_runner_->PostDelayedTask( 716 plugin_task_runner_->PostDelayedTask(
716 FROM_HERE, base::Bind(&ChromotingInstance::SendPerfStats, AsWeakPtr()), 717 FROM_HERE, base::Bind(&ChromotingInstance::SendPerfStats,
718 weak_factory_.GetWeakPtr()),
717 base::TimeDelta::FromMilliseconds(kPerfStatsIntervalMs)); 719 base::TimeDelta::FromMilliseconds(kPerfStatsIntervalMs));
718 } 720 }
719 721
720 void ChromotingInstance::Disconnect() { 722 void ChromotingInstance::Disconnect() {
721 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); 723 DCHECK(plugin_task_runner_->BelongsToCurrentThread());
722 724
723 // PepperView must be destroyed before the client. 725 // PepperView must be destroyed before the client.
724 view_.reset(); 726 view_.reset();
725 727
726 LOG(INFO) << "Disconnecting from host."; 728 LOG(INFO) << "Disconnecting from host.";
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 data->SetString("iq", iq); 869 data->SetString("iq", iq);
868 PostChromotingMessage("sendOutgoingIq", data.Pass()); 870 PostChromotingMessage("sendOutgoingIq", data.Pass());
869 } 871 }
870 872
871 void ChromotingInstance::SendPerfStats() { 873 void ChromotingInstance::SendPerfStats() {
872 if (!client_.get()) { 874 if (!client_.get()) {
873 return; 875 return;
874 } 876 }
875 877
876 plugin_task_runner_->PostDelayedTask( 878 plugin_task_runner_->PostDelayedTask(
877 FROM_HERE, base::Bind(&ChromotingInstance::SendPerfStats, AsWeakPtr()), 879 FROM_HERE, base::Bind(&ChromotingInstance::SendPerfStats,
880 weak_factory_.GetWeakPtr()),
878 base::TimeDelta::FromMilliseconds(kPerfStatsIntervalMs)); 881 base::TimeDelta::FromMilliseconds(kPerfStatsIntervalMs));
879 882
880 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); 883 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue());
881 ChromotingStats* stats = client_->GetStats(); 884 ChromotingStats* stats = client_->GetStats();
882 data->SetDouble("videoBandwidth", stats->video_bandwidth()->Rate()); 885 data->SetDouble("videoBandwidth", stats->video_bandwidth()->Rate());
883 data->SetDouble("videoFrameRate", stats->video_frame_rate()->Rate()); 886 data->SetDouble("videoFrameRate", stats->video_frame_rate()->Rate());
884 data->SetDouble("captureLatency", stats->video_capture_ms()->Average()); 887 data->SetDouble("captureLatency", stats->video_capture_ms()->Average());
885 data->SetDouble("encodeLatency", stats->video_encode_ms()->Average()); 888 data->SetDouble("encodeLatency", stats->video_encode_ms()->Average());
886 data->SetDouble("decodeLatency", stats->video_decode_ms()->Average()); 889 data->SetDouble("decodeLatency", stats->video_decode_ms()->Average());
887 data->SetDouble("renderLatency", stats->video_paint_ms()->Average()); 890 data->SetDouble("renderLatency", stats->video_paint_ms()->Average());
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 url_components.scheme.len); 1009 url_components.scheme.len);
1007 return url_scheme == kChromeExtensionUrlScheme; 1010 return url_scheme == kChromeExtensionUrlScheme;
1008 } 1011 }
1009 1012
1010 bool ChromotingInstance::IsConnected() { 1013 bool ChromotingInstance::IsConnected() {
1011 return host_connection_.get() && 1014 return host_connection_.get() &&
1012 (host_connection_->state() == protocol::ConnectionToHost::CONNECTED); 1015 (host_connection_->state() == protocol::ConnectionToHost::CONNECTED);
1013 } 1016 }
1014 1017
1015 } // namespace remoting 1018 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/plugin/chromoting_instance.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698