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

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

Issue 1212333011: Retrieved Hostlist information from Directory service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added unittests and cleaned up format of C++ code. 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_CHROMOTING_HOST_LIST_FETCHER_H_
6 #define REMOTING_TEST_CHROMOTING_HOST_LIST_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 kChromotingHostListProdRequestUrl[] = "https://www.googleapis.com/"
30 "chromoting/v1/@me/hosts";
31
32 // Supplied by the client for each hostlist request and returns a valid,
33 // initialized Hostlist object on success.
34 typedef base::Callback<void(std::vector<ChromotingHostInfo>* hostlist)>
Sergey Ulanov 2015/07/07 00:01:46 I think the argument can be passed as const refere
Sergey Ulanov 2015/07/07 00:01:46 move this inside the class.
tonychun 2015/07/08 03:12:14 Done.
tonychun 2015/07/08 03:12:14 Done.
35 HostlistCallback;
36
37 // Calls the Directory service to request for a host list for an access token.
joedow 2015/07/06 22:19:13 s/to request for a/to request a
tonychun 2015/07/08 03:12:14 Requests a host list from the Directory service fo
38 // Destroying the RemoteHostInfoFetcher while a request is outstanding
39 // will cancel the request. It is safe to delete the fetcher from within a
40 // completion callback. Must be used from a thread running an IO message loop.
41 // The public method is virtual to allow for mocking and fakes.
42 class ChromotingHostListFetcher : public net::URLFetcherDelegate {
43 public:
44 ChromotingHostListFetcher();
45 ~ChromotingHostListFetcher() override;
46
47 // Makes a service call to retrieve the details for a hostlist. The
joedow 2015/07/06 22:19:13 Makes a service call to retrieve a hostlist.
tonychun 2015/07/08 03:12:14 Done.
48 // callback will be called once the HTTP request has completed.
49 virtual bool RetrieveHostlist(const std::string& access_token,
50 const HostlistCallback& callback);
51
52 private:
53 // net::URLFetcherDelegate interface.
54 void OnURLFetchComplete(const net::URLFetcher* source) override;
55
56 // Holds the URLFetcher for the ChromotingHostInfo request.
joedow 2015/07/06 22:19:13 s/ChromotingHostInfo/ChromotingHostList
tonychun 2015/07/08 03:12:14 Done.
57 scoped_ptr<net::URLFetcher> request_;
58
59 // Provides application-specific context for the network request.
60 scoped_refptr<remoting::URLRequestContextGetter> request_context_getter_;
Sergey Ulanov 2015/07/07 00:01:46 this doesn't need to be remoting::URLRequestContex
tonychun 2015/07/08 03:12:14 I do not think it is possible to just use net::URL
61
62 // Caller-supplied callback used to return hostlist on success.
63 HostlistCallback hostlist_callback_;
64
65 DISALLOW_COPY_AND_ASSIGN(ChromotingHostListFetcher);
66 };
67
68 } // namespace test
69 } // namespace remoting
70
71 #endif // REMOTING_TEST_CHROMOTING_HOST_LIST_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698