| 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_factory.h" | |
| 10 #include "net/url_request/url_fetcher_impl.h" | |
| 11 | |
| 12 // static | |
| 13 net::URLFetcher* content::URLFetcher::Create( | |
| 14 const GURL& url, | |
| 15 net::URLFetcher::RequestType request_type, | |
| 16 net::URLFetcherDelegate* d) { | |
| 17 return new net::URLFetcherImpl(url, request_type, d); | |
| 18 } | |
| 19 | |
| 20 // static | |
| 21 net::URLFetcher* content::URLFetcher::Create( | |
| 22 int id, | |
| 23 const GURL& url, | |
| 24 net::URLFetcher::RequestType request_type, | |
| 25 net::URLFetcherDelegate* d) { | |
| 26 net::URLFetcherFactory* factory = net::URLFetcherImpl::factory(); | |
| 27 return factory ? factory->CreateURLFetcher(id, url, request_type, d) : | |
| 28 new net::URLFetcherImpl(url, request_type, d); | |
| 29 } | |
| 30 | |
| 31 // static | |
| 32 void content::URLFetcher::CancelAll() { | |
| 33 net::URLFetcherImpl::CancelAll(); | |
| 34 } | |
| 35 | |
| 36 // static | |
| 37 void content::URLFetcher::SetEnableInterceptionForTests(bool enabled) { | |
| 38 net::URLFetcherImpl::SetEnableInterceptionForTests(enabled); | |
| 39 } | |
| 40 | |
| 41 namespace { | |
| 42 | |
| 43 base::SupportsUserData::Data* CreateURLRequestUserData( | |
| 44 int render_process_id, | |
| 45 int render_view_id) { | |
| 46 return new URLRequestUserData(render_process_id, render_view_id); | |
| 47 } | |
| 48 | |
| 49 } // namespace | |
| 50 | |
| 51 namespace content { | |
| 52 | |
| 53 void AssociateURLFetcherWithRenderView(net::URLFetcher* url_fetcher, | |
| 54 const GURL& first_party_for_cookies, | |
| 55 int render_process_id, | |
| 56 int render_view_id) { | |
| 57 url_fetcher->SetFirstPartyForCookies(first_party_for_cookies); | |
| 58 url_fetcher->SetURLRequestUserData( | |
| 59 URLRequestUserData::kUserDataKey, | |
| 60 base::Bind(&CreateURLRequestUserData, | |
| 61 render_process_id, render_view_id)); | |
| 62 } | |
| 63 | |
| 64 } // namespace content | |
| OLD | NEW |