Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Side by Side Diff: net/url_request/url_request_context.cc

Issue 2414883005: TEMP DO NOT LAND (Closed)
Patch Set: temp Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "net/cookies/cookie_store.h" 11 #include "net/cookies/cookie_store.h"
12 #include "net/dns/host_resolver.h" 12 #include "net/dns/host_resolver.h"
13 #include "net/http/http_transaction_factory.h" 13 #include "net/http/http_transaction_factory.h"
14 #include "net/url_request/http_user_agent_settings.h" 14 #include "net/url_request/http_user_agent_settings.h"
15 #include "net/url_request/url_request.h" 15 #include "net/url_request/url_request.h"
16 16
17 #include "base/trace_event/memory_dump_manager.h"
18 #include "base/strings/stringprintf.h"
19
17 namespace net { 20 namespace net {
18 21
19 URLRequestContext::URLRequestContext() 22 URLRequestContext::URLRequestContext()
20 : net_log_(nullptr), 23 : net_log_(nullptr),
21 host_resolver_(nullptr), 24 host_resolver_(nullptr),
22 cert_verifier_(nullptr), 25 cert_verifier_(nullptr),
23 channel_id_service_(nullptr), 26 channel_id_service_(nullptr),
24 http_auth_handler_factory_(nullptr), 27 http_auth_handler_factory_(nullptr),
25 proxy_service_(nullptr), 28 proxy_service_(nullptr),
26 network_delegate_(nullptr), 29 network_delegate_(nullptr),
27 http_server_properties_(nullptr), 30 http_server_properties_(nullptr),
28 http_user_agent_settings_(nullptr), 31 http_user_agent_settings_(nullptr),
29 cookie_store_(nullptr), 32 cookie_store_(nullptr),
30 transport_security_state_(nullptr), 33 transport_security_state_(nullptr),
31 cert_transparency_verifier_(nullptr), 34 cert_transparency_verifier_(nullptr),
32 ct_policy_enforcer_(nullptr), 35 ct_policy_enforcer_(nullptr),
33 http_transaction_factory_(nullptr), 36 http_transaction_factory_(nullptr),
34 job_factory_(nullptr), 37 job_factory_(nullptr),
35 throttler_manager_(nullptr), 38 throttler_manager_(nullptr),
36 backoff_manager_(nullptr), 39 backoff_manager_(nullptr),
37 sdch_manager_(nullptr), 40 sdch_manager_(nullptr),
38 network_quality_estimator_(nullptr), 41 network_quality_estimator_(nullptr),
39 url_requests_(new std::set<const URLRequest*>), 42 url_requests_(new std::set<const URLRequest*>),
40 enable_brotli_(false) {} 43 enable_brotli_(false) {
44 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
45 this, "URLRequestContext", base::ThreadTaskRunnerHandle::Get());
46 }
41 47
42 URLRequestContext::~URLRequestContext() { 48 URLRequestContext::~URLRequestContext() {
43 AssertNoURLRequests(); 49 AssertNoURLRequests();
50 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider(
51 this);
44 } 52 }
45 53
46 void URLRequestContext::CopyFrom(const URLRequestContext* other) { 54 void URLRequestContext::CopyFrom(const URLRequestContext* other) {
47 // Copy URLRequestContext parameters. 55 // Copy URLRequestContext parameters.
48 set_net_log(other->net_log_); 56 set_net_log(other->net_log_);
49 set_host_resolver(other->host_resolver_); 57 set_host_resolver(other->host_resolver_);
50 set_cert_verifier(other->cert_verifier_); 58 set_cert_verifier(other->cert_verifier_);
51 set_channel_id_service(other->channel_id_service_); 59 set_channel_id_service(other->channel_id_service_);
52 set_http_auth_handler_factory(other->http_auth_handler_factory_); 60 set_http_auth_handler_factory(other->http_auth_handler_factory_);
53 set_proxy_service(other->proxy_service_); 61 set_proxy_service(other->proxy_service_);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 base::strlcpy(url_buf, request->url().spec().c_str(), arraysize(url_buf)); 109 base::strlcpy(url_buf, request->url().spec().c_str(), arraysize(url_buf));
102 int load_flags = request->load_flags(); 110 int load_flags = request->load_flags();
103 base::debug::Alias(url_buf); 111 base::debug::Alias(url_buf);
104 base::debug::Alias(&num_requests); 112 base::debug::Alias(&num_requests);
105 base::debug::Alias(&load_flags); 113 base::debug::Alias(&load_flags);
106 CHECK(false) << "Leaked " << num_requests << " URLRequest(s). First URL: " 114 CHECK(false) << "Leaked " << num_requests << " URLRequest(s). First URL: "
107 << request->url().spec().c_str() << "."; 115 << request->url().spec().c_str() << ".";
108 } 116 }
109 } 117 }
110 118
119 bool URLRequestContext::OnMemoryDump(
120 const base::trace_event::MemoryDumpArgs& args,
121 base::trace_event::ProcessMemoryDump* pmd) {
122 if (name_string_.empty())
123 name_string_ = "uninitialized";
124 base::trace_event::MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(
125 base::StringPrintf("url_request_context/%p_%s",
126 this, name_string_.c_str()));
127 for (auto url_request : *url_requests_.get()) {
128 //url_request->PopulateAllocatorDump(dump);
129 DCHECK(url_request);
130 }
131
132 HttpTransactionFactory* transaction_factory = http_transaction_factory();
133 if (transaction_factory) {
134 HttpNetworkSession* network_session = transaction_factory->GetSession();
135 if (network_session)
136 network_session->PopulateAllocatorDump(dump);
137 }
138
139 return true;
140 }
141
111 } // namespace net 142 } // namespace net
OLDNEW
« net/http/http_network_session.cc ('K') | « net/url_request/url_request_context.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698