Chromium Code Reviews| 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 #ifndef CONTENT_PUBLIC_COMMON_URL_FETCHER_H_ | 5 #ifndef CONTENT_PUBLIC_COMMON_URL_FETCHER_H_ |
| 6 #define CONTENT_PUBLIC_COMMON_URL_FETCHER_H_ | 6 #define CONTENT_PUBLIC_COMMON_URL_FETCHER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "content/common/content_export.h" | 9 #include "content/common/content_export.h" |
| 10 #include "net/url_request/url_fetcher.h" | 10 #include "net/url_request/url_fetcher.h" |
| 11 | 11 |
| 12 namespace content { | 12 namespace content { |
| 13 | 13 |
| 14 class URLFetcherDelegate; | 14 class URLFetcherDelegate; |
| 15 | 15 |
| 16 // Extend net::URLFetcher to add content-specific methods. | 16 // TODO(akalin): Move the static functions to net::URLFetcher and |
| 17 // | 17 // remove content::URLFetcher. |
| 18 // TODO(akalin): Move some more content-specific methods from | |
| 19 // net::URLFetcher. | |
| 20 class CONTENT_EXPORT URLFetcher : public net::URLFetcher { | 18 class CONTENT_EXPORT URLFetcher : public net::URLFetcher { |
| 21 public: | 19 public: |
| 22 // TODO(akalin): Move the static functions to net::URLFetcher. | |
| 23 | |
| 24 // |url| is the URL to send the request to. | 20 // |url| is the URL to send the request to. |
| 25 // |request_type| is the type of request to make. | 21 // |request_type| is the type of request to make. |
| 26 // |d| the object that will receive the callback on fetch completion. | 22 // |d| the object that will receive the callback on fetch completion. |
| 27 static URLFetcher* Create(const GURL& url, | 23 static URLFetcher* Create(const GURL& url, |
| 28 RequestType request_type, | 24 RequestType request_type, |
| 29 URLFetcherDelegate* d); | 25 URLFetcherDelegate* d); |
| 30 | 26 |
| 31 // Like above, but if there's a URLFetcherFactory registered with the | 27 // Like above, but if there's a URLFetcherFactory registered with the |
| 32 // implementation it will be used. |id| may be used during testing to identify | 28 // implementation it will be used. |id| may be used during testing to identify |
| 33 // who is creating the URLFetcher. | 29 // who is creating the URLFetcher. |
| 34 static URLFetcher* Create(int id, | 30 static URLFetcher* Create(int id, |
| 35 const GURL& url, | 31 const GURL& url, |
| 36 RequestType request_type, | 32 RequestType request_type, |
| 37 URLFetcherDelegate* d); | 33 URLFetcherDelegate* d); |
| 38 | 34 |
| 39 // Cancels all existing URLFetchers. Will notify the URLFetcherDelegates. | 35 // Cancels all existing URLFetchers. Will notify the URLFetcherDelegates. |
| 40 // Note that any new URLFetchers created while this is running will not be | 36 // Note that any new URLFetchers created while this is running will not be |
| 41 // cancelled. Typically, one would call this in the CleanUp() method of an IO | 37 // cancelled. Typically, one would call this in the CleanUp() method of an IO |
| 42 // thread, so that no new URLRequests would be able to start on the IO thread | 38 // thread, so that no new URLRequests would be able to start on the IO thread |
| 43 // anyway. This doesn't prevent new URLFetchers from trying to post to the IO | 39 // anyway. This doesn't prevent new URLFetchers from trying to post to the IO |
| 44 // thread though, even though the task won't ever run. | 40 // thread though, even though the task won't ever run. |
| 45 static void CancelAll(); | 41 static void CancelAll(); |
| 46 | 42 |
| 47 // Normally interception is disabled for URLFetcher, but you can use this | 43 // Normally interception is disabled for URLFetcher, but you can use this |
| 48 // to enable it for tests. Also see ScopedURLFetcherFactory for another way | 44 // to enable it for tests. Also see ScopedURLFetcherFactory for another way |
| 49 // of testing code that uses an URLFetcher. | 45 // of testing code that uses an URLFetcher. |
| 50 static void SetEnableInterceptionForTests(bool enabled); | 46 static void SetEnableInterceptionForTests(bool enabled); |
| 47 }; | |
| 51 | 48 |
| 52 // Mark URLRequests started by the URLFetcher to stem from the given render | 49 // Mark URLRequests started by the URLFetcher to stem from the given render |
| 53 // view. | 50 // view. |
| 54 virtual void AssociateWithRenderView(const GURL& first_party_for_cookies, | 51 void CONTENT_EXPORT AssociateWithRenderView( |
|
jam
2012/05/21 21:39:19
nit: convention is CONTENT_EXPORT void
since this
akalin
2012/05/21 22:28:37
Done.
| |
| 55 int render_process_id, | 52 net::URLFetcher* url_fetcher, |
| 56 int render_view_id) = 0; | 53 const GURL& first_party_for_cookies, |
| 57 }; | 54 int render_process_id, |
| 55 int render_view_id); | |
| 58 | 56 |
| 59 } // namespace content | 57 } // namespace content |
| 60 | 58 |
| 61 #endif // CONTENT_PUBLIC_COMMON_URL_FETCHER_H_ | 59 #endif // CONTENT_PUBLIC_COMMON_URL_FETCHER_H_ |
| OLD | NEW |