Home | History | Annotate | Download | only in setup
      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.
      4 
      5 #ifndef REMOTING_HOST_SETUP_SERVICE_CLIENT_H_
      6 #define REMOTING_HOST_SETUP_SERVICE_CLIENT_H_
      7 
      8 #include <string>
      9 
     10 #include "base/memory/ref_counted.h"
     11 
     12 namespace net {
     13 class URLRequestContextGetter;
     14 }
     15 
     16 // A class that gives access to the Chromoting service.
     17 namespace remoting {
     18 
     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;
     33 
     34    protected:
     35     virtual ~Delegate() {}
     36   };
     37   ServiceClient(const std::string& chromoting_hosts_url,
     38                 net::URLRequestContextGetter* context_getter);
     39   ~ServiceClient();
     40 
     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);
     52 
     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);
     58 };
     59 
     60 }  // namespace remoting
     61 
     62 #endif  // REMOTING_HOST_SETUP_SERVICE_CLIENT_H_
     63