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

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

Issue 10185007: [net] Change order of RequestPriority to natural: higher > lower (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed left-over comment Created 8 years, 8 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 | « no previous file | net/base/prioritized_dispatcher.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 (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/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 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 return highest_priority_; 382 return highest_priority_;
383 } 383 }
384 384
385 size_t total_count() const { 385 size_t total_count() const {
386 return total_count_; 386 return total_count_;
387 } 387 }
388 388
389 void Add(RequestPriority req_priority) { 389 void Add(RequestPriority req_priority) {
390 ++total_count_; 390 ++total_count_;
391 ++counts_[req_priority]; 391 ++counts_[req_priority];
392 if (highest_priority_ > req_priority) 392 if (highest_priority_ < req_priority)
393 highest_priority_ = req_priority; 393 highest_priority_ = req_priority;
394 } 394 }
395 395
396 void Remove(RequestPriority req_priority) { 396 void Remove(RequestPriority req_priority) {
397 DCHECK_GT(total_count_, 0u); 397 DCHECK_GT(total_count_, 0u);
398 DCHECK_GT(counts_[req_priority], 0u); 398 DCHECK_GT(counts_[req_priority], 0u);
399 --total_count_; 399 --total_count_;
400 --counts_[req_priority]; 400 --counts_[req_priority];
401 size_t i; 401 size_t i;
402 for (i = highest_priority_; i < NUM_PRIORITIES && !counts_[i]; ++i); 402 for (i = highest_priority_; i > MINIMUM_PRIORITY && !counts_[i]; --i);
403 highest_priority_ = static_cast<RequestPriority>(i); 403 highest_priority_ = static_cast<RequestPriority>(i);
404 404
405 // In absence of requests set default. 405 // In absence of requests, default to MINIMUM_PRIORITY.
406 if (highest_priority_ == NUM_PRIORITIES) { 406 if (total_count_ == 0)
407 DCHECK_EQ(0u, total_count_); 407 DCHECK_EQ(MINIMUM_PRIORITY, highest_priority_);
408 highest_priority_ = IDLE;
409 }
410 } 408 }
411 409
412 private: 410 private:
413 RequestPriority highest_priority_; 411 RequestPriority highest_priority_;
414 size_t total_count_; 412 size_t total_count_;
415 size_t counts_[NUM_PRIORITIES]; 413 size_t counts_[NUM_PRIORITIES];
416 }; 414 };
417 415
418 //----------------------------------------------------------------------------- 416 //-----------------------------------------------------------------------------
419 417
(...skipping 1533 matching lines...) Expand 10 before | Expand all | Expand 10 after
1953 1951
1954 if (self && dns_config.IsValid()) 1952 if (self && dns_config.IsValid())
1955 TryServingAllJobsFromHosts(); 1953 TryServingAllJobsFromHosts();
1956 } 1954 }
1957 1955
1958 bool HostResolverImpl::HaveDnsConfig() const { 1956 bool HostResolverImpl::HaveDnsConfig() const {
1959 return (dns_client_.get() != NULL) && (dns_client_->GetConfig() != NULL); 1957 return (dns_client_.get() != NULL) && (dns_client_->GetConfig() != NULL);
1960 } 1958 }
1961 1959
1962 } // namespace net 1960 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/base/prioritized_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698