OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "content/public/common/url_fetcher.h" | |
6 | |
7 #include "base/bind.h" | |
8 #include "content/common/net/url_request_user_data.h" | |
9 #include "net/url_request/url_fetcher_core.h" | |
10 #include "net/url_request/url_fetcher_factory.h" | |
11 #include "net/url_request/url_fetcher_impl.h" | |
12 | |
13 // static | |
14 net::URLFetcher* content::URLFetcher::Create( | |
15 const GURL& url, | |
16 net::URLFetcher::RequestType request_type, | |
17 net::URLFetcherDelegate* d) { | |
18 return new net::URLFetcherImpl(url, request_type, d); | |
19 } | |
20 | |
21 // static | |
22 net::URLFetcher* content::URLFetcher::Create( | |
23 int id, | |
24 const GURL& url, | |
25 net::URLFetcher::RequestType request_type, | |
26 net::URLFetcherDelegate* d) { | |
27 net::URLFetcherFactory* const factory = net::URLFetcherImpl::factory(); | |
wtc
2012/06/14 19:52:28
Nit: the use of 'const' here seems a little excess
akalin
2012/06/15 03:42:16
Done.
| |
28 return factory ? factory->CreateURLFetcher(id, url, request_type, d) : | |
29 new net::URLFetcherImpl(url, request_type, d); | |
30 } | |
31 | |
32 // static | |
33 void content::URLFetcher::CancelAll() { | |
34 net::URLFetcherImpl::CancelAll(); | |
35 } | |
36 | |
37 // static | |
38 void content::URLFetcher::SetEnableInterceptionForTests(bool enabled) { | |
39 net::URLFetcherCore::SetEnableInterceptionForTests(enabled); | |
40 } | |
41 | |
42 namespace { | |
43 | |
44 base::SupportsUserData::Data* CreateURLRequestUserData( | |
45 int render_process_id, | |
46 int render_view_id) { | |
47 return new URLRequestUserData(render_process_id, render_view_id); | |
48 } | |
49 | |
50 } // namespace | |
51 | |
52 namespace content { | |
53 | |
54 void AssociateURLFetcherWithRenderView(net::URLFetcher* url_fetcher, | |
55 const GURL& first_party_for_cookies, | |
56 int render_process_id, | |
57 int render_view_id) { | |
58 url_fetcher->SetFirstPartyForCookies(first_party_for_cookies); | |
59 url_fetcher->SetURLRequestUserData( | |
60 URLRequestUserData::kUserDataKey, | |
61 base::Bind(&CreateURLRequestUserData, | |
62 render_process_id, render_view_id)); | |
63 } | |
64 | |
65 } // namespace content | |
OLD | NEW |