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" |
11 #include "net/base/load_flags.h" | 11 #include "net/base/load_flags.h" |
12 #include "net/base/load_log.h" | 12 #include "net/base/load_log.h" |
13 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
14 #include "net/base/ssl_cert_request_info.h" | 14 #include "net/base/ssl_cert_request_info.h" |
15 #include "net/base/upload_data.h" | 15 #include "net/base/upload_data.h" |
16 #include "net/http/http_response_headers.h" | 16 #include "net/http/http_response_headers.h" |
17 #include "net/http/http_util.h" | 17 #include "net/http/http_util.h" |
18 #include "net/url_request/url_request_context.h" | 18 #include "net/url_request/url_request_context.h" |
19 #include "net/url_request/url_request_job.h" | 19 #include "net/url_request/url_request_job.h" |
20 #include "net/url_request/url_request_job_manager.h" | 20 #include "net/url_request/url_request_job_manager.h" |
21 | 21 |
22 using base::Time; | 22 using base::Time; |
23 using net::UploadData; | 23 using net::UploadData; |
24 using std::string; | 24 using std::string; |
25 using std::wstring; | 25 using std::wstring; |
26 | 26 |
27 // Max number of http redirects to follow. Same number as gecko. | 27 // Max number of http redirects to follow. Same number as gecko. |
28 static const int kMaxRedirects = 20; | 28 static const int kMaxRedirects = 20; |
29 | 29 |
| 30 // The maximum size of the passive LoadLog associated with each request. |
| 31 static const int kMaxNumLoadLogEntries = 50; |
| 32 |
30 static URLRequestJobManager* GetJobManager() { | 33 static URLRequestJobManager* GetJobManager() { |
31 return Singleton<URLRequestJobManager>::get(); | 34 return Singleton<URLRequestJobManager>::get(); |
32 } | 35 } |
33 | 36 |
34 /////////////////////////////////////////////////////////////////////////////// | 37 /////////////////////////////////////////////////////////////////////////////// |
35 // URLRequest | 38 // URLRequest |
36 | 39 |
37 URLRequest::URLRequest(const GURL& url, Delegate* delegate) | 40 URLRequest::URLRequest(const GURL& url, Delegate* delegate) |
38 : load_log_(new net::LoadLog), | 41 : load_log_(new net::LoadLog(kMaxNumLoadLogEntries)), |
39 url_(url), | 42 url_(url), |
40 original_url_(url), | 43 original_url_(url), |
41 method_("GET"), | 44 method_("GET"), |
42 load_flags_(net::LOAD_NORMAL), | 45 load_flags_(net::LOAD_NORMAL), |
43 delegate_(delegate), | 46 delegate_(delegate), |
44 is_pending_(false), | 47 is_pending_(false), |
45 enable_profiling_(false), | 48 enable_profiling_(false), |
46 redirect_limit_(kMaxRedirects), | 49 redirect_limit_(kMaxRedirects), |
47 final_upload_progress_(0), | 50 final_upload_progress_(0), |
48 priority_(0), | 51 priority_(0), |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 URLRequest::UserData* URLRequest::GetUserData(const void* key) const { | 512 URLRequest::UserData* URLRequest::GetUserData(const void* key) const { |
510 UserDataMap::const_iterator found = user_data_.find(key); | 513 UserDataMap::const_iterator found = user_data_.find(key); |
511 if (found != user_data_.end()) | 514 if (found != user_data_.end()) |
512 return found->second.get(); | 515 return found->second.get(); |
513 return NULL; | 516 return NULL; |
514 } | 517 } |
515 | 518 |
516 void URLRequest::SetUserData(const void* key, UserData* data) { | 519 void URLRequest::SetUserData(const void* key, UserData* data) { |
517 user_data_[key] = linked_ptr<UserData>(data); | 520 user_data_[key] = linked_ptr<UserData>(data); |
518 } | 521 } |
OLD | NEW |