Skip to content

Commit

Permalink
Convert use of int ms to TimeDelta in files owned by jar.
Browse files Browse the repository at this point in the history
R=jar@chromium.org
BUG=108171
TEST=


Review URL: http://codereview.chromium.org/9190027

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119547 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
tedvessenes@gmail.com committed Jan 28, 2012
1 parent 1a30dd3 commit 26b9973
Show file tree
Hide file tree
Showing 27 changed files with 189 additions and 175 deletions.
5 changes: 2 additions & 3 deletions chrome/browser/net/network_stats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,10 @@ void NetworkStats::OnReadComplete(int result) {
// of 1ms so that the time-out will fire before we have time to really hog
// the CPU too extensively (waiting for the time-out) in case of an infinite
// loop.
const int kReadDataDelayMs = 1;
MessageLoop::current()->PostDelayedTask(
FROM_HERE,
base::Bind(&NetworkStats::ReadData, weak_factory_.GetWeakPtr()),
kReadDataDelayMs);
base::TimeDelta::FromMilliseconds(1));
}
}

Expand Down Expand Up @@ -280,7 +279,7 @@ void NetworkStats::StartReadDataTimer(int milliseconds) {
MessageLoop::current()->PostDelayedTask(
FROM_HERE,
base::Bind(&NetworkStats::OnReadDataTimeout, weak_factory_.GetWeakPtr()),
milliseconds);
base::TimeDelta::FromMilliseconds(milliseconds));
}

void NetworkStats::OnReadDataTimeout() {
Expand Down
7 changes: 3 additions & 4 deletions chrome/browser/net/predictor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1063,14 +1063,13 @@ void Predictor::LoadUrlsForTrimming() {
void Predictor::PostIncrementalTrimTask() {
if (urls_being_trimmed_.empty())
return;
const int64 kDurationBetweenTrimmingIncrementsMilliseconds =
TimeDelta::FromSeconds(kDurationBetweenTrimmingIncrementsSeconds)
.InMilliseconds();
const TimeDelta kDurationBetweenTrimmingIncrements =
TimeDelta::FromSeconds(kDurationBetweenTrimmingIncrementsSeconds);
MessageLoop::current()->PostDelayedTask(
FROM_HERE,
base::Bind(&Predictor::IncrementalTrimReferrers,
weak_factory_->GetWeakPtr(), false),
kDurationBetweenTrimmingIncrementsMilliseconds);
kDurationBetweenTrimmingIncrements);
}

void Predictor::IncrementalTrimReferrers(bool trim_all_now) {
Expand Down
8 changes: 5 additions & 3 deletions chrome/browser/net/predictor_unittest.cc
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -127,8 +127,10 @@ TEST_F(PredictorTest, ShutdownWhenResolutionIsPendingTest) {

testing_master.ResolveList(names, UrlInfo::PAGE_SCAN_MOTIVATED);

MessageLoop::current()->PostDelayedTask(FROM_HERE,
MessageLoop::QuitClosure(), 500);
MessageLoop::current()->PostDelayedTask(
FROM_HERE,
MessageLoop::QuitClosure(),
base::TimeDelta::FromMilliseconds(500));
MessageLoop::current()->Run();

EXPECT_FALSE(testing_master.WasFound(localhost));
Expand Down
6 changes: 3 additions & 3 deletions chrome/browser/net/sdch_dictionary_fetcher.cc
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -52,8 +52,8 @@ void SdchDictionaryFetcher::ScheduleDelayedRun() {
return;
MessageLoop::current()->PostDelayedTask(FROM_HERE,
base::Bind(&SdchDictionaryFetcher::StartFetching,
weak_factory_.GetWeakPtr()),
kMsDelayFromRequestTillDownload);
weak_factory_.GetWeakPtr()),
base::TimeDelta::FromMilliseconds(kMsDelayFromRequestTillDownload));
task_is_pending_ = true;
}

Expand Down
9 changes: 6 additions & 3 deletions net/base/cookie_monster_unittest.cc
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -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(
Expand All @@ -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));
}
Expand Down Expand Up @@ -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_);
Expand Down
8 changes: 4 additions & 4 deletions net/base/cookie_store_test_helpers.cc
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand Down
6 changes: 4 additions & 2 deletions net/base/mock_host_resolver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
16 changes: 9 additions & 7 deletions net/disk_cache/backend_unittest.cc
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand All @@ -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());
Expand Down Expand Up @@ -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));
Expand All @@ -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));
Expand All @@ -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());
Expand Down
12 changes: 7 additions & 5 deletions net/disk_cache/entry_unittest.cc
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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:
Expand Down Expand Up @@ -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));
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
5 changes: 3 additions & 2 deletions net/disk_cache/eviction.cc
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions net/disk_cache/stress_cache.cc
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions net/dns/watching_file_reader.cc
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions net/proxy/dhcp_proxy_script_adapter_fetcher_win_unittest.cc
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -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_;
Expand Down Expand Up @@ -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);
}
};
Expand Down
Loading

0 comments on commit 26b9973

Please sign in to comment.