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> | |
8 #include <vector> | |
9 | |
10 #include <nacl_io/nacl_io.h> | 7 #include <nacl_io/nacl_io.h> |
11 #include <sys/mount.h> | 8 #include <sys/mount.h> |
12 | 9 |
| 10 #include <string> |
| 11 #include <utility> |
| 12 #include <vector> |
| 13 |
13 #include "base/bind.h" | 14 #include "base/bind.h" |
14 #include "base/callback.h" | 15 #include "base/callback.h" |
15 #include "base/callback_helpers.h" | 16 #include "base/callback_helpers.h" |
16 #include "base/json/json_reader.h" | 17 #include "base/json/json_reader.h" |
17 #include "base/json/json_writer.h" | 18 #include "base/json/json_writer.h" |
18 #include "base/lazy_instance.h" | 19 #include "base/lazy_instance.h" |
19 #include "base/logging.h" | 20 #include "base/logging.h" |
20 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
21 #include "base/strings/string_split.h" | 22 #include "base/strings/string_split.h" |
22 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 | 181 |
181 // Resister this instance to handle debug log messsages. | 182 // Resister this instance to handle debug log messsages. |
182 RegisterLoggingInstance(); | 183 RegisterLoggingInstance(); |
183 | 184 |
184 // Initialize random seed for libjingle. It's necessary only with OpenSSL. | 185 // Initialize random seed for libjingle. It's necessary only with OpenSSL. |
185 char random_seed[kRandomSeedSize]; | 186 char random_seed[kRandomSeedSize]; |
186 crypto::RandBytes(random_seed, sizeof(random_seed)); | 187 crypto::RandBytes(random_seed, sizeof(random_seed)); |
187 rtc::InitRandom(random_seed, sizeof(random_seed)); | 188 rtc::InitRandom(random_seed, sizeof(random_seed)); |
188 | 189 |
189 // Send hello message. | 190 // Send hello message. |
190 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 191 PostLegacyJsonMessage("hello", make_scoped_ptr(new base::DictionaryValue())); |
191 PostLegacyJsonMessage("hello", data.Pass()); | |
192 } | 192 } |
193 | 193 |
194 ChromotingInstance::~ChromotingInstance() { | 194 ChromotingInstance::~ChromotingInstance() { |
195 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); | 195 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); |
196 | 196 |
197 // Disconnect the client. | 197 // Disconnect the client. |
198 Disconnect(); | 198 Disconnect(); |
199 | 199 |
200 // Unregister this instance so that debug log messages will no longer be sent | 200 // Unregister this instance so that debug log messages will no longer be sent |
201 // to it. This will stop all logging in all Chromoting instances. | 201 // to it. This will stop all logging in all Chromoting instances. |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 | 329 |
330 // Assume that the decoder failure was caused by the host not encoding video | 330 // Assume that the decoder failure was caused by the host not encoding video |
331 // correctly and report it as a protocol error. | 331 // correctly and report it as a protocol error. |
332 // TODO(sergeyu): Consider using a different error code in case the decoder | 332 // TODO(sergeyu): Consider using a different error code in case the decoder |
333 // error was caused by some other problem. | 333 // error was caused by some other problem. |
334 OnConnectionState(protocol::ConnectionToHost::FAILED, | 334 OnConnectionState(protocol::ConnectionToHost::FAILED, |
335 protocol::INCOMPATIBLE_PROTOCOL); | 335 protocol::INCOMPATIBLE_PROTOCOL); |
336 } | 336 } |
337 | 337 |
338 void ChromotingInstance::OnVideoFirstFrameReceived() { | 338 void ChromotingInstance::OnVideoFirstFrameReceived() { |
339 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 339 PostLegacyJsonMessage("onFirstFrameReceived", |
340 PostLegacyJsonMessage("onFirstFrameReceived", data.Pass()); | 340 make_scoped_ptr(new base::DictionaryValue())); |
341 } | 341 } |
342 | 342 |
343 void ChromotingInstance::OnVideoSize(const webrtc::DesktopSize& size, | 343 void ChromotingInstance::OnVideoSize(const webrtc::DesktopSize& size, |
344 const webrtc::DesktopVector& dpi) { | 344 const webrtc::DesktopVector& dpi) { |
345 mouse_input_filter_.set_output_size(size); | 345 mouse_input_filter_.set_output_size(size); |
346 touch_input_scaler_.set_output_size(size); | 346 touch_input_scaler_.set_output_size(size); |
347 | 347 |
348 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 348 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
349 data->SetInteger("width", size.width()); | 349 data->SetInteger("width", size.width()); |
350 data->SetInteger("height", size.height()); | 350 data->SetInteger("height", size.height()); |
351 if (dpi.x()) | 351 if (dpi.x()) |
352 data->SetInteger("x_dpi", dpi.x()); | 352 data->SetInteger("x_dpi", dpi.x()); |
353 if (dpi.y()) | 353 if (dpi.y()) |
354 data->SetInteger("y_dpi", dpi.y()); | 354 data->SetInteger("y_dpi", dpi.y()); |
355 PostLegacyJsonMessage("onDesktopSize", data.Pass()); | 355 PostLegacyJsonMessage("onDesktopSize", std::move(data)); |
356 } | 356 } |
357 | 357 |
358 void ChromotingInstance::OnVideoShape(const webrtc::DesktopRegion* shape) { | 358 void ChromotingInstance::OnVideoShape(const webrtc::DesktopRegion* shape) { |
359 if ((shape && desktop_shape_ && shape->Equals(*desktop_shape_)) || | 359 if ((shape && desktop_shape_ && shape->Equals(*desktop_shape_)) || |
360 (!shape && !desktop_shape_)) { | 360 (!shape && !desktop_shape_)) { |
361 return; | 361 return; |
362 } | 362 } |
363 | 363 |
364 scoped_ptr<base::DictionaryValue> shape_message(new base::DictionaryValue()); | 364 scoped_ptr<base::DictionaryValue> shape_message(new base::DictionaryValue()); |
365 if (shape) { | 365 if (shape) { |
366 desktop_shape_ = make_scoped_ptr(new webrtc::DesktopRegion(*shape)); | 366 desktop_shape_ = make_scoped_ptr(new webrtc::DesktopRegion(*shape)); |
367 scoped_ptr<base::ListValue> rects_value(new base::ListValue()); | 367 scoped_ptr<base::ListValue> rects_value(new base::ListValue()); |
368 for (webrtc::DesktopRegion::Iterator i(*shape); !i.IsAtEnd(); i.Advance()) { | 368 for (webrtc::DesktopRegion::Iterator i(*shape); !i.IsAtEnd(); i.Advance()) { |
369 const webrtc::DesktopRect& rect = i.rect(); | 369 const webrtc::DesktopRect& rect = i.rect(); |
370 scoped_ptr<base::ListValue> rect_value(new base::ListValue()); | 370 scoped_ptr<base::ListValue> rect_value(new base::ListValue()); |
371 rect_value->AppendInteger(rect.left()); | 371 rect_value->AppendInteger(rect.left()); |
372 rect_value->AppendInteger(rect.top()); | 372 rect_value->AppendInteger(rect.top()); |
373 rect_value->AppendInteger(rect.width()); | 373 rect_value->AppendInteger(rect.width()); |
374 rect_value->AppendInteger(rect.height()); | 374 rect_value->AppendInteger(rect.height()); |
375 rects_value->Append(rect_value.release()); | 375 rects_value->Append(rect_value.release()); |
376 } | 376 } |
377 shape_message->Set("rects", rects_value.release()); | 377 shape_message->Set("rects", rects_value.release()); |
378 } | 378 } |
379 | 379 |
380 PostLegacyJsonMessage("onDesktopShape", shape_message.Pass()); | 380 PostLegacyJsonMessage("onDesktopShape", std::move(shape_message)); |
381 } | 381 } |
382 | 382 |
383 void ChromotingInstance::OnVideoFrameDirtyRegion( | 383 void ChromotingInstance::OnVideoFrameDirtyRegion( |
384 const webrtc::DesktopRegion& dirty_region) { | 384 const webrtc::DesktopRegion& dirty_region) { |
385 scoped_ptr<base::ListValue> rects_value(new base::ListValue()); | 385 scoped_ptr<base::ListValue> rects_value(new base::ListValue()); |
386 for (webrtc::DesktopRegion::Iterator i(dirty_region); !i.IsAtEnd(); | 386 for (webrtc::DesktopRegion::Iterator i(dirty_region); !i.IsAtEnd(); |
387 i.Advance()) { | 387 i.Advance()) { |
388 const webrtc::DesktopRect& rect = i.rect(); | 388 const webrtc::DesktopRect& rect = i.rect(); |
389 scoped_ptr<base::ListValue> rect_value(new base::ListValue()); | 389 scoped_ptr<base::ListValue> rect_value(new base::ListValue()); |
390 rect_value->AppendInteger(rect.left()); | 390 rect_value->AppendInteger(rect.left()); |
391 rect_value->AppendInteger(rect.top()); | 391 rect_value->AppendInteger(rect.top()); |
392 rect_value->AppendInteger(rect.width()); | 392 rect_value->AppendInteger(rect.width()); |
393 rect_value->AppendInteger(rect.height()); | 393 rect_value->AppendInteger(rect.height()); |
394 rects_value->Append(rect_value.release()); | 394 rects_value->Append(rect_value.release()); |
395 } | 395 } |
396 | 396 |
397 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 397 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
398 data->Set("rects", rects_value.release()); | 398 data->Set("rects", rects_value.release()); |
399 PostLegacyJsonMessage("onDebugRegion", data.Pass()); | 399 PostLegacyJsonMessage("onDebugRegion", std::move(data)); |
400 } | 400 } |
401 | 401 |
402 void ChromotingInstance::OnConnectionState( | 402 void ChromotingInstance::OnConnectionState( |
403 protocol::ConnectionToHost::State state, | 403 protocol::ConnectionToHost::State state, |
404 protocol::ErrorCode error) { | 404 protocol::ErrorCode error) { |
405 pp::UMAPrivate uma(this); | 405 pp::UMAPrivate uma(this); |
406 | 406 |
407 switch (state) { | 407 switch (state) { |
408 case protocol::ConnectionToHost::INITIALIZING: | 408 case protocol::ConnectionToHost::INITIALIZING: |
409 NOTREACHED(); | 409 NOTREACHED(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 kConnectionDurationHistogramMinMinutes, | 449 kConnectionDurationHistogramMinMinutes, |
450 kConnectionDurationHistogramMaxMinutes, | 450 kConnectionDurationHistogramMaxMinutes, |
451 kConnectionDurationHistogramBuckets); | 451 kConnectionDurationHistogramBuckets); |
452 } | 452 } |
453 break; | 453 break; |
454 } | 454 } |
455 | 455 |
456 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 456 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
457 data->SetString("state", protocol::ConnectionToHost::StateToString(state)); | 457 data->SetString("state", protocol::ConnectionToHost::StateToString(state)); |
458 data->SetString("error", ConnectionErrorToString(error)); | 458 data->SetString("error", ConnectionErrorToString(error)); |
459 PostLegacyJsonMessage("onConnectionStatus", data.Pass()); | 459 PostLegacyJsonMessage("onConnectionStatus", std::move(data)); |
460 } | 460 } |
461 | 461 |
462 void ChromotingInstance::FetchThirdPartyToken( | 462 void ChromotingInstance::FetchThirdPartyToken( |
463 const GURL& token_url, | 463 const GURL& token_url, |
464 const std::string& host_public_key, | 464 const std::string& host_public_key, |
465 const std::string& scope, | 465 const std::string& scope, |
466 base::WeakPtr<TokenFetcherProxy> token_fetcher_proxy) { | 466 base::WeakPtr<TokenFetcherProxy> token_fetcher_proxy) { |
467 // Once the Session object calls this function, it won't continue the | 467 // Once the Session object calls this function, it won't continue the |
468 // authentication until the callback is called (or connection is canceled). | 468 // authentication until the callback is called (or connection is canceled). |
469 // So, it's impossible to reach this with a callback already registered. | 469 // So, it's impossible to reach this with a callback already registered. |
470 DCHECK(!token_fetcher_proxy_.get()); | 470 DCHECK(!token_fetcher_proxy_.get()); |
471 token_fetcher_proxy_ = token_fetcher_proxy; | 471 token_fetcher_proxy_ = token_fetcher_proxy; |
472 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 472 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
473 data->SetString("tokenUrl", token_url.spec()); | 473 data->SetString("tokenUrl", token_url.spec()); |
474 data->SetString("hostPublicKey", host_public_key); | 474 data->SetString("hostPublicKey", host_public_key); |
475 data->SetString("scope", scope); | 475 data->SetString("scope", scope); |
476 PostLegacyJsonMessage("fetchThirdPartyToken", data.Pass()); | 476 PostLegacyJsonMessage("fetchThirdPartyToken", std::move(data)); |
477 } | 477 } |
478 | 478 |
479 void ChromotingInstance::OnConnectionReady(bool ready) { | 479 void ChromotingInstance::OnConnectionReady(bool ready) { |
480 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 480 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
481 data->SetBoolean("ready", ready); | 481 data->SetBoolean("ready", ready); |
482 PostLegacyJsonMessage("onConnectionReady", data.Pass()); | 482 PostLegacyJsonMessage("onConnectionReady", std::move(data)); |
483 } | 483 } |
484 | 484 |
485 void ChromotingInstance::OnRouteChanged(const std::string& channel_name, | 485 void ChromotingInstance::OnRouteChanged(const std::string& channel_name, |
486 const protocol::TransportRoute& route) { | 486 const protocol::TransportRoute& route) { |
487 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 487 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
488 data->SetString("channel", channel_name); | 488 data->SetString("channel", channel_name); |
489 data->SetString("connectionType", | 489 data->SetString("connectionType", |
490 protocol::TransportRoute::GetTypeString(route.type)); | 490 protocol::TransportRoute::GetTypeString(route.type)); |
491 PostLegacyJsonMessage("onRouteChanged", data.Pass()); | 491 PostLegacyJsonMessage("onRouteChanged", std::move(data)); |
492 } | 492 } |
493 | 493 |
494 void ChromotingInstance::SetCapabilities(const std::string& capabilities) { | 494 void ChromotingInstance::SetCapabilities(const std::string& capabilities) { |
495 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 495 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
496 data->SetString("capabilities", capabilities); | 496 data->SetString("capabilities", capabilities); |
497 PostLegacyJsonMessage("setCapabilities", data.Pass()); | 497 PostLegacyJsonMessage("setCapabilities", std::move(data)); |
498 } | 498 } |
499 | 499 |
500 void ChromotingInstance::SetPairingResponse( | 500 void ChromotingInstance::SetPairingResponse( |
501 const protocol::PairingResponse& pairing_response) { | 501 const protocol::PairingResponse& pairing_response) { |
502 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 502 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
503 data->SetString("clientId", pairing_response.client_id()); | 503 data->SetString("clientId", pairing_response.client_id()); |
504 data->SetString("sharedSecret", pairing_response.shared_secret()); | 504 data->SetString("sharedSecret", pairing_response.shared_secret()); |
505 PostLegacyJsonMessage("pairingResponse", data.Pass()); | 505 PostLegacyJsonMessage("pairingResponse", std::move(data)); |
506 } | 506 } |
507 | 507 |
508 void ChromotingInstance::DeliverHostMessage( | 508 void ChromotingInstance::DeliverHostMessage( |
509 const protocol::ExtensionMessage& message) { | 509 const protocol::ExtensionMessage& message) { |
510 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 510 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
511 data->SetString("type", message.type()); | 511 data->SetString("type", message.type()); |
512 data->SetString("data", message.data()); | 512 data->SetString("data", message.data()); |
513 PostLegacyJsonMessage("extensionMessage", data.Pass()); | 513 PostLegacyJsonMessage("extensionMessage", std::move(data)); |
514 } | 514 } |
515 | 515 |
516 void ChromotingInstance::FetchSecretFromDialog( | 516 void ChromotingInstance::FetchSecretFromDialog( |
517 bool pairing_supported, | 517 bool pairing_supported, |
518 const protocol::SecretFetchedCallback& secret_fetched_callback) { | 518 const protocol::SecretFetchedCallback& secret_fetched_callback) { |
519 // Once the Session object calls this function, it won't continue the | 519 // Once the Session object calls this function, it won't continue the |
520 // authentication until the callback is called (or connection is canceled). | 520 // authentication until the callback is called (or connection is canceled). |
521 // So, it's impossible to reach this with a callback already registered. | 521 // So, it's impossible to reach this with a callback already registered. |
522 DCHECK(secret_fetched_callback_.is_null()); | 522 DCHECK(secret_fetched_callback_.is_null()); |
523 secret_fetched_callback_ = secret_fetched_callback; | 523 secret_fetched_callback_ = secret_fetched_callback; |
524 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 524 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
525 data->SetBoolean("pairingSupported", pairing_supported); | 525 data->SetBoolean("pairingSupported", pairing_supported); |
526 PostLegacyJsonMessage("fetchPin", data.Pass()); | 526 PostLegacyJsonMessage("fetchPin", std::move(data)); |
527 } | 527 } |
528 | 528 |
529 void ChromotingInstance::FetchSecretFromString( | 529 void ChromotingInstance::FetchSecretFromString( |
530 const std::string& shared_secret, | 530 const std::string& shared_secret, |
531 bool pairing_supported, | 531 bool pairing_supported, |
532 const protocol::SecretFetchedCallback& secret_fetched_callback) { | 532 const protocol::SecretFetchedCallback& secret_fetched_callback) { |
533 secret_fetched_callback.Run(shared_secret); | 533 secret_fetched_callback.Run(shared_secret); |
534 } | 534 } |
535 | 535 |
536 protocol::ClipboardStub* ChromotingInstance::GetClipboardStub() { | 536 protocol::ClipboardStub* ChromotingInstance::GetClipboardStub() { |
537 // TODO(sergeyu): Move clipboard handling to a separate class. | 537 // TODO(sergeyu): Move clipboard handling to a separate class. |
538 // crbug.com/138108 | 538 // crbug.com/138108 |
539 return this; | 539 return this; |
540 } | 540 } |
541 | 541 |
542 protocol::CursorShapeStub* ChromotingInstance::GetCursorShapeStub() { | 542 protocol::CursorShapeStub* ChromotingInstance::GetCursorShapeStub() { |
543 return &empty_cursor_filter_; | 543 return &empty_cursor_filter_; |
544 } | 544 } |
545 | 545 |
546 void ChromotingInstance::InjectClipboardEvent( | 546 void ChromotingInstance::InjectClipboardEvent( |
547 const protocol::ClipboardEvent& event) { | 547 const protocol::ClipboardEvent& event) { |
548 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 548 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
549 data->SetString("mimeType", event.mime_type()); | 549 data->SetString("mimeType", event.mime_type()); |
550 data->SetString("item", event.data()); | 550 data->SetString("item", event.data()); |
551 PostLegacyJsonMessage("injectClipboardItem", data.Pass()); | 551 PostLegacyJsonMessage("injectClipboardItem", std::move(data)); |
552 } | 552 } |
553 | 553 |
554 void ChromotingInstance::SetCursorShape( | 554 void ChromotingInstance::SetCursorShape( |
555 const protocol::CursorShapeInfo& cursor_shape) { | 555 const protocol::CursorShapeInfo& cursor_shape) { |
556 // If the delegated cursor is empty then stop rendering a DOM cursor. | 556 // If the delegated cursor is empty then stop rendering a DOM cursor. |
557 if (IsCursorShapeEmpty(cursor_shape)) { | 557 if (IsCursorShapeEmpty(cursor_shape)) { |
558 PostChromotingMessage("unsetCursorShape", pp::VarDictionary()); | 558 PostChromotingMessage("unsetCursorShape", pp::VarDictionary()); |
559 return; | 559 return; |
560 } | 560 } |
561 | 561 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 base::Bind(&ChromotingInstance::UpdateUmaCustomHistogram, | 669 base::Bind(&ChromotingInstance::UpdateUmaCustomHistogram, |
670 weak_factory_.GetWeakPtr(), true), | 670 weak_factory_.GetWeakPtr(), true), |
671 base::Bind(&ChromotingInstance::UpdateUmaCustomHistogram, | 671 base::Bind(&ChromotingInstance::UpdateUmaCustomHistogram, |
672 weak_factory_.GetWeakPtr(), false), | 672 weak_factory_.GetWeakPtr(), false), |
673 base::Bind(&ChromotingInstance::UpdateUmaEnumHistogram, | 673 base::Bind(&ChromotingInstance::UpdateUmaEnumHistogram, |
674 weak_factory_.GetWeakPtr())); | 674 weak_factory_.GetWeakPtr())); |
675 | 675 |
676 if (!plugin_view_.is_null()) | 676 if (!plugin_view_.is_null()) |
677 video_renderer_->OnViewChanged(plugin_view_); | 677 video_renderer_->OnViewChanged(plugin_view_); |
678 | 678 |
679 scoped_ptr<AudioPlayer> audio_player(new PepperAudioPlayer(this)); | 679 client_.reset( |
680 client_.reset(new ChromotingClient(&context_, this, video_renderer_.get(), | 680 new ChromotingClient(&context_, this, video_renderer_.get(), |
681 audio_player.Pass())); | 681 make_scoped_ptr(new PepperAudioPlayer(this)))); |
682 | 682 |
683 // Connect the input pipeline to the protocol stub & initialize components. | 683 // Connect the input pipeline to the protocol stub & initialize components. |
684 mouse_input_filter_.set_input_stub(client_->input_stub()); | 684 mouse_input_filter_.set_input_stub(client_->input_stub()); |
685 if (!plugin_view_.is_null()) { | 685 if (!plugin_view_.is_null()) { |
686 webrtc::DesktopSize size(plugin_view_.GetRect().width(), | 686 webrtc::DesktopSize size(plugin_view_.GetRect().width(), |
687 plugin_view_.GetRect().height()); | 687 plugin_view_.GetRect().height()); |
688 mouse_input_filter_.set_input_size(size); | 688 mouse_input_filter_.set_input_size(size); |
689 touch_input_scaler_.set_input_size(size); | 689 touch_input_scaler_.set_input_size(size); |
690 } | 690 } |
691 | 691 |
(...skipping 22 matching lines...) Expand all Loading... |
714 auth_methods.push_back(protocol::AuthenticationMethod::ThirdParty()); | 714 auth_methods.push_back(protocol::AuthenticationMethod::ThirdParty()); |
715 auth_methods.push_back(protocol::AuthenticationMethod::Spake2Pair()); | 715 auth_methods.push_back(protocol::AuthenticationMethod::Spake2Pair()); |
716 auth_methods.push_back(protocol::AuthenticationMethod::Spake2( | 716 auth_methods.push_back(protocol::AuthenticationMethod::Spake2( |
717 protocol::AuthenticationMethod::HMAC_SHA256)); | 717 protocol::AuthenticationMethod::HMAC_SHA256)); |
718 auth_methods.push_back(protocol::AuthenticationMethod::Spake2( | 718 auth_methods.push_back(protocol::AuthenticationMethod::Spake2( |
719 protocol::AuthenticationMethod::NONE)); | 719 protocol::AuthenticationMethod::NONE)); |
720 | 720 |
721 scoped_ptr<protocol::Authenticator> authenticator( | 721 scoped_ptr<protocol::Authenticator> authenticator( |
722 new protocol::NegotiatingClientAuthenticator( | 722 new protocol::NegotiatingClientAuthenticator( |
723 client_pairing_id, client_paired_secret, authentication_tag, | 723 client_pairing_id, client_paired_secret, authentication_tag, |
724 fetch_secret_callback, token_fetcher.Pass(), auth_methods)); | 724 fetch_secret_callback, std::move(token_fetcher), auth_methods)); |
725 | 725 |
726 scoped_ptr<protocol::CandidateSessionConfig> config = | 726 scoped_ptr<protocol::CandidateSessionConfig> config = |
727 protocol::CandidateSessionConfig::CreateDefault(); | 727 protocol::CandidateSessionConfig::CreateDefault(); |
728 if (std::find(experiments_list.begin(), experiments_list.end(), "vp9") != | 728 if (std::find(experiments_list.begin(), experiments_list.end(), "vp9") != |
729 experiments_list.end()) { | 729 experiments_list.end()) { |
730 config->set_vp9_experiment_enabled(true); | 730 config->set_vp9_experiment_enabled(true); |
731 } | 731 } |
732 client_->set_protocol_config(config.Pass()); | 732 client_->set_protocol_config(std::move(config)); |
733 | 733 |
734 // Kick off the connection. | 734 // Kick off the connection. |
735 client_->Start(signal_strategy_.get(), authenticator.Pass(), | 735 client_->Start(signal_strategy_.get(), std::move(authenticator), |
736 transport_context, host_jid, capabilities); | 736 transport_context, host_jid, capabilities); |
737 | 737 |
738 // Start timer that periodically sends perf stats. | 738 // Start timer that periodically sends perf stats. |
739 stats_update_timer_.Start( | 739 stats_update_timer_.Start( |
740 FROM_HERE, base::TimeDelta::FromSeconds(kUIStatsUpdatePeriodSeconds), | 740 FROM_HERE, base::TimeDelta::FromSeconds(kUIStatsUpdatePeriodSeconds), |
741 base::Bind(&ChromotingInstance::UpdatePerfStatsInUI, | 741 base::Bind(&ChromotingInstance::UpdatePerfStatsInUI, |
742 base::Unretained(this))); | 742 base::Unretained(this))); |
743 } | 743 } |
744 | 744 |
745 void ChromotingInstance::HandleDisconnect(const base::DictionaryValue& data) { | 745 void ChromotingInstance::HandleDisconnect(const base::DictionaryValue& data) { |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1029 | 1029 |
1030 std::string message_json; | 1030 std::string message_json; |
1031 base::JSONWriter::Write(message, &message_json); | 1031 base::JSONWriter::Write(message, &message_json); |
1032 PostMessage(pp::Var(message_json)); | 1032 PostMessage(pp::Var(message_json)); |
1033 } | 1033 } |
1034 | 1034 |
1035 void ChromotingInstance::SendTrappedKey(uint32_t usb_keycode, bool pressed) { | 1035 void ChromotingInstance::SendTrappedKey(uint32_t usb_keycode, bool pressed) { |
1036 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 1036 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
1037 data->SetInteger("usbKeycode", usb_keycode); | 1037 data->SetInteger("usbKeycode", usb_keycode); |
1038 data->SetBoolean("pressed", pressed); | 1038 data->SetBoolean("pressed", pressed); |
1039 PostLegacyJsonMessage("trappedKeyEvent", data.Pass()); | 1039 PostLegacyJsonMessage("trappedKeyEvent", std::move(data)); |
1040 } | 1040 } |
1041 | 1041 |
1042 void ChromotingInstance::SendOutgoingIq(const std::string& iq) { | 1042 void ChromotingInstance::SendOutgoingIq(const std::string& iq) { |
1043 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 1043 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
1044 data->SetString("iq", iq); | 1044 data->SetString("iq", iq); |
1045 PostLegacyJsonMessage("sendOutgoingIq", data.Pass()); | 1045 PostLegacyJsonMessage("sendOutgoingIq", std::move(data)); |
1046 } | 1046 } |
1047 | 1047 |
1048 void ChromotingInstance::UpdatePerfStatsInUI() { | 1048 void ChromotingInstance::UpdatePerfStatsInUI() { |
1049 // Fetch performance stats from the VideoRenderer and send them to the client | 1049 // Fetch performance stats from the VideoRenderer and send them to the client |
1050 // for display to users. | 1050 // for display to users. |
1051 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 1051 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
1052 data->SetDouble("videoBandwidth", perf_tracker_.video_bandwidth()); | 1052 data->SetDouble("videoBandwidth", perf_tracker_.video_bandwidth()); |
1053 data->SetDouble("videoFrameRate", perf_tracker_.video_frame_rate()); | 1053 data->SetDouble("videoFrameRate", perf_tracker_.video_frame_rate()); |
1054 data->SetDouble("captureLatency", perf_tracker_.video_capture_ms()); | 1054 data->SetDouble("captureLatency", perf_tracker_.video_capture_ms()); |
1055 data->SetDouble("encodeLatency", perf_tracker_.video_encode_ms()); | 1055 data->SetDouble("encodeLatency", perf_tracker_.video_encode_ms()); |
1056 data->SetDouble("decodeLatency", perf_tracker_.video_decode_ms()); | 1056 data->SetDouble("decodeLatency", perf_tracker_.video_decode_ms()); |
1057 data->SetDouble("renderLatency", perf_tracker_.video_paint_ms()); | 1057 data->SetDouble("renderLatency", perf_tracker_.video_paint_ms()); |
1058 data->SetDouble("roundtripLatency", perf_tracker_.round_trip_ms()); | 1058 data->SetDouble("roundtripLatency", perf_tracker_.round_trip_ms()); |
1059 PostLegacyJsonMessage("onPerfStats", data.Pass()); | 1059 PostLegacyJsonMessage("onPerfStats", std::move(data)); |
1060 } | 1060 } |
1061 | 1061 |
1062 // static | 1062 // static |
1063 void ChromotingInstance::RegisterLogMessageHandler() { | 1063 void ChromotingInstance::RegisterLogMessageHandler() { |
1064 base::AutoLock lock(g_logging_lock.Get()); | 1064 base::AutoLock lock(g_logging_lock.Get()); |
1065 | 1065 |
1066 // Set up log message handler. | 1066 // Set up log message handler. |
1067 // This is not thread-safe so we need it within our lock. | 1067 // This is not thread-safe so we need it within our lock. |
1068 logging::SetLogMessageHandler(&LogToUI); | 1068 logging::SetLogMessageHandler(&LogToUI); |
1069 } | 1069 } |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1149 if (is_custom_counts_histogram) { | 1149 if (is_custom_counts_histogram) { |
1150 uma.HistogramCustomCounts(histogram_name, value, histogram_min, | 1150 uma.HistogramCustomCounts(histogram_name, value, histogram_min, |
1151 histogram_max, histogram_buckets); | 1151 histogram_max, histogram_buckets); |
1152 } else { | 1152 } else { |
1153 uma.HistogramCustomTimes(histogram_name, value, histogram_min, | 1153 uma.HistogramCustomTimes(histogram_name, value, histogram_min, |
1154 histogram_max, histogram_buckets); | 1154 histogram_max, histogram_buckets); |
1155 } | 1155 } |
1156 } | 1156 } |
1157 | 1157 |
1158 } // namespace remoting | 1158 } // namespace remoting |
OLD | NEW |