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

Side by Side Diff: remoting/test/hostlist_fetcher.h

Issue 1212333011: Retrieved Hostlist information from Directory service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 months 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
OLDNEW
(Empty)
1 // Copyright 2015 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 REMOTING_TEST_HOSTLIST_FETCHER_H_
6 #define REMOTING_TEST_HOSTLIST_FETCHER_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/callback.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "net/url_request/url_fetcher_delegate.h"
15 #include "remoting/test/chromoting_host_info.h"
16
17 namespace net {
18 class UrlFetcher;
19 }
20 namespace remoting {
21 class URLRequestContextGetter;
22 }
23
24 namespace remoting {
25 namespace test {
26
27 // Used by the HostlistFetcher to make HTTP requests and also by the
28 // unittests for this class to set fake response data for these URLs.
29 const char kProdServiceEnvironmentUrlFormat[] = "https://www.googleapis.com/"
joedow 2015/07/01 03:39:36 Can you rename this? It isn't a format string bec
tonychun 2015/07/06 20:11:51 Done.
30 "chromoting/v1/@me/hosts";
31
32 // Specifies the service API to call for the hostlist.
33 // Note: When adding new environments, add them before kUnknownEnvironment as
34 // the last entry is used for bounds checking.
35 enum ServiceEnvironment {
joedow 2015/07/01 03:39:36 This is going to collide with the app remoting Ser
tonychun 2015/07/06 20:11:51 Done.
36 kProductionEnvironment,
37 kUnknownEnvironment
38 };
39
40 // Supplied by the client for each hostlist request and returns a valid,
41 // initialized Hostlist object on success.
joedow 2015/07/01 03:39:36 The callback doesn't return a Hostlist object, it
tonychun 2015/07/06 20:11:51 Done.
42 typedef base::Callback<void(const std::vector<ChromotingHostInfo>& hostlist)>
43 HostlistCallback;
44
45 // Calls the App Remoting service API to request connection info for a remote
joedow 2015/07/01 03:39:35 I'm guessing this class does not call the App Remo
tonychun 2015/07/06 20:11:51 Done.
46 // host. Destroying the RemoteHostInfoFetcher while a request is outstanding
47 // will cancel the request. It is safe to delete the fetcher from within a
48 // completion callback. Must be used from a thread running an IO message loop.
49 // The public method is virtual to allow for mocking and fakes.
50 class HostlistFetcher : public net::URLFetcherDelegate {
joedow 2015/07/01 03:39:35 Can you rename this class ChromotingHostListFetche
tonychun 2015/07/06 20:11:51 Done.
51 public:
52 HostlistFetcher();
53 ~HostlistFetcher() override;
54
55 // Makes a service call to retrieve the details for a hostlist. The
56 // callback will be called once the HTTP request has completed.
57 virtual bool RetrieveHostlist(const std::string& access_token,
58 ServiceEnvironment service_environment,
59 const HostlistCallback& callback);
60
61 private:
62 // net::URLFetcherDelegate interface.
63 void OnURLFetchComplete(const net::URLFetcher* source) override;
64
65 // Holds the URLFetcher for the RemoteHostInfo request.
joedow 2015/07/01 03:39:36 RemoteHostInfo request?
tonychun 2015/07/06 20:11:51 Done.
66 scoped_ptr<net::URLFetcher> request_;
67
68 // Provides application-specific context for the network request.
69 scoped_refptr<remoting::URLRequestContextGetter> request_context_getter_;
70
71 // Caller-supplied callback used to return hostlist on success.
72 HostlistCallback hostlist_callback_;
73
74 DISALLOW_COPY_AND_ASSIGN(HostlistFetcher);
75 };
76
77 } // namespace test
78 } // namespace remoting
79
80 #endif // REMOTING_TEST_HOSTLIST_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698