Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Side by Side Diff: net/url_request/url_fetcher_impl.cc

Issue 10534154: Move URLFetcherImpl to net/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix windows link error Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/url_request/url_fetcher_impl.h ('k') | net/url_request/url_fetcher_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "content/common/net/url_fetcher_impl.h" 5 #include "net/url_request/url_fetcher_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop_proxy.h" 8 #include "base/message_loop_proxy.h"
9 #include "content/common/net/url_request_user_data.h"
10 #include "net/url_request/url_fetcher_core.h" 9 #include "net/url_request/url_fetcher_core.h"
11 #include "net/url_request/url_fetcher_factory.h" 10 #include "net/url_request/url_fetcher_factory.h"
12 11
13 static net::URLFetcherFactory* g_factory = NULL; 12 namespace net {
14 13
15 // static 14 static URLFetcherFactory* g_factory = NULL;
16 net::URLFetcher* content::URLFetcher::Create(
17 const GURL& url,
18 net::URLFetcher::RequestType request_type,
19 net::URLFetcherDelegate* d) {
20 return new URLFetcherImpl(url, request_type, d);
21 }
22
23 // static
24 net::URLFetcher* content::URLFetcher::Create(
25 int id,
26 const GURL& url,
27 net::URLFetcher::RequestType request_type,
28 net::URLFetcherDelegate* d) {
29 return g_factory ? g_factory->CreateURLFetcher(id, url, request_type, d) :
30 new URLFetcherImpl(url, request_type, d);
31 }
32
33 // static
34 void content::URLFetcher::CancelAll() {
35 URLFetcherImpl::CancelAll();
36 }
37
38 // static
39 void content::URLFetcher::SetEnableInterceptionForTests(bool enabled) {
40 net::URLFetcherCore::SetEnableInterceptionForTests(enabled);
41 }
42
43 namespace {
44
45 base::SupportsUserData::Data* CreateURLRequestUserData(
46 int render_process_id,
47 int render_view_id) {
48 return new URLRequestUserData(render_process_id, render_view_id);
49 }
50
51 } // namespace
52
53 namespace content {
54
55 void AssociateURLFetcherWithRenderView(net::URLFetcher* url_fetcher,
56 const GURL& first_party_for_cookies,
57 int render_process_id,
58 int render_view_id) {
59 url_fetcher->SetFirstPartyForCookies(first_party_for_cookies);
60 url_fetcher->SetURLRequestUserData(
61 URLRequestUserData::kUserDataKey,
62 base::Bind(&CreateURLRequestUserData,
63 render_process_id, render_view_id));
64 }
65
66 } // namespace content
67 15
68 URLFetcherImpl::URLFetcherImpl(const GURL& url, 16 URLFetcherImpl::URLFetcherImpl(const GURL& url,
69 RequestType request_type, 17 RequestType request_type,
70 net::URLFetcherDelegate* d) 18 URLFetcherDelegate* d)
71 : ALLOW_THIS_IN_INITIALIZER_LIST( 19 : ALLOW_THIS_IN_INITIALIZER_LIST(
72 core_(new net::URLFetcherCore(this, url, request_type, d))) { 20 core_(new URLFetcherCore(this, url, request_type, d))) {
73 } 21 }
74 22
75 URLFetcherImpl::~URLFetcherImpl() { 23 URLFetcherImpl::~URLFetcherImpl() {
76 core_->Stop(); 24 core_->Stop();
77 } 25 }
78 26
79 void URLFetcherImpl::SetUploadData(const std::string& upload_content_type, 27 void URLFetcherImpl::SetUploadData(const std::string& upload_content_type,
80 const std::string& upload_content) { 28 const std::string& upload_content) {
81 core_->SetUploadData(upload_content_type, upload_content); 29 core_->SetUploadData(upload_content_type, upload_content);
82 } 30 }
(...skipping 23 matching lines...) Expand all
106 void URLFetcherImpl::SetExtraRequestHeaders( 54 void URLFetcherImpl::SetExtraRequestHeaders(
107 const std::string& extra_request_headers) { 55 const std::string& extra_request_headers) {
108 core_->SetExtraRequestHeaders(extra_request_headers); 56 core_->SetExtraRequestHeaders(extra_request_headers);
109 } 57 }
110 58
111 void URLFetcherImpl::AddExtraRequestHeader(const std::string& header_line) { 59 void URLFetcherImpl::AddExtraRequestHeader(const std::string& header_line) {
112 core_->AddExtraRequestHeader(header_line); 60 core_->AddExtraRequestHeader(header_line);
113 } 61 }
114 62
115 void URLFetcherImpl::GetExtraRequestHeaders( 63 void URLFetcherImpl::GetExtraRequestHeaders(
116 net::HttpRequestHeaders* headers) const { 64 HttpRequestHeaders* headers) const {
117 GetExtraRequestHeaders(headers); 65 GetExtraRequestHeaders(headers);
118 } 66 }
119 67
120 void URLFetcherImpl::SetRequestContext( 68 void URLFetcherImpl::SetRequestContext(
121 net::URLRequestContextGetter* request_context_getter) { 69 URLRequestContextGetter* request_context_getter) {
122 core_->SetRequestContext(request_context_getter); 70 core_->SetRequestContext(request_context_getter);
123 } 71 }
124 72
125 void URLFetcherImpl::SetFirstPartyForCookies( 73 void URLFetcherImpl::SetFirstPartyForCookies(
126 const GURL& first_party_for_cookies) { 74 const GURL& first_party_for_cookies) {
127 core_->SetFirstPartyForCookies(first_party_for_cookies); 75 core_->SetFirstPartyForCookies(first_party_for_cookies);
128 } 76 }
129 77
130 void URLFetcherImpl::SetURLRequestUserData( 78 void URLFetcherImpl::SetURLRequestUserData(
131 const void* key, 79 const void* key,
(...skipping 26 matching lines...) Expand all
158 const FilePath& file_path, 106 const FilePath& file_path,
159 scoped_refptr<base::MessageLoopProxy> file_message_loop_proxy) { 107 scoped_refptr<base::MessageLoopProxy> file_message_loop_proxy) {
160 core_->SaveResponseToFileAtPath(file_path, file_message_loop_proxy); 108 core_->SaveResponseToFileAtPath(file_path, file_message_loop_proxy);
161 } 109 }
162 110
163 void URLFetcherImpl::SaveResponseToTemporaryFile( 111 void URLFetcherImpl::SaveResponseToTemporaryFile(
164 scoped_refptr<base::MessageLoopProxy> file_message_loop_proxy) { 112 scoped_refptr<base::MessageLoopProxy> file_message_loop_proxy) {
165 core_->SaveResponseToTemporaryFile(file_message_loop_proxy); 113 core_->SaveResponseToTemporaryFile(file_message_loop_proxy);
166 } 114 }
167 115
168 net::HttpResponseHeaders* URLFetcherImpl::GetResponseHeaders() const { 116 HttpResponseHeaders* URLFetcherImpl::GetResponseHeaders() const {
169 return core_->GetResponseHeaders(); 117 return core_->GetResponseHeaders();
170 } 118 }
171 119
172 net::HostPortPair URLFetcherImpl::GetSocketAddress() const { 120 HostPortPair URLFetcherImpl::GetSocketAddress() const {
173 return core_->GetSocketAddress(); 121 return core_->GetSocketAddress();
174 } 122 }
175 123
176 bool URLFetcherImpl::WasFetchedViaProxy() const { 124 bool URLFetcherImpl::WasFetchedViaProxy() const {
177 return core_->WasFetchedViaProxy(); 125 return core_->WasFetchedViaProxy();
178 } 126 }
179 127
180 void URLFetcherImpl::Start() { 128 void URLFetcherImpl::Start() {
181 core_->Start(); 129 core_->Start();
182 } 130 }
183 131
184 const GURL& URLFetcherImpl::GetOriginalURL() const { 132 const GURL& URLFetcherImpl::GetOriginalURL() const {
185 return core_->GetOriginalURL(); 133 return core_->GetOriginalURL();
186 } 134 }
187 135
188 const GURL& URLFetcherImpl::GetURL() const { 136 const GURL& URLFetcherImpl::GetURL() const {
189 return core_->GetURL(); 137 return core_->GetURL();
190 } 138 }
191 139
192 const net::URLRequestStatus& URLFetcherImpl::GetStatus() const { 140 const URLRequestStatus& URLFetcherImpl::GetStatus() const {
193 return core_->GetStatus(); 141 return core_->GetStatus();
194 } 142 }
195 143
196 int URLFetcherImpl::GetResponseCode() const { 144 int URLFetcherImpl::GetResponseCode() const {
197 return core_->GetResponseCode(); 145 return core_->GetResponseCode();
198 } 146 }
199 147
200 const net::ResponseCookies& URLFetcherImpl::GetCookies() const { 148 const ResponseCookies& URLFetcherImpl::GetCookies() const {
201 return core_->GetCookies(); 149 return core_->GetCookies();
202 } 150 }
203 151
204 bool URLFetcherImpl::FileErrorOccurred( 152 bool URLFetcherImpl::FileErrorOccurred(
205 base::PlatformFileError* out_error_code) const { 153 base::PlatformFileError* out_error_code) const {
206 return core_->FileErrorOccurred(out_error_code); 154 return core_->FileErrorOccurred(out_error_code);
207 } 155 }
208 156
209 void URLFetcherImpl::ReceivedContentWasMalformed() { 157 void URLFetcherImpl::ReceivedContentWasMalformed() {
210 core_->ReceivedContentWasMalformed(); 158 core_->ReceivedContentWasMalformed();
211 } 159 }
212 160
213 bool URLFetcherImpl::GetResponseAsString( 161 bool URLFetcherImpl::GetResponseAsString(
214 std::string* out_response_string) const { 162 std::string* out_response_string) const {
215 return core_->GetResponseAsString(out_response_string); 163 return core_->GetResponseAsString(out_response_string);
216 } 164 }
217 165
218 bool URLFetcherImpl::GetResponseAsFilePath( 166 bool URLFetcherImpl::GetResponseAsFilePath(
219 bool take_ownership, 167 bool take_ownership,
220 FilePath* out_response_path) const { 168 FilePath* out_response_path) const {
221 return core_->GetResponseAsFilePath(take_ownership, out_response_path); 169 return core_->GetResponseAsFilePath(take_ownership, out_response_path);
222 } 170 }
223 171
224 // static 172 // static
225 void URLFetcherImpl::CancelAll() { 173 void URLFetcherImpl::CancelAll() {
226 net::URLFetcherCore::CancelAll(); 174 URLFetcherCore::CancelAll();
175 }
176
177 // static
178 void URLFetcherImpl::SetEnableInterceptionForTests(bool enabled) {
179 URLFetcherCore::SetEnableInterceptionForTests(enabled);
227 } 180 }
228 181
229 // static 182 // static
230 int URLFetcherImpl::GetNumFetcherCores() { 183 int URLFetcherImpl::GetNumFetcherCores() {
231 return net::URLFetcherCore::GetNumFetcherCores(); 184 return URLFetcherCore::GetNumFetcherCores();
232 } 185 }
233 186
234 net::URLFetcherDelegate* URLFetcherImpl::delegate() const { 187 URLFetcherDelegate* URLFetcherImpl::delegate() const {
235 return core_->delegate(); 188 return core_->delegate();
236 } 189 }
237 190
238 // static 191 // static
239 net::URLFetcherFactory* URLFetcherImpl::factory() { 192 URLFetcherFactory* URLFetcherImpl::factory() {
240 return g_factory; 193 return g_factory;
241 } 194 }
242 195
243 // static 196 // static
244 void URLFetcherImpl::set_factory(net::URLFetcherFactory* factory) { 197 void URLFetcherImpl::set_factory(URLFetcherFactory* factory) {
245 g_factory = factory; 198 g_factory = factory;
246 } 199 }
200
201 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_fetcher_impl.h ('k') | net/url_request/url_fetcher_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698