diff options
Diffstat (limited to 'chrome')
35 files changed, 148 insertions, 116 deletions
diff --git a/chrome/browser/feedback/feedback_util.cc b/chrome/browser/feedback/feedback_util.cc index 065cc80..f0b92ca 100644 --- a/chrome/browser/feedback/feedback_util.cc +++ b/chrome/browser/feedback/feedback_util.cc @@ -172,8 +172,10 @@ void FeedbackUtil::DispatchFeedback(Profile* profile, int64 delay) { DCHECK(post_body); - MessageLoop::current()->PostDelayedTask(FROM_HERE, base::Bind( - &FeedbackUtil::SendFeedback, profile, post_body, delay), delay); + MessageLoop::current()->PostDelayedTask( + FROM_HERE, + base::Bind(&FeedbackUtil::SendFeedback, profile, post_body, delay), + base::TimeDelta::FromMilliseconds(delay)); } // static diff --git a/chrome/browser/google/google_url_tracker.cc b/chrome/browser/google/google_url_tracker.cc index 2df3568..dd2da73 100644 --- a/chrome/browser/google/google_url_tracker.cc +++ b/chrome/browser/google/google_url_tracker.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. @@ -188,10 +188,11 @@ void GoogleURLTracker::QueueWakeupTask() { // browser is starting up, and if so, come back later", but there is currently // no function to do this. static const int kStartFetchDelayMS = 5000; + MessageLoop::current()->PostDelayedTask(FROM_HERE, base::Bind(&GoogleURLTracker::FinishSleep, weak_ptr_factory_.GetWeakPtr()), - kStartFetchDelayMS); + base::TimeDelta::FromMilliseconds(kStartFetchDelayMS)); } void GoogleURLTracker::FinishSleep() { diff --git a/chrome/browser/history/expire_history_backend.cc b/chrome/browser/history/expire_history_backend.cc index 2a749dd..3da7271 100644 --- a/chrome/browser/history/expire_history_backend.cc +++ b/chrome/browser/history/expire_history_backend.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. @@ -592,7 +592,7 @@ void ExpireHistoryBackend::ScheduleArchive() { FROM_HERE, base::Bind(&ExpireHistoryBackend::DoArchiveIteration, weak_factory_.GetWeakPtr()), - delay.InMilliseconds()); + delay); } void ExpireHistoryBackend::DoArchiveIteration() { @@ -687,7 +687,7 @@ void ExpireHistoryBackend::ScheduleExpireHistoryIndexFiles() { FROM_HERE, base::Bind(&ExpireHistoryBackend::DoExpireHistoryIndexFiles, weak_factory_.GetWeakPtr()), - delay.InMilliseconds()); + delay); } void ExpireHistoryBackend::DoExpireHistoryIndexFiles() { diff --git a/chrome/browser/history/history_backend.cc b/chrome/browser/history/history_backend.cc index defc2f3..d79fa6a 100644 --- a/chrome/browser/history/history_backend.cc +++ b/chrome/browser/history/history_backend.cc @@ -71,9 +71,8 @@ namespace history { // dependency between MostVisitedModel and the history backend. static const int kSegmentDataRetention = 90; -// The number of milliseconds we'll wait to do a commit, so that things are -// batched together. -static const int kCommitIntervalMs = 10000; +// How long we'll wait to do a commit, so that things are batched together. +static const int kCommitIntervalSeconds = 10; // The amount of time before we re-fetch the favicon. static const int kFaviconRefetchDays = 7; @@ -1942,7 +1941,7 @@ void HistoryBackend::ScheduleCommit() { MessageLoop::current()->PostDelayedTask( FROM_HERE, base::Bind(&CommitLaterTask::RunCommit, scheduled_commit_.get()), - kCommitIntervalMs); + base::TimeDelta::FromSeconds(kCommitIntervalSeconds)); } void HistoryBackend::CancelScheduledCommit() { diff --git a/chrome/browser/history/redirect_uitest.cc b/chrome/browser/history/redirect_uitest.cc index 85126a1..964fee3 100644 --- a/chrome/browser/history/redirect_uitest.cc +++ b/chrome/browser/history/redirect_uitest.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. @@ -214,7 +214,7 @@ TEST_F(RedirectTest, ClientServerServer) { NavigateToURL(first_url); for (int i = 0; i < 10; ++i) { - base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms()); + base::PlatformThread::Sleep(TestTimeouts::action_timeout()); scoped_refptr<TabProxy> tab_proxy(GetActiveTab()); ASSERT_TRUE(tab_proxy.get()); ASSERT_TRUE(tab_proxy->GetRedirectsFrom(first_url, &redirects)); @@ -322,7 +322,7 @@ TEST_F(RedirectTest, std::wstring final_url_title = UTF8ToWide("Title Of Awesomeness"); // Wait till the final page has been loaded. for (int i = 0; i < 10; ++i) { - base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms()); + base::PlatformThread::Sleep(TestTimeouts::action_timeout()); scoped_refptr<TabProxy> tab_proxy(GetActiveTab()); ASSERT_TRUE(tab_proxy.get()); ASSERT_TRUE(tab_proxy->GetTabTitle(&tab_title)); diff --git a/chrome/browser/history/text_database_manager.cc b/chrome/browser/history/text_database_manager.cc index 98e5990..499e3e1 100644 --- a/chrome/browser/history/text_database_manager.cc +++ b/chrome/browser/history/text_database_manager.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. @@ -33,7 +33,7 @@ std::string ConvertStringForIndexer(const string16& input) { // Data older than this will be committed to the full text index even if we // haven't gotten a title and/or body. -const int kExpirationSec = 20; +const int kExpirationSeconds = 20; } // namespace @@ -71,7 +71,7 @@ void TextDatabaseManager::PageInfo::set_body(const string16& bdy) { } bool TextDatabaseManager::PageInfo::Expired(TimeTicks now) const { - return now - added_time_ > TimeDelta::FromSeconds(kExpirationSec); + return now - added_time_ > base::TimeDelta::FromSeconds(kExpirationSeconds); } // TextDatabaseManager --------------------------------------------------------- @@ -208,8 +208,8 @@ void TextDatabaseManager::AddPageTitle(const GURL& url, // not worth it for this edge case. // // It will be almost impossible for the title to take longer than - // kExpirationSec yet we got a body in less than that time, since the - // title should always come in first. + // kExpirationSeconds yet we got a body in less than that time, since + // the title should always come in first. return; } @@ -235,9 +235,9 @@ void TextDatabaseManager::AddPageContents(const GURL& url, RecentChangeList::iterator found = recent_changes_.Peek(url); if (found == recent_changes_.end()) { // This page is not in our cache of recent pages. This means that the page - // took more than kExpirationSec to load. Often, this will be the result of - // a very slow iframe or other resource on the page that makes us think its - // still loading. + // took more than kExpirationSeconds to load. Often, this will be the result + // of a very slow iframe or other resource on the page that makes us think + // its still loading. // // As a fallback, set the most recent visit's contents using the input, and // use the last set title in the URL table as the title to index. @@ -538,7 +538,7 @@ void TextDatabaseManager::ScheduleFlushOldChanges() { FROM_HERE, base::Bind(&TextDatabaseManager::FlushOldChanges, weak_factory_.GetWeakPtr()), - kExpirationSec * Time::kMillisecondsPerSecond); + base::TimeDelta::FromSeconds(kExpirationSeconds)); } void TextDatabaseManager::FlushOldChanges() { diff --git a/chrome/browser/images_uitest.cc b/chrome/browser/images_uitest.cc index 5c36e40..bc146eb 100644 --- a/chrome/browser/images_uitest.cc +++ b/chrome/browser/images_uitest.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. @@ -17,7 +17,7 @@ TEST_F(ImagesTest, AnimatedGIFs) { NavigateToURL(net::FilePathToFileURL(test_file)); // Let the GIFs fully animate. - base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms()); + base::PlatformThread::Sleep(TestTimeouts::action_timeout()); std::wstring page_title = L"animated gif test"; EXPECT_EQ(page_title, GetActiveTabTitle()); diff --git a/chrome/browser/intranet_redirect_detector.cc b/chrome/browser/intranet_redirect_detector.cc index eb3265b..ab7d520 100644 --- a/chrome/browser/intranet_redirect_detector.cc +++ b/chrome/browser/intranet_redirect_detector.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. @@ -33,11 +33,11 @@ IntranetRedirectDetector::IntranetRedirectDetector() // Ideally, instead of this timer, we'd do something like "check if the // browser is starting up, and if so, come back later", but there is currently // no function to do this. - static const int kStartFetchDelayMS = 7000; + static const int kStartFetchDelaySeconds = 7; MessageLoop::current()->PostDelayedTask(FROM_HERE, base::Bind(&IntranetRedirectDetector::FinishSleep, weak_factory_.GetWeakPtr()), - kStartFetchDelayMS); + base::TimeDelta::FromSeconds(kStartFetchDelaySeconds)); net::NetworkChangeNotifier::AddIPAddressObserver(this); } @@ -154,7 +154,7 @@ void IntranetRedirectDetector::OnIPAddressChanged() { MessageLoop::current()->PostDelayedTask(FROM_HERE, base::Bind(&IntranetRedirectDetector::FinishSleep, weak_factory_.GetWeakPtr()), - kNetworkSwitchDelayMS); + base::TimeDelta::FromMilliseconds(kNetworkSwitchDelayMS)); } IntranetRedirectHostResolverProc::IntranetRedirectHostResolverProc( diff --git a/chrome/browser/media_uitest.cc b/chrome/browser/media_uitest.cc index 91732ce..58e0433 100644 --- a/chrome/browser/media_uitest.cc +++ b/chrome/browser/media_uitest.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. @@ -31,15 +31,16 @@ class MediaTest : public UITest { const std::wstring kPlaying = L"PLAYING"; const std::wstring kFailed = L"FAILED"; const std::wstring kError = L"ERROR"; - const int kSleepIntervalMs = 250; + const base::TimeDelta kSleepInterval = + base::TimeDelta::FromMilliseconds(250); const int kNumIntervals = - TestTimeouts::action_timeout_ms() / kSleepIntervalMs; + TestTimeouts::action_timeout() / kSleepInterval; for (int i = 0; i < kNumIntervals; ++i) { const std::wstring& title = GetActiveTabTitle(); if (title == kPlaying || title == kFailed || StartsWith(title, kError, true)) break; - base::PlatformThread::Sleep(kSleepIntervalMs); + base::PlatformThread::Sleep(kSleepInterval); } EXPECT_EQ(kPlaying, GetActiveTabTitle()); diff --git a/chrome/browser/omnibox_search_hint.cc b/chrome/browser/omnibox_search_hint.cc index cfaf6ef..2c9b4c6 100644 --- a/chrome/browser/omnibox_search_hint.cc +++ b/chrome/browser/omnibox_search_hint.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. @@ -100,7 +100,7 @@ HintInfoBar::HintInfoBar(OmniboxSearchHint* omnibox_hint) MessageLoop::current()->PostDelayedTask( FROM_HERE, base::Bind(&HintInfoBar::AllowExpiry, weak_factory_.GetWeakPtr()), - 8000); // 8 seconds. + base::TimeDelta::FromSeconds(8)); } HintInfoBar::~HintInfoBar() { diff --git a/chrome/browser/process_singleton_linux.cc b/chrome/browser/process_singleton_linux.cc index eda06a0..ca9f9a3 100644 --- a/chrome/browser/process_singleton_linux.cc +++ b/chrome/browser/process_singleton_linux.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. @@ -835,7 +835,7 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessWithTimeout( return PROCESS_NONE; } - base::PlatformThread::Sleep(1000 /* ms */); + base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1)); } timeval timeout = {timeout_seconds, 0}; diff --git a/chrome/browser/renderer_host/web_cache_manager.cc b/chrome/browser/renderer_host/web_cache_manager.cc index 02bf510..5999a27 100644 --- a/chrome/browser/renderer_host/web_cache_manager.cc +++ b/chrome/browser/renderer_host/web_cache_manager.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. @@ -26,7 +26,7 @@ using base::Time; using base::TimeDelta; using WebKit::WebCache; -static const unsigned int kReviseAllocationDelayMS = 200 /* milliseconds */; +static const int kReviseAllocationDelayMS = 200; // The default size limit of the in-memory cache is 8 MB static const int kDefaultMemoryCacheSize = 8 * 1024 * 1024; @@ -421,7 +421,7 @@ void WebCacheManager::ReviseAllocationStrategyLater() { base::Bind( &WebCacheManager::ReviseAllocationStrategy, weak_factory_.GetWeakPtr()), - kReviseAllocationDelayMS); + base::TimeDelta::FromMilliseconds(kReviseAllocationDelayMS)); } void WebCacheManager::FindInactiveRenderers() { diff --git a/chrome/browser/safe_browsing/client_side_detection_service.cc b/chrome/browser/safe_browsing/client_side_detection_service.cc index 0af1ab4..85c410e 100644 --- a/chrome/browser/safe_browsing/client_side_detection_service.cc +++ b/chrome/browser/safe_browsing/client_side_detection_service.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. @@ -245,7 +245,7 @@ void ClientSideDetectionService::ScheduleFetchModel(int64 delay_ms) { FROM_HERE, base::Bind(&ClientSideDetectionService::StartFetchModel, weak_factory_.GetWeakPtr()), - delay_ms); + base::TimeDelta::FromMilliseconds(delay_ms)); } void ClientSideDetectionService::StartFetchModel() { diff --git a/chrome/browser/safe_browsing/safe_browsing_service.cc b/chrome/browser/safe_browsing/safe_browsing_service.cc index 907a424..9c8c652 100644 --- a/chrome/browser/safe_browsing/safe_browsing_service.cc +++ b/chrome/browser/safe_browsing/safe_browsing_service.cc @@ -1239,7 +1239,7 @@ void SafeBrowsingService::StartDownloadCheck(SafeBrowsingCheck* check, MessageLoop::current()->PostDelayedTask(FROM_HERE, base::Bind(&SafeBrowsingService::TimeoutCallback, check->timeout_factory_->GetWeakPtr(), check), - timeout_ms); + base::TimeDelta::FromMilliseconds(timeout_ms)); } void SafeBrowsingService::UpdateWhitelist(const UnsafeResource& resource) { diff --git a/chrome/browser/service/service_process_control.cc b/chrome/browser/service/service_process_control.cc index 2d974f6..94a3a89 100644 --- a/chrome/browser/service/service_process_control.cc +++ b/chrome/browser/service/service_process_control.cc @@ -300,7 +300,7 @@ void ServiceProcessControl::Launcher::DoDetectLaunched() { retry_count_++; // If the service process is not launched yet then check again in 2 seconds. - const int kDetectLaunchRetry = 2000; + const base::TimeDelta kDetectLaunchRetry = base::TimeDelta::FromSeconds(2); MessageLoop::current()->PostDelayedTask( FROM_HERE, base::Bind(&Launcher::DoDetectLaunched, this), kDetectLaunchRetry); diff --git a/chrome/browser/task_manager/task_manager.cc b/chrome/browser/task_manager/task_manager.cc index 9015f14..c141ed0 100644 --- a/chrome/browser/task_manager/task_manager.cc +++ b/chrome/browser/task_manager/task_manager.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. @@ -627,8 +627,9 @@ void TaskManagerModel::StartUpdating() { // it to TASK_PENDING ensures the tasks keep being posted (by Refresh()). if (update_state_ == IDLE) { MessageLoop::current()->PostDelayedTask( - FROM_HERE, base::Bind(&TaskManagerModel::Refresh, this), - kUpdateTimeMs); + FROM_HERE, + base::Bind(&TaskManagerModel::Refresh, this), + base::TimeDelta::FromMilliseconds(kUpdateTimeMs)); } update_state_ = TASK_PENDING; @@ -870,14 +871,16 @@ void TaskManagerModel::Refresh() { // Compute the new network usage values. displayed_network_usage_map_.clear(); + base::TimeDelta update_time = + base::TimeDelta::FromMilliseconds(kUpdateTimeMs); for (ResourceValueMap::iterator iter = current_byte_count_map_.begin(); iter != current_byte_count_map_.end(); ++iter) { - if (kUpdateTimeMs > 1000) { - int divider = (kUpdateTimeMs / 1000); + if (update_time > base::TimeDelta::FromSeconds(1)) { + int divider = update_time.InSeconds(); displayed_network_usage_map_[iter->first] = iter->second / divider; } else { displayed_network_usage_map_[iter->first] = iter->second * - (1000 / kUpdateTimeMs); + (1 / update_time.InSeconds()); } // Then we reset the current byte count. @@ -897,7 +900,9 @@ void TaskManagerModel::Refresh() { // Schedule the next update. MessageLoop::current()->PostDelayedTask( - FROM_HERE, base::Bind(&TaskManagerModel::Refresh, this), kUpdateTimeMs); + FROM_HERE, + base::Bind(&TaskManagerModel::Refresh, this), + base::TimeDelta::FromMilliseconds(kUpdateTimeMs)); } int64 TaskManagerModel::GetNetworkUsageForResource( diff --git a/chrome/browser/translate/translate_manager.cc b/chrome/browser/translate/translate_manager.cc index 8fd0c4f..94db9d2 100644 --- a/chrome/browser/translate/translate_manager.cc +++ b/chrome/browser/translate/translate_manager.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. @@ -138,7 +138,7 @@ const char* const kReportLanguageDetectionErrorURL = const char* const kLanguageListFetchURL = "http://translate.googleapis.com/translate_a/l?client=chrome&cb=sl"; const int kMaxRetryLanguageListFetch = 5; -const int kTranslateScriptExpirationDelayMS = 24 * 60 * 60 * 1000; // 1 day. +const int kTranslateScriptExpirationDelayDays = 1; } // namespace @@ -450,7 +450,8 @@ bool TranslateManager::IsShowingTranslateInfobar(WebContents* tab) { TranslateManager::TranslateManager() : ALLOW_THIS_IN_INITIALIZER_LIST(weak_method_factory_(this)), - translate_script_expiration_delay_(kTranslateScriptExpirationDelayMS) { + translate_script_expiration_delay_( + base::TimeDelta::FromDays(kTranslateScriptExpirationDelayDays)) { notification_registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, content::NotificationService::AllSources()); notification_registrar_.Add(this, diff --git a/chrome/browser/translate/translate_manager.h b/chrome/browser/translate/translate_manager.h index 5e7f089..9409732 100644 --- a/chrome/browser/translate/translate_manager.h +++ b/chrome/browser/translate/translate_manager.h @@ -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. @@ -83,7 +83,8 @@ class TranslateManager : public content::NotificationObserver, // Used by unit-tests to override the default delay after which the translate // script is fetched again from the translation server. void set_translate_script_expiration_delay(int delay_ms) { - translate_script_expiration_delay_ = delay_ms; + translate_script_expiration_delay_ = + base::TimeDelta::FromMilliseconds(delay_ms); } // Convenience method to know if a tab is showing a translate infobar. @@ -198,9 +199,9 @@ class TranslateManager : public content::NotificationObserver, // The JS injected in the page to do the translation. std::string translate_script_; - // Delay in milli-seconds after which the translate script is fetched again + // Delay after which the translate script is fetched again // from the translate server. - int translate_script_expiration_delay_; + base::TimeDelta translate_script_expiration_delay_; // Set when the translate JS is currently being retrieved. NULL otherwise. scoped_ptr<content::URLFetcher> translate_script_request_pending_; diff --git a/chrome/browser/unload_uitest.cc b/chrome/browser/unload_uitest.cc index 3ef1290..7058e27 100644 --- a/chrome/browser/unload_uitest.cc +++ b/chrome/browser/unload_uitest.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. @@ -16,6 +16,8 @@ #include "ui/base/events.h" #include "ui/base/ui_base_types.h" +using base::TimeDelta; + const std::string NOLISTENERS_HTML = "<html><head><title>nolisteners</title></head><body></body></html>"; @@ -105,12 +107,12 @@ class UnloadTest : public UITest { } void CheckTitle(const std::wstring& expected_title) { - const int kCheckDelayMs = 100; - for (int max_wait_time = TestTimeouts::action_max_timeout_ms(); - max_wait_time > 0; max_wait_time -= kCheckDelayMs) { + const TimeDelta kCheckDelay = TimeDelta::FromMilliseconds(100); + for (TimeDelta max_wait_time = TestTimeouts::action_max_timeout(); + max_wait_time > TimeDelta(); max_wait_time -= kCheckDelay) { if (expected_title == GetActiveTabTitle()) break; - base::PlatformThread::Sleep(kCheckDelayMs); + base::PlatformThread::Sleep(kCheckDelay); } EXPECT_EQ(expected_title, GetActiveTabTitle()); @@ -304,7 +306,7 @@ TEST_F(UnloadTest, BrowserCloseBeforeUnloadCancel) { // There's no real graceful way to wait for something _not_ to happen, so // we just wait a short period. - base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms()); + base::PlatformThread::Sleep(TestTimeouts::action_timeout()); CloseBrowserAsync(browser.get()); ClickModalDialogButton(ui::DIALOG_BUTTON_OK); diff --git a/chrome/browser/visitedlink/visitedlink_unittest.cc b/chrome/browser/visitedlink/visitedlink_unittest.cc index 2d52cb0..e148691 100644 --- a/chrome/browser/visitedlink/visitedlink_unittest.cc +++ b/chrome/browser/visitedlink/visitedlink_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. @@ -590,8 +590,10 @@ class VisitedLinkEventsTest : public ChromeRenderViewHostTestHarness { void WaitForCoalescense() { // Let the timer fire. - MessageLoop::current()->PostDelayedTask(FROM_HERE, - MessageLoop::QuitClosure(), 110); + MessageLoop::current()->PostDelayedTask( + FROM_HERE, + MessageLoop::QuitClosure(), + base::TimeDelta::FromMilliseconds(110)); MessageLoop::current()->Run(); } diff --git a/chrome/browser/web_resource/promo_resource_service.cc b/chrome/browser/web_resource/promo_resource_service.cc index 3ca0e80..8d12fb5 100644 --- a/chrome/browser/web_resource/promo_resource_service.cc +++ b/chrome/browser/web_resource/promo_resource_service.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. @@ -217,7 +217,7 @@ void PromoResourceService::PostNotification(int64 delay_ms) { FROM_HERE, base::Bind(&PromoResourceService::PromoResourceStateChange, weak_ptr_factory_.GetWeakPtr()), - delay_ms); + base::TimeDelta::FromMilliseconds(delay_ms)); } else if (delay_ms == 0) { PromoResourceStateChange(); } diff --git a/chrome/browser/web_resource/web_resource_service.cc b/chrome/browser/web_resource/web_resource_service.cc index 65a6de5..8fc7ae7 100644 --- a/chrome/browser/web_resource/web_resource_service.cc +++ b/chrome/browser/web_resource/web_resource_service.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. @@ -180,7 +180,7 @@ void WebResourceService::ScheduleFetch(int64 delay_ms) { FROM_HERE, base::Bind(&WebResourceService::StartFetch, weak_ptr_factory_.GetWeakPtr()), - delay_ms); + base::TimeDelta::FromMilliseconds(delay_ms)); } // Initializes the fetching of data from the resource server. Data diff --git a/chrome/common/important_file_writer_unittest.cc b/chrome/common/important_file_writer_unittest.cc index 84d307a..f44ce60 100644 --- a/chrome/common/important_file_writer_unittest.cc +++ b/chrome/common/important_file_writer_unittest.cc @@ -75,8 +75,10 @@ TEST_F(ImportantFileWriterTest, ScheduleWrite) { DataSerializer serializer("foo"); writer.ScheduleWrite(&serializer); EXPECT_TRUE(writer.HasPendingWrite()); - MessageLoop::current()->PostDelayedTask(FROM_HERE, - MessageLoop::QuitClosure(), 100); + MessageLoop::current()->PostDelayedTask( + FROM_HERE, + MessageLoop::QuitClosure(), + base::TimeDelta::FromMilliseconds(100)); MessageLoop::current()->Run(); EXPECT_FALSE(writer.HasPendingWrite()); ASSERT_TRUE(file_util::PathExists(writer.path())); @@ -91,8 +93,10 @@ TEST_F(ImportantFileWriterTest, DoScheduledWrite) { writer.ScheduleWrite(&serializer); EXPECT_TRUE(writer.HasPendingWrite()); writer.DoScheduledWrite(); - MessageLoop::current()->PostDelayedTask(FROM_HERE, - MessageLoop::QuitClosure(), 100); + MessageLoop::current()->PostDelayedTask( + FROM_HERE, + MessageLoop::QuitClosure(), + base::TimeDelta::FromMilliseconds(100)); MessageLoop::current()->Run(); EXPECT_FALSE(writer.HasPendingWrite()); ASSERT_TRUE(file_util::PathExists(writer.path())); @@ -108,8 +112,10 @@ TEST_F(ImportantFileWriterTest, FLAKY_BatchingWrites) { writer.ScheduleWrite(&foo); writer.ScheduleWrite(&bar); writer.ScheduleWrite(&baz); - MessageLoop::current()->PostDelayedTask(FROM_HERE, - MessageLoop::QuitClosure(), 100); + MessageLoop::current()->PostDelayedTask( + FROM_HERE, + MessageLoop::QuitClosure(), + base::TimeDelta::FromMilliseconds(100)); MessageLoop::current()->Run(); ASSERT_TRUE(file_util::PathExists(writer.path())); EXPECT_EQ("baz", GetFileContent(writer.path())); diff --git a/chrome/common/profiling.cc b/chrome/common/profiling.cc index f355052..e9d33f5 100644 --- a/chrome/common/profiling.cc +++ b/chrome/common/profiling.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. @@ -41,7 +41,7 @@ void FlushProfilingData(base::Thread* thread) { return; base::debug::FlushProfiling(); - static int flush_seconds = 0; + static int flush_seconds; if (!flush_seconds) { const CommandLine& command_line = *CommandLine::ForCurrentProcess(); std::string profiling_flush = @@ -54,7 +54,9 @@ void FlushProfilingData(base::Thread* thread) { } } thread->message_loop()->PostDelayedTask( - FROM_HERE, base::Bind(&FlushProfilingData, thread), flush_seconds * 1000); + FROM_HERE, + base::Bind(&FlushProfilingData, thread), + base::TimeDelta::FromSeconds(flush_seconds)); } class ProfilingThreadControl { diff --git a/chrome/common/service_process_util_linux.cc b/chrome/common/service_process_util_linux.cc index 457a50c..5fb5a81 100644 --- a/chrome/common/service_process_util_linux.cc +++ b/chrome/common/service_process_util_linux.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. @@ -31,7 +31,7 @@ MultiProcessLock* TakeNamedLock(const std::string& name, bool waiting) { break; } if (!waiting) break; - base::PlatformThread::Sleep(100 * i); + base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100 * i)); } if (!got_lock) { lock.reset(); diff --git a/chrome/common/service_process_util_unittest.cc b/chrome/common/service_process_util_unittest.cc index 5de195d..c8f5677 100644 --- a/chrome/common/service_process_util_unittest.cc +++ b/chrome/common/service_process_util_unittest.cc @@ -185,7 +185,7 @@ TEST_F(ServiceProcessStateTest, MAYBE_ForceShutdown) { true); ASSERT_TRUE(handle); for (int i = 0; !CheckServiceProcessReady() && i < 10; ++i) { - base::PlatformThread::Sleep(TestTimeouts::tiny_timeout_ms()); + base::PlatformThread::Sleep(TestTimeouts::tiny_timeout()); } ASSERT_TRUE(CheckServiceProcessReady()); std::string version; @@ -228,7 +228,7 @@ MULTIPROCESS_TEST_MAIN(ServiceProcessStateTestShutdown) { MessageLoop::current()))); message_loop.PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(), - TestTimeouts::action_max_timeout_ms()); + TestTimeouts::action_max_timeout()); EXPECT_FALSE(g_good_shutdown); message_loop.Run(); EXPECT_TRUE(g_good_shutdown); @@ -274,7 +274,7 @@ class ServiceProcessStateFileManipulationTest : public ::testing::Test { base::Closure())); loop_.PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(), - TestTimeouts::action_max_timeout_ms()); + TestTimeouts::action_max_timeout()); } const MockLaunchd* mock_launchd() const { return mock_launchd_.get(); } diff --git a/chrome/common/worker_thread_ticker.cc b/chrome/common/worker_thread_ticker.cc index 391f0a3..b1dc279 100644 --- a/chrome/common/worker_thread_ticker.cc +++ b/chrome/common/worker_thread_ticker.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. @@ -15,7 +15,7 @@ WorkerThreadTicker::WorkerThreadTicker(int tick_interval) : timer_thread_("worker_thread_ticker"), is_running_(false), - tick_interval_(tick_interval) { + tick_interval_(base::TimeDelta::FromMilliseconds(tick_interval)) { } WorkerThreadTicker::~WorkerThreadTicker() { diff --git a/chrome/common/worker_thread_ticker.h b/chrome/common/worker_thread_ticker.h index dc5f542..d009a62 100644 --- a/chrome/common/worker_thread_ticker.h +++ b/chrome/common/worker_thread_ticker.h @@ -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. @@ -58,11 +58,11 @@ class WorkerThreadTicker { } void set_tick_interval(int tick_interval) { - tick_interval_ = tick_interval; + tick_interval_ = base::TimeDelta::FromMilliseconds(tick_interval); } int tick_interval() const { - return tick_interval_; + return tick_interval_.InMilliseconds(); } private: @@ -80,7 +80,7 @@ class WorkerThreadTicker { bool is_running_; // The interval at which the callbacks are to be invoked - int tick_interval_; + base::TimeDelta tick_interval_; // A list that holds all registered callback interfaces TickHandlerListType tick_handler_list_; diff --git a/chrome/common/worker_thread_ticker_unittest.cc b/chrome/common/worker_thread_ticker_unittest.cc index b999c33..ffb0d00 100644 --- a/chrome/common/worker_thread_ticker_unittest.cc +++ b/chrome/common/worker_thread_ticker_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 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,13 +32,15 @@ class TestCallback : public WorkerThreadTicker::Callback { class LongCallback : public WorkerThreadTicker::Callback { public: virtual void OnTick() { - base::PlatformThread::Sleep(1500); + base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(1500)); } }; void RunMessageLoopForAWhile() { - MessageLoop::current()->PostDelayedTask(FROM_HERE, - MessageLoop::QuitClosure(), 500); + MessageLoop::current()->PostDelayedTask( + FROM_HERE, + MessageLoop::QuitClosure(), + base::TimeDelta::FromMilliseconds(500)); MessageLoop::current()->Run(); } diff --git a/chrome/renderer/about_handler.cc b/chrome/renderer/about_handler.cc index 1b21e76..8651b6e 100644 --- a/chrome/renderer/about_handler.cc +++ b/chrome/renderer/about_handler.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. @@ -61,13 +61,13 @@ void AboutHandler::AboutKill() { // static void AboutHandler::AboutHang() { for (;;) { - base::PlatformThread::Sleep(1000); + base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1)); } } // static void AboutHandler::AboutShortHang() { - base::PlatformThread::Sleep(20000); + base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20)); } // static diff --git a/chrome/renderer/chrome_render_process_observer.cc b/chrome/renderer/chrome_render_process_observer.cc index 7df7197..ed58e72 100644 --- a/chrome/renderer/chrome_render_process_observer.cc +++ b/chrome/renderer/chrome_render_process_observer.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. @@ -56,7 +56,7 @@ using content::RenderThread; namespace { -static const unsigned int kCacheStatsDelayMS = 2000 /* milliseconds */; +static const int kCacheStatsDelayMS = 2000; class RendererResourceDelegate : public content::ResourceDispatcherDelegate { public: @@ -75,7 +75,7 @@ class RendererResourceDelegate : public content::ResourceDispatcherDelegate { FROM_HERE, base::Bind(&RendererResourceDelegate::InformHostOfCacheStats, weak_factory_.GetWeakPtr()), - kCacheStatsDelayMS); + base::TimeDelta::FromMilliseconds(kCacheStatsDelayMS)); } if (status.status() != net::URLRequestStatus::CANCELED || diff --git a/chrome/renderer/chrome_render_view_observer.cc b/chrome/renderer/chrome_render_view_observer.cc index 55b3dda..403cdc8 100644 --- a/chrome/renderer/chrome_render_view_observer.cc +++ b/chrome/renderer/chrome_render_view_observer.cc @@ -665,7 +665,9 @@ void ChromeRenderViewObserver::DidStopLoading() { FROM_HERE, base::Bind(&ChromeRenderViewObserver::CapturePageInfo, weak_factory_.GetWeakPtr(), render_view()->GetPageId(), false), - render_view()->GetContentStateImmediately() ? 0 : kDelayForCaptureMs); + base::TimeDelta::FromMilliseconds( + render_view()->GetContentStateImmediately() ? + 0 : kDelayForCaptureMs)); WebFrame* main_frame = render_view()->GetWebView()->mainFrame(); GURL osd_url = main_frame->document().openSearchDescriptionURL(); @@ -721,7 +723,7 @@ void ChromeRenderViewObserver::DidCommitProvisionalLoad( FROM_HERE, base::Bind(&ChromeRenderViewObserver::CapturePageInfo, weak_factory_.GetWeakPtr(), render_view()->GetPageId(), true), - kDelayForForcedCaptureMs); + base::TimeDelta::FromMilliseconds(kDelayForForcedCaptureMs)); } void ChromeRenderViewObserver::DidClearWindowObject(WebFrame* frame) { diff --git a/chrome/renderer/extensions/user_script_idle_scheduler.cc b/chrome/renderer/extensions/user_script_idle_scheduler.cc index 4042bfd..13853d6 100644 --- a/chrome/renderer/extensions/user_script_idle_scheduler.cc +++ b/chrome/renderer/extensions/user_script_idle_scheduler.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. @@ -56,7 +56,7 @@ void UserScriptIdleScheduler::DidFinishDocumentLoad() { MessageLoop::current()->PostDelayedTask( FROM_HERE, base::Bind(&UserScriptIdleScheduler::MaybeRun, weak_factory_.GetWeakPtr()), - kUserScriptIdleTimeoutMs); + base::TimeDelta::FromMilliseconds(kUserScriptIdleTimeoutMs)); } void UserScriptIdleScheduler::DidFinishLoad() { diff --git a/chrome/renderer/net/renderer_net_predictor.cc b/chrome/renderer/net/renderer_net_predictor.cc index 9b6c489..746cd22 100644 --- a/chrome/renderer/net/renderer_net_predictor.cc +++ b/chrome/renderer/net/renderer_net_predictor.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. @@ -57,7 +57,7 @@ void RendererNetPredictor::Resolve(const char* name, size_t length) { RenderThread::Get()->GetMessageLoop()->PostDelayedTask( FROM_HERE, base::Bind(&RendererNetPredictor::SubmitHostnames, weak_factory_.GetWeakPtr()), - 10); + base::TimeDelta::FromMilliseconds(10)); } return; } @@ -92,7 +92,7 @@ void RendererNetPredictor::SubmitHostnames() { RenderThread::Get()->GetMessageLoop()->PostDelayedTask( FROM_HERE, base::Bind(&RendererNetPredictor::SubmitHostnames, weak_factory_.GetWeakPtr()), - 10); + base::TimeDelta::FromMilliseconds(10)); } else { // TODO(JAR): Should we only clear the map when we navigate, or reload? domain_map_.clear(); diff --git a/chrome/renderer/translate_helper.cc b/chrome/renderer/translate_helper.cc index 36e1e4c..124fffb 100644 --- a/chrome/renderer/translate_helper.cc +++ b/chrome/renderer/translate_helper.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,7 +28,7 @@ using WebKit::WebScriptSource; using WebKit::WebString; using WebKit::WebView; -// The delay in millliseconds that we'll wait before checking to see if the +// The delay in milliseconds that we'll wait before checking to see if the // translate library injected in the page is ready. static const int kTranslateInitCheckDelayMs = 150; @@ -339,10 +339,12 @@ void TranslateHelper::CheckTranslateStatus() { } // The translation is still pending, check again later. - MessageLoop::current()->PostDelayedTask(FROM_HERE, + MessageLoop::current()->PostDelayedTask( + FROM_HERE, base::Bind(&TranslateHelper::CheckTranslateStatus, weak_method_factory_.GetWeakPtr()), - DontDelayTasks() ? 0 : kTranslateStatusCheckDelayMs); + base::TimeDelta::FromMilliseconds( + DontDelayTasks() ? 0 : kTranslateStatusCheckDelayMs)); } bool TranslateHelper::ExecuteScript(const std::string& script) { @@ -401,10 +403,12 @@ void TranslateHelper::TranslatePageImpl(int count) { NotifyBrowserTranslationFailed(TranslateErrors::INITIALIZATION_ERROR); return; } - MessageLoop::current()->PostDelayedTask(FROM_HERE, + MessageLoop::current()->PostDelayedTask( + FROM_HERE, base::Bind(&TranslateHelper::TranslatePageImpl, weak_method_factory_.GetWeakPtr(), count), - DontDelayTasks() ? 0 : count * kTranslateInitCheckDelayMs); + base::TimeDelta::FromMilliseconds( + DontDelayTasks() ? 0 : count * kTranslateInitCheckDelayMs)); return; } @@ -413,10 +417,12 @@ void TranslateHelper::TranslatePageImpl(int count) { return; } // Check the status of the translation. - MessageLoop::current()->PostDelayedTask(FROM_HERE, + MessageLoop::current()->PostDelayedTask( + FROM_HERE, base::Bind(&TranslateHelper::CheckTranslateStatus, weak_method_factory_.GetWeakPtr()), - DontDelayTasks() ? 0 : kTranslateStatusCheckDelayMs); + base::TimeDelta::FromMilliseconds( + DontDelayTasks() ? 0 : kTranslateStatusCheckDelayMs)); } void TranslateHelper::NotifyBrowserTranslationFailed( |