Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / remoting / host / setup / service_client.h
blobeaa26abdc384c41187194cb08f319bada549656d
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef REMOTING_HOST_SETUP_SERVICE_CLIENT_H_
6 #define REMOTING_HOST_SETUP_SERVICE_CLIENT_H_
8 #include <string>
10 #include "base/memory/ref_counted.h"
12 namespace net {
13 class URLRequestContextGetter;
16 // A class that gives access to the Chromoting service.
17 namespace remoting {
19 class ServiceClient {
20 public:
21 // TODO(simonmorris): Consider using a Callback instead of a delegate.
22 class Delegate {
23 public:
24 // Invoked when a host has been registered.
25 virtual void OnHostRegistered(const std::string& authorization_code) = 0;
26 // Invoked when a host has been unregistered.
27 virtual void OnHostUnregistered() = 0;
28 // Invoked when there is an OAuth error.
29 virtual void OnOAuthError() = 0;
30 // Invoked when there is a network error or upon receiving an invalid
31 // response.
32 virtual void OnNetworkError(int response_code) = 0;
34 protected:
35 virtual ~Delegate() {}
37 ServiceClient(const std::string& chromoting_hosts_url,
38 net::URLRequestContextGetter* context_getter);
39 ~ServiceClient();
41 // Register a host.
42 void RegisterHost(const std::string& host_id,
43 const std::string& host_name,
44 const std::string& public_key,
45 const std::string& host_client_id,
46 const std::string& oauth_access_token,
47 Delegate* delegate);
48 // Unregister a host.
49 void UnregisterHost(const std::string& host_id,
50 const std::string& oauth_access_token,
51 Delegate* delegate);
53 private:
54 // The guts of the implementation live in this class.
55 class Core;
56 scoped_refptr<Core> core_;
57 DISALLOW_COPY_AND_ASSIGN(ServiceClient);
60 } // namespace remoting
62 #endif // REMOTING_HOST_SETUP_SERVICE_CLIENT_H_