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" |
(...skipping 20 matching lines...) Expand all Loading... |
31 NETWORK_ERROR, | 31 NETWORK_ERROR, |
32 OAUTH_ERROR, | 32 OAUTH_ERROR, |
33 START_ERROR, | 33 START_ERROR, |
34 }; | 34 }; |
35 | 35 |
36 typedef base::Callback<void(Result)> CompletionCallback; | 36 typedef base::Callback<void(Result)> CompletionCallback; |
37 | 37 |
38 ~HostStarter() override; | 38 ~HostStarter() override; |
39 | 39 |
40 // Creates a HostStarter. | 40 // Creates a HostStarter. |
41 static scoped_ptr<HostStarter> Create( | 41 static std::unique_ptr<HostStarter> Create( |
42 const std::string& chromoting_hosts_url, | 42 const std::string& chromoting_hosts_url, |
43 net::URLRequestContextGetter* url_request_context_getter); | 43 net::URLRequestContextGetter* url_request_context_getter); |
44 | 44 |
45 // Registers a new host with the Chromoting service, and starts it. | 45 // Registers a new host with the Chromoting service, and starts it. |
46 // |auth_code| must be a valid OAuth2 authorization code, typically acquired | 46 // |auth_code| must be a valid OAuth2 authorization code, typically acquired |
47 // from a browser. This method uses that code to get an OAuth2 refresh token. | 47 // from a browser. This method uses that code to get an OAuth2 refresh token. |
48 void StartHost(const std::string& host_name, | 48 void StartHost(const std::string& host_name, |
49 const std::string& host_pin, | 49 const std::string& host_pin, |
50 bool consent_to_data_collection, | 50 bool consent_to_data_collection, |
51 const std::string& auth_code, | 51 const std::string& auth_code, |
(...skipping 13 matching lines...) Expand all Loading... |
65 void OnHostUnregistered() override; | 65 void OnHostUnregistered() override; |
66 | 66 |
67 // TODO(sergeyu): Following methods are members of all three delegate | 67 // TODO(sergeyu): Following methods are members of all three delegate |
68 // interfaces implemented in this class. Fix ServiceClient and | 68 // interfaces implemented in this class. Fix ServiceClient and |
69 // GaiaUserEmailFetcher so that Delegate interfaces do not overlap (ideally | 69 // GaiaUserEmailFetcher so that Delegate interfaces do not overlap (ideally |
70 // they should be changed to use Callback<>). | 70 // they should be changed to use Callback<>). |
71 void OnOAuthError() override; | 71 void OnOAuthError() override; |
72 void OnNetworkError(int response_code) override; | 72 void OnNetworkError(int response_code) override; |
73 | 73 |
74 private: | 74 private: |
75 HostStarter(scoped_ptr<gaia::GaiaOAuthClient> oauth_client, | 75 HostStarter(std::unique_ptr<gaia::GaiaOAuthClient> oauth_client, |
76 scoped_ptr<remoting::ServiceClient> service_client, | 76 std::unique_ptr<remoting::ServiceClient> service_client, |
77 scoped_refptr<remoting::DaemonController> daemon_controller); | 77 scoped_refptr<remoting::DaemonController> daemon_controller); |
78 | 78 |
79 void StartHostProcess(); | 79 void StartHostProcess(); |
80 | 80 |
81 void OnHostStarted(DaemonController::AsyncResult result); | 81 void OnHostStarted(DaemonController::AsyncResult result); |
82 | 82 |
83 scoped_ptr<gaia::GaiaOAuthClient> oauth_client_; | 83 std::unique_ptr<gaia::GaiaOAuthClient> oauth_client_; |
84 scoped_ptr<remoting::ServiceClient> service_client_; | 84 std::unique_ptr<remoting::ServiceClient> service_client_; |
85 scoped_refptr<remoting::DaemonController> daemon_controller_; | 85 scoped_refptr<remoting::DaemonController> daemon_controller_; |
86 gaia::OAuthClientInfo oauth_client_info_; | 86 gaia::OAuthClientInfo oauth_client_info_; |
87 std::string host_name_; | 87 std::string host_name_; |
88 std::string host_pin_; | 88 std::string host_pin_; |
89 bool consent_to_data_collection_; | 89 bool consent_to_data_collection_; |
90 CompletionCallback on_done_; | 90 CompletionCallback on_done_; |
91 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | 91 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
92 std::string refresh_token_; | 92 std::string refresh_token_; |
93 std::string access_token_; | 93 std::string access_token_; |
94 std::string host_owner_; | 94 std::string host_owner_; |
95 std::string xmpp_login_; | 95 std::string xmpp_login_; |
96 scoped_refptr<remoting::RsaKeyPair> key_pair_; | 96 scoped_refptr<remoting::RsaKeyPair> key_pair_; |
97 std::string host_id_; | 97 std::string host_id_; |
98 | 98 |
99 // True if the host was not started and unregistration was requested. If this | 99 // True if the host was not started and unregistration was requested. If this |
100 // is set and a network/OAuth error occurs during unregistration, this will | 100 // is set and a network/OAuth error occurs during unregistration, this will |
101 // be logged, but the error will still be reported as START_ERROR. | 101 // be logged, but the error will still be reported as START_ERROR. |
102 bool unregistering_host_; | 102 bool unregistering_host_; |
103 | 103 |
104 base::WeakPtr<HostStarter> weak_ptr_; | 104 base::WeakPtr<HostStarter> weak_ptr_; |
105 base::WeakPtrFactory<HostStarter> weak_ptr_factory_; | 105 base::WeakPtrFactory<HostStarter> weak_ptr_factory_; |
106 | 106 |
107 DISALLOW_COPY_AND_ASSIGN(HostStarter); | 107 DISALLOW_COPY_AND_ASSIGN(HostStarter); |
108 }; | 108 }; |
109 | 109 |
110 } // namespace remoting | 110 } // namespace remoting |
111 | 111 |
112 #endif // REMOTING_HOST_HOST_STARTER | 112 #endif // REMOTING_HOST_HOST_STARTER |
OLD | NEW |