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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/remoting/directory_add_request.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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.
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 rejected request because it was invalid (e.g. specified
27 // public key is invalid).
28 ERROR_INVALID_REQUEST,
29 // Host is already registered.
30 ERROR_EXISTS,
31 // Internal server error.
32 ERROR_SERVER,
33 // Timeout expired.
34 ERROR_TIMEOUT_EXPIRED,
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. The error message may
41 // not be localized, and should be used for logging, but not shown
42 // to the user.
43 typedef Callback2<Result, const std::string&>::Type DoneCallback;
44
45 explicit DirectoryAddRequest(URLRequestContextGetter* getter);
46 ~DirectoryAddRequest();
47
48 // Add this computer as a host. Use the token for
49 // authentication. |done_callback| is called when the request is
50 // finished. Request can be cancelled by destroying 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 URLRequestContextGetter* getter_;
67 scoped_ptr<DoneCallback> done_callback_;
68 scoped_ptr<URLFetcher> fetcher_;
69
70 DISALLOW_COPY_AND_ASSIGN(DirectoryAddRequest);
71 };
72
73 } // namespace remoting
74
75 #endif // CHROME_BROWSER_REMOTING_DIRECTORY_ADD_REQUEST_H_
OLDNEW
« 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