Chromium Code Reviews| Index: chrome/browser/remoting/directory_add_request.h |
| diff --git a/chrome/browser/remoting/directory_add_request.h b/chrome/browser/remoting/directory_add_request.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9e644ba2e25c3e8a1c72e58745b3069b9809cf0e |
| --- /dev/null |
| +++ b/chrome/browser/remoting/directory_add_request.h |
| @@ -0,0 +1,74 @@ |
| +// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_REMOTING_DIRECTORY_ADD_REQUEST_H_ |
| +#define CHROME_BROWSER_REMOTING_DIRECTORY_ADD_REQUEST_H_ |
| + |
| +#include <string> |
| + |
| +#include "base/callback.h" |
| +#include "base/scoped_ptr.h" |
| +#include "chrome/common/remoting/chromoting_host_info.h" |
| +#include "chrome/common/net/url_fetcher.h" |
| +#include "googleurl/src/gurl.h" |
| + |
| +namespace remoting { |
| + |
| +// 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
|
| +class DirectoryAddRequest : public URLFetcher::Delegate { |
| + public: |
| + enum Result { |
| + // Host was added successfully. |
| + SUCCESS, |
| + // Invalid authentication token. |
| + ERROR_AUTH, |
| + // 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.
|
| + // 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.
|
| + ERROR_INVALID_REQUEST, |
| + // Host is already registered. |
| + ERROR_EXISTS, |
| + // Internal server error. |
| + ERROR_INTERNAL, |
| + // Timeout expired. |
| + ERROR_TIMEOUT, |
| + // Some other error, e.g. network failure. |
| + ERROR_OTHER, |
| + }; |
| + |
| + // Callback called when request is finished. The second parameter |
| + // 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.
|
| + // be localized, and should be used for logging, but not shown to |
| + // the user. |
| + typedef Callback2<Result, const std::string&>::Type DoneCallback; |
| + |
| + DirectoryAddRequest(); |
| + ~DirectoryAddRequest(); |
| + |
| + // 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.
|
| + // authentication. |done_callback| is called when request is |
| + // finished. Request can be cancelled by destorying this object. |
| + void AddHost(const remoting::ChromotingHostInfo& host_info, |
| + const std::string& auth_token, |
| + DoneCallback* done_callback); |
| + |
| + // URLFetcher::Delegate implementation. |
| + virtual void OnURLFetchComplete(const URLFetcher* source, |
| + const GURL& url, |
| + const URLRequestStatus& status, |
| + int response_code, |
| + const ResponseCookies& cookies, |
| + const std::string& data); |
| + |
| + private: |
| + friend class DirectoryAddRequestTest; |
| + |
| + scoped_ptr<DoneCallback> done_callback_; |
| + scoped_ptr<URLFetcher> fetcher_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(DirectoryAddRequest); |
| +}; |
| + |
| +} // namespace remoting |
| + |
| +#endif // CHROME_BROWSER_REMOTING_DIRECTORY_ADD_REQUEST_H_ |