| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 URLRequest that handles | 5 // This file contains URLFetcher, a wrapper around 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 #ifndef CHROME_BROWSER_URL_FETCHER_H_ | 10 #ifndef CHROME_BROWSER_URL_FETCHER_H_ |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 // This will be called when the URL has been fetched, successfully or not. | 68 // This will be called when the URL has been fetched, successfully or not. |
| 69 // |response_code| is the HTTP response code (200, 404, etc.) if | 69 // |response_code| is the HTTP response code (200, 404, etc.) if |
| 70 // applicable. |url|, |status| and |data| are all valid until the | 70 // applicable. |url|, |status| and |data| are all valid until the |
| 71 // URLFetcher instance is destroyed. | 71 // URLFetcher instance is destroyed. |
| 72 virtual void OnURLFetchComplete(const URLFetcher* source, | 72 virtual void OnURLFetchComplete(const URLFetcher* source, |
| 73 const GURL& url, | 73 const GURL& url, |
| 74 const URLRequestStatus& status, | 74 const URLRequestStatus& status, |
| 75 int response_code, | 75 int response_code, |
| 76 const ResponseCookies& cookies, | 76 const ResponseCookies& cookies, |
| 77 const std::string& data) = 0; | 77 const std::string& data) = 0; |
| 78 protected: | |
| 79 ~Delegate() {} | |
| 80 }; | 78 }; |
| 81 | 79 |
| 82 // URLFetcher::Create uses the currently registered Factory to create the | 80 // URLFetcher::Create uses the currently registered Factory to create the |
| 83 // URLFetcher. Factory is intended for testing. | 81 // URLFetcher. Factory is intended for testing. |
| 84 class Factory { | 82 class Factory { |
| 85 public: | 83 public: |
| 86 virtual URLFetcher* CreateURLFetcher(int id, | 84 virtual URLFetcher* CreateURLFetcher(int id, |
| 87 const GURL& url, | 85 const GURL& url, |
| 88 RequestType request_type, | 86 RequestType request_type, |
| 89 Delegate* d) = 0; | 87 Delegate* d) = 0; |
| 90 protected: | |
| 91 ~Factory() {} | |
| 92 }; | 88 }; |
| 93 | 89 |
| 94 // |url| is the URL to send the request to. | 90 // |url| is the URL to send the request to. |
| 95 // |request_type| is the type of request to make. | 91 // |request_type| is the type of request to make. |
| 96 // |d| the object that will receive the callback on fetch completion. | 92 // |d| the object that will receive the callback on fetch completion. |
| 97 URLFetcher(const GURL& url, RequestType request_type, Delegate* d); | 93 URLFetcher(const GURL& url, RequestType request_type, Delegate* d); |
| 98 | 94 |
| 99 virtual ~URLFetcher(); | 95 virtual ~URLFetcher(); |
| 100 | 96 |
| 101 // Sets the factory used by the static method Create to create a URLFetcher. | 97 // Sets the factory used by the static method Create to create a URLFetcher. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 scoped_refptr<Core> core_; | 163 scoped_refptr<Core> core_; |
| 168 | 164 |
| 169 static Factory* factory_; | 165 static Factory* factory_; |
| 170 | 166 |
| 171 base::LeakTracker<URLFetcher> leak_tracker_; | 167 base::LeakTracker<URLFetcher> leak_tracker_; |
| 172 | 168 |
| 173 DISALLOW_EVIL_CONSTRUCTORS(URLFetcher); | 169 DISALLOW_EVIL_CONSTRUCTORS(URLFetcher); |
| 174 }; | 170 }; |
| 175 | 171 |
| 176 #endif // CHROME_BROWSER_URL_FETCHER_H_ | 172 #endif // CHROME_BROWSER_URL_FETCHER_H_ |
| OLD | NEW |