| 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 <nacl_io/nacl_io.h> | 7 #include <nacl_io/nacl_io.h> |
| 8 #include <sys/mount.h> | 8 #include <sys/mount.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 #include <utility> | 11 #include <utility> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/bind.h" | 14 #include "base/bind.h" |
| 15 #include "base/callback.h" | 15 #include "base/callback.h" |
| 16 #include "base/callback_helpers.h" | 16 #include "base/callback_helpers.h" |
| 17 #include "base/json/json_reader.h" | 17 #include "base/json/json_reader.h" |
| 18 #include "base/json/json_writer.h" | 18 #include "base/json/json_writer.h" |
| 19 #include "base/lazy_instance.h" | 19 #include "base/lazy_instance.h" |
| 20 #include "base/logging.h" | 20 #include "base/logging.h" |
| 21 #include "base/memory/ptr_util.h" |
| 21 #include "base/strings/string_number_conversions.h" | 22 #include "base/strings/string_number_conversions.h" |
| 22 #include "base/strings/string_split.h" | 23 #include "base/strings/string_split.h" |
| 23 #include "base/strings/stringprintf.h" | 24 #include "base/strings/stringprintf.h" |
| 24 #include "base/synchronization/lock.h" | 25 #include "base/synchronization/lock.h" |
| 25 #include "base/threading/platform_thread.h" | 26 #include "base/threading/platform_thread.h" |
| 26 #include "base/threading/thread.h" | 27 #include "base/threading/thread.h" |
| 27 #include "base/values.h" | 28 #include "base/values.h" |
| 28 #include "crypto/random.h" | 29 #include "crypto/random.h" |
| 29 #include "jingle/glue/thread_wrapper.h" | 30 #include "jingle/glue/thread_wrapper.h" |
| 30 #include "net/socket/ssl_server_socket.h" | 31 #include "net/socket/ssl_server_socket.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 | 183 |
| 183 // Resister this instance to handle debug log messsages. | 184 // Resister this instance to handle debug log messsages. |
| 184 RegisterLoggingInstance(); | 185 RegisterLoggingInstance(); |
| 185 | 186 |
| 186 // Initialize random seed for libjingle. It's necessary only with OpenSSL. | 187 // Initialize random seed for libjingle. It's necessary only with OpenSSL. |
| 187 char random_seed[kRandomSeedSize]; | 188 char random_seed[kRandomSeedSize]; |
| 188 crypto::RandBytes(random_seed, sizeof(random_seed)); | 189 crypto::RandBytes(random_seed, sizeof(random_seed)); |
| 189 rtc::InitRandom(random_seed, sizeof(random_seed)); | 190 rtc::InitRandom(random_seed, sizeof(random_seed)); |
| 190 | 191 |
| 191 // Send hello message. | 192 // Send hello message. |
| 192 PostLegacyJsonMessage("hello", make_scoped_ptr(new base::DictionaryValue())); | 193 PostLegacyJsonMessage("hello", base::WrapUnique(new base::DictionaryValue())); |
| 193 } | 194 } |
| 194 | 195 |
| 195 ChromotingInstance::~ChromotingInstance() { | 196 ChromotingInstance::~ChromotingInstance() { |
| 196 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); | 197 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); |
| 197 | 198 |
| 198 // Disconnect the client. | 199 // Disconnect the client. |
| 199 Disconnect(); | 200 Disconnect(); |
| 200 | 201 |
| 201 // Unregister this instance so that debug log messages will no longer be sent | 202 // Unregister this instance so that debug log messages will no longer be sent |
| 202 // to it. This will stop all logging in all Chromoting instances. | 203 // to it. This will stop all logging in all Chromoting instances. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 219 | 220 |
| 220 return true; | 221 return true; |
| 221 } | 222 } |
| 222 | 223 |
| 223 void ChromotingInstance::HandleMessage(const pp::Var& message) { | 224 void ChromotingInstance::HandleMessage(const pp::Var& message) { |
| 224 if (!message.is_string()) { | 225 if (!message.is_string()) { |
| 225 LOG(ERROR) << "Received a message that is not a string."; | 226 LOG(ERROR) << "Received a message that is not a string."; |
| 226 return; | 227 return; |
| 227 } | 228 } |
| 228 | 229 |
| 229 scoped_ptr<base::Value> json = base::JSONReader::Read( | 230 std::unique_ptr<base::Value> json = base::JSONReader::Read( |
| 230 message.AsString(), base::JSON_ALLOW_TRAILING_COMMAS); | 231 message.AsString(), base::JSON_ALLOW_TRAILING_COMMAS); |
| 231 base::DictionaryValue* message_dict = nullptr; | 232 base::DictionaryValue* message_dict = nullptr; |
| 232 std::string method; | 233 std::string method; |
| 233 base::DictionaryValue* data = nullptr; | 234 base::DictionaryValue* data = nullptr; |
| 234 if (!json.get() || | 235 if (!json.get() || |
| 235 !json->GetAsDictionary(&message_dict) || | 236 !json->GetAsDictionary(&message_dict) || |
| 236 !message_dict->GetString("method", &method) || | 237 !message_dict->GetString("method", &method) || |
| 237 !message_dict->GetDictionary("data", &data)) { | 238 !message_dict->GetDictionary("data", &data)) { |
| 238 LOG(ERROR) << "Received invalid message:" << message.AsString(); | 239 LOG(ERROR) << "Received invalid message:" << message.AsString(); |
| 239 return; | 240 return; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 // Assume that the decoder failure was caused by the host not encoding video | 332 // Assume that the decoder failure was caused by the host not encoding video |
| 332 // correctly and report it as a protocol error. | 333 // correctly and report it as a protocol error. |
| 333 // TODO(sergeyu): Consider using a different error code in case the decoder | 334 // TODO(sergeyu): Consider using a different error code in case the decoder |
| 334 // error was caused by some other problem. | 335 // error was caused by some other problem. |
| 335 OnConnectionState(protocol::ConnectionToHost::FAILED, | 336 OnConnectionState(protocol::ConnectionToHost::FAILED, |
| 336 protocol::INCOMPATIBLE_PROTOCOL); | 337 protocol::INCOMPATIBLE_PROTOCOL); |
| 337 } | 338 } |
| 338 | 339 |
| 339 void ChromotingInstance::OnVideoFirstFrameReceived() { | 340 void ChromotingInstance::OnVideoFirstFrameReceived() { |
| 340 PostLegacyJsonMessage("onFirstFrameReceived", | 341 PostLegacyJsonMessage("onFirstFrameReceived", |
| 341 make_scoped_ptr(new base::DictionaryValue())); | 342 base::WrapUnique(new base::DictionaryValue())); |
| 342 } | 343 } |
| 343 | 344 |
| 344 void ChromotingInstance::OnVideoFrameDirtyRegion( | 345 void ChromotingInstance::OnVideoFrameDirtyRegion( |
| 345 const webrtc::DesktopRegion& dirty_region) { | 346 const webrtc::DesktopRegion& dirty_region) { |
| 346 scoped_ptr<base::ListValue> rects_value(new base::ListValue()); | 347 std::unique_ptr<base::ListValue> rects_value(new base::ListValue()); |
| 347 for (webrtc::DesktopRegion::Iterator i(dirty_region); !i.IsAtEnd(); | 348 for (webrtc::DesktopRegion::Iterator i(dirty_region); !i.IsAtEnd(); |
| 348 i.Advance()) { | 349 i.Advance()) { |
| 349 const webrtc::DesktopRect& rect = i.rect(); | 350 const webrtc::DesktopRect& rect = i.rect(); |
| 350 scoped_ptr<base::ListValue> rect_value(new base::ListValue()); | 351 std::unique_ptr<base::ListValue> rect_value(new base::ListValue()); |
| 351 rect_value->AppendInteger(rect.left()); | 352 rect_value->AppendInteger(rect.left()); |
| 352 rect_value->AppendInteger(rect.top()); | 353 rect_value->AppendInteger(rect.top()); |
| 353 rect_value->AppendInteger(rect.width()); | 354 rect_value->AppendInteger(rect.width()); |
| 354 rect_value->AppendInteger(rect.height()); | 355 rect_value->AppendInteger(rect.height()); |
| 355 rects_value->Append(rect_value.release()); | 356 rects_value->Append(rect_value.release()); |
| 356 } | 357 } |
| 357 | 358 |
| 358 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 359 std::unique_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
| 359 data->Set("rects", rects_value.release()); | 360 data->Set("rects", rects_value.release()); |
| 360 PostLegacyJsonMessage("onDebugRegion", std::move(data)); | 361 PostLegacyJsonMessage("onDebugRegion", std::move(data)); |
| 361 } | 362 } |
| 362 | 363 |
| 363 void ChromotingInstance::OnConnectionState( | 364 void ChromotingInstance::OnConnectionState( |
| 364 protocol::ConnectionToHost::State state, | 365 protocol::ConnectionToHost::State state, |
| 365 protocol::ErrorCode error) { | 366 protocol::ErrorCode error) { |
| 366 pp::UMAPrivate uma(this); | 367 pp::UMAPrivate uma(this); |
| 367 | 368 |
| 368 switch (state) { | 369 switch (state) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 kFailedSessionDurationHistogram, | 408 kFailedSessionDurationHistogram, |
| 408 (base::TimeTicks::Now() - connection_connected_time_) | 409 (base::TimeTicks::Now() - connection_connected_time_) |
| 409 .InMilliseconds(), | 410 .InMilliseconds(), |
| 410 kConnectionDurationHistogramMinMinutes, | 411 kConnectionDurationHistogramMinMinutes, |
| 411 kConnectionDurationHistogramMaxMinutes, | 412 kConnectionDurationHistogramMaxMinutes, |
| 412 kConnectionDurationHistogramBuckets); | 413 kConnectionDurationHistogramBuckets); |
| 413 } | 414 } |
| 414 break; | 415 break; |
| 415 } | 416 } |
| 416 | 417 |
| 417 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 418 std::unique_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
| 418 data->SetString("state", protocol::ConnectionToHost::StateToString(state)); | 419 data->SetString("state", protocol::ConnectionToHost::StateToString(state)); |
| 419 data->SetString("error", ConnectionErrorToString(error)); | 420 data->SetString("error", ConnectionErrorToString(error)); |
| 420 PostLegacyJsonMessage("onConnectionStatus", std::move(data)); | 421 PostLegacyJsonMessage("onConnectionStatus", std::move(data)); |
| 421 } | 422 } |
| 422 | 423 |
| 423 void ChromotingInstance::FetchThirdPartyToken( | 424 void ChromotingInstance::FetchThirdPartyToken( |
| 424 const std::string& host_public_key, | 425 const std::string& host_public_key, |
| 425 const std::string& token_url, | 426 const std::string& token_url, |
| 426 const std::string& scope, | 427 const std::string& scope, |
| 427 const protocol::ThirdPartyTokenFetchedCallback& token_fetched_callback) { | 428 const protocol::ThirdPartyTokenFetchedCallback& token_fetched_callback) { |
| 428 // Once the Session object calls this function, it won't continue the | 429 // Once the Session object calls this function, it won't continue the |
| 429 // authentication until the callback is called (or connection is canceled). | 430 // authentication until the callback is called (or connection is canceled). |
| 430 // So, it's impossible to reach this with a callback already registered. | 431 // So, it's impossible to reach this with a callback already registered. |
| 431 DCHECK(third_party_token_fetched_callback_.is_null()); | 432 DCHECK(third_party_token_fetched_callback_.is_null()); |
| 432 third_party_token_fetched_callback_ = token_fetched_callback; | 433 third_party_token_fetched_callback_ = token_fetched_callback; |
| 433 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 434 std::unique_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
| 434 data->SetString("tokenUrl", token_url); | 435 data->SetString("tokenUrl", token_url); |
| 435 data->SetString("hostPublicKey", host_public_key); | 436 data->SetString("hostPublicKey", host_public_key); |
| 436 data->SetString("scope", scope); | 437 data->SetString("scope", scope); |
| 437 PostLegacyJsonMessage("fetchThirdPartyToken", std::move(data)); | 438 PostLegacyJsonMessage("fetchThirdPartyToken", std::move(data)); |
| 438 } | 439 } |
| 439 | 440 |
| 440 void ChromotingInstance::OnConnectionReady(bool ready) { | 441 void ChromotingInstance::OnConnectionReady(bool ready) { |
| 441 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 442 std::unique_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
| 442 data->SetBoolean("ready", ready); | 443 data->SetBoolean("ready", ready); |
| 443 PostLegacyJsonMessage("onConnectionReady", std::move(data)); | 444 PostLegacyJsonMessage("onConnectionReady", std::move(data)); |
| 444 } | 445 } |
| 445 | 446 |
| 446 void ChromotingInstance::OnRouteChanged(const std::string& channel_name, | 447 void ChromotingInstance::OnRouteChanged(const std::string& channel_name, |
| 447 const protocol::TransportRoute& route) { | 448 const protocol::TransportRoute& route) { |
| 448 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 449 std::unique_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
| 449 data->SetString("channel", channel_name); | 450 data->SetString("channel", channel_name); |
| 450 data->SetString("connectionType", | 451 data->SetString("connectionType", |
| 451 protocol::TransportRoute::GetTypeString(route.type)); | 452 protocol::TransportRoute::GetTypeString(route.type)); |
| 452 PostLegacyJsonMessage("onRouteChanged", std::move(data)); | 453 PostLegacyJsonMessage("onRouteChanged", std::move(data)); |
| 453 } | 454 } |
| 454 | 455 |
| 455 void ChromotingInstance::SetCapabilities(const std::string& capabilities) { | 456 void ChromotingInstance::SetCapabilities(const std::string& capabilities) { |
| 456 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 457 std::unique_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
| 457 data->SetString("capabilities", capabilities); | 458 data->SetString("capabilities", capabilities); |
| 458 PostLegacyJsonMessage("setCapabilities", std::move(data)); | 459 PostLegacyJsonMessage("setCapabilities", std::move(data)); |
| 459 } | 460 } |
| 460 | 461 |
| 461 void ChromotingInstance::SetPairingResponse( | 462 void ChromotingInstance::SetPairingResponse( |
| 462 const protocol::PairingResponse& pairing_response) { | 463 const protocol::PairingResponse& pairing_response) { |
| 463 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 464 std::unique_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
| 464 data->SetString("clientId", pairing_response.client_id()); | 465 data->SetString("clientId", pairing_response.client_id()); |
| 465 data->SetString("sharedSecret", pairing_response.shared_secret()); | 466 data->SetString("sharedSecret", pairing_response.shared_secret()); |
| 466 PostLegacyJsonMessage("pairingResponse", std::move(data)); | 467 PostLegacyJsonMessage("pairingResponse", std::move(data)); |
| 467 } | 468 } |
| 468 | 469 |
| 469 void ChromotingInstance::DeliverHostMessage( | 470 void ChromotingInstance::DeliverHostMessage( |
| 470 const protocol::ExtensionMessage& message) { | 471 const protocol::ExtensionMessage& message) { |
| 471 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 472 std::unique_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
| 472 data->SetString("type", message.type()); | 473 data->SetString("type", message.type()); |
| 473 data->SetString("data", message.data()); | 474 data->SetString("data", message.data()); |
| 474 PostLegacyJsonMessage("extensionMessage", std::move(data)); | 475 PostLegacyJsonMessage("extensionMessage", std::move(data)); |
| 475 } | 476 } |
| 476 | 477 |
| 477 void ChromotingInstance::SetDesktopSize(const webrtc::DesktopSize& size, | 478 void ChromotingInstance::SetDesktopSize(const webrtc::DesktopSize& size, |
| 478 const webrtc::DesktopVector& dpi) { | 479 const webrtc::DesktopVector& dpi) { |
| 479 DCHECK(!dpi.is_zero()); | 480 DCHECK(!dpi.is_zero()); |
| 480 | 481 |
| 481 mouse_input_filter_.set_output_size(size); | 482 mouse_input_filter_.set_output_size(size); |
| 482 touch_input_scaler_.set_output_size(size); | 483 touch_input_scaler_.set_output_size(size); |
| 483 | 484 |
| 484 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 485 std::unique_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
| 485 data->SetInteger("width", size.width()); | 486 data->SetInteger("width", size.width()); |
| 486 data->SetInteger("height", size.height()); | 487 data->SetInteger("height", size.height()); |
| 487 data->SetInteger("x_dpi", dpi.x()); | 488 data->SetInteger("x_dpi", dpi.x()); |
| 488 data->SetInteger("y_dpi", dpi.y()); | 489 data->SetInteger("y_dpi", dpi.y()); |
| 489 PostLegacyJsonMessage("onDesktopSize", std::move(data)); | 490 PostLegacyJsonMessage("onDesktopSize", std::move(data)); |
| 490 } | 491 } |
| 491 | 492 |
| 492 void ChromotingInstance::FetchSecretFromDialog( | 493 void ChromotingInstance::FetchSecretFromDialog( |
| 493 bool pairing_supported, | 494 bool pairing_supported, |
| 494 const protocol::SecretFetchedCallback& secret_fetched_callback) { | 495 const protocol::SecretFetchedCallback& secret_fetched_callback) { |
| 495 // Once the Session object calls this function, it won't continue the | 496 // Once the Session object calls this function, it won't continue the |
| 496 // authentication until the callback is called (or connection is canceled). | 497 // authentication until the callback is called (or connection is canceled). |
| 497 // So, it's impossible to reach this with a callback already registered. | 498 // So, it's impossible to reach this with a callback already registered. |
| 498 DCHECK(secret_fetched_callback_.is_null()); | 499 DCHECK(secret_fetched_callback_.is_null()); |
| 499 secret_fetched_callback_ = secret_fetched_callback; | 500 secret_fetched_callback_ = secret_fetched_callback; |
| 500 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 501 std::unique_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
| 501 data->SetBoolean("pairingSupported", pairing_supported); | 502 data->SetBoolean("pairingSupported", pairing_supported); |
| 502 PostLegacyJsonMessage("fetchPin", std::move(data)); | 503 PostLegacyJsonMessage("fetchPin", std::move(data)); |
| 503 } | 504 } |
| 504 | 505 |
| 505 void ChromotingInstance::FetchSecretFromString( | 506 void ChromotingInstance::FetchSecretFromString( |
| 506 const std::string& shared_secret, | 507 const std::string& shared_secret, |
| 507 bool pairing_supported, | 508 bool pairing_supported, |
| 508 const protocol::SecretFetchedCallback& secret_fetched_callback) { | 509 const protocol::SecretFetchedCallback& secret_fetched_callback) { |
| 509 secret_fetched_callback.Run(shared_secret); | 510 secret_fetched_callback.Run(shared_secret); |
| 510 } | 511 } |
| 511 | 512 |
| 512 protocol::ClipboardStub* ChromotingInstance::GetClipboardStub() { | 513 protocol::ClipboardStub* ChromotingInstance::GetClipboardStub() { |
| 513 // TODO(sergeyu): Move clipboard handling to a separate class. | 514 // TODO(sergeyu): Move clipboard handling to a separate class. |
| 514 // crbug.com/138108 | 515 // crbug.com/138108 |
| 515 return this; | 516 return this; |
| 516 } | 517 } |
| 517 | 518 |
| 518 protocol::CursorShapeStub* ChromotingInstance::GetCursorShapeStub() { | 519 protocol::CursorShapeStub* ChromotingInstance::GetCursorShapeStub() { |
| 519 return &empty_cursor_filter_; | 520 return &empty_cursor_filter_; |
| 520 } | 521 } |
| 521 | 522 |
| 522 void ChromotingInstance::InjectClipboardEvent( | 523 void ChromotingInstance::InjectClipboardEvent( |
| 523 const protocol::ClipboardEvent& event) { | 524 const protocol::ClipboardEvent& event) { |
| 524 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 525 std::unique_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
| 525 data->SetString("mimeType", event.mime_type()); | 526 data->SetString("mimeType", event.mime_type()); |
| 526 data->SetString("item", event.data()); | 527 data->SetString("item", event.data()); |
| 527 PostLegacyJsonMessage("injectClipboardItem", std::move(data)); | 528 PostLegacyJsonMessage("injectClipboardItem", std::move(data)); |
| 528 } | 529 } |
| 529 | 530 |
| 530 void ChromotingInstance::SetCursorShape( | 531 void ChromotingInstance::SetCursorShape( |
| 531 const protocol::CursorShapeInfo& cursor_shape) { | 532 const protocol::CursorShapeInfo& cursor_shape) { |
| 532 // If the delegated cursor is empty then stop rendering a DOM cursor. | 533 // If the delegated cursor is empty then stop rendering a DOM cursor. |
| 533 if (IsCursorShapeEmpty(cursor_shape)) { | 534 if (IsCursorShapeEmpty(cursor_shape)) { |
| 534 PostChromotingMessage("unsetCursorShape", pp::VarDictionary()); | 535 PostChromotingMessage("unsetCursorShape", pp::VarDictionary()); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 base::Bind(&ChromotingInstance::UpdateUmaCustomHistogram, | 650 base::Bind(&ChromotingInstance::UpdateUmaCustomHistogram, |
| 650 weak_factory_.GetWeakPtr(), false), | 651 weak_factory_.GetWeakPtr(), false), |
| 651 base::Bind(&ChromotingInstance::UpdateUmaEnumHistogram, | 652 base::Bind(&ChromotingInstance::UpdateUmaEnumHistogram, |
| 652 weak_factory_.GetWeakPtr())); | 653 weak_factory_.GetWeakPtr())); |
| 653 | 654 |
| 654 if (!plugin_view_.is_null()) | 655 if (!plugin_view_.is_null()) |
| 655 video_renderer_->OnViewChanged(plugin_view_); | 656 video_renderer_->OnViewChanged(plugin_view_); |
| 656 | 657 |
| 657 client_.reset( | 658 client_.reset( |
| 658 new ChromotingClient(&context_, this, video_renderer_.get(), | 659 new ChromotingClient(&context_, this, video_renderer_.get(), |
| 659 make_scoped_ptr(new PepperAudioPlayer(this)))); | 660 base::WrapUnique(new PepperAudioPlayer(this)))); |
| 660 | 661 |
| 661 // Setup the signal strategy. | 662 // Setup the signal strategy. |
| 662 signal_strategy_.reset(new DelegatingSignalStrategy( | 663 signal_strategy_.reset(new DelegatingSignalStrategy( |
| 663 local_jid, base::Bind(&ChromotingInstance::SendOutgoingIq, | 664 local_jid, base::Bind(&ChromotingInstance::SendOutgoingIq, |
| 664 weak_factory_.GetWeakPtr()))); | 665 weak_factory_.GetWeakPtr()))); |
| 665 | 666 |
| 666 // Create TransportContext. | 667 // Create TransportContext. |
| 667 scoped_refptr<protocol::TransportContext> transport_context( | 668 scoped_refptr<protocol::TransportContext> transport_context( |
| 668 new protocol::TransportContext( | 669 new protocol::TransportContext( |
| 669 signal_strategy_.get(), | 670 signal_strategy_.get(), |
| 670 make_scoped_ptr(new PepperPortAllocatorFactory(this)), | 671 base::WrapUnique(new PepperPortAllocatorFactory(this)), |
| 671 make_scoped_ptr(new PepperUrlRequestFactory(this)), | 672 base::WrapUnique(new PepperUrlRequestFactory(this)), |
| 672 protocol::NetworkSettings( | 673 protocol::NetworkSettings( |
| 673 protocol::NetworkSettings::NAT_TRAVERSAL_FULL), | 674 protocol::NetworkSettings::NAT_TRAVERSAL_FULL), |
| 674 protocol::TransportRole::CLIENT)); | 675 protocol::TransportRole::CLIENT)); |
| 675 | 676 |
| 676 scoped_ptr<protocol::CandidateSessionConfig> config = | 677 std::unique_ptr<protocol::CandidateSessionConfig> config = |
| 677 protocol::CandidateSessionConfig::CreateDefault(); | 678 protocol::CandidateSessionConfig::CreateDefault(); |
| 678 if (std::find(experiments_list.begin(), experiments_list.end(), "vp9") != | 679 if (std::find(experiments_list.begin(), experiments_list.end(), "vp9") != |
| 679 experiments_list.end()) { | 680 experiments_list.end()) { |
| 680 config->set_vp9_experiment_enabled(true); | 681 config->set_vp9_experiment_enabled(true); |
| 681 } | 682 } |
| 682 client_->set_protocol_config(std::move(config)); | 683 client_->set_protocol_config(std::move(config)); |
| 683 | 684 |
| 684 // Kick off the connection. | 685 // Kick off the connection. |
| 685 client_->Start(signal_strategy_.get(), client_auth_config, transport_context, | 686 client_->Start(signal_strategy_.get(), client_auth_config, transport_context, |
| 686 host_jid, capabilities); | 687 host_jid, capabilities); |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 974 void ChromotingInstance::PostChromotingMessage(const std::string& method, | 975 void ChromotingInstance::PostChromotingMessage(const std::string& method, |
| 975 const pp::VarDictionary& data) { | 976 const pp::VarDictionary& data) { |
| 976 pp::VarDictionary message; | 977 pp::VarDictionary message; |
| 977 message.Set(pp::Var("method"), pp::Var(method)); | 978 message.Set(pp::Var("method"), pp::Var(method)); |
| 978 message.Set(pp::Var("data"), data); | 979 message.Set(pp::Var("data"), data); |
| 979 PostMessage(message); | 980 PostMessage(message); |
| 980 } | 981 } |
| 981 | 982 |
| 982 void ChromotingInstance::PostLegacyJsonMessage( | 983 void ChromotingInstance::PostLegacyJsonMessage( |
| 983 const std::string& method, | 984 const std::string& method, |
| 984 scoped_ptr<base::DictionaryValue> data) { | 985 std::unique_ptr<base::DictionaryValue> data) { |
| 985 base::DictionaryValue message; | 986 base::DictionaryValue message; |
| 986 message.SetString("method", method); | 987 message.SetString("method", method); |
| 987 message.Set("data", data.release()); | 988 message.Set("data", data.release()); |
| 988 | 989 |
| 989 std::string message_json; | 990 std::string message_json; |
| 990 base::JSONWriter::Write(message, &message_json); | 991 base::JSONWriter::Write(message, &message_json); |
| 991 PostMessage(pp::Var(message_json)); | 992 PostMessage(pp::Var(message_json)); |
| 992 } | 993 } |
| 993 | 994 |
| 994 void ChromotingInstance::SendTrappedKey(uint32_t usb_keycode, bool pressed) { | 995 void ChromotingInstance::SendTrappedKey(uint32_t usb_keycode, bool pressed) { |
| 995 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 996 std::unique_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
| 996 data->SetInteger("usbKeycode", usb_keycode); | 997 data->SetInteger("usbKeycode", usb_keycode); |
| 997 data->SetBoolean("pressed", pressed); | 998 data->SetBoolean("pressed", pressed); |
| 998 PostLegacyJsonMessage("trappedKeyEvent", std::move(data)); | 999 PostLegacyJsonMessage("trappedKeyEvent", std::move(data)); |
| 999 } | 1000 } |
| 1000 | 1001 |
| 1001 void ChromotingInstance::SendOutgoingIq(const std::string& iq) { | 1002 void ChromotingInstance::SendOutgoingIq(const std::string& iq) { |
| 1002 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 1003 std::unique_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
| 1003 data->SetString("iq", iq); | 1004 data->SetString("iq", iq); |
| 1004 PostLegacyJsonMessage("sendOutgoingIq", std::move(data)); | 1005 PostLegacyJsonMessage("sendOutgoingIq", std::move(data)); |
| 1005 } | 1006 } |
| 1006 | 1007 |
| 1007 void ChromotingInstance::UpdatePerfStatsInUI() { | 1008 void ChromotingInstance::UpdatePerfStatsInUI() { |
| 1008 // Fetch performance stats from the VideoRenderer and send them to the client | 1009 // Fetch performance stats from the VideoRenderer and send them to the client |
| 1009 // for display to users. | 1010 // for display to users. |
| 1010 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 1011 std::unique_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
| 1011 data->SetDouble("videoBandwidth", perf_tracker_.video_bandwidth()); | 1012 data->SetDouble("videoBandwidth", perf_tracker_.video_bandwidth()); |
| 1012 data->SetDouble("videoFrameRate", perf_tracker_.video_frame_rate()); | 1013 data->SetDouble("videoFrameRate", perf_tracker_.video_frame_rate()); |
| 1013 data->SetDouble("captureLatency", perf_tracker_.video_capture_ms().Average()); | 1014 data->SetDouble("captureLatency", perf_tracker_.video_capture_ms().Average()); |
| 1014 data->SetDouble("maxCaptureLatency", perf_tracker_.video_capture_ms().Max()); | 1015 data->SetDouble("maxCaptureLatency", perf_tracker_.video_capture_ms().Max()); |
| 1015 data->SetDouble("encodeLatency", perf_tracker_.video_encode_ms().Average()); | 1016 data->SetDouble("encodeLatency", perf_tracker_.video_encode_ms().Average()); |
| 1016 data->SetDouble("maxEncodeLatency", perf_tracker_.video_encode_ms().Max()); | 1017 data->SetDouble("maxEncodeLatency", perf_tracker_.video_encode_ms().Max()); |
| 1017 data->SetDouble("decodeLatency", perf_tracker_.video_decode_ms().Average()); | 1018 data->SetDouble("decodeLatency", perf_tracker_.video_decode_ms().Average()); |
| 1018 data->SetDouble("maxDecodeLatency", perf_tracker_.video_decode_ms().Max()); | 1019 data->SetDouble("maxDecodeLatency", perf_tracker_.video_decode_ms().Max()); |
| 1019 data->SetDouble("renderLatency", perf_tracker_.video_paint_ms().Average()); | 1020 data->SetDouble("renderLatency", perf_tracker_.video_paint_ms().Average()); |
| 1020 data->SetDouble("maxRenderLatency", perf_tracker_.video_paint_ms().Max()); | 1021 data->SetDouble("maxRenderLatency", perf_tracker_.video_paint_ms().Max()); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1113 if (is_custom_counts_histogram) { | 1114 if (is_custom_counts_histogram) { |
| 1114 uma.HistogramCustomCounts(histogram_name, value, histogram_min, | 1115 uma.HistogramCustomCounts(histogram_name, value, histogram_min, |
| 1115 histogram_max, histogram_buckets); | 1116 histogram_max, histogram_buckets); |
| 1116 } else { | 1117 } else { |
| 1117 uma.HistogramCustomTimes(histogram_name, value, histogram_min, | 1118 uma.HistogramCustomTimes(histogram_name, value, histogram_min, |
| 1118 histogram_max, histogram_buckets); | 1119 histogram_max, histogram_buckets); |
| 1119 } | 1120 } |
| 1120 } | 1121 } |
| 1121 | 1122 |
| 1122 } // namespace remoting | 1123 } // namespace remoting |
| OLD | NEW |