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

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

Issue 2315613002: Extracted NetLog class's inner enum types into their own enum classes and (Closed)
Patch Set: Ran "git cl format" on code. Much formatting ensued. Created 4 years, 3 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/proxy/multi_threaded_proxy_resolver.h" 5 #include "net/proxy/multi_threaded_proxy_resolver.h"
6 6
7 #include <deque> 7 #include <deque>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/location.h" 13 #include "base/location.h"
14 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
15 #include "base/stl_util.h" 15 #include "base/stl_util.h"
16 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
17 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
18 #include "base/threading/non_thread_safe.h" 18 #include "base/threading/non_thread_safe.h"
19 #include "base/threading/thread.h" 19 #include "base/threading/thread.h"
20 #include "base/threading/thread_restrictions.h" 20 #include "base/threading/thread_restrictions.h"
21 #include "base/threading/thread_task_runner_handle.h" 21 #include "base/threading/thread_task_runner_handle.h"
22 #include "net/base/net_errors.h" 22 #include "net/base/net_errors.h"
23 #include "net/log/net_log.h" 23 #include "net/log/net_log.h"
24 #include "net/log/net_log_event_type.h"
24 #include "net/proxy/proxy_info.h" 25 #include "net/proxy/proxy_info.h"
25 #include "net/proxy/proxy_resolver.h" 26 #include "net/proxy/proxy_resolver.h"
26 27
27 namespace net { 28 namespace net {
28 namespace { 29 namespace {
29 class Job; 30 class Job;
30 31
31 // An "executor" is a job-runner for PAC requests. It encapsulates a worker 32 // An "executor" is a job-runner for PAC requests. It encapsulates a worker
32 // thread and a synchronous ProxyResolver (which will be operated on said 33 // thread and a synchronous ProxyResolver (which will be operated on said
33 // thread.) 34 // thread.)
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 net_log_(net_log), 288 net_log_(net_log),
288 url_(url), 289 url_(url),
289 was_waiting_for_thread_(false) { 290 was_waiting_for_thread_(false) {
290 DCHECK(!callback.is_null()); 291 DCHECK(!callback.is_null());
291 } 292 }
292 293
293 BoundNetLog* net_log() { return &net_log_; } 294 BoundNetLog* net_log() { return &net_log_; }
294 295
295 void WaitingForThread() override { 296 void WaitingForThread() override {
296 was_waiting_for_thread_ = true; 297 was_waiting_for_thread_ = true;
297 net_log_.BeginEvent(NetLog::TYPE_WAITING_FOR_PROXY_RESOLVER_THREAD); 298 net_log_.BeginEvent(NetLogEventType::WAITING_FOR_PROXY_RESOLVER_THREAD);
298 } 299 }
299 300
300 void FinishedWaitingForThread() override { 301 void FinishedWaitingForThread() override {
301 DCHECK(executor()); 302 DCHECK(executor());
302 303
303 if (was_waiting_for_thread_) { 304 if (was_waiting_for_thread_) {
304 net_log_.EndEvent(NetLog::TYPE_WAITING_FOR_PROXY_RESOLVER_THREAD); 305 net_log_.EndEvent(NetLogEventType::WAITING_FOR_PROXY_RESOLVER_THREAD);
305 } 306 }
306 307
307 net_log_.AddEvent( 308 net_log_.AddEvent(
308 NetLog::TYPE_SUBMITTED_TO_RESOLVER_THREAD, 309 NetLogEventType::SUBMITTED_TO_RESOLVER_THREAD,
309 NetLog::IntCallback("thread_number", executor()->thread_number())); 310 NetLog::IntCallback("thread_number", executor()->thread_number()));
310 } 311 }
311 312
312 // Runs on the worker thread. 313 // Runs on the worker thread.
313 void Run(scoped_refptr<base::SingleThreadTaskRunner> origin_runner) override { 314 void Run(scoped_refptr<base::SingleThreadTaskRunner> origin_runner) override {
314 ProxyResolver* resolver = executor()->resolver(); 315 ProxyResolver* resolver = executor()->resolver();
315 DCHECK(resolver); 316 DCHECK(resolver);
316 int rv = resolver->GetProxyForURL( 317 int rv = resolver->GetProxyForURL(
317 url_, &results_buf_, CompletionCallback(), NULL, net_log_); 318 url_, &results_buf_, CompletionCallback(), NULL, net_log_);
318 DCHECK_NE(rv, ERR_IO_PENDING); 319 DCHECK_NE(rv, ERR_IO_PENDING);
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 return ERR_IO_PENDING; 625 return ERR_IO_PENDING;
625 } 626 }
626 627
627 void MultiThreadedProxyResolverFactory::RemoveJob( 628 void MultiThreadedProxyResolverFactory::RemoveJob(
628 MultiThreadedProxyResolverFactory::Job* job) { 629 MultiThreadedProxyResolverFactory::Job* job) {
629 size_t erased = jobs_.erase(job); 630 size_t erased = jobs_.erase(job);
630 DCHECK_EQ(1u, erased); 631 DCHECK_EQ(1u, erased);
631 } 632 }
632 633
633 } // namespace net 634 } // namespace net
OLDNEW
« no previous file with comments | « net/log/write_to_file_net_log_observer_unittest.cc ('k') | net/proxy/multi_threaded_proxy_resolver_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698