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 16 matching lines...) Expand all Loading... |
27 public: | 27 public: |
28 enum Result { | 28 enum Result { |
29 START_COMPLETE, | 29 START_COMPLETE, |
30 NETWORK_ERROR, | 30 NETWORK_ERROR, |
31 OAUTH_ERROR, | 31 OAUTH_ERROR, |
32 START_ERROR, | 32 START_ERROR, |
33 }; | 33 }; |
34 | 34 |
35 typedef base::Callback<void(Result)> CompletionCallback; | 35 typedef base::Callback<void(Result)> CompletionCallback; |
36 | 36 |
37 virtual ~HostStarter(); | 37 ~HostStarter() override; |
38 | 38 |
39 // Creates a HostStarter. | 39 // Creates a HostStarter. |
40 static scoped_ptr<HostStarter> Create( | 40 static scoped_ptr<HostStarter> Create( |
41 const std::string& chromoting_hosts_url, | 41 const std::string& chromoting_hosts_url, |
42 net::URLRequestContextGetter* url_request_context_getter); | 42 net::URLRequestContextGetter* url_request_context_getter); |
43 | 43 |
44 // Registers a new host with the Chromoting service, and starts it. | 44 // Registers a new host with the Chromoting service, and starts it. |
45 // |auth_code| must be a valid OAuth2 authorization code, typically acquired | 45 // |auth_code| must be a valid OAuth2 authorization code, typically acquired |
46 // from a browser. This method uses that code to get an OAuth2 refresh token. | 46 // from a browser. This method uses that code to get an OAuth2 refresh token. |
47 void StartHost(const std::string& host_name, | 47 void StartHost(const std::string& host_name, |
48 const std::string& host_pin, | 48 const std::string& host_pin, |
49 bool consent_to_data_collection, | 49 bool consent_to_data_collection, |
50 const std::string& auth_code, | 50 const std::string& auth_code, |
51 const std::string& redirect_url, | 51 const std::string& redirect_url, |
52 CompletionCallback on_done); | 52 CompletionCallback on_done); |
53 | 53 |
54 // gaia::GaiaOAuthClient::Delegate | 54 // gaia::GaiaOAuthClient::Delegate |
55 virtual void OnGetTokensResponse(const std::string& refresh_token, | 55 void OnGetTokensResponse(const std::string& refresh_token, |
56 const std::string& access_token, | 56 const std::string& access_token, |
57 int expires_in_seconds) override; | 57 int expires_in_seconds) override; |
58 virtual void OnRefreshTokenResponse(const std::string& access_token, | 58 void OnRefreshTokenResponse(const std::string& access_token, |
59 int expires_in_seconds) override; | 59 int expires_in_seconds) override; |
60 virtual void OnGetUserEmailResponse(const std::string& user_email) override; | 60 void OnGetUserEmailResponse(const std::string& user_email) override; |
61 | 61 |
62 // remoting::ServiceClient::Delegate | 62 // remoting::ServiceClient::Delegate |
63 virtual void OnHostRegistered(const std::string& authorization_code) override; | 63 void OnHostRegistered(const std::string& authorization_code) override; |
64 virtual void OnHostUnregistered() override; | 64 void OnHostUnregistered() override; |
65 | 65 |
66 // TODO(sergeyu): Following methods are members of all three delegate | 66 // TODO(sergeyu): Following methods are members of all three delegate |
67 // interfaces implemented in this class. Fix ServiceClient and | 67 // interfaces implemented in this class. Fix ServiceClient and |
68 // GaiaUserEmailFetcher so that Delegate interfaces do not overlap (ideally | 68 // GaiaUserEmailFetcher so that Delegate interfaces do not overlap (ideally |
69 // they should be changed to use Callback<>). | 69 // they should be changed to use Callback<>). |
70 virtual void OnOAuthError() override; | 70 void OnOAuthError() override; |
71 virtual void OnNetworkError(int response_code) override; | 71 void OnNetworkError(int response_code) override; |
72 | 72 |
73 private: | 73 private: |
74 HostStarter(scoped_ptr<gaia::GaiaOAuthClient> oauth_client, | 74 HostStarter(scoped_ptr<gaia::GaiaOAuthClient> oauth_client, |
75 scoped_ptr<remoting::ServiceClient> service_client, | 75 scoped_ptr<remoting::ServiceClient> service_client, |
76 scoped_refptr<remoting::DaemonController> daemon_controller); | 76 scoped_refptr<remoting::DaemonController> daemon_controller); |
77 | 77 |
78 void StartHostProcess(); | 78 void StartHostProcess(); |
79 | 79 |
80 void OnHostStarted(DaemonController::AsyncResult result); | 80 void OnHostStarted(DaemonController::AsyncResult result); |
81 | 81 |
(...skipping 21 matching lines...) Expand all Loading... |
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 |