Chromium Code Reviews| Index: remoting/test/chromoting_host_list_fetcher.h |
| diff --git a/remoting/test/chromoting_host_list_fetcher.h b/remoting/test/chromoting_host_list_fetcher.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c3d8da245719c4c48bd97bcdc0a9f78775c99f1e |
| --- /dev/null |
| +++ b/remoting/test/chromoting_host_list_fetcher.h |
| @@ -0,0 +1,71 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef REMOTING_TEST_CHROMOTING_HOST_LIST_FETCHER_H_ |
| +#define REMOTING_TEST_CHROMOTING_HOST_LIST_FETCHER_H_ |
| + |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "base/callback.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "net/url_request/url_fetcher_delegate.h" |
| +#include "remoting/test/chromoting_host_info.h" |
| + |
| +namespace net { |
| +class UrlFetcher; |
| +} |
| +namespace remoting { |
| +class URLRequestContextGetter; |
| +} |
| + |
| +namespace remoting { |
| +namespace test { |
| + |
| +// Used by the HostlistFetcher to make HTTP requests and also by the |
| +// unittests for this class to set fake response data for these URLs. |
| +const char kChromotingHostListProdRequestUrl[] = "https://www.googleapis.com/" |
| + "chromoting/v1/@me/hosts"; |
| + |
| +// Supplied by the client for each hostlist request and returns a valid, |
| +// initialized Hostlist object on success. |
| +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.
|
| + HostlistCallback; |
| + |
| +// 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
|
| +// Destroying the RemoteHostInfoFetcher while a request is outstanding |
| +// will cancel the request. It is safe to delete the fetcher from within a |
| +// completion callback. Must be used from a thread running an IO message loop. |
| +// The public method is virtual to allow for mocking and fakes. |
| +class ChromotingHostListFetcher : public net::URLFetcherDelegate { |
| + public: |
| + ChromotingHostListFetcher(); |
| + ~ChromotingHostListFetcher() override; |
| + |
| + // 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.
|
| + // callback will be called once the HTTP request has completed. |
| + virtual bool RetrieveHostlist(const std::string& access_token, |
| + const HostlistCallback& callback); |
| + |
| + private: |
| + // net::URLFetcherDelegate interface. |
| + void OnURLFetchComplete(const net::URLFetcher* source) override; |
| + |
| + // 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.
|
| + scoped_ptr<net::URLFetcher> request_; |
| + |
| + // Provides application-specific context for the network request. |
| + 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
|
| + |
| + // Caller-supplied callback used to return hostlist on success. |
| + HostlistCallback hostlist_callback_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ChromotingHostListFetcher); |
| +}; |
| + |
| +} // namespace test |
| +} // namespace remoting |
| + |
| +#endif // REMOTING_TEST_CHROMOTING_HOST_LIST_FETCHER_H_ |