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

Side by Side Diff: net/proxy/mojo_proxy_resolver_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_impl.h ('k') | net/proxy/proxy_bypass_rules.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_impl.h" 5 #include "net/proxy/mojo_proxy_resolver_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/stl_util.h"
12 #include "net/base/net_errors.h" 11 #include "net/base/net_errors.h"
13 #include "net/proxy/mojo_proxy_resolver_v8_tracing_bindings.h" 12 #include "net/proxy/mojo_proxy_resolver_v8_tracing_bindings.h"
14 #include "net/proxy/mojo_proxy_type_converters.h" 13 #include "net/proxy/mojo_proxy_type_converters.h"
15 #include "net/proxy/proxy_info.h" 14 #include "net/proxy/proxy_info.h"
16 #include "net/proxy/proxy_resolver_script_data.h" 15 #include "net/proxy/proxy_resolver_script_data.h"
17 #include "net/proxy/proxy_resolver_v8_tracing.h" 16 #include "net/proxy/proxy_resolver_v8_tracing.h"
18 17
19 namespace net { 18 namespace net {
20 19
21 class MojoProxyResolverImpl::Job { 20 class MojoProxyResolverImpl::Job {
(...skipping 21 matching lines...) Expand all
43 bool done_; 42 bool done_;
44 43
45 DISALLOW_COPY_AND_ASSIGN(Job); 44 DISALLOW_COPY_AND_ASSIGN(Job);
46 }; 45 };
47 46
48 MojoProxyResolverImpl::MojoProxyResolverImpl( 47 MojoProxyResolverImpl::MojoProxyResolverImpl(
49 std::unique_ptr<ProxyResolverV8Tracing> resolver) 48 std::unique_ptr<ProxyResolverV8Tracing> resolver)
50 : resolver_(std::move(resolver)) {} 49 : resolver_(std::move(resolver)) {}
51 50
52 MojoProxyResolverImpl::~MojoProxyResolverImpl() { 51 MojoProxyResolverImpl::~MojoProxyResolverImpl() {
53 base::STLDeleteElements(&resolve_jobs_);
54 } 52 }
55 53
56 void MojoProxyResolverImpl::GetProxyForUrl( 54 void MojoProxyResolverImpl::GetProxyForUrl(
57 const GURL& url, 55 const GURL& url,
58 interfaces::ProxyResolverRequestClientPtr client) { 56 interfaces::ProxyResolverRequestClientPtr client) {
59 DVLOG(1) << "GetProxyForUrl(" << url << ")"; 57 DVLOG(1) << "GetProxyForUrl(" << url << ")";
60 Job* job = new Job(std::move(client), this, url); 58 std::unique_ptr<Job> job =
61 bool inserted = resolve_jobs_.insert(job).second; 59 base::MakeUnique<Job>(std::move(client), this, url);
62 DCHECK(inserted); 60 Job* job_ptr = job.get();
63 job->Start(); 61 resolve_jobs_[job_ptr] = std::move(job);
62 job_ptr->Start();
64 } 63 }
65 64
66 void MojoProxyResolverImpl::DeleteJob(Job* job) { 65 void MojoProxyResolverImpl::DeleteJob(Job* job) {
67 size_t num_erased = resolve_jobs_.erase(job); 66 auto it = resolve_jobs_.find(job);
68 DCHECK(num_erased); 67 DCHECK(it != resolve_jobs_.end());
69 delete job; 68 resolve_jobs_.erase(it);
70 } 69 }
71 70
72 MojoProxyResolverImpl::Job::Job( 71 MojoProxyResolverImpl::Job::Job(
73 interfaces::ProxyResolverRequestClientPtr client, 72 interfaces::ProxyResolverRequestClientPtr client,
74 MojoProxyResolverImpl* resolver, 73 MojoProxyResolverImpl* resolver,
75 const GURL& url) 74 const GURL& url)
76 : resolver_(resolver), 75 : resolver_(resolver),
77 client_(std::move(client)), 76 client_(std::move(client)),
78 url_(url), 77 url_(url),
79 request_handle_(nullptr), 78 request_handle_(nullptr),
(...skipping 28 matching lines...) Expand all
108 } 107 }
109 client_->ReportResult(error, std::move(result)); 108 client_->ReportResult(error, std::move(result));
110 resolver_->DeleteJob(this); 109 resolver_->DeleteJob(this);
111 } 110 }
112 111
113 void MojoProxyResolverImpl::Job::OnConnectionError() { 112 void MojoProxyResolverImpl::Job::OnConnectionError() {
114 resolver_->DeleteJob(this); 113 resolver_->DeleteJob(this);
115 } 114 }
116 115
117 } // namespace net 116 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/mojo_proxy_resolver_impl.h ('k') | net/proxy/proxy_bypass_rules.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698