| OLD | NEW |
| 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 "net/url_request/url_request_context.h" | 5 #include "net/url_request/url_request_context.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/debug/alias.h" | 8 #include "base/debug/alias.h" |
| 9 #include "base/debug/stack_trace.h" | 9 #include "base/debug/stack_trace.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 const GURL& url, | 74 const GURL& url, |
| 75 RequestPriority priority, | 75 RequestPriority priority, |
| 76 URLRequest::Delegate* delegate) const { | 76 URLRequest::Delegate* delegate) const { |
| 77 return scoped_ptr<URLRequest>(new URLRequest(url, priority, delegate, this)); | 77 return scoped_ptr<URLRequest>(new URLRequest(url, priority, delegate, this)); |
| 78 } | 78 } |
| 79 | 79 |
| 80 void URLRequestContext::set_cookie_store(CookieStore* cookie_store) { | 80 void URLRequestContext::set_cookie_store(CookieStore* cookie_store) { |
| 81 cookie_store_ = cookie_store; | 81 cookie_store_ = cookie_store; |
| 82 } | 82 } |
| 83 | 83 |
| 84 std::string URLRequestContext::GetAcceptLanguage() const { | |
| 85 return http_user_agent_settings_ ? | |
| 86 http_user_agent_settings_->GetAcceptLanguage() : std::string(); | |
| 87 } | |
| 88 | |
| 89 std::string URLRequestContext::GetUserAgent(const GURL& url) const { | |
| 90 return http_user_agent_settings_ ? | |
| 91 http_user_agent_settings_->GetUserAgent(url) : std::string(); | |
| 92 } | |
| 93 | |
| 94 void URLRequestContext::AssertNoURLRequests() const { | 84 void URLRequestContext::AssertNoURLRequests() const { |
| 95 int num_requests = url_requests_->size(); | 85 int num_requests = url_requests_->size(); |
| 96 if (num_requests != 0) { | 86 if (num_requests != 0) { |
| 97 // We're leaking URLRequests :( Dump the URL of the first one and record how | 87 // We're leaking URLRequests :( Dump the URL of the first one and record how |
| 98 // many we leaked so we have an idea of how bad it is. | 88 // many we leaked so we have an idea of how bad it is. |
| 99 char url_buf[128]; | 89 char url_buf[128]; |
| 100 const URLRequest* request = *url_requests_->begin(); | 90 const URLRequest* request = *url_requests_->begin(); |
| 101 base::strlcpy(url_buf, request->url().spec().c_str(), arraysize(url_buf)); | 91 base::strlcpy(url_buf, request->url().spec().c_str(), arraysize(url_buf)); |
| 102 bool has_delegate = request->has_delegate(); | 92 bool has_delegate = request->has_delegate(); |
| 103 int load_flags = request->load_flags(); | 93 int load_flags = request->load_flags(); |
| 104 base::debug::StackTrace stack_trace(NULL, 0); | 94 base::debug::StackTrace stack_trace(NULL, 0); |
| 105 if (request->stack_trace()) | 95 if (request->stack_trace()) |
| 106 stack_trace = *request->stack_trace(); | 96 stack_trace = *request->stack_trace(); |
| 107 base::debug::Alias(url_buf); | 97 base::debug::Alias(url_buf); |
| 108 base::debug::Alias(&num_requests); | 98 base::debug::Alias(&num_requests); |
| 109 base::debug::Alias(&has_delegate); | 99 base::debug::Alias(&has_delegate); |
| 110 base::debug::Alias(&load_flags); | 100 base::debug::Alias(&load_flags); |
| 111 base::debug::Alias(&stack_trace); | 101 base::debug::Alias(&stack_trace); |
| 112 CHECK(false) << "Leaked " << num_requests << " URLRequest(s). First URL: " | 102 CHECK(false) << "Leaked " << num_requests << " URLRequest(s). First URL: " |
| 113 << request->url().spec().c_str() << "."; | 103 << request->url().spec().c_str() << "."; |
| 114 } | 104 } |
| 115 } | 105 } |
| 116 | 106 |
| 117 } // namespace net | 107 } // namespace net |
| OLD | NEW |