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/host/setup/host_starter.h" | 5 #include "remoting/host/setup/host_starter.h" |
6 | 6 |
7 #include "base/guid.h" | 7 #include "base/guid.h" |
8 #include "base/thread_task_runner_handle.h" | 8 #include "base/thread_task_runner_handle.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "google_apis/google_api_keys.h" | 10 #include "google_apis/google_api_keys.h" |
11 #include "remoting/host/pin_hash.h" | 11 #include "remoting/host/pin_hash.h" |
12 #include "remoting/host/setup/oauth_helper.h" | 12 #include "remoting/host/setup/oauth_helper.h" |
13 | 13 |
14 namespace { | 14 namespace { |
15 const int kMaxGetTokensRetries = 3; | 15 const int kMaxGetTokensRetries = 3; |
16 } // namespace | 16 } // namespace |
17 | 17 |
18 namespace remoting { | 18 namespace remoting { |
19 | 19 |
20 HostStarter::HostStarter( | 20 HostStarter::HostStarter( |
21 scoped_ptr<gaia::GaiaOAuthClient> oauth_client, | 21 scoped_ptr<gaia::GaiaOAuthClient> oauth_client, |
22 scoped_ptr<remoting::ServiceClient> service_client, | 22 scoped_ptr<remoting::ServiceClient> service_client, |
23 scoped_ptr<remoting::DaemonController> daemon_controller) | 23 scoped_refptr<remoting::DaemonController> daemon_controller) |
24 : oauth_client_(oauth_client.Pass()), | 24 : oauth_client_(oauth_client.Pass()), |
25 service_client_(service_client.Pass()), | 25 service_client_(service_client.Pass()), |
26 daemon_controller_(daemon_controller.Pass()), | 26 daemon_controller_(daemon_controller), |
27 consent_to_data_collection_(false), | 27 consent_to_data_collection_(false), |
28 unregistering_host_(false), | 28 unregistering_host_(false), |
29 weak_ptr_factory_(this), | 29 weak_ptr_factory_(this), |
30 weak_ptr_(weak_ptr_factory_.GetWeakPtr()) { | 30 weak_ptr_(weak_ptr_factory_.GetWeakPtr()) { |
31 main_task_runner_ = base::ThreadTaskRunnerHandle::Get(); | 31 main_task_runner_ = base::ThreadTaskRunnerHandle::Get(); |
32 } | 32 } |
33 | 33 |
34 HostStarter::~HostStarter() { | 34 HostStarter::~HostStarter() { |
35 } | 35 } |
36 | 36 |
37 scoped_ptr<HostStarter> HostStarter::Create( | 37 scoped_ptr<HostStarter> HostStarter::Create( |
38 const std::string& chromoting_hosts_url, | 38 const std::string& chromoting_hosts_url, |
39 net::URLRequestContextGetter* url_request_context_getter) { | 39 net::URLRequestContextGetter* url_request_context_getter) { |
40 scoped_ptr<gaia::GaiaOAuthClient> oauth_client( | 40 scoped_ptr<gaia::GaiaOAuthClient> oauth_client( |
41 new gaia::GaiaOAuthClient(url_request_context_getter)); | 41 new gaia::GaiaOAuthClient(url_request_context_getter)); |
42 scoped_ptr<remoting::ServiceClient> service_client( | 42 scoped_ptr<remoting::ServiceClient> service_client( |
43 new remoting::ServiceClient( | 43 new remoting::ServiceClient( |
44 chromoting_hosts_url, url_request_context_getter)); | 44 chromoting_hosts_url, url_request_context_getter)); |
45 scoped_ptr<remoting::DaemonController> daemon_controller( | 45 scoped_refptr<remoting::DaemonController> daemon_controller( |
46 remoting::DaemonController::Create()); | 46 remoting::DaemonController::Create()); |
47 return scoped_ptr<HostStarter>( | 47 return scoped_ptr<HostStarter>( |
48 new HostStarter(oauth_client.Pass(), service_client.Pass(), | 48 new HostStarter(oauth_client.Pass(), service_client.Pass(), |
49 daemon_controller.Pass())); | 49 daemon_controller)); |
50 } | 50 } |
51 | 51 |
52 void HostStarter::StartHost( | 52 void HostStarter::StartHost( |
53 const std::string& host_name, | 53 const std::string& host_name, |
54 const std::string& host_pin, | 54 const std::string& host_pin, |
55 bool consent_to_data_collection, | 55 bool consent_to_data_collection, |
56 const std::string& auth_code, | 56 const std::string& auth_code, |
57 const std::string& redirect_url, | 57 const std::string& redirect_url, |
58 CompletionCallback on_done) { | 58 CompletionCallback on_done) { |
59 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 59 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 main_task_runner_->PostTask(FROM_HERE, base::Bind( | 225 main_task_runner_->PostTask(FROM_HERE, base::Bind( |
226 &HostStarter::OnHostUnregistered, weak_ptr_)); | 226 &HostStarter::OnHostUnregistered, weak_ptr_)); |
227 return; | 227 return; |
228 } | 228 } |
229 CompletionCallback cb = on_done_; | 229 CompletionCallback cb = on_done_; |
230 on_done_.Reset(); | 230 on_done_.Reset(); |
231 cb.Run(START_ERROR); | 231 cb.Run(START_ERROR); |
232 } | 232 } |
233 | 233 |
234 } // namespace remoting | 234 } // namespace remoting |
OLD | NEW |