| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 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_HOST_URL_FETCHER_H_ | |
| 6 #define REMOTING_HOST_URL_FETCHER_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/callback_forward.h" | |
| 12 #include "base/memory/ref_counted.h" | |
| 13 | |
| 14 class GURL; | |
| 15 | |
| 16 namespace net { | |
| 17 class URLRequestContextGetter; | |
| 18 class URLRequestStatus; | |
| 19 } // namespace net | |
| 20 | |
| 21 namespace remoting { | |
| 22 | |
| 23 // UrlFetcher implements HTTP querying functionality that is used in | |
| 24 // remoting code (e.g. in GaiaOAuthClient). It takes care of switching | |
| 25 // threads when neccessary and provides interface that is simpler to | |
| 26 // use than net::UrlRequest. | |
| 27 // | |
| 28 // This code is a simplified version of content::UrlFetcher from | |
| 29 // content/common/net. It implements only features that remoting code | |
| 30 // needs. | |
| 31 class UrlFetcher { | |
| 32 public: | |
| 33 enum Method { | |
| 34 GET, | |
| 35 POST, | |
| 36 }; | |
| 37 | |
| 38 typedef base::Callback<void(const net::URLRequestStatus& status, | |
| 39 int response_code, | |
| 40 const std::string& response)> | |
| 41 DoneCallback; | |
| 42 | |
| 43 UrlFetcher(const GURL& url, Method method); | |
| 44 ~UrlFetcher(); | |
| 45 | |
| 46 void SetRequestContext( | |
| 47 net::URLRequestContextGetter* request_context_getter); | |
| 48 void SetUploadData(const std::string& upload_content_type, | |
| 49 const std::string& upload_content); | |
| 50 void SetHeader(const std::string& key, const std::string& value); | |
| 51 void Start(const DoneCallback& done_callback); | |
| 52 | |
| 53 private: | |
| 54 // Ref-counted core of the implementation. | |
| 55 class Core; | |
| 56 | |
| 57 scoped_refptr<Core> core_; | |
| 58 | |
| 59 DISALLOW_COPY_AND_ASSIGN(UrlFetcher); | |
| 60 }; | |
| 61 | |
| 62 } // namespace remoting | |
| 63 | |
| 64 #endif // REMOTING_HOST_URL_FETCHER_H_ | |
| OLD | NEW |