Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3952)

Unified Diff: chrome/browser/remoting/directory_add_request.h

Issue 6036001: Move directory code from chrome/service to chrome/browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merges Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/remoting/directory_add_request.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..2ec6ed20fc92aecf1dbf43e416ec235e3e51461d
--- /dev/null
+++ b/chrome/browser/remoting/directory_add_request.h
@@ -0,0 +1,75 @@
+// 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.
+class DirectoryAddRequest : public URLFetcher::Delegate {
+ public:
+ enum Result {
+ // Host was added successfully.
+ SUCCESS,
+ // Invalid authentication token.
+ ERROR_AUTH,
+ // Server rejected request because it was invalid (e.g. specified
+ // public key is invalid).
+ ERROR_INVALID_REQUEST,
+ // Host is already registered.
+ ERROR_EXISTS,
+ // Internal server error.
+ ERROR_SERVER,
+ // Timeout expired.
+ ERROR_TIMEOUT_EXPIRED,
+ // 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. The error message may
+ // not be localized, and should be used for logging, but not shown
+ // to the user.
+ typedef Callback2<Result, const std::string&>::Type DoneCallback;
+
+ explicit DirectoryAddRequest(URLRequestContextGetter* getter);
+ ~DirectoryAddRequest();
+
+ // Add this computer as a host. Use the token for
+ // authentication. |done_callback| is called when the request is
+ // finished. Request can be cancelled by destroying 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;
+
+ URLRequestContextGetter* getter_;
+ scoped_ptr<DoneCallback> done_callback_;
+ scoped_ptr<URLFetcher> fetcher_;
+
+ DISALLOW_COPY_AND_ASSIGN(DirectoryAddRequest);
+};
+
+} // namespace remoting
+
+#endif // CHROME_BROWSER_REMOTING_DIRECTORY_ADD_REQUEST_H_
« no previous file with comments | « no previous file | chrome/browser/remoting/directory_add_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698