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