| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/extensions/api/gcd_private/gcd_private_api.h" | 5 #include "chrome/browser/extensions/api/gcd_private/gcd_private_api.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/memory/linked_ptr.h" | 8 #include "base/memory/linked_ptr.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 return true; | 629 return true; |
| 630 } | 630 } |
| 631 | 631 |
| 632 void GcdPrivatePrefetchWifiPasswordFunction::OnResponse(bool response) { | 632 void GcdPrivatePrefetchWifiPasswordFunction::OnResponse(bool response) { |
| 633 scoped_ptr<base::FundamentalValue> response_value( | 633 scoped_ptr<base::FundamentalValue> response_value( |
| 634 new base::FundamentalValue(response)); | 634 new base::FundamentalValue(response)); |
| 635 SetResult(response_value.release()); | 635 SetResult(response_value.release()); |
| 636 SendResponse(true); | 636 SendResponse(true); |
| 637 } | 637 } |
| 638 | 638 |
| 639 GcdPrivateEstablishSessionFunction::GcdPrivateEstablishSessionFunction() { | |
| 640 } | |
| 641 | |
| 642 GcdPrivateEstablishSessionFunction::~GcdPrivateEstablishSessionFunction() { | |
| 643 } | |
| 644 | |
| 645 bool GcdPrivateEstablishSessionFunction::RunAsync() { | |
| 646 scoped_ptr<gcd_private::EstablishSession::Params> params = | |
| 647 gcd_private::EstablishSession::Params::Create(*args_); | |
| 648 | |
| 649 if (!params) | |
| 650 return false; | |
| 651 | |
| 652 GcdPrivateAPIImpl* gcd_api = GcdPrivateAPIImpl::Get(GetProfile()); | |
| 653 | |
| 654 GcdPrivateAPIImpl::EstablishSessionCallback callback = base::Bind( | |
| 655 &GcdPrivateEstablishSessionFunction::OnSessionInitialized, this); | |
| 656 gcd_api->EstablishSession(params->ip_address, params->port, callback); | |
| 657 | |
| 658 return true; | |
| 659 } | |
| 660 | |
| 661 void GcdPrivateEstablishSessionFunction::OnSessionInitialized( | |
| 662 int session_id, | |
| 663 api::gcd_private::Status status, | |
| 664 const std::vector<api::gcd_private::PairingType>& pairing_types) { | |
| 665 results_ = gcd_private::EstablishSession::Results::Create(session_id, status, | |
| 666 pairing_types); | |
| 667 SendResponse(true); | |
| 668 } | |
| 669 | |
| 670 GcdPrivateCreateSessionFunction::GcdPrivateCreateSessionFunction() { | 639 GcdPrivateCreateSessionFunction::GcdPrivateCreateSessionFunction() { |
| 671 } | 640 } |
| 672 | 641 |
| 673 GcdPrivateCreateSessionFunction::~GcdPrivateCreateSessionFunction() { | 642 GcdPrivateCreateSessionFunction::~GcdPrivateCreateSessionFunction() { |
| 674 } | 643 } |
| 675 | 644 |
| 676 bool GcdPrivateCreateSessionFunction::RunAsync() { | 645 bool GcdPrivateCreateSessionFunction::RunAsync() { |
| 677 scoped_ptr<gcd_private::CreateSession::Params> params = | 646 scoped_ptr<gcd_private::CreateSession::Params> params = |
| 678 gcd_private::CreateSession::Params::Create(*args_); | 647 gcd_private::CreateSession::Params::Create(*args_); |
| 679 | 648 |
| 680 if (!params) | 649 if (!params) |
| 681 return false; | 650 return false; |
| 682 | 651 |
| 683 GcdPrivateAPIImpl* gcd_api = GcdPrivateAPIImpl::Get(GetProfile()); | 652 GcdPrivateAPIImpl* gcd_api = GcdPrivateAPIImpl::Get(GetProfile()); |
| 684 | 653 |
| 685 GcdPrivateAPIImpl::EstablishSessionCallback callback = | 654 GcdPrivateAPIImpl::EstablishSessionCallback callback = |
| 686 base::Bind(&GcdPrivateCreateSessionFunction::OnSessionInitialized, this); | 655 base::Bind(&GcdPrivateCreateSessionFunction::OnSessionInitialized, this); |
| 687 gcd_api->CreateSession(params->service_name, callback); | 656 gcd_api->CreateSession(params->service_name, callback); |
| 688 | 657 |
| 689 return true; | 658 return true; |
| 690 } | 659 } |
| 691 | 660 |
| 692 void GcdPrivateCreateSessionFunction::OnSessionInitialized( | 661 void GcdPrivateCreateSessionFunction::OnSessionInitialized( |
| 693 int session_id, | 662 int session_id, |
| 694 api::gcd_private::Status status, | 663 api::gcd_private::Status status, |
| 695 const std::vector<api::gcd_private::PairingType>& pairing_types) { | 664 const std::vector<api::gcd_private::PairingType>& pairing_types) { |
| 696 results_ = gcd_private::EstablishSession::Results::Create(session_id, status, | 665 results_ = gcd_private::CreateSession::Results::Create(session_id, status, |
| 697 pairing_types); | 666 pairing_types); |
| 698 SendResponse(true); | 667 SendResponse(true); |
| 699 } | 668 } |
| 700 | 669 |
| 701 GcdPrivateStartPairingFunction::GcdPrivateStartPairingFunction() { | 670 GcdPrivateStartPairingFunction::GcdPrivateStartPairingFunction() { |
| 702 } | 671 } |
| 703 | 672 |
| 704 GcdPrivateStartPairingFunction::~GcdPrivateStartPairingFunction() { | 673 GcdPrivateStartPairingFunction::~GcdPrivateStartPairingFunction() { |
| 705 } | 674 } |
| 706 | 675 |
| 707 bool GcdPrivateStartPairingFunction::RunAsync() { | 676 bool GcdPrivateStartPairingFunction::RunAsync() { |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 874 } | 843 } |
| 875 | 844 |
| 876 GcdPrivateGetCommandsListFunction::~GcdPrivateGetCommandsListFunction() { | 845 GcdPrivateGetCommandsListFunction::~GcdPrivateGetCommandsListFunction() { |
| 877 } | 846 } |
| 878 | 847 |
| 879 bool GcdPrivateGetCommandsListFunction::RunAsync() { | 848 bool GcdPrivateGetCommandsListFunction::RunAsync() { |
| 880 return false; | 849 return false; |
| 881 } | 850 } |
| 882 | 851 |
| 883 } // namespace extensions | 852 } // namespace extensions |
| OLD | NEW |