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

Side by Side Diff: net/base/host_resolver_impl.cc

Issue 6079009: Move some misc thread-related stuff from base to base/thread and into the bas... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « net/base/file_stream_posix.cc ('k') | net/base/keygen_handler_unittest.cc » ('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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/base/host_resolver_impl.h" 5 #include "net/base/host_resolver_impl.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <Winsock2.h> 8 #include <Winsock2.h>
9 #elif defined(OS_POSIX) 9 #elif defined(OS_POSIX)
10 #include <netdb.h> 10 #include <netdb.h>
11 #endif 11 #endif
12 12
13 #include <cmath> 13 #include <cmath>
14 #include <deque> 14 #include <deque>
15 #include <vector> 15 #include <vector>
16 16
17 #include "base/basictypes.h" 17 #include "base/basictypes.h"
18 #include "base/compiler_specific.h" 18 #include "base/compiler_specific.h"
19 #include "base/debug/debugger.h" 19 #include "base/debug/debugger.h"
20 #include "base/debug/stack_trace.h" 20 #include "base/debug/stack_trace.h"
21 #include "base/lock.h" 21 #include "base/lock.h"
22 #include "base/message_loop.h" 22 #include "base/message_loop.h"
23 #include "base/metrics/field_trial.h" 23 #include "base/metrics/field_trial.h"
24 #include "base/metrics/histogram.h" 24 #include "base/metrics/histogram.h"
25 #include "base/stl_util-inl.h" 25 #include "base/stl_util-inl.h"
26 #include "base/string_util.h" 26 #include "base/string_util.h"
27 #include "base/threading/worker_pool.h"
27 #include "base/time.h" 28 #include "base/time.h"
28 #include "base/utf_string_conversions.h" 29 #include "base/utf_string_conversions.h"
29 #include "base/values.h" 30 #include "base/values.h"
30 #include "base/worker_pool.h"
31 #include "net/base/address_list.h" 31 #include "net/base/address_list.h"
32 #include "net/base/address_list_net_log_param.h" 32 #include "net/base/address_list_net_log_param.h"
33 #include "net/base/host_port_pair.h" 33 #include "net/base/host_port_pair.h"
34 #include "net/base/host_resolver_proc.h" 34 #include "net/base/host_resolver_proc.h"
35 #include "net/base/net_errors.h" 35 #include "net/base/net_errors.h"
36 #include "net/base/net_log.h" 36 #include "net/base/net_log.h"
37 #include "net/base/net_util.h" 37 #include "net/base/net_util.h"
38 38
39 #if defined(OS_WIN) 39 #if defined(OS_WIN)
40 #include "net/base/winsock_init.h" 40 #include "net/base/winsock_init.h"
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 375
376 if (!req->info().is_speculative()) 376 if (!req->info().is_speculative())
377 had_non_speculative_request_ = true; 377 had_non_speculative_request_ = true;
378 } 378 }
379 379
380 // Called from origin loop. 380 // Called from origin loop.
381 void Start() { 381 void Start() {
382 start_time_ = base::TimeTicks::Now(); 382 start_time_ = base::TimeTicks::Now();
383 383
384 // Dispatch the job to a worker thread. 384 // Dispatch the job to a worker thread.
385 if (!WorkerPool::PostTask(FROM_HERE, 385 if (!base::WorkerPool::PostTask(FROM_HERE,
386 NewRunnableMethod(this, &Job::DoLookup), true)) { 386 NewRunnableMethod(this, &Job::DoLookup), true)) {
387 NOTREACHED(); 387 NOTREACHED();
388 388
389 // Since we could be running within Resolve() right now, we can't just 389 // Since we could be running within Resolve() right now, we can't just
390 // call OnLookupComplete(). Instead we must wait until Resolve() has 390 // call OnLookupComplete(). Instead we must wait until Resolve() has
391 // returned (IO_PENDING). 391 // returned (IO_PENDING).
392 error_ = ERR_UNEXPECTED; 392 error_ = ERR_UNEXPECTED;
393 MessageLoop::current()->PostTask( 393 MessageLoop::current()->PostTask(
394 FROM_HERE, NewRunnableMethod(this, &Job::OnLookupComplete)); 394 FROM_HERE, NewRunnableMethod(this, &Job::OnLookupComplete));
395 } 395 }
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 : resolver_(resolver), 643 : resolver_(resolver),
644 origin_loop_(MessageLoop::current()) { 644 origin_loop_(MessageLoop::current()) {
645 DCHECK(!was_cancelled()); 645 DCHECK(!was_cancelled());
646 } 646 }
647 647
648 void Start() { 648 void Start() {
649 if (was_cancelled()) 649 if (was_cancelled())
650 return; 650 return;
651 DCHECK(IsOnOriginThread()); 651 DCHECK(IsOnOriginThread());
652 const bool kIsSlow = true; 652 const bool kIsSlow = true;
653 WorkerPool::PostTask( 653 base::WorkerPool::PostTask(
654 FROM_HERE, NewRunnableMethod(this, &IPv6ProbeJob::DoProbe), kIsSlow); 654 FROM_HERE, NewRunnableMethod(this, &IPv6ProbeJob::DoProbe), kIsSlow);
655 } 655 }
656 656
657 // Cancels the current job. 657 // Cancels the current job.
658 void Cancel() { 658 void Cancel() {
659 if (was_cancelled()) 659 if (was_cancelled())
660 return; 660 return;
661 DCHECK(IsOnOriginThread()); 661 DCHECK(IsOnOriginThread());
662 resolver_ = NULL; // Read/write ONLY on origin thread. 662 resolver_ = NULL; // Read/write ONLY on origin thread.
663 { 663 {
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
1452 job_pools_[i]->ResetNumOutstandingJobs(); 1452 job_pools_[i]->ResetNumOutstandingJobs();
1453 JobMap jobs; 1453 JobMap jobs;
1454 jobs.swap(jobs_); 1454 jobs.swap(jobs_);
1455 for (JobMap::iterator it = jobs.begin(); it != jobs.end(); ++it) { 1455 for (JobMap::iterator it = jobs.begin(); it != jobs.end(); ++it) {
1456 AbortJob(it->second); 1456 AbortJob(it->second);
1457 it->second->Cancel(); 1457 it->second->Cancel();
1458 } 1458 }
1459 } 1459 }
1460 1460
1461 } // namespace net 1461 } // namespace net
OLDNEW
« no previous file with comments | « net/base/file_stream_posix.cc ('k') | net/base/keygen_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698