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

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

Issue 8533011: Remove unused HostResolver::Observer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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>
(...skipping 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 req->request_net_log().EndEvent( 1255 req->request_net_log().EndEvent(
1256 NetLog::TYPE_HOST_RESOLVER_IMPL_JOB_ATTACH, NULL); 1256 NetLog::TYPE_HOST_RESOLVER_IMPL_JOB_ATTACH, NULL);
1257 } 1257 }
1258 1258
1259 // NULL out the fields of req, to mark it as cancelled. 1259 // NULL out the fields of req, to mark it as cancelled.
1260 req->MarkAsCancelled(); 1260 req->MarkAsCancelled();
1261 OnCancelRequest(req->source_net_log(), req->request_net_log(), req->id(), 1261 OnCancelRequest(req->source_net_log(), req->request_net_log(), req->id(),
1262 req->info()); 1262 req->info());
1263 } 1263 }
1264 1264
1265 void HostResolverImpl::AddObserver(HostResolver::Observer* observer) {
1266 DCHECK(CalledOnValidThread());
1267 observers_.push_back(observer);
1268 }
1269
1270 void HostResolverImpl::RemoveObserver(HostResolver::Observer* observer) {
1271 DCHECK(CalledOnValidThread());
1272 ObserversList::iterator it =
1273 std::find(observers_.begin(), observers_.end(), observer);
1274
1275 // Observer must exist.
1276 DCHECK(it != observers_.end());
1277
1278 observers_.erase(it);
1279 }
1280
1281 void HostResolverImpl::SetDefaultAddressFamily(AddressFamily address_family) { 1265 void HostResolverImpl::SetDefaultAddressFamily(AddressFamily address_family) {
1282 DCHECK(CalledOnValidThread()); 1266 DCHECK(CalledOnValidThread());
1283 ipv6_probe_monitoring_ = false; 1267 ipv6_probe_monitoring_ = false;
1284 DiscardIPv6ProbeJob(); 1268 DiscardIPv6ProbeJob();
1285 default_address_family_ = address_family; 1269 default_address_family_ = address_family;
1286 } 1270 }
1287 1271
1288 AddressFamily HostResolverImpl::GetDefaultAddressFamily() const { 1272 AddressFamily HostResolverImpl::GetDefaultAddressFamily() const {
1289 return default_address_family_; 1273 return default_address_family_;
1290 } 1274 }
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1436 const RequestInfo& info) { 1420 const RequestInfo& info) {
1437 source_net_log.BeginEvent( 1421 source_net_log.BeginEvent(
1438 NetLog::TYPE_HOST_RESOLVER_IMPL, 1422 NetLog::TYPE_HOST_RESOLVER_IMPL,
1439 make_scoped_refptr(new NetLogSourceParameter( 1423 make_scoped_refptr(new NetLogSourceParameter(
1440 "source_dependency", request_net_log.source()))); 1424 "source_dependency", request_net_log.source())));
1441 1425
1442 request_net_log.BeginEvent( 1426 request_net_log.BeginEvent(
1443 NetLog::TYPE_HOST_RESOLVER_IMPL_REQUEST, 1427 NetLog::TYPE_HOST_RESOLVER_IMPL_REQUEST,
1444 make_scoped_refptr(new RequestInfoParameters( 1428 make_scoped_refptr(new RequestInfoParameters(
1445 info, source_net_log.source()))); 1429 info, source_net_log.source())));
1446
1447 // Notify the observers of the start.
1448 if (!observers_.empty()) {
1449 for (ObserversList::iterator it = observers_.begin();
1450 it != observers_.end(); ++it) {
1451 (*it)->OnStartResolution(request_id, info);
1452 }
1453 }
1454 } 1430 }
1455 1431
1456 void HostResolverImpl::OnFinishRequest(const BoundNetLog& source_net_log, 1432 void HostResolverImpl::OnFinishRequest(const BoundNetLog& source_net_log,
1457 const BoundNetLog& request_net_log, 1433 const BoundNetLog& request_net_log,
1458 int request_id, 1434 int request_id,
1459 const RequestInfo& info, 1435 const RequestInfo& info,
1460 int net_error, 1436 int net_error,
1461 int os_error) { 1437 int os_error) {
1462 bool was_resolved = net_error == OK; 1438 bool was_resolved = net_error == OK;
1463 1439
1464 // Notify the observers of the completion.
1465 if (!observers_.empty()) {
1466 for (ObserversList::iterator it = observers_.begin();
1467 it != observers_.end(); ++it) {
1468 (*it)->OnFinishResolutionWithStatus(request_id, was_resolved, info);
1469 }
1470 }
1471
1472 // Log some extra parameters on failure for synchronous requests. 1440 // Log some extra parameters on failure for synchronous requests.
1473 scoped_refptr<NetLog::EventParameters> params; 1441 scoped_refptr<NetLog::EventParameters> params;
1474 if (!was_resolved) { 1442 if (!was_resolved) {
1475 params = new HostResolveFailedParams(0, net_error, os_error); 1443 params = new HostResolveFailedParams(0, net_error, os_error);
1476 } 1444 }
1477 1445
1478 request_net_log.EndEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_REQUEST, params); 1446 request_net_log.EndEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_REQUEST, params);
1479 source_net_log.EndEvent(NetLog::TYPE_HOST_RESOLVER_IMPL, NULL); 1447 source_net_log.EndEvent(NetLog::TYPE_HOST_RESOLVER_IMPL, NULL);
1480 } 1448 }
1481 1449
1482 void HostResolverImpl::OnCancelRequest(const BoundNetLog& source_net_log, 1450 void HostResolverImpl::OnCancelRequest(const BoundNetLog& source_net_log,
1483 const BoundNetLog& request_net_log, 1451 const BoundNetLog& request_net_log,
1484 int request_id, 1452 int request_id,
1485 const RequestInfo& info) { 1453 const RequestInfo& info) {
1486 request_net_log.AddEvent(NetLog::TYPE_CANCELLED, NULL); 1454 request_net_log.AddEvent(NetLog::TYPE_CANCELLED, NULL);
1487
1488 // Notify the observers of the cancellation.
1489 if (!observers_.empty()) {
1490 for (ObserversList::iterator it = observers_.begin();
1491 it != observers_.end(); ++it) {
1492 (*it)->OnCancelResolution(request_id, info);
1493 }
1494 }
1495
1496 request_net_log.EndEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_REQUEST, NULL); 1455 request_net_log.EndEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_REQUEST, NULL);
1497 source_net_log.EndEvent(NetLog::TYPE_HOST_RESOLVER_IMPL, NULL); 1456 source_net_log.EndEvent(NetLog::TYPE_HOST_RESOLVER_IMPL, NULL);
1498 } 1457 }
1499 1458
1500 void HostResolverImpl::DiscardIPv6ProbeJob() { 1459 void HostResolverImpl::DiscardIPv6ProbeJob() {
1501 if (ipv6_probe_job_.get()) { 1460 if (ipv6_probe_job_.get()) {
1502 ipv6_probe_job_->Cancel(); 1461 ipv6_probe_job_->Cancel();
1503 ipv6_probe_job_ = NULL; 1462 ipv6_probe_job_ = NULL;
1504 } 1463 }
1505 } 1464 }
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1654 // resolv.conf changes so we don't need to do anything to clear that cache. 1613 // resolv.conf changes so we don't need to do anything to clear that cache.
1655 if (cache_.get()) 1614 if (cache_.get())
1656 cache_->clear(); 1615 cache_->clear();
1657 // Existing jobs will have been sent to the original server so they need to 1616 // Existing jobs will have been sent to the original server so they need to
1658 // be aborted. TODO(Craig): Should these jobs be restarted? 1617 // be aborted. TODO(Craig): Should these jobs be restarted?
1659 AbortAllInProgressJobs(); 1618 AbortAllInProgressJobs();
1660 // |this| may be deleted inside AbortAllInProgressJobs(). 1619 // |this| may be deleted inside AbortAllInProgressJobs().
1661 } 1620 }
1662 1621
1663 } // namespace net 1622 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698