summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/base/cookie_monster_unittest.cc9
-rw-r--r--net/base/cookie_store_test_helpers.cc8
-rw-r--r--net/base/mock_host_resolver.cc6
-rw-r--r--net/disk_cache/backend_unittest.cc16
-rw-r--r--net/disk_cache/entry_unittest.cc12
-rw-r--r--net/disk_cache/eviction.cc5
-rw-r--r--net/disk_cache/stress_cache.cc4
-rw-r--r--net/dns/watching_file_reader.cc4
-rw-r--r--net/proxy/dhcp_proxy_script_adapter_fetcher_win_unittest.cc4
-rw-r--r--net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc6
-rw-r--r--net/proxy/multi_threaded_proxy_resolver_unittest.cc17
-rw-r--r--net/proxy/proxy_script_fetcher_impl.cc4
-rw-r--r--net/proxy/proxy_service.cc76
-rw-r--r--net/proxy/proxy_service.h16
-rw-r--r--net/proxy/proxy_service_unittest.cc53
-rw-r--r--net/socket/client_socket_pool_base.cc2
-rw-r--r--net/socket/client_socket_pool_base.h5
-rw-r--r--net/socket/client_socket_pool_base_unittest.cc22
-rw-r--r--net/socket/socket_test_util.cc4
-rw-r--r--net/socket/transport_client_socket_pool_unittest.cc40
-rw-r--r--net/spdy/spdy_http_stream.cc6
-rw-r--r--net/spdy/spdy_session.cc17
-rw-r--r--net/spdy/spdy_session.h2
23 files changed, 176 insertions, 162 deletions
diff --git a/net/base/cookie_monster_unittest.cc b/net/base/cookie_monster_unittest.cc
index 72e3579..19ad779 100644
--- a/net/base/cookie_monster_unittest.cc
+++ b/net/base/cookie_monster_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -2019,6 +2019,7 @@ TEST_F(CookieMonsterTest, TestSecure) {
}
static const int kLastAccessThresholdMilliseconds = 200;
+static const int kAccessDelayMs = kLastAccessThresholdMilliseconds + 20;
TEST_F(CookieMonsterTest, TestLastAccess) {
scoped_refptr<CookieMonster> cm(
@@ -2033,7 +2034,8 @@ TEST_F(CookieMonsterTest, TestLastAccess) {
EXPECT_TRUE(last_access_date == GetFirstCookieAccessDate(cm));
// Reading after a short wait should update the access date.
- base::PlatformThread::Sleep(kLastAccessThresholdMilliseconds + 20);
+ base::PlatformThread::Sleep(
+ base::TimeDelta::FromMilliseconds(kAccessDelayMs));
EXPECT_EQ("A=B", GetCookies(cm, url_google_));
EXPECT_FALSE(last_access_date == GetFirstCookieAccessDate(cm));
}
@@ -2117,7 +2119,8 @@ TEST_F(CookieMonsterTest, GetAllCookiesForURL) {
const Time last_access_date(GetFirstCookieAccessDate(cm));
- base::PlatformThread::Sleep(kLastAccessThresholdMilliseconds + 20);
+ base::PlatformThread::Sleep(
+ base::TimeDelta::FromMilliseconds(kAccessDelayMs));
// Check cookies for url.
CookieList cookies = GetAllCookiesForURL(cm, url_google_);
diff --git a/net/base/cookie_store_test_helpers.cc b/net/base/cookie_store_test_helpers.cc
index add1483..832e3da 100644
--- a/net/base/cookie_store_test_helpers.cc
+++ b/net/base/cookie_store_test_helpers.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -53,7 +53,7 @@ void DelayedCookieMonster::GetCookiesWithInfoAsync(
FROM_HERE,
base::Bind(&DelayedCookieMonster::InvokeGetCookiesCallback,
base::Unretained(this), callback),
- kDelayedTime);
+ base::TimeDelta::FromMilliseconds(kDelayedTime));
}
void DelayedCookieMonster::SetCookieWithOptionsAsync(
@@ -70,7 +70,7 @@ void DelayedCookieMonster::SetCookieWithOptionsAsync(
FROM_HERE,
base::Bind(&DelayedCookieMonster::InvokeSetCookiesCallback,
base::Unretained(this), callback),
- kDelayedTime);
+ base::TimeDelta::FromMilliseconds(kDelayedTime));
}
void DelayedCookieMonster::GetCookiesWithOptionsAsync(
@@ -86,7 +86,7 @@ void DelayedCookieMonster::GetCookiesWithOptionsAsync(
FROM_HERE,
base::Bind(&DelayedCookieMonster::InvokeGetCookieStringCallback,
base::Unretained(this), callback),
- kDelayedTime);
+ base::TimeDelta::FromMilliseconds(kDelayedTime));
}
void DelayedCookieMonster::InvokeGetCookiesCallback(
diff --git a/net/base/mock_host_resolver.cc b/net/base/mock_host_resolver.cc
index a41a0ce..36603f1 100644
--- a/net/base/mock_host_resolver.cc
+++ b/net/base/mock_host_resolver.cc
@@ -319,8 +319,10 @@ int RuleBasedHostResolverProc::Resolve(const std::string& host,
host_resolver_flags;
if (matches_flags && matches_address_family &&
MatchPattern(host, r->host_pattern)) {
- if (r->latency_ms != 0)
- base::PlatformThread::Sleep(r->latency_ms);
+ if (r->latency_ms != 0) {
+ base::PlatformThread::Sleep(
+ base::TimeDelta::FromMilliseconds(r->latency_ms));
+ }
// Remap to a new host.
const std::string& effective_host =
diff --git a/net/disk_cache/backend_unittest.cc b/net/disk_cache/backend_unittest.cc
index 9f8eb2e..21875b5 100644
--- a/net/disk_cache/backend_unittest.cc
+++ b/net/disk_cache/backend_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -28,6 +28,8 @@
using base::Time;
+static const int kDiskDelayMs = 20;
+
// Tests that can run with different types of caches.
class DiskCacheBackendTest : public DiskCacheTestWithCache {
protected:
@@ -939,7 +941,7 @@ void DiskCacheBackendTest::BackendEnumerations2() {
FlushQueueForTest();
// Make sure that the timestamp is not the same.
- base::PlatformThread::Sleep(20);
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(kDiskDelayMs));
ASSERT_EQ(net::OK, OpenEntry(second, &entry1));
void* iter = NULL;
ASSERT_EQ(net::OK, OpenNextEntry(&iter, &entry2));
@@ -1115,7 +1117,7 @@ void DiskCacheBackendTest::BackendDoomRecent() {
entry->Close();
FlushQueueForTest();
- base::PlatformThread::Sleep(20);
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(kDiskDelayMs));
Time middle = Time::Now();
ASSERT_EQ(net::OK, CreateEntry("third", &entry));
@@ -1124,7 +1126,7 @@ void DiskCacheBackendTest::BackendDoomRecent() {
entry->Close();
FlushQueueForTest();
- base::PlatformThread::Sleep(20);
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(kDiskDelayMs));
Time final = Time::Now();
ASSERT_EQ(4, cache_->GetEntryCount());
@@ -1160,7 +1162,7 @@ void DiskCacheBackendTest::BackendDoomBetween() {
entry->Close();
FlushQueueForTest();
- base::PlatformThread::Sleep(20);
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(kDiskDelayMs));
Time middle_start = Time::Now();
ASSERT_EQ(net::OK, CreateEntry("second", &entry));
@@ -1169,7 +1171,7 @@ void DiskCacheBackendTest::BackendDoomBetween() {
entry->Close();
FlushQueueForTest();
- base::PlatformThread::Sleep(20);
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(kDiskDelayMs));
Time middle_end = Time::Now();
ASSERT_EQ(net::OK, CreateEntry("fourth", &entry));
@@ -1178,7 +1180,7 @@ void DiskCacheBackendTest::BackendDoomBetween() {
entry->Close();
FlushQueueForTest();
- base::PlatformThread::Sleep(20);
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(kDiskDelayMs));
Time final = Time::Now();
ASSERT_EQ(4, cache_->GetEntryCount());
diff --git a/net/disk_cache/entry_unittest.cc b/net/disk_cache/entry_unittest.cc
index 7585191..21a5bb1 100644
--- a/net/disk_cache/entry_unittest.cc
+++ b/net/disk_cache/entry_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -22,6 +22,8 @@
using base::Time;
+static const int kDiskDelayMs = 20;
+
// Tests that can run with different types of caches.
class DiskCacheEntryTest : public DiskCacheTestWithCache {
public:
@@ -605,7 +607,7 @@ void DiskCacheEntryTest::GetTimes() {
EXPECT_TRUE(entry->GetLastModified() >= t1);
EXPECT_TRUE(entry->GetLastModified() == entry->GetLastUsed());
- base::PlatformThread::Sleep(20);
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(kDiskDelayMs));
Time t2 = Time::Now();
EXPECT_TRUE(t2 > t1);
EXPECT_EQ(0, WriteData(entry, 0, 200, NULL, 0, false));
@@ -616,7 +618,7 @@ void DiskCacheEntryTest::GetTimes() {
}
EXPECT_TRUE(entry->GetLastModified() == entry->GetLastUsed());
- base::PlatformThread::Sleep(20);
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(kDiskDelayMs));
Time t3 = Time::Now();
EXPECT_TRUE(t3 > t2);
const int kSize = 200;
@@ -1258,7 +1260,7 @@ void DiskCacheEntryTest::DoomedEntry() {
FlushQueueForTest();
EXPECT_EQ(0, cache_->GetEntryCount());
Time initial = Time::Now();
- base::PlatformThread::Sleep(20);
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(kDiskDelayMs));
const int kSize1 = 2000;
const int kSize2 = 2000;
@@ -1760,7 +1762,7 @@ void DiskCacheEntryTest::DoomSparseEntry() {
// Most likely we are waiting for the result of reading the sparse info
// (it's always async on Posix so it is easy to miss). Unfortunately we
// don't have any signal to watch for so we can only wait.
- base::PlatformThread::Sleep(500);
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(500));
MessageLoop::current()->RunAllPending();
}
EXPECT_EQ(0, cache_->GetEntryCount());
diff --git a/net/disk_cache/eviction.cc b/net/disk_cache/eviction.cc
index 2e50db9..19a4f09 100644
--- a/net/disk_cache/eviction.cc
+++ b/net/disk_cache/eviction.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -204,7 +204,8 @@ void Eviction::PostDelayedTrim() {
delay_trim_ = true;
trim_delays_++;
MessageLoop::current()->PostDelayedTask(FROM_HERE,
- base::Bind(&Eviction::DelayedTrim, ptr_factory_.GetWeakPtr()), 1000);
+ base::Bind(&Eviction::DelayedTrim, ptr_factory_.GetWeakPtr()),
+ base::TimeDelta::FromMilliseconds(1000));
}
void Eviction::DelayedTrim() {
diff --git a/net/disk_cache/stress_cache.cc b/net/disk_cache/stress_cache.cc
index 40a0143..b01e5b3 100644
--- a/net/disk_cache/stress_cache.cc
+++ b/net/disk_cache/stress_cache.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -271,7 +271,7 @@ int main(int argc, const char* argv[]) {
#endif
// Some time for the memory manager to flush stuff.
- base::PlatformThread::Sleep(3000);
+ base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(3));
MessageLoop message_loop(MessageLoop::TYPE_IO);
char* end;
diff --git a/net/dns/watching_file_reader.cc b/net/dns/watching_file_reader.cc
index 869da37..cf4f2e9 100644
--- a/net/dns/watching_file_reader.cc
+++ b/net/dns/watching_file_reader.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -81,7 +81,7 @@ void WatchingFileReader::RescheduleWatch() {
MessageLoop::current()->PostDelayedTask(
FROM_HERE,
base::Bind(&WatchingFileReader::RestartWatch, AsWeakPtr()),
- kWatchRetryDelayMs);
+ base::TimeDelta::FromMilliseconds(kWatchRetryDelayMs));
}
void WatchingFileReader::RestartWatch() {
diff --git a/net/proxy/dhcp_proxy_script_adapter_fetcher_win_unittest.cc b/net/proxy/dhcp_proxy_script_adapter_fetcher_win_unittest.cc
index ff75fbe..f8f2f94 100644
--- a/net/proxy/dhcp_proxy_script_adapter_fetcher_win_unittest.cc
+++ b/net/proxy/dhcp_proxy_script_adapter_fetcher_win_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -220,7 +220,7 @@ TEST(DhcpProxyScriptAdapterFetcher, CancelWhileFetcher) {
client.RunTest();
int max_loops = 4;
while (!client.fetcher_->IsWaitingForFetcher() && max_loops--) {
- base::PlatformThread::Sleep(10);
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(10));
MessageLoop::current()->RunAllPending();
}
client.fetcher_->Cancel();
diff --git a/net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc b/net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc
index 97a6d8e..bc1700b 100644
--- a/net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc
+++ b/net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -111,7 +111,7 @@ class RealFetchTester {
// do something a bit more clever to track worker threads even when the
// DhcpProxyScriptFetcherWin state machine has finished.
void FinishTestAllowCleanup() {
- base::PlatformThread::Sleep(30);
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(30));
}
scoped_refptr<URLRequestContext> context_;
@@ -169,7 +169,7 @@ class DelayingDhcpProxyScriptAdapterFetcher
std::string ImplGetPacURLFromDhcp(
const std::string& adapter_name) OVERRIDE {
- base::PlatformThread::Sleep(20);
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(20));
return DhcpQuery::ImplGetPacURLFromDhcp(adapter_name);
}
};
diff --git a/net/proxy/multi_threaded_proxy_resolver_unittest.cc b/net/proxy/multi_threaded_proxy_resolver_unittest.cc
index 59c33f4..a1a4ad6 100644
--- a/net/proxy/multi_threaded_proxy_resolver_unittest.cc
+++ b/net/proxy/multi_threaded_proxy_resolver_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -32,8 +32,7 @@ class MockProxyResolver : public ProxyResolver {
: ProxyResolver(true /*expects_pac_bytes*/),
wrong_loop_(MessageLoop::current()),
request_count_(0),
- purge_count_(0),
- resolve_latency_ms_(0) {}
+ purge_count_(0) {}
// ProxyResolver implementation.
virtual int GetProxyForURL(const GURL& query_url,
@@ -41,8 +40,8 @@ class MockProxyResolver : public ProxyResolver {
const CompletionCallback& callback,
RequestHandle* request,
const BoundNetLog& net_log) OVERRIDE {
- if (resolve_latency_ms_)
- base::PlatformThread::Sleep(resolve_latency_ms_);
+ if (resolve_latency_ != base::TimeDelta())
+ base::PlatformThread::Sleep(resolve_latency_);
CheckIsOnWorkerThread();
@@ -97,8 +96,8 @@ class MockProxyResolver : public ProxyResolver {
return last_script_data_;
}
- void SetResolveLatency(int latency_ms) {
- resolve_latency_ms_ = latency_ms;
+ void SetResolveLatency(base::TimeDelta latency) {
+ resolve_latency_ = latency;
}
private:
@@ -114,7 +113,7 @@ class MockProxyResolver : public ProxyResolver {
int request_count_;
int purge_count_;
scoped_refptr<ProxyResolverScriptData> last_script_data_;
- int resolve_latency_ms_;
+ base::TimeDelta resolve_latency_;
};
@@ -566,7 +565,7 @@ TEST(MultiThreadedProxyResolverTest, SingleThread_CancelRequestByDeleting) {
// of the worker thread. The test will pass regardless, so this race doesn't
// cause flakiness. However the destruction during execution is a more
// interesting case to test.
- mock->SetResolveLatency(100);
+ mock->SetResolveLatency(base::TimeDelta::FromMilliseconds(100));
// Unblock the worker thread and delete the underlying
// MultiThreadedProxyResolver immediately.
diff --git a/net/proxy/proxy_script_fetcher_impl.cc b/net/proxy/proxy_script_fetcher_impl.cc
index def3382..32f6542 100644
--- a/net/proxy/proxy_script_fetcher_impl.cc
+++ b/net/proxy/proxy_script_fetcher_impl.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -162,7 +162,7 @@ int ProxyScriptFetcherImpl::Fetch(
FROM_HERE,
base::Bind(&ProxyScriptFetcherImpl::OnTimeout, weak_factory_.GetWeakPtr(),
cur_request_id_),
- static_cast<int>(max_duration_.InMilliseconds()));
+ max_duration_);
// Start the request.
cur_request_->Start();
diff --git a/net/proxy/proxy_service.cc b/net/proxy/proxy_service.cc
index ba567c6..a18805b 100644
--- a/net/proxy/proxy_service.cc
+++ b/net/proxy/proxy_service.cc
@@ -119,32 +119,34 @@ class DefaultPollPolicy : public ProxyService::PacPollPolicy {
DefaultPollPolicy() {}
virtual Mode GetNextDelay(int initial_error,
- int64 current_delay_ms,
- int64* next_delay_ms) const OVERRIDE {
+ TimeDelta current_delay,
+ TimeDelta* next_delay) const OVERRIDE {
if (initial_error != OK) {
// Re-try policy for failures.
- const int kDelay1 = 8000; // 8 seconds
- const int kDelay2 = 32000; // 32 seconds
- const int kDelay3 = 120000; // 2 minutes
- const int kDelay4 = 14400000; // 4 hours
-
- switch (current_delay_ms) {
- case -1: // Initial poll.
- *next_delay_ms = kDelay1;
- return MODE_USE_TIMER;
- case kDelay1:
- *next_delay_ms = kDelay2;
+ const int kDelay1Seconds = 8;
+ const int kDelay2Seconds = 32;
+ const int kDelay3Seconds = 2 * 60; // 2 minutes
+ const int kDelay4Seconds = 4 * 60 * 60; // 4 Hours
+
+ // Initial poll.
+ if (current_delay < TimeDelta()) {
+ *next_delay = TimeDelta::FromSeconds(kDelay1Seconds);
+ return MODE_USE_TIMER;
+ }
+ switch (current_delay.InSeconds()) {
+ case kDelay1Seconds:
+ *next_delay = TimeDelta::FromSeconds(kDelay2Seconds);
return MODE_START_AFTER_ACTIVITY;
- case kDelay2:
- *next_delay_ms = kDelay3;
+ case kDelay2Seconds:
+ *next_delay = TimeDelta::FromSeconds(kDelay3Seconds);
return MODE_START_AFTER_ACTIVITY;
default:
- *next_delay_ms = kDelay4;
+ *next_delay = TimeDelta::FromSeconds(kDelay4Seconds);
return MODE_START_AFTER_ACTIVITY;
}
} else {
// Re-try policy for succeses.
- *next_delay_ms = 43200000; // 12 hours
+ *next_delay = TimeDelta::FromHours(12);
return MODE_START_AFTER_ACTIVITY;
}
}
@@ -412,7 +414,7 @@ class ProxyService::InitProxyResolver {
DhcpProxyScriptFetcher* dhcp_proxy_script_fetcher,
NetLog* net_log,
const ProxyConfig& config,
- base::TimeDelta wait_delay,
+ TimeDelta wait_delay,
const CompletionCallback& callback) {
DCHECK_EQ(STATE_NONE, next_state_);
proxy_resolver_ = proxy_resolver;
@@ -549,7 +551,7 @@ class ProxyService::InitProxyResolver {
ProxyConfig config_;
ProxyConfig effective_config_;
scoped_refptr<ProxyResolverScriptData> script_data_;
- base::TimeDelta wait_delay_;
+ TimeDelta wait_delay_;
scoped_ptr<ProxyScriptDecider> decider_;
ProxyResolver* proxy_resolver_;
CompletionCallback callback_;
@@ -605,10 +607,10 @@ class ProxyService::ProxyScriptDeciderPoller {
dhcp_proxy_script_fetcher_(dhcp_proxy_script_fetcher),
last_error_(init_net_error),
last_script_data_(init_script_data),
- last_poll_time_(base::TimeTicks::Now()) {
+ last_poll_time_(TimeTicks::Now()) {
// Set the initial poll delay.
next_poll_mode_ = poll_policy()->GetNextDelay(
- last_error_, -1, &next_poll_delay_ms_);
+ last_error_, TimeDelta::FromSeconds(-1), &next_poll_delay_);
TryToStartNextPoll(false);
}
@@ -640,7 +642,7 @@ class ProxyService::ProxyScriptDeciderPoller {
FROM_HERE,
base::Bind(&ProxyScriptDeciderPoller::DoPoll,
weak_factory_.GetWeakPtr()),
- next_poll_delay_ms_);
+ next_poll_delay_);
}
void TryToStartNextPoll(bool triggered_by_activity) {
@@ -652,9 +654,8 @@ class ProxyService::ProxyScriptDeciderPoller {
case PacPollPolicy::MODE_START_AFTER_ACTIVITY:
if (triggered_by_activity && !decider_.get()) {
- base::TimeDelta elapsed_time =
- base::TimeTicks::Now() - last_poll_time_;
- if (elapsed_time.InMilliseconds() >= next_poll_delay_ms_)
+ TimeDelta elapsed_time = TimeTicks::Now() - last_poll_time_;
+ if (elapsed_time >= next_poll_delay_)
DoPoll();
}
break;
@@ -662,14 +663,14 @@ class ProxyService::ProxyScriptDeciderPoller {
}
void DoPoll() {
- last_poll_time_ = base::TimeTicks::Now();
+ last_poll_time_ = TimeTicks::Now();
// Start the proxy script decider to see if anything has changed.
// TODO(eroman): Pass a proper NetLog rather than NULL.
decider_.reset(new ProxyScriptDecider(
proxy_script_fetcher_, dhcp_proxy_script_fetcher_, NULL));
int result = decider_->Start(
- config_, base::TimeDelta(), proxy_resolver_expects_pac_bytes_,
+ config_, TimeDelta(), proxy_resolver_expects_pac_bytes_,
base::Bind(&ProxyScriptDeciderPoller::OnProxyScriptDeciderCompleted,
base::Unretained(this)));
@@ -700,7 +701,7 @@ class ProxyService::ProxyScriptDeciderPoller {
// Decide when the next poll should take place, and possibly start the
// next timer.
next_poll_mode_ = poll_policy()->GetNextDelay(
- last_error_, next_poll_delay_ms_, &next_poll_delay_ms_);
+ last_error_, next_poll_delay_, &next_poll_delay_);
TryToStartNextPoll(false);
}
@@ -744,10 +745,10 @@ class ProxyService::ProxyScriptDeciderPoller {
scoped_refptr<ProxyResolverScriptData> last_script_data_;
scoped_ptr<ProxyScriptDecider> decider_;
- int64 next_poll_delay_ms_;
+ TimeDelta next_poll_delay_;
PacPollPolicy::Mode next_poll_mode_;
- base::TimeTicks last_poll_time_;
+ TimeTicks last_poll_time_;
// Polling policy injected by unit-tests. Otherwise this is NULL and the
// default policy will be used.
@@ -902,9 +903,8 @@ ProxyService::ProxyService(ProxyConfigService* config_service,
next_config_id_(1),
current_state_(STATE_NONE) ,
net_log_(net_log),
- stall_proxy_auto_config_delay_(
- base::TimeDelta::FromMilliseconds(
- kDelayAfterNetworkChangesMs)) {
+ stall_proxy_auto_config_delay_(TimeDelta::FromMilliseconds(
+ kDelayAfterNetworkChangesMs)) {
NetworkChangeNotifier::AddIPAddressObserver(this);
ResetConfigService(config_service);
}
@@ -1266,7 +1266,7 @@ void ProxyService::ReportSuccess(const ProxyInfo& result) {
}
if (net_log_) {
net_log_->AddEntry(NetLog::TYPE_BAD_PROXY_LIST_REPORTED,
- base::TimeTicks::Now(),
+ TimeTicks::Now(),
NetLog::Source(),
NetLog::PHASE_NONE,
make_scoped_refptr(
@@ -1474,7 +1474,7 @@ void ProxyService::OnProxyConfigChanged(
scoped_refptr<NetLog::EventParameters> params(
new ProxyConfigChangedNetLogParam(fetched_config_, effective_config));
net_log_->AddEntry(net::NetLog::TYPE_PROXY_CONFIG_CHANGED,
- base::TimeTicks::Now(),
+ TimeTicks::Now(),
NetLog::Source(),
NetLog::PHASE_NONE,
params);
@@ -1505,8 +1505,8 @@ void ProxyService::InitializeUsingLastFetchedConfig() {
current_state_ = STATE_WAITING_FOR_INIT_PROXY_RESOLVER;
// If we changed networks recently, we should delay running proxy auto-config.
- base::TimeDelta wait_delay =
- stall_proxy_autoconfig_until_ - base::TimeTicks::Now();
+ TimeDelta wait_delay =
+ stall_proxy_autoconfig_until_ - TimeTicks::Now();
init_proxy_resolver_.reset(new InitProxyResolver());
int rv = init_proxy_resolver_->Start(
@@ -1550,7 +1550,7 @@ void ProxyService::InitializeUsingDecidedConfig(
void ProxyService::OnIPAddressChanged() {
// See the comment block by |kDelayAfterNetworkChangesMs| for info.
stall_proxy_autoconfig_until_ =
- base::TimeTicks::Now() + stall_proxy_auto_config_delay_;
+ TimeTicks::Now() + stall_proxy_auto_config_delay_;
State previous_state = ResetProxyConfig(false);
if (previous_state != STATE_NONE)
diff --git a/net/proxy/proxy_service.h b/net/proxy/proxy_service.h
index 8b657a9..ac32408 100644
--- a/net/proxy/proxy_service.h
+++ b/net/proxy/proxy_service.h
@@ -73,15 +73,15 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver,
virtual ~PacPollPolicy() {}
- // Decides the next poll delay. |current_delay_ms| is the delay used
- // by the preceding poll, or -1 if determining the delay for the initial
- // poll. |initial_error| is the network error code that the last PAC
- // fetch (or WPAD initialization) failed with, or OK if it completed
- // successfully. Implementations must set |next_delay_ms| to a non-negative
- // value.
+ // Decides the next poll delay. |current_delay| is the delay used
+ // by the preceding poll, or a negative TimeDelta value if determining
+ // the delay for the initial poll. |initial_error| is the network error
+ // code that the last PAC fetch (or WPAD initialization) failed with,
+ // or OK if it completed successfully. Implementations must set
+ // |next_delay| to a non-negative value.
virtual Mode GetNextDelay(int initial_error,
- int64 current_delay_ms,
- int64* next_delay_ms) const = 0;
+ base::TimeDelta current_delay,
+ base::TimeDelta* next_delay) const = 0;
};
// The instance takes ownership of |config_service| and |resolver|.
diff --git a/net/proxy/proxy_service_unittest.cc b/net/proxy/proxy_service_unittest.cc
index 2df1725..6271809 100644
--- a/net/proxy/proxy_service_unittest.cc
+++ b/net/proxy/proxy_service_unittest.cc
@@ -33,9 +33,9 @@ class ImmediatePollPolicy : public ProxyService::PacPollPolicy {
public:
ImmediatePollPolicy() {}
- virtual Mode GetNextDelay(int error, int64 current_delay_ms,
- int64* next_delay_ms) const OVERRIDE {
- *next_delay_ms = 1;
+ virtual Mode GetNextDelay(int error, base::TimeDelta current_delay,
+ base::TimeDelta* next_delay) const OVERRIDE {
+ *next_delay = base::TimeDelta::FromMilliseconds(1);
return MODE_USE_TIMER;
}
@@ -49,9 +49,9 @@ class NeverPollPolicy : public ProxyService::PacPollPolicy {
public:
NeverPollPolicy() {}
- virtual Mode GetNextDelay(int error, int64 current_delay_ms,
- int64* next_delay_ms) const OVERRIDE {
- *next_delay_ms = 0xFFFFFFFF; // Big number of milliseconds!
+ virtual Mode GetNextDelay(int error, base::TimeDelta current_delay,
+ base::TimeDelta* next_delay) const OVERRIDE {
+ *next_delay = base::TimeDelta::FromDays(60);
return MODE_USE_TIMER;
}
@@ -64,9 +64,9 @@ class ImmediateAfterActivityPollPolicy : public ProxyService::PacPollPolicy {
public:
ImmediateAfterActivityPollPolicy() {}
- virtual Mode GetNextDelay(int error, int64 current_delay_ms,
- int64* next_delay_ms) const OVERRIDE {
- *next_delay_ms = 0;
+ virtual Mode GetNextDelay(int error, base::TimeDelta current_delay,
+ base::TimeDelta* next_delay) const OVERRIDE {
+ *next_delay = base::TimeDelta();
return MODE_START_AFTER_ACTIVITY;
}
@@ -2428,7 +2428,8 @@ TEST_F(ProxyServiceTest, PACScriptPollingPolicy) {
int error;
ProxyService::PacPollPolicy::Mode mode;
- int64 delay_ms = -1;
+ const base::TimeDelta initial_delay = base::TimeDelta::FromMilliseconds(-1);
+ base::TimeDelta delay = initial_delay;
// --------------------------------------------------
// Test the poll sequence in response to a failure.
@@ -2436,28 +2437,28 @@ TEST_F(ProxyServiceTest, PACScriptPollingPolicy) {
error = ERR_NAME_NOT_RESOLVED;
// Poll #0
- mode = policy->GetNextDelay(error, -1, &delay_ms);
- EXPECT_EQ(8000, delay_ms);
+ mode = policy->GetNextDelay(error, initial_delay, &delay);
+ EXPECT_EQ(8, delay.InSeconds());
EXPECT_EQ(ProxyService::PacPollPolicy::MODE_USE_TIMER, mode);
// Poll #1
- mode = policy->GetNextDelay(error, delay_ms, &delay_ms);
- EXPECT_EQ(32000, delay_ms);
+ mode = policy->GetNextDelay(error, delay, &delay);
+ EXPECT_EQ(32, delay.InSeconds());
EXPECT_EQ(ProxyService::PacPollPolicy::MODE_START_AFTER_ACTIVITY, mode);
// Poll #2
- mode = policy->GetNextDelay(error, delay_ms, &delay_ms);
- EXPECT_EQ(120000, delay_ms);
+ mode = policy->GetNextDelay(error, delay, &delay);
+ EXPECT_EQ(120, delay.InSeconds());
EXPECT_EQ(ProxyService::PacPollPolicy::MODE_START_AFTER_ACTIVITY, mode);
// Poll #3
- mode = policy->GetNextDelay(error, delay_ms, &delay_ms);
- EXPECT_EQ(14400000, delay_ms);
+ mode = policy->GetNextDelay(error, delay, &delay);
+ EXPECT_EQ(14400, delay.InSeconds());
EXPECT_EQ(ProxyService::PacPollPolicy::MODE_START_AFTER_ACTIVITY, mode);
// Poll #4
- mode = policy->GetNextDelay(error, delay_ms, &delay_ms);
- EXPECT_EQ(14400000, delay_ms);
+ mode = policy->GetNextDelay(error, delay, &delay);
+ EXPECT_EQ(14400, delay.InSeconds());
EXPECT_EQ(ProxyService::PacPollPolicy::MODE_START_AFTER_ACTIVITY, mode);
// --------------------------------------------------
@@ -2466,18 +2467,18 @@ TEST_F(ProxyServiceTest, PACScriptPollingPolicy) {
error = OK;
// Poll #0
- mode = policy->GetNextDelay(error, -1, &delay_ms);
- EXPECT_EQ(43200000, delay_ms);
+ mode = policy->GetNextDelay(error, initial_delay, &delay);
+ EXPECT_EQ(43200, delay.InSeconds());
EXPECT_EQ(ProxyService::PacPollPolicy::MODE_START_AFTER_ACTIVITY, mode);
// Poll #1
- mode = policy->GetNextDelay(error, delay_ms, &delay_ms);
- EXPECT_EQ(43200000, delay_ms);
+ mode = policy->GetNextDelay(error, delay, &delay);
+ EXPECT_EQ(43200, delay.InSeconds());
EXPECT_EQ(ProxyService::PacPollPolicy::MODE_START_AFTER_ACTIVITY, mode);
// Poll #2
- mode = policy->GetNextDelay(error, delay_ms, &delay_ms);
- EXPECT_EQ(43200000, delay_ms);
+ mode = policy->GetNextDelay(error, delay, &delay);
+ EXPECT_EQ(43200, delay.InSeconds());
EXPECT_EQ(ProxyService::PacPollPolicy::MODE_START_AFTER_ACTIVITY, mode);
}
diff --git a/net/socket/client_socket_pool_base.cc b/net/socket/client_socket_pool_base.cc
index 93a3dee..d230ad4 100644
--- a/net/socket/client_socket_pool_base.cc
+++ b/net/socket/client_socket_pool_base.cc
@@ -1100,7 +1100,7 @@ void ClientSocketPoolBaseHelper::Group::StartBackupSocketTimer(
FROM_HERE,
base::Bind(&Group::OnBackupSocketTimerFired, weak_factory_.GetWeakPtr(),
group_name, pool),
- pool->ConnectRetryIntervalMs());
+ pool->ConnectRetryInterval());
}
bool ClientSocketPoolBaseHelper::Group::TryToUsePreconnectConnectJob() {
diff --git a/net/socket/client_socket_pool_base.h b/net/socket/client_socket_pool_base.h
index 4efb43d..f550e42 100644
--- a/net/socket/client_socket_pool_base.h
+++ b/net/socket/client_socket_pool_base.h
@@ -277,10 +277,11 @@ class NET_EXPORT_PRIVATE ClientSocketPoolBaseHelper
LoadState GetLoadState(const std::string& group_name,
const ClientSocketHandle* handle) const;
- int ConnectRetryIntervalMs() const {
+ base::TimeDelta ConnectRetryInterval() const {
// TODO(mbelshe): Make this tuned dynamically based on measured RTT.
// For now, just use the max retry interval.
- return ClientSocketPool::kMaxConnectRetryIntervalMs;
+ return base::TimeDelta::FromMilliseconds(
+ ClientSocketPool::kMaxConnectRetryIntervalMs);
}
int NumConnectJobsInGroup(const std::string& group_name) const {
diff --git a/net/socket/client_socket_pool_base_unittest.cc b/net/socket/client_socket_pool_base_unittest.cc
index 23360f5..5cde58b 100644
--- a/net/socket/client_socket_pool_base_unittest.cc
+++ b/net/socket/client_socket_pool_base_unittest.cc
@@ -732,7 +732,7 @@ TEST_F(ClientSocketPoolBaseTest, ConnectJob_TimedOut) {
&client_socket_factory_,
&log);
ASSERT_EQ(ERR_IO_PENDING, job->Connect());
- base::PlatformThread::Sleep(1);
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(1));
EXPECT_EQ(ERR_TIMED_OUT, delegate.WaitForResult());
net::CapturingNetLog::EntryList entries;
@@ -986,7 +986,7 @@ TEST_F(ClientSocketPoolBaseTest, TotalLimitCountsConnectingSockets) {
// actually become pending until 2ms after they have been created. In order
// to flush all tasks, we need to wait so that we know there are no
// soon-to-be-pending tasks waiting.
- base::PlatformThread::Sleep(10);
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(10));
MessageLoop::current()->RunAllPending();
// The next synchronous request should wait for its turn.
@@ -1439,7 +1439,7 @@ class RequestSocketCallback : public TestCompletionCallbackBase {
{
MessageLoop::ScopedNestableTaskAllower nestable(
MessageLoop::current());
- base::PlatformThread::Sleep(10);
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(10));
EXPECT_EQ(OK, next_job_callback.WaitForResult());
}
break;
@@ -2005,7 +2005,7 @@ TEST_F(ClientSocketPoolBaseTest, DisableCleanupTimer) {
// The idle socket timeout value was set to 10 milliseconds. Wait 20
// milliseconds so the sockets timeout.
- base::PlatformThread::Sleep(20);
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(20));
MessageLoop::current()->RunAllPending();
ASSERT_EQ(2, pool_->IdleSocketCount());
@@ -2082,7 +2082,7 @@ TEST_F(ClientSocketPoolBaseTest, CleanupTimedOutIdleSockets) {
// actually become pending until 2ms after they have been created. In order
// to flush all tasks, we need to wait so that we know there are no
// soon-to-be-pending tasks waiting.
- base::PlatformThread::Sleep(10);
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(10));
MessageLoop::current()->RunAllPending();
ASSERT_EQ(2, pool_->IdleSocketCount());
@@ -2509,8 +2509,8 @@ TEST_F(ClientSocketPoolBaseTest, BackupSocketCancelAtMaxSockets) {
handle.Reset();
// Wait for the backup timer to fire (add some slop to ensure it fires)
- base::PlatformThread::Sleep(
- ClientSocketPool::kMaxConnectRetryIntervalMs / 2 * 3);
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(
+ ClientSocketPool::kMaxConnectRetryIntervalMs / 2 * 3));
MessageLoop::current()->RunAllPending();
EXPECT_EQ(kDefaultMaxSockets, client_socket_factory_.allocation_count());
@@ -2538,8 +2538,8 @@ TEST_F(ClientSocketPoolBaseTest, CancelBackupSocketAfterCancelingAllRequests) {
// the backup time to see if it indeed got canceled.
handle.Reset();
// Wait for the backup timer to fire (add some slop to ensure it fires)
- base::PlatformThread::Sleep(
- ClientSocketPool::kMaxConnectRetryIntervalMs / 2 * 3);
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(
+ ClientSocketPool::kMaxConnectRetryIntervalMs / 2 * 3));
MessageLoop::current()->RunAllPending();
ASSERT_TRUE(pool_->HasGroup("bar"));
EXPECT_EQ(1, pool_->NumConnectJobsInGroup("bar"));
@@ -2577,8 +2577,8 @@ TEST_F(ClientSocketPoolBaseTest, CancelBackupSocketAfterFinishingAllRequests) {
handle.Reset();
EXPECT_EQ(OK, callback2.WaitForResult());
// Wait for the backup timer to fire (add some slop to ensure it fires)
- base::PlatformThread::Sleep(
- ClientSocketPool::kMaxConnectRetryIntervalMs / 2 * 3);
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(
+ ClientSocketPool::kMaxConnectRetryIntervalMs / 2 * 3));
MessageLoop::current()->RunAllPending();
}
diff --git a/net/socket/socket_test_util.cc b/net/socket/socket_test_util.cc
index baca959..b8ac5ad 100644
--- a/net/socket/socket_test_util.cc
+++ b/net/socket/socket_test_util.cc
@@ -294,7 +294,7 @@ MockWriteResult DelayedSocketData::OnWrite(const std::string& data) {
FROM_HERE,
base::Bind(&DelayedSocketData::CompleteRead,
weak_factory_.GetWeakPtr()),
- 100);
+ base::TimeDelta::FromMilliseconds(100));
return rv;
}
@@ -385,7 +385,7 @@ MockWriteResult OrderedSocketData::OnWrite(const std::string& data) {
FROM_HERE,
base::Bind(&OrderedSocketData::CompleteRead,
weak_factory_.GetWeakPtr()),
- 100);
+ base::TimeDelta::FromMilliseconds(100));
}
return StaticSocketDataProvider::OnWrite(data);
}
diff --git a/net/socket/transport_client_socket_pool_unittest.cc b/net/socket/transport_client_socket_pool_unittest.cc
index d78c15e..858bae7 100644
--- a/net/socket/transport_client_socket_pool_unittest.cc
+++ b/net/socket/transport_client_socket_pool_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -174,11 +174,11 @@ class MockPendingClientSocket : public StreamSocket {
const AddressList& addrlist,
bool should_connect,
bool should_stall,
- int delay_ms)
+ base::TimeDelta delay)
: ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
should_connect_(should_connect),
should_stall_(should_stall),
- delay_ms_(delay_ms),
+ delay_(delay),
is_connected_(false),
addrlist_(addrlist) {}
@@ -188,7 +188,7 @@ class MockPendingClientSocket : public StreamSocket {
FROM_HERE,
base::Bind(&MockPendingClientSocket::DoCallback,
weak_factory_.GetWeakPtr(), callback),
- delay_ms_);
+ delay_);
return ERR_IO_PENDING;
}
@@ -255,7 +255,7 @@ class MockPendingClientSocket : public StreamSocket {
base::WeakPtrFactory<MockPendingClientSocket> weak_factory_;
bool should_connect_;
bool should_stall_;
- int delay_ms_;
+ base::TimeDelta delay_;
bool is_connected_;
const AddressList addrlist_;
BoundNetLog net_log_;
@@ -278,7 +278,8 @@ class MockClientSocketFactory : public ClientSocketFactory {
: allocation_count_(0), client_socket_type_(MOCK_CLIENT_SOCKET),
client_socket_types_(NULL), client_socket_index_(0),
client_socket_index_max_(0),
- delay_ms_(ClientSocketPool::kMaxConnectRetryIntervalMs) {}
+ delay_(base::TimeDelta::FromMilliseconds(
+ ClientSocketPool::kMaxConnectRetryIntervalMs)) {}
virtual DatagramClientSocket* CreateDatagramClientSocket(
DatagramSocket::BindType bind_type,
@@ -307,13 +308,16 @@ class MockClientSocketFactory : public ClientSocketFactory {
case MOCK_FAILING_CLIENT_SOCKET:
return new MockFailingClientSocket(addresses);
case MOCK_PENDING_CLIENT_SOCKET:
- return new MockPendingClientSocket(addresses, true, false, 0);
+ return new MockPendingClientSocket(
+ addresses, true, false, base::TimeDelta());
case MOCK_PENDING_FAILING_CLIENT_SOCKET:
- return new MockPendingClientSocket(addresses, false, false, 0);
+ return new MockPendingClientSocket(
+ addresses, false, false, base::TimeDelta());
case MOCK_DELAYED_CLIENT_SOCKET:
- return new MockPendingClientSocket(addresses, true, false, delay_ms_);
+ return new MockPendingClientSocket(addresses, true, false, delay_);
case MOCK_STALLED_CLIENT_SOCKET:
- return new MockPendingClientSocket(addresses, true, true, 0);
+ return new MockPendingClientSocket(
+ addresses, true, true, base::TimeDelta());
default:
NOTREACHED();
return new MockClientSocket(addresses);
@@ -350,7 +354,7 @@ class MockClientSocketFactory : public ClientSocketFactory {
client_socket_index_max_ = num_types;
}
- void set_delay_ms(int delay_ms) { delay_ms_ = delay_ms; }
+ void set_delay(base::TimeDelta delay) { delay_ = delay; }
private:
int allocation_count_;
@@ -358,14 +362,14 @@ class MockClientSocketFactory : public ClientSocketFactory {
ClientSocketType* client_socket_types_;
int client_socket_index_;
int client_socket_index_max_;
- int delay_ms_;
+ base::TimeDelta delay_;
};
class TransportClientSocketPoolTest : public testing::Test {
protected:
TransportClientSocketPoolTest()
: connect_backup_jobs_enabled_(
- ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(true)),
+ ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(true)),
params_(
new TransportSocketParams(HostPortPair("www.google.com", 80),
kDefaultPriority, false, false)),
@@ -948,8 +952,8 @@ TEST_F(TransportClientSocketPoolTest, BackupSocketConnect) {
MessageLoop::current()->RunAllPending();
// Wait for the backup socket timer to fire.
- base::PlatformThread::Sleep(
- ClientSocketPool::kMaxConnectRetryIntervalMs + 50);
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(
+ ClientSocketPool::kMaxConnectRetryIntervalMs + 50));
// Let the appropriate socket connect.
MessageLoop::current()->RunAllPending();
@@ -1066,7 +1070,7 @@ TEST_F(TransportClientSocketPoolTest, BackupSocketFailAfterDelay) {
};
client_socket_factory_.set_client_socket_types(case_types, 2);
- client_socket_factory_.set_delay_ms(5000);
+ client_socket_factory_.set_delay(base::TimeDelta::FromSeconds(5));
EXPECT_EQ(0, pool_.IdleSocketCount());
@@ -1163,8 +1167,8 @@ TEST_F(TransportClientSocketPoolTest, IPv6FallbackSocketIPv6FinishesFirst) {
};
client_socket_factory_.set_client_socket_types(case_types, 2);
- client_socket_factory_.set_delay_ms(
- TransportConnectJob::kIPv6FallbackTimerInMs + 50);
+ client_socket_factory_.set_delay(base::TimeDelta::FromMilliseconds(
+ TransportConnectJob::kIPv6FallbackTimerInMs + 50));
// Resolve an AddressList with a IPv6 address first and then a IPv4 address.
host_resolver_->rules()->AddIPLiteralRule(
diff --git a/net/spdy/spdy_http_stream.cc b/net/spdy/spdy_http_stream.cc
index 1eed08f..ff96716 100644
--- a/net/spdy/spdy_http_stream.cc
+++ b/net/spdy/spdy_http_stream.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -401,12 +401,12 @@ void SpdyHttpStream::ScheduleBufferedReadCallback() {
more_read_data_pending_ = false;
buffered_read_callback_pending_ = true;
- const int kBufferTimeMs = 1;
+ const base::TimeDelta kBufferTime = base::TimeDelta::FromMilliseconds(1);
MessageLoop::current()->PostDelayedTask(
FROM_HERE,
base::Bind(base::IgnoreResult(&SpdyHttpStream::DoBufferedReadCallback),
weak_factory_.GetWeakPtr()),
- kBufferTimeMs);
+ kBufferTime);
}
// Checks to see if we should wait for more buffered data before notifying
diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc
index 71a55fc..7f9d8166 100644
--- a/net/spdy/spdy_session.cc
+++ b/net/spdy/spdy_session.cc
@@ -243,10 +243,10 @@ bool SpdySession::enable_ping_based_connection_checking_ = true;
int SpdySession::connection_at_risk_of_loss_seconds_ = 10;
// static
-int SpdySession::trailing_ping_delay_time_ms_ = 1000;
+int SpdySession::trailing_ping_delay_time_ms_ = 1000; // 1 second
// static
-int SpdySession::hung_interval_ms_ = 10000;
+int SpdySession::hung_interval_ms_ = 10000; // 10 seconds
SpdySession::SpdySession(const HostPortProxyPair& host_port_proxy_pair,
SpdySessionPool* spdy_session_pool,
@@ -1604,7 +1604,7 @@ void SpdySession::PlanToSendTrailingPing() {
MessageLoop::current()->PostDelayedTask(
FROM_HERE,
base::Bind(&SpdySession::SendTrailingPing, weak_factory_.GetWeakPtr()),
- trailing_ping_delay_time_ms_);
+ base::TimeDelta::FromMilliseconds(trailing_ping_delay_time_ms_));
}
void SpdySession::SendTrailingPing() {
@@ -1641,7 +1641,7 @@ void SpdySession::PlanToCheckPingStatus() {
FROM_HERE,
base::Bind(&SpdySession::CheckPingStatus, weak_factory_.GetWeakPtr(),
base::TimeTicks::Now()),
- hung_interval_ms_);
+ base::TimeDelta::FromMilliseconds(hung_interval_ms_));
}
void SpdySession::CheckPingStatus(base::TimeTicks last_check_time) {
@@ -1653,11 +1653,10 @@ void SpdySession::CheckPingStatus(base::TimeTicks last_check_time) {
DCHECK(check_ping_status_pending_);
- const base::TimeDelta kHungInterval =
- base::TimeDelta::FromMilliseconds(hung_interval_ms_);
-
base::TimeTicks now = base::TimeTicks::Now();
- base::TimeDelta delay = kHungInterval - (now - received_data_time_);
+ base::TimeDelta delay =
+ base::TimeDelta::FromMilliseconds(hung_interval_ms_) -
+ (now - received_data_time_);
if (delay.InMilliseconds() < 0 || received_data_time_ < last_check_time) {
CloseSessionOnError(net::ERR_SPDY_PING_FAILED, true);
@@ -1673,7 +1672,7 @@ void SpdySession::CheckPingStatus(base::TimeTicks last_check_time) {
FROM_HERE,
base::Bind(&SpdySession::CheckPingStatus, weak_factory_.GetWeakPtr(),
now),
- delay.InMilliseconds());
+ delay);
}
void SpdySession::RecordPingRTTHistogram(base::TimeDelta duration) {
diff --git a/net/spdy/spdy_session.h b/net/spdy/spdy_session.h
index 47c33f7..20570be 100644
--- a/net/spdy/spdy_session.h
+++ b/net/spdy/spdy_session.h
@@ -621,7 +621,7 @@ class NET_EXPORT SpdySession : public base::RefCounted<SpdySession>,
static int trailing_ping_delay_time_ms_;
// The amount of time (in milliseconds) that we are willing to tolerate with
- // no data received (of any form), while there is a ping in flight, before we
+ // no data received (of any form), while there is a ping in flight, before w e
// declare the connection to be hung.
static int hung_interval_ms_;
};