| 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 #ifndef REMOTING_HOST_HOST_STARTER | 5 #ifndef REMOTING_HOST_HOST_STARTER |
| 6 #define REMOTING_HOST_HOST_STARTER | 6 #define REMOTING_HOST_HOST_STARTER |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/memory/ref_counted.h" |
| 11 #include "google_apis/gaia/gaia_oauth_client.h" | 12 #include "google_apis/gaia/gaia_oauth_client.h" |
| 12 #include "remoting/base/rsa_key_pair.h" | 13 #include "remoting/base/rsa_key_pair.h" |
| 13 #include "remoting/base/url_request_context.h" | 14 #include "remoting/base/url_request_context.h" |
| 14 #include "remoting/host/setup/daemon_controller.h" | 15 #include "remoting/host/setup/daemon_controller.h" |
| 15 #include "remoting/host/setup/service_client.h" | 16 #include "remoting/host/setup/service_client.h" |
| 16 | 17 |
| 17 namespace remoting { | 18 namespace remoting { |
| 18 | 19 |
| 19 // A helper class that registers and starts a host. | 20 // A helper class that registers and starts a host. |
| 20 class HostStarter : public gaia::GaiaOAuthClient::Delegate, | 21 class HostStarter : public gaia::GaiaOAuthClient::Delegate, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 // TODO(sergeyu): Following methods are members of all three delegate | 62 // TODO(sergeyu): Following methods are members of all three delegate |
| 62 // interfaces implemented in this class. Fix ServiceClient and | 63 // interfaces implemented in this class. Fix ServiceClient and |
| 63 // GaiaUserEmailFetcher so that Delegate interfaces do not overlap (ideally | 64 // GaiaUserEmailFetcher so that Delegate interfaces do not overlap (ideally |
| 64 // they should be changed to use Callback<>). | 65 // they should be changed to use Callback<>). |
| 65 virtual void OnOAuthError() OVERRIDE; | 66 virtual void OnOAuthError() OVERRIDE; |
| 66 virtual void OnNetworkError(int response_code) OVERRIDE; | 67 virtual void OnNetworkError(int response_code) OVERRIDE; |
| 67 | 68 |
| 68 private: | 69 private: |
| 69 HostStarter(scoped_ptr<gaia::GaiaOAuthClient> oauth_client, | 70 HostStarter(scoped_ptr<gaia::GaiaOAuthClient> oauth_client, |
| 70 scoped_ptr<remoting::ServiceClient> service_client, | 71 scoped_ptr<remoting::ServiceClient> service_client, |
| 71 scoped_ptr<remoting::DaemonController> daemon_controller); | 72 scoped_refptr<remoting::DaemonController> daemon_controller); |
| 72 | 73 |
| 73 void StartHostProcess(); | 74 void StartHostProcess(); |
| 74 | 75 |
| 75 void OnHostStarted(DaemonController::AsyncResult result); | 76 void OnHostStarted(DaemonController::AsyncResult result); |
| 76 | 77 |
| 77 scoped_ptr<gaia::GaiaOAuthClient> oauth_client_; | 78 scoped_ptr<gaia::GaiaOAuthClient> oauth_client_; |
| 78 scoped_ptr<remoting::ServiceClient> service_client_; | 79 scoped_ptr<remoting::ServiceClient> service_client_; |
| 79 scoped_ptr<remoting::DaemonController> daemon_controller_; | 80 scoped_refptr<remoting::DaemonController> daemon_controller_; |
| 80 gaia::OAuthClientInfo oauth_client_info_; | 81 gaia::OAuthClientInfo oauth_client_info_; |
| 81 std::string host_name_; | 82 std::string host_name_; |
| 82 std::string host_pin_; | 83 std::string host_pin_; |
| 83 bool consent_to_data_collection_; | 84 bool consent_to_data_collection_; |
| 84 CompletionCallback on_done_; | 85 CompletionCallback on_done_; |
| 85 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | 86 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
| 86 std::string refresh_token_; | 87 std::string refresh_token_; |
| 87 std::string access_token_; | 88 std::string access_token_; |
| 88 std::string host_owner_; | 89 std::string host_owner_; |
| 89 std::string xmpp_login_; | 90 std::string xmpp_login_; |
| 90 scoped_refptr<remoting::RsaKeyPair> key_pair_; | 91 scoped_refptr<remoting::RsaKeyPair> key_pair_; |
| 91 std::string host_id_; | 92 std::string host_id_; |
| 92 bool use_service_account_; | 93 bool use_service_account_; |
| 93 | 94 |
| 94 // True if the host was not started and unregistration was requested. If this | 95 // True if the host was not started and unregistration was requested. If this |
| 95 // is set and a network/OAuth error occurs during unregistration, this will | 96 // is set and a network/OAuth error occurs during unregistration, this will |
| 96 // be logged, but the error will still be reported as START_ERROR. | 97 // be logged, but the error will still be reported as START_ERROR. |
| 97 bool unregistering_host_; | 98 bool unregistering_host_; |
| 98 | 99 |
| 99 base::WeakPtrFactory<HostStarter> weak_ptr_factory_; | 100 base::WeakPtrFactory<HostStarter> weak_ptr_factory_; |
| 100 base::WeakPtr<HostStarter> weak_ptr_; | 101 base::WeakPtr<HostStarter> weak_ptr_; |
| 101 | 102 |
| 102 DISALLOW_COPY_AND_ASSIGN(HostStarter); | 103 DISALLOW_COPY_AND_ASSIGN(HostStarter); |
| 103 }; | 104 }; |
| 104 | 105 |
| 105 } // namespace remoting | 106 } // namespace remoting |
| 106 | 107 |
| 107 #endif // REMOTING_HOST_HOST_STARTER | 108 #endif // REMOTING_HOST_HOST_STARTER |
| OLD | NEW |