OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "net/url_request/url_request.h" | 5 #include "net/url_request/url_request.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/singleton.h" | 9 #include "base/singleton.h" |
10 #include "base/stats_counters.h" | 10 #include "base/stats_counters.h" |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 StartJob(GetJobManager()->CreateJob(this)); | 253 StartJob(GetJobManager()->CreateJob(this)); |
254 } | 254 } |
255 | 255 |
256 /////////////////////////////////////////////////////////////////////////////// | 256 /////////////////////////////////////////////////////////////////////////////// |
257 | 257 |
258 void URLRequest::StartJob(URLRequestJob* job) { | 258 void URLRequest::StartJob(URLRequestJob* job) { |
259 DCHECK(!is_pending_); | 259 DCHECK(!is_pending_); |
260 DCHECK(!job_); | 260 DCHECK(!job_); |
261 | 261 |
262 net_log_.BeginEventWithString(net::NetLog::TYPE_URL_REQUEST_START, | 262 net_log_.BeginEventWithString(net::NetLog::TYPE_URL_REQUEST_START, |
263 original_url().possibly_invalid_spec()); | 263 "url", original_url().possibly_invalid_spec()); |
264 | 264 |
265 job_ = job; | 265 job_ = job; |
266 job_->SetExtraRequestHeaders(extra_request_headers_); | 266 job_->SetExtraRequestHeaders(extra_request_headers_); |
267 | 267 |
268 if (upload_.get()) | 268 if (upload_.get()) |
269 job_->SetUpload(upload_.get()); | 269 job_->SetUpload(upload_.get()); |
270 | 270 |
271 is_pending_ = true; | 271 is_pending_ = true; |
272 | 272 |
273 response_info_.request_time = Time::Now(); | 273 response_info_.request_time = Time::Now(); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 if (job) { | 361 if (job) { |
362 RestartWithJob(job); | 362 RestartWithJob(job); |
363 } else if (delegate_) { | 363 } else if (delegate_) { |
364 delegate_->OnReceivedRedirect(this, location, defer_redirect); | 364 delegate_->OnReceivedRedirect(this, location, defer_redirect); |
365 } | 365 } |
366 } | 366 } |
367 | 367 |
368 void URLRequest::ResponseStarted() { | 368 void URLRequest::ResponseStarted() { |
369 if (!status_.is_success()) { | 369 if (!status_.is_success()) { |
370 net_log_.EndEventWithInteger(net::NetLog::TYPE_URL_REQUEST_START, | 370 net_log_.EndEventWithInteger(net::NetLog::TYPE_URL_REQUEST_START, |
371 status_.os_error()); | 371 "net_error", status_.os_error()); |
372 } else { | 372 } else { |
373 net_log_.EndEvent(net::NetLog::TYPE_URL_REQUEST_START); | 373 net_log_.EndEvent(net::NetLog::TYPE_URL_REQUEST_START); |
374 } | 374 } |
375 | 375 |
376 URLRequestJob* job = GetJobManager()->MaybeInterceptResponse(this); | 376 URLRequestJob* job = GetJobManager()->MaybeInterceptResponse(this); |
377 if (job) { | 377 if (job) { |
378 RestartWithJob(job); | 378 RestartWithJob(job); |
379 } else if (delegate_) { | 379 } else if (delegate_) { |
380 delegate_->OnResponseStarted(this); | 380 delegate_->OnResponseStarted(this); |
381 } | 381 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 "content-type", | 438 "content-type", |
439 "content-length", | 439 "content-length", |
440 "origin" | 440 "origin" |
441 }; | 441 }; |
442 return net::HttpUtil::StripHeaders( | 442 return net::HttpUtil::StripHeaders( |
443 headers, kPostHeaders, arraysize(kPostHeaders)); | 443 headers, kPostHeaders, arraysize(kPostHeaders)); |
444 } | 444 } |
445 | 445 |
446 int URLRequest::Redirect(const GURL& location, int http_status_code) { | 446 int URLRequest::Redirect(const GURL& location, int http_status_code) { |
447 if (net_log_.HasListener()) { | 447 if (net_log_.HasListener()) { |
448 net_log_.AddString(StringPrintf("Redirected (%d) to %s", | 448 net_log_.AddEventWithString(net::NetLog::TYPE_URL_REQUEST_REDIRECTED, |
449 http_status_code, location.spec().c_str())); | 449 "location", location.possibly_invalid_spec()); |
450 } | 450 } |
451 if (redirect_limit_ <= 0) { | 451 if (redirect_limit_ <= 0) { |
452 DLOG(INFO) << "disallowing redirect: exceeds limit"; | 452 DLOG(INFO) << "disallowing redirect: exceeds limit"; |
453 return net::ERR_TOO_MANY_REDIRECTS; | 453 return net::ERR_TOO_MANY_REDIRECTS; |
454 } | 454 } |
455 | 455 |
456 if (!location.is_valid()) | 456 if (!location.is_valid()) |
457 return net::ERR_INVALID_URL; | 457 return net::ERR_INVALID_URL; |
458 | 458 |
459 if (!job_->IsSafeRedirect(location)) { | 459 if (!job_->IsSafeRedirect(location)) { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 URLRequest::UserData* URLRequest::GetUserData(const void* key) const { | 534 URLRequest::UserData* URLRequest::GetUserData(const void* key) const { |
535 UserDataMap::const_iterator found = user_data_.find(key); | 535 UserDataMap::const_iterator found = user_data_.find(key); |
536 if (found != user_data_.end()) | 536 if (found != user_data_.end()) |
537 return found->second.get(); | 537 return found->second.get(); |
538 return NULL; | 538 return NULL; |
539 } | 539 } |
540 | 540 |
541 void URLRequest::SetUserData(const void* key, UserData* data) { | 541 void URLRequest::SetUserData(const void* key, UserData* data) { |
542 user_data_[key] = linked_ptr<UserData>(data); | 542 user_data_[key] = linked_ptr<UserData>(data); |
543 } | 543 } |
OLD | NEW |