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

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

Issue 12088090: Fix a memory error in ProxyResolverV8Tracing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/proxy_resolver_v8_tracing.h" 5 #include "net/proxy/proxy_resolver_v8_tracing.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop_proxy.h" 8 #include "base/message_loop_proxy.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "base/synchronization/cancellation_flag.h" 10 #include "base/synchronization/cancellation_flag.h"
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 } 652 }
653 653
654 void ProxyResolverV8Tracing::Job::DoDnsOperation( 654 void ProxyResolverV8Tracing::Job::DoDnsOperation(
655 const std::string& host, ResolveDnsOperation op, bool* out_cache_hit) { 655 const std::string& host, ResolveDnsOperation op, bool* out_cache_hit) {
656 CheckIsOnOriginThread(); 656 CheckIsOnOriginThread();
657 DCHECK(!pending_dns_); 657 DCHECK(!pending_dns_);
658 658
659 if (cancelled_.IsSet()) 659 if (cancelled_.IsSet())
660 return; 660 return;
661 661
662 HostResolver::RequestHandle dns_request = NULL;
662 int result = host_resolver()->Resolve( 663 int result = host_resolver()->Resolve(
663 MakeDnsRequestInfo(host, op), 664 MakeDnsRequestInfo(host, op),
664 &pending_dns_addresses_, 665 &pending_dns_addresses_,
665 base::Bind(&Job::OnDnsOperationComplete, this), 666 base::Bind(&Job::OnDnsOperationComplete, this),
666 &pending_dns_, 667 &dns_request,
667 bound_net_log_); 668 bound_net_log_);
668 669
669 bool completed_synchronously = result != ERR_IO_PENDING; 670 bool completed_synchronously = result != ERR_IO_PENDING;
670 671
672 // Check if the request was cancelled as a side-effect of calling into the
673 // HostResolver. This isn't the ordinary execution flow, however it is
674 // exercised by unit-tests.
675 if (cancelled_.IsSet()) {
676 if (!completed_synchronously)
677 host_resolver()->CancelRequest(dns_request);
678 return;
679 }
680
681 if (!completed_synchronously) {
682 DCHECK(dns_request);
683 pending_dns_ = dns_request;
mmenke 2013/01/31 21:11:23 This isn't correct. If we're doing a blocking cal
eroman 2013/01/31 21:29:49 Actually it is the DCHECK in OnDnsOperationComplet
mmenke 2013/01/31 21:34:32 You're right. Was thinking that we could just alw
684 }
685
671 if (!blocking_dns_) { 686 if (!blocking_dns_) {
672 // Check if the DNS result can be serviced directly from the cache. 687 // Check if the DNS result can be serviced directly from the cache.
673 // (The worker thread is blocked waiting for this information). 688 // (The worker thread is blocked waiting for this information).
674 if (completed_synchronously) { 689 if (completed_synchronously)
675 SaveDnsToLocalCache(host, op, result, pending_dns_addresses_); 690 SaveDnsToLocalCache(host, op, result, pending_dns_addresses_);
676 pending_dns_ = NULL;
677 }
678 691
679 // Important: Do not read/write |out_cache_hit| after signalling, since 692 // Important: Do not read/write |out_cache_hit| after signalling, since
680 // the memory may no longer be valid. 693 // the memory may no longer be valid.
681 *out_cache_hit = completed_synchronously; 694 *out_cache_hit = completed_synchronously;
682 event_.Signal(); 695 event_.Signal();
683 696
684 if (completed_synchronously) 697 if (completed_synchronously)
685 return; 698 return;
686 } 699 }
687 700
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 DCHECK(!set_pac_script_job_); 988 DCHECK(!set_pac_script_job_);
976 CHECK_EQ(0, num_outstanding_callbacks_); 989 CHECK_EQ(0, num_outstanding_callbacks_);
977 990
978 set_pac_script_job_ = new Job(this); 991 set_pac_script_job_ = new Job(this);
979 set_pac_script_job_->StartSetPacScript(script_data, callback); 992 set_pac_script_job_->StartSetPacScript(script_data, callback);
980 993
981 return ERR_IO_PENDING; 994 return ERR_IO_PENDING;
982 } 995 }
983 996
984 } // namespace net 997 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/proxy/proxy_resolver_v8_tracing_unittest.cc » ('j') | net/proxy/proxy_resolver_v8_tracing_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698