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