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

Side by Side Diff: remoting/client/ios/facade/host_list_fetcher.h

Issue 2871993003: Moving the iOS directory to be remoting top level. (Closed)
Patch Set: //remoting/ios was the old landing target for the internal iOS application. Fix. Created 3 years, 7 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 2017 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_CLIENT_IOS_FACADE_HOST_LIST_FETCHER_H_
6 #define REMOTING_CLIENT_IOS_FACADE_HOST_LIST_FETCHER_H_
7
8 #include <memory>
9 #include <string>
10 #include <vector>
11
12 #include "base/callback.h"
13 #include "base/macros.h"
14 #include "base/memory/ref_counted.h"
15 #include "net/url_request/url_fetcher_delegate.h"
16 #include "net/url_request/url_request_context_getter.h"
17 #include "remoting/client/ios/facade/host_info.h"
18
19 namespace remoting {
20
21 // Used by the HostlistFetcher to make HTTP requests and also by the
22 // unittests for this class to set fake response data for these URLs.
23 // TODO(nicholss): Consider moving this to an extern and conditionally include
24 // prod or test environment urls based on config. A test env app would be nice.
25 const char kHostListProdRequestUrl[] =
26 "https://www.googleapis.com/chromoting/v1/@me/hosts";
27
28 // Requests a host list from the directory service for an access token.
29 // Destroying the RemoteHostInfoFetcher while a request is outstanding
30 // will cancel the request. It is safe to delete the fetcher from within a
31 // completion callback. Must be used from a thread running a message loop.
32 // The public method is virtual to allow for mocking and fakes.
33 class HostListFetcher : public net::URLFetcherDelegate {
34 public:
35 HostListFetcher(const scoped_refptr<net::URLRequestContextGetter>&
36 url_request_context_getter);
37 ~HostListFetcher() override;
38
39 // Supplied by the client for each hostlist request and returns a valid,
40 // initialized Hostlist object on success.
41 typedef base::Callback<void(const std::vector<remoting::HostInfo>& hostlist)>
42 HostlistCallback;
43
44 // Makes a service call to retrieve a hostlist. The
45 // callback will be called once the HTTP request has completed.
46 virtual void RetrieveHostlist(const std::string& access_token,
47 const HostlistCallback& callback);
48
49 private:
50 // Processes the response from the directory service.
51 bool ProcessResponse(std::vector<remoting::HostInfo>* hostlist);
52
53 // net::URLFetcherDelegate interface.
54 void OnURLFetchComplete(const net::URLFetcher* source) override;
55
56 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
57
58 // Holds the URLFetcher for the Host List request.
59 std::unique_ptr<net::URLFetcher> request_;
60
61 // Caller-supplied callback used to return hostlist on success.
62 HostlistCallback hostlist_callback_;
63
64 DISALLOW_COPY_AND_ASSIGN(HostListFetcher);
65 };
66
67 } // namespace remoting
68
69 #endif // REMOTING_CLIENT_IOS_FACADE_HOST_LIST_FETCHER_H_
OLDNEW
« no previous file with comments | « remoting/client/ios/facade/host_info.cc ('k') | remoting/client/ios/facade/host_list_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698