Adding grunell@ as owner of chrome/browser/resources/hangout_services.
[chromium-blink-merge.git] / remoting / test / remote_host_info_fetcher.h
blob984e375cb285ee5dc5d3eea6ea3b58719ebbb6ab
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_REMOTE_HOST_INFO_FETCHER_H_
6 #define REMOTING_TEST_REMOTE_HOST_INFO_FETCHER_H_
8 #include <string>
10 #include "base/callback.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "net/url_request/url_fetcher_delegate.h"
14 #include "remoting/test/app_remoting_service_urls.h"
15 #include "remoting/test/remote_host_info.h"
17 namespace net {
18 class UrlFetcher;
20 namespace remoting {
21 class URLRequestContextGetter;
24 namespace remoting {
25 namespace test {
27 // Supplied by the client for each remote host info request and returns a valid,
28 // initialized RemoteHostInfo object on success.
29 typedef base::Callback<void(const RemoteHostInfo& remote_host_info)>
30 RemoteHostInfoCallback;
32 // Calls the App Remoting service API to request connection info for a remote
33 // host. 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 an IO message loop.
36 // The public method is virtual to allow for mocking and fakes.
37 class RemoteHostInfoFetcher : public net::URLFetcherDelegate {
38 public:
39 RemoteHostInfoFetcher();
40 ~RemoteHostInfoFetcher() override;
42 // Makes a service call to retrieve the details for a remote host. The
43 // callback will be called once the HTTP request has completed.
44 virtual bool RetrieveRemoteHostInfo(const std::string& application_id,
45 const std::string& access_token,
46 ServiceEnvironment service_environment,
47 const RemoteHostInfoCallback& callback);
49 private:
50 // net::URLFetcherDelegate interface.
51 void OnURLFetchComplete(const net::URLFetcher* source) override;
53 // Holds the URLFetcher for the RemoteHostInfo request.
54 scoped_ptr<net::URLFetcher> request_;
56 // Provides application-specific context for the network request.
57 scoped_refptr<remoting::URLRequestContextGetter> request_context_getter_;
59 // Caller-supplied callback used to return remote host info on success.
60 RemoteHostInfoCallback remote_host_info_callback_;
62 DISALLOW_COPY_AND_ASSIGN(RemoteHostInfoFetcher);
65 } // namespace test
66 } // namespace remoting
68 #endif // REMOTING_TEST_REMOTE_HOST_INFO_FETCHER_H_