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

Side by Side Diff: net/dns/dns_session_unittest.cc

Issue 20482002: Use Histogram algorithm to calculate DNS timeout. Honor DnsConfig timeout if it exceeds 5s. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved unit test comments. Created 7 years, 4 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/dns/dns_session.cc ('k') | no next file » | 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/dns/dns_session.h" 5 #include "net/dns/dns_session.h"
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 213
214 lease1.reset(); 214 lease1.reset();
215 EXPECT_TRUE(DidFree(0)); 215 EXPECT_TRUE(DidFree(0));
216 EXPECT_TRUE(NoMoreEvents()); 216 EXPECT_TRUE(NoMoreEvents());
217 217
218 lease2.reset(); 218 lease2.reset();
219 EXPECT_TRUE(DidFree(1)); 219 EXPECT_TRUE(DidFree(1));
220 EXPECT_TRUE(NoMoreEvents()); 220 EXPECT_TRUE(NoMoreEvents());
221 } 221 }
222 222
223 } // namespace 223 // Expect default calculated timeout to be within 10ms of in DnsConfig.
224 TEST_F(DnsSessionTest, HistogramTimeoutNormal) {
225 Initialize(2);
226 base::TimeDelta timeoutDelta = session_->NextTimeout(0, 0) - config_.timeout;
227 EXPECT_LT(timeoutDelta.InMilliseconds(), 10);
228 }
229
230 // Expect short calculated timeout to be within 10ms of in DnsConfig.
231 TEST_F(DnsSessionTest, HistogramTimeoutShort) {
232 config_.timeout = base::TimeDelta::FromMilliseconds(15);
233 Initialize(2);
234 base::TimeDelta timeoutDelta = session_->NextTimeout(0, 0) - config_.timeout;
235 EXPECT_LT(timeoutDelta.InMilliseconds(), 10);
236 }
237
238 // Expect long calculated timeout to be equal to one in DnsConfig.
239 TEST_F(DnsSessionTest, HistogramTimeoutLong) {
240 config_.timeout = base::TimeDelta::FromSeconds(15);
241 Initialize(2);
242 base::TimeDelta timeout = session_->NextTimeout(0, 0);
243 EXPECT_EQ(config_.timeout.InMilliseconds(), timeout.InMilliseconds());
244 }
245
246 } // namespace
224 247
225 } // namespace net 248 } // namespace net
OLDNEW
« no previous file with comments | « net/dns/dns_session.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698