OLD | NEW |
| (Empty) |
1 // Copyright (c) 2010 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 CHROME_SERVICE_REMOTING_REMOTING_DIRECTORY_SERVICE_H_ | |
6 #define CHROME_SERVICE_REMOTING_REMOTING_DIRECTORY_SERVICE_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/scoped_ptr.h" | |
11 #include "chrome/common/net/url_fetcher.h" | |
12 #include "googleurl/src/gurl.h" | |
13 | |
14 namespace remoting { | |
15 class HostKeyPair; | |
16 } // namespace remoting | |
17 | |
18 // A class to provide access to the remoting directory service. | |
19 // TODO(hclam): Should implement this in Javascript. | |
20 class RemotingDirectoryService : public URLFetcher::Delegate { | |
21 public: | |
22 // Client to receive events from the directory service. | |
23 class Client { | |
24 public: | |
25 virtual ~Client() {} | |
26 | |
27 // Called when a remoting host was added. | |
28 virtual void OnRemotingHostAdded() {} | |
29 | |
30 // Called when the last operation has failed. | |
31 virtual void OnRemotingDirectoryError() {} | |
32 }; | |
33 | |
34 explicit RemotingDirectoryService(Client* client); | |
35 ~RemotingDirectoryService(); | |
36 | |
37 // Add this computer as host. Use the token for authentication. | |
38 // TODO(hclam): Need more information for this method call. | |
39 void AddHost(const std::string& token); | |
40 | |
41 // Cancel the last requested operation. | |
42 void CancelRequest(); | |
43 | |
44 // URLFetcher::Delegate implementation. | |
45 virtual void OnURLFetchComplete(const URLFetcher* source, | |
46 const GURL& url, | |
47 const URLRequestStatus& status, | |
48 int response_code, | |
49 const ResponseCookies& cookies, | |
50 const std::string& data); | |
51 | |
52 const std::string& host_id() const { return host_id_; } | |
53 const std::string& host_name() const { return host_name_; } | |
54 remoting::HostKeyPair* host_key_pair() const { | |
55 return host_key_pair_.get(); | |
56 } | |
57 | |
58 private: | |
59 Client* client_; | |
60 scoped_ptr<URLFetcher> fetcher_; | |
61 | |
62 // Host key generated during host registration. | |
63 scoped_ptr<remoting::HostKeyPair> host_key_pair_; | |
64 | |
65 // Host info used for registration. | |
66 std::string host_id_; | |
67 std::string host_name_; | |
68 | |
69 DISALLOW_COPY_AND_ASSIGN(RemotingDirectoryService); | |
70 }; | |
71 | |
72 #endif // CHROME_SERVICE_REMOTING_REMOTING_DIRECTORY_SERVICE_H_ | |
OLD | NEW |