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