Chromium Code Reviews| 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_BROWSER_REMOTING_DIRECTORY_ADD_REQUEST_H_ | |
| 6 #define CHROME_BROWSER_REMOTING_DIRECTORY_ADD_REQUEST_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/callback.h" | |
| 11 #include "base/scoped_ptr.h" | |
| 12 #include "chrome/common/remoting/chromoting_host_info.h" | |
| 13 #include "chrome/common/net/url_fetcher.h" | |
| 14 #include "googleurl/src/gurl.h" | |
| 15 | |
| 16 namespace remoting { | |
| 17 | |
| 18 // A class implements REST API insert call for the Chromoting directory service. | |
|
dmac
2010/12/17 22:05:46
// A class that implements the REST API insert cal
Sergey Ulanov
2010/12/17 22:33:07
In all our docs the service is called Chromoting d
| |
| 19 class DirectoryAddRequest : public URLFetcher::Delegate { | |
| 20 public: | |
| 21 enum Result { | |
| 22 // Host was added successfully. | |
| 23 SUCCESS, | |
| 24 // Invalid authentication token. | |
| 25 ERROR_AUTH, | |
| 26 // Server rejested request because it was invalid. This may | |
|
dmac
2010/12/17 22:05:46
Server rejected the
Sergey Ulanov
2010/12/17 22:33:07
Done.
| |
| 27 // happen, for example, if the specified public key was invalid. | |
|
dmac
2010/12/17 22:05:46
get rid of , for example,
Sergey Ulanov
2010/12/17 22:33:07
Done.
| |
| 28 ERROR_INVALID_REQUEST, | |
| 29 // Host is already registered. | |
| 30 ERROR_EXISTS, | |
| 31 // Internal server error. | |
| 32 ERROR_INTERNAL, | |
| 33 // Timeout expired. | |
| 34 ERROR_TIMEOUT, | |
| 35 // Some other error, e.g. network failure. | |
| 36 ERROR_OTHER, | |
| 37 }; | |
| 38 | |
| 39 // Callback called when request is finished. The second parameter | |
| 40 // contains error message in case of an error. Error message may not | |
|
dmac
2010/12/17 22:05:46
an error message
. The error message
Sergey Ulanov
2010/12/17 22:33:07
Done.
| |
| 41 // be localized, and should be used for logging, but not shown to | |
| 42 // the user. | |
| 43 typedef Callback2<Result, const std::string&>::Type DoneCallback; | |
| 44 | |
| 45 DirectoryAddRequest(); | |
| 46 ~DirectoryAddRequest(); | |
| 47 | |
| 48 // Add this computer as host. Use the token for | |
|
dmac
2010/12/17 22:05:46
as a host.
|done_callback| is called when the req
Sergey Ulanov
2010/12/17 22:33:07
Done.
| |
| 49 // authentication. |done_callback| is called when request is | |
| 50 // finished. Request can be cancelled by destorying this object. | |
| 51 void AddHost(const remoting::ChromotingHostInfo& host_info, | |
| 52 const std::string& auth_token, | |
| 53 DoneCallback* done_callback); | |
| 54 | |
| 55 // URLFetcher::Delegate implementation. | |
| 56 virtual void OnURLFetchComplete(const URLFetcher* source, | |
| 57 const GURL& url, | |
| 58 const URLRequestStatus& status, | |
| 59 int response_code, | |
| 60 const ResponseCookies& cookies, | |
| 61 const std::string& data); | |
| 62 | |
| 63 private: | |
| 64 friend class DirectoryAddRequestTest; | |
| 65 | |
| 66 scoped_ptr<DoneCallback> done_callback_; | |
| 67 scoped_ptr<URLFetcher> fetcher_; | |
| 68 | |
| 69 DISALLOW_COPY_AND_ASSIGN(DirectoryAddRequest); | |
| 70 }; | |
| 71 | |
| 72 } // namespace remoting | |
| 73 | |
| 74 #endif // CHROME_BROWSER_REMOTING_DIRECTORY_ADD_REQUEST_H_ | |
| OLD | NEW |