| 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/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 } | 80 } |
| 81 | 81 |
| 82 std::unique_ptr<URLRequest> URLRequestContext::CreateRequest( | 82 std::unique_ptr<URLRequest> URLRequestContext::CreateRequest( |
| 83 const GURL& url, | 83 const GURL& url, |
| 84 RequestPriority priority, | 84 RequestPriority priority, |
| 85 URLRequest::Delegate* delegate) const { | 85 URLRequest::Delegate* delegate) const { |
| 86 return base::WrapUnique( | 86 return base::WrapUnique( |
| 87 new URLRequest(url, priority, delegate, this, network_delegate_)); | 87 new URLRequest(url, priority, delegate, this, network_delegate_)); |
| 88 } | 88 } |
| 89 | 89 |
| 90 std::unique_ptr<URLRequest> URLRequestContext::CreateRequest( |
| 91 const GURL& url, |
| 92 RequestPriority priority, |
| 93 URLRequest::Delegate* delegate, |
| 94 NetworkTrafficAnnotationTag traffic_classification) const { |
| 95 // traffic_annotation is just a tag that is extracted during static |
| 96 // code analysis and can be ignored here. |
| 97 return CreateRequest(url, priority, delegate); |
| 98 } |
| 99 |
| 90 void URLRequestContext::set_cookie_store(CookieStore* cookie_store) { | 100 void URLRequestContext::set_cookie_store(CookieStore* cookie_store) { |
| 91 cookie_store_ = cookie_store; | 101 cookie_store_ = cookie_store; |
| 92 } | 102 } |
| 93 | 103 |
| 94 void URLRequestContext::AssertNoURLRequests() const { | 104 void URLRequestContext::AssertNoURLRequests() const { |
| 95 int num_requests = url_requests_->size(); | 105 int num_requests = url_requests_->size(); |
| 96 if (num_requests != 0) { | 106 if (num_requests != 0) { |
| 97 // We're leaking URLRequests :( Dump the URL of the first one and record how | 107 // 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. | 108 // many we leaked so we have an idea of how bad it is. |
| 99 char url_buf[128]; | 109 char url_buf[128]; |
| 100 const URLRequest* request = *url_requests_->begin(); | 110 const URLRequest* request = *url_requests_->begin(); |
| 101 base::strlcpy(url_buf, request->url().spec().c_str(), arraysize(url_buf)); | 111 base::strlcpy(url_buf, request->url().spec().c_str(), arraysize(url_buf)); |
| 102 int load_flags = request->load_flags(); | 112 int load_flags = request->load_flags(); |
| 103 base::debug::Alias(url_buf); | 113 base::debug::Alias(url_buf); |
| 104 base::debug::Alias(&num_requests); | 114 base::debug::Alias(&num_requests); |
| 105 base::debug::Alias(&load_flags); | 115 base::debug::Alias(&load_flags); |
| 106 CHECK(false) << "Leaked " << num_requests << " URLRequest(s). First URL: " | 116 CHECK(false) << "Leaked " << num_requests << " URLRequest(s). First URL: " |
| 107 << request->url().spec().c_str() << "."; | 117 << request->url().spec().c_str() << "."; |
| 108 } | 118 } |
| 109 } | 119 } |
| 110 | 120 |
| 111 } // namespace net | 121 } // namespace net |
| OLD | NEW |