| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // This file contains URLFetcher, a wrapper around net::URLRequest that handles | 5 // This file contains URLFetcher, a wrapper around net::URLRequest that handles |
| 6 // low-level details like thread safety, ref counting, and incremental buffer | 6 // low-level details like thread safety, ref counting, and incremental buffer |
| 7 // reading. This is useful for callers who simply want to get the data from a | 7 // reading. This is useful for callers who simply want to get the data from a |
| 8 // URL and don't care about all the nitty-gritty details. | 8 // URL and don't care about all the nitty-gritty details. |
| 9 // | 9 // |
| 10 // NOTE(willchan): Only one "IO" thread is supported for URLFetcher. This is a | 10 // NOTE(willchan): Only one "IO" thread is supported for URLFetcher. This is a |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 class URLFetcherFactory; | 26 class URLFetcherFactory; |
| 27 } // namespace content | 27 } // namespace content |
| 28 | 28 |
| 29 class CONTENT_EXPORT URLFetcherImpl : public content::URLFetcher { | 29 class CONTENT_EXPORT URLFetcherImpl : public content::URLFetcher { |
| 30 public: | 30 public: |
| 31 // |url| is the URL to send the request to. | 31 // |url| is the URL to send the request to. |
| 32 // |request_type| is the type of request to make. | 32 // |request_type| is the type of request to make. |
| 33 // |d| the object that will receive the callback on fetch completion. | 33 // |d| the object that will receive the callback on fetch completion. |
| 34 URLFetcherImpl(const GURL& url, | 34 URLFetcherImpl(const GURL& url, |
| 35 RequestType request_type, | 35 RequestType request_type, |
| 36 content::URLFetcherDelegate* d); | 36 net::URLFetcherDelegate* d); |
| 37 virtual ~URLFetcherImpl(); | 37 virtual ~URLFetcherImpl(); |
| 38 | 38 |
| 39 // content::URLFetcher implementation: | 39 // content::URLFetcher implementation: |
| 40 virtual void SetUploadData(const std::string& upload_content_type, | 40 virtual void SetUploadData(const std::string& upload_content_type, |
| 41 const std::string& upload_content) OVERRIDE; | 41 const std::string& upload_content) OVERRIDE; |
| 42 virtual void SetChunkedUpload( | 42 virtual void SetChunkedUpload( |
| 43 const std::string& upload_content_type) OVERRIDE; | 43 const std::string& upload_content_type) OVERRIDE; |
| 44 virtual void AppendChunkToUpload(const std::string& data, | 44 virtual void AppendChunkToUpload(const std::string& data, |
| 45 bool is_last_chunk) OVERRIDE; | 45 bool is_last_chunk) OVERRIDE; |
| 46 virtual void SetLoadFlags(int load_flags) OVERRIDE; | 46 virtual void SetLoadFlags(int load_flags) OVERRIDE; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 virtual bool GetResponseAsString( | 82 virtual bool GetResponseAsString( |
| 83 std::string* out_response_string) const OVERRIDE; | 83 std::string* out_response_string) const OVERRIDE; |
| 84 virtual bool GetResponseAsFilePath( | 84 virtual bool GetResponseAsFilePath( |
| 85 bool take_ownership, | 85 bool take_ownership, |
| 86 FilePath* out_response_path) const OVERRIDE; | 86 FilePath* out_response_path) const OVERRIDE; |
| 87 | 87 |
| 88 static void CancelAll(); | 88 static void CancelAll(); |
| 89 | 89 |
| 90 protected: | 90 protected: |
| 91 // Returns the delegate. | 91 // Returns the delegate. |
| 92 content::URLFetcherDelegate* delegate() const; | 92 net::URLFetcherDelegate* delegate() const; |
| 93 | 93 |
| 94 private: | 94 private: |
| 95 friend class ScopedURLFetcherFactory; | 95 friend class ScopedURLFetcherFactory; |
| 96 friend class TestURLFetcher; | 96 friend class TestURLFetcher; |
| 97 friend class URLFetcherTest; | 97 friend class URLFetcherTest; |
| 98 | 98 |
| 99 // Only used by URLFetcherTest, returns the number of URLFetcher::Core objects | 99 // Only used by URLFetcherTest, returns the number of URLFetcher::Core objects |
| 100 // actively running. | 100 // actively running. |
| 101 static int GetNumFetcherCores(); | 101 static int GetNumFetcherCores(); |
| 102 | 102 |
| 103 static content::URLFetcherFactory* factory(); | 103 static content::URLFetcherFactory* factory(); |
| 104 | 104 |
| 105 // Sets the factory used by the static method Create to create a URLFetcher. | 105 // Sets the factory used by the static method Create to create a URLFetcher. |
| 106 // URLFetcher does not take ownership of |factory|. A value of NULL results | 106 // URLFetcher does not take ownership of |factory|. A value of NULL results |
| 107 // in a URLFetcher being created directly. | 107 // in a URLFetcher being created directly. |
| 108 // | 108 // |
| 109 // NOTE: for safety, this should only be used through ScopedURLFetcherFactory! | 109 // NOTE: for safety, this should only be used through ScopedURLFetcherFactory! |
| 110 static void set_factory(content::URLFetcherFactory* factory); | 110 static void set_factory(content::URLFetcherFactory* factory); |
| 111 | 111 |
| 112 const scoped_refptr<content::URLFetcherCore> core_; | 112 const scoped_refptr<content::URLFetcherCore> core_; |
| 113 | 113 |
| 114 DISALLOW_COPY_AND_ASSIGN(URLFetcherImpl); | 114 DISALLOW_COPY_AND_ASSIGN(URLFetcherImpl); |
| 115 }; | 115 }; |
| 116 | 116 |
| 117 #endif // CONTENT_COMMON_NET_URL_FETCHER_IMPL_H_ | 117 #endif // CONTENT_COMMON_NET_URL_FETCHER_IMPL_H_ |
| OLD | NEW |