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

Side by Side Diff: net/proxy/mojo_proxy_resolver_factory_impl.cc

Issue 2391453002: Remove stl_util's deletion functions from net/proxy/. (Closed)
Patch Set: fixes 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
« no previous file with comments | « net/proxy/mojo_proxy_resolver_factory_impl.h ('k') | net/proxy/mojo_proxy_resolver_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/proxy/mojo_proxy_resolver_factory_impl.h" 5 #include "net/proxy/mojo_proxy_resolver_factory_impl.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/stl_util.h"
13 #include "mojo/public/cpp/bindings/strong_binding.h" 12 #include "mojo/public/cpp/bindings/strong_binding.h"
14 #include "net/base/net_errors.h" 13 #include "net/base/net_errors.h"
15 #include "net/proxy/mojo_proxy_resolver_impl.h" 14 #include "net/proxy/mojo_proxy_resolver_impl.h"
16 #include "net/proxy/mojo_proxy_resolver_v8_tracing_bindings.h" 15 #include "net/proxy/mojo_proxy_resolver_v8_tracing_bindings.h"
17 #include "net/proxy/proxy_resolver_factory.h" 16 #include "net/proxy/proxy_resolver_factory.h"
18 #include "net/proxy/proxy_resolver_v8_tracing.h" 17 #include "net/proxy/proxy_resolver_v8_tracing.h"
19 18
20 namespace net { 19 namespace net {
21 20
22 class MojoProxyResolverFactoryImpl::Job { 21 class MojoProxyResolverFactoryImpl::Job {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 } 84 }
86 85
87 MojoProxyResolverFactoryImpl::MojoProxyResolverFactoryImpl( 86 MojoProxyResolverFactoryImpl::MojoProxyResolverFactoryImpl(
88 std::unique_ptr<ProxyResolverV8TracingFactory> proxy_resolver_factory) 87 std::unique_ptr<ProxyResolverV8TracingFactory> proxy_resolver_factory)
89 : proxy_resolver_impl_factory_(std::move(proxy_resolver_factory)) {} 88 : proxy_resolver_impl_factory_(std::move(proxy_resolver_factory)) {}
90 89
91 MojoProxyResolverFactoryImpl::MojoProxyResolverFactoryImpl() 90 MojoProxyResolverFactoryImpl::MojoProxyResolverFactoryImpl()
92 : MojoProxyResolverFactoryImpl(ProxyResolverV8TracingFactory::Create()) {} 91 : MojoProxyResolverFactoryImpl(ProxyResolverV8TracingFactory::Create()) {}
93 92
94 MojoProxyResolverFactoryImpl::~MojoProxyResolverFactoryImpl() { 93 MojoProxyResolverFactoryImpl::~MojoProxyResolverFactoryImpl() {
95 base::STLDeleteElements(&jobs_);
96 } 94 }
97 95
98 void MojoProxyResolverFactoryImpl::CreateResolver( 96 void MojoProxyResolverFactoryImpl::CreateResolver(
99 const mojo::String& pac_script, 97 const mojo::String& pac_script,
100 mojo::InterfaceRequest<interfaces::ProxyResolver> request, 98 mojo::InterfaceRequest<interfaces::ProxyResolver> request,
101 interfaces::ProxyResolverFactoryRequestClientPtr client) { 99 interfaces::ProxyResolverFactoryRequestClientPtr client) {
102 // The Job will call RemoveJob on |this| when either the create request 100 // The Job will call RemoveJob on |this| when either the create request
103 // finishes or |request| or |client| encounters a connection error. 101 // finishes or |request| or |client| encounters a connection error.
104 jobs_.insert(new Job( 102 std::unique_ptr<Job> job = base::MakeUnique<Job>(
105 this, ProxyResolverScriptData::FromUTF8(pac_script.To<std::string>()), 103 this, ProxyResolverScriptData::FromUTF8(pac_script.To<std::string>()),
106 proxy_resolver_impl_factory_.get(), std::move(request), 104 proxy_resolver_impl_factory_.get(), std::move(request),
107 std::move(client))); 105 std::move(client));
106 Job* job_ptr = job.get();
107 jobs_[job_ptr] = std::move(job);
108 } 108 }
109 109
110 void MojoProxyResolverFactoryImpl::RemoveJob(Job* job) { 110 void MojoProxyResolverFactoryImpl::RemoveJob(Job* job) {
111 size_t erased = jobs_.erase(job); 111 auto it = jobs_.find(job);
112 DCHECK_EQ(1u, erased); 112 DCHECK(it != jobs_.end());
113 delete job; 113 jobs_.erase(it);
114 } 114 }
115 115
116 } // namespace net 116 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/mojo_proxy_resolver_factory_impl.h ('k') | net/proxy/mojo_proxy_resolver_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698