Compute if a layer is clipped outside CalcDrawProps
[chromium-blink-merge.git] / remoting / test / host_list_fetcher.h
blobaf014d24dac8344d96fbd0033e38e8d78e5a4520
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.
5 #ifndef REMOTING_TEST_HOST_LIST_FETCHER_H_
6 #define REMOTING_TEST_HOST_LIST_FETCHER_H_
8 #include <string>
9 #include <vector>
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/host_info.h"
17 namespace net {
18 class UrlFetcher;
20 namespace remoting {
21 class URLRequestContextGetter;
24 namespace remoting {
25 namespace test {
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 kHostListProdRequestUrl[] = "https://www.googleapis.com/"
30 "chromoting/v1/@me/hosts";
32 // Requests a host list from the directory service for an access token.
33 // Destroying the RemoteHostInfoFetcher while a request is outstanding
34 // will cancel the request. It is safe to delete the fetcher from within a
35 // completion callback. Must be used from a thread running a message loop.
36 // The public method is virtual to allow for mocking and fakes.
37 class HostListFetcher : public net::URLFetcherDelegate {
38 public:
39 HostListFetcher();
40 ~HostListFetcher() override;
42 // Supplied by the client for each hostlist request and returns a valid,
43 // initialized Hostlist object on success.
44 typedef base::Callback<void(const std::vector<HostInfo>& hostlist)>
45 HostlistCallback;
47 // Makes a service call to retrieve a hostlist. The
48 // callback will be called once the HTTP request has completed.
49 virtual void RetrieveHostlist(const std::string& access_token,
50 const HostlistCallback& callback);
52 private:
53 // Processes the response from the directory service.
54 bool ProcessResponse(std::vector<HostInfo>* hostlist);
56 // net::URLFetcherDelegate interface.
57 void OnURLFetchComplete(const net::URLFetcher* source) override;
59 // Holds the URLFetcher for the Host List request.
60 scoped_ptr<net::URLFetcher> request_;
62 // Provides application-specific context for the network request.
63 scoped_refptr<remoting::URLRequestContextGetter> request_context_getter_;
65 // Caller-supplied callback used to return hostlist on success.
66 HostlistCallback hostlist_callback_;
68 DISALLOW_COPY_AND_ASSIGN(HostListFetcher);
71 } // namespace test
72 } // namespace remoting
74 #endif // REMOTING_TEST_HOST_LIST_FETCHER_H_