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