diff options
45 files changed, 176 insertions, 139 deletions
diff --git a/base/message_loop_proxy_impl.cc b/base/message_loop_proxy_impl.cc index e0ecd89..dd20b39 100644 --- a/base/message_loop_proxy_impl.cc +++ b/base/message_loop_proxy_impl.cc @@ -81,11 +81,11 @@ bool MessageLoopProxyImpl::PostTaskHelper( int64 delay_ms, bool nestable) { AutoLock lock(message_loop_lock_); if (target_message_loop_) { + base::TimeDelta delay = base::TimeDelta::FromMilliseconds(delay_ms); if (nestable) { - target_message_loop_->PostDelayedTask(from_here, task, delay_ms); + target_message_loop_->PostDelayedTask(from_here, task, delay); } else { - target_message_loop_->PostNonNestableDelayedTask(from_here, task, - delay_ms); + target_message_loop_->PostNonNestableDelayedTask(from_here, task, delay); } return true; } diff --git a/base/timer.cc b/base/timer.cc index 9d175f3..5c2aa21 100644 --- a/base/timer.cc +++ b/base/timer.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. @@ -25,7 +25,7 @@ void BaseTimer_Helper::InitiateDelayedTask(TimerTask* timer_task) { MessageLoop::current()->PostDelayedTask( timer_task->posted_from_, base::Bind(&TimerTask::Run, base::Owned(timer_task)), - static_cast<int>(timer_task->delay_.InMillisecondsRoundedUp())); + timer_task->delay_); } } // namespace base diff --git a/chrome/browser/feedback/feedback_util.cc b/chrome/browser/feedback/feedback_util.cc index 1c22d47..56d9896 100644 --- a/chrome/browser/feedback/feedback_util.cc +++ b/chrome/browser/feedback/feedback_util.cc @@ -173,8 +173,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 6f666b3..669dc33 100644 --- a/chrome/browser/safe_browsing/safe_browsing_service.cc +++ b/chrome/browser/safe_browsing/safe_browsing_service.cc @@ -1240,7 +1240,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 8a801b7..36bf397 100644 --- a/chrome/browser/task_manager/task_manager.cc +++ b/chrome/browser/task_manager/task_manager.cc @@ -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 5c383d8..978fcf84 100644 --- a/chrome/browser/translate/translate_manager.cc +++ b/chrome/browser/translate/translate_manager.cc @@ -159,7 +159,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 @@ -487,7 +487,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 0dcf695..5646795 100644 --- a/chrome/browser/translate/translate_manager.h +++ b/chrome/browser/translate/translate_manager.h @@ -15,6 +15,7 @@ #include "base/lazy_instance.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" +#include "base/time.h" #include "chrome/browser/prefs/pref_change_registrar.h" #include "chrome/common/translate_errors.h" #include "content/public/common/url_fetcher_delegate.h" @@ -84,7 +85,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. @@ -201,9 +203,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 536384f..6525d8b 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. @@ -593,8 +593,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 a93fdde..72724e6 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. @@ -181,7 +181,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 24914d5..b15cc96 100644 --- a/chrome/common/profiling.cc +++ b/chrome/common/profiling.cc @@ -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_unittest.cc b/chrome/common/service_process_util_unittest.cc index c402fb6..c0516b9 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); @@ -275,7 +275,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 d55bb57..9f29c66 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( diff --git a/content/browser/browser_child_process_host_impl.cc b/content/browser/browser_child_process_host_impl.cc index 54f8fcc..c5874df 100644 --- a/content/browser/browser_child_process_host_impl.cc +++ b/content/browser/browser_child_process_host_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. @@ -258,12 +258,13 @@ void BrowserChildProcessHostImpl::OnChildDisconnected() { // disconnecting the channel so that the exit code and termination status // become available. This is best effort -- if the process doesn't die // within the time limit, this object gets destroyed. - const int kExitCodeWaitMs = 250; + const base::TimeDelta kExitCodeWait = + base::TimeDelta::FromMilliseconds(250); MessageLoop::current()->PostDelayedTask( FROM_HERE, base::Bind(&BrowserChildProcessHostImpl::OnChildDisconnected, task_factory_.GetWeakPtr()), - kExitCodeWaitMs); + kExitCodeWait); #endif return; } diff --git a/content/browser/browser_thread_impl.cc b/content/browser/browser_thread_impl.cc index 0814a3c..155160b 100644 --- a/content/browser/browser_thread_impl.cc +++ b/content/browser/browser_thread_impl.cc @@ -161,10 +161,11 @@ bool BrowserThreadImpl::PostTaskHelper( MessageLoop* message_loop = globals.threads[identifier] ? globals.threads[identifier]->message_loop() : NULL; if (message_loop) { + base::TimeDelta delay = base::TimeDelta::FromMilliseconds(delay_ms); if (nestable) { - message_loop->PostDelayedTask(from_here, task, delay_ms); + message_loop->PostDelayedTask(from_here, task, delay); } else { - message_loop->PostNonNestableDelayedTask(from_here, task, delay_ms); + message_loop->PostNonNestableDelayedTask(from_here, task, delay); } } diff --git a/content/browser/gamepad/gamepad_provider.cc b/content/browser/gamepad/gamepad_provider.cc index 4c00cc1..3c533c3 100644 --- a/content/browser/gamepad/gamepad_provider.cc +++ b/content/browser/gamepad/gamepad_provider.cc @@ -140,7 +140,7 @@ void GamepadProvider::ScheduleDoPoll() { MessageLoop::current()->PostDelayedTask( FROM_HERE, base::Bind(&GamepadProvider::DoPoll, weak_factory_.GetWeakPtr()), - kDesiredSamplingIntervalMs); + base::TimeDelta::FromMilliseconds(kDesiredSamplingIntervalMs)); } GamepadHardwareBuffer* GamepadProvider::SharedMemoryAsHardwareBuffer() { diff --git a/content/browser/renderer_host/resource_dispatcher_host_uitest.cc b/content/browser/renderer_host/resource_dispatcher_host_uitest.cc index b46ae9f..8fbb16d 100644 --- a/content/browser/renderer_host/resource_dispatcher_host_uitest.cc +++ b/content/browser/renderer_host/resource_dispatcher_host_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. @@ -287,7 +287,7 @@ TEST_F(ResourceDispatcherTest, FAILS_CrossSiteAfterCrash) { #endif ASSERT_TRUE(tab->NavigateToURLAsync(GURL(chrome::kAboutCrashURL))); // Wait for browser to notice the renderer crash. - base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms()); + base::PlatformThread::Sleep(TestTimeouts::action_timeout()); // Navigate to a new cross-site page. The browser should not wait around for // the old renderer's on{before}unload handlers to run. diff --git a/content/ppapi_plugin/broker_process_dispatcher.cc b/content/ppapi_plugin/broker_process_dispatcher.cc index 6fce803..7cdc0e34 100644 --- a/content/ppapi_plugin/broker_process_dispatcher.cc +++ b/content/ppapi_plugin/broker_process_dispatcher.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. @@ -11,7 +11,7 @@ namespace { // How long we wait before releasing the broker process. -const int kBrokerReleaseTimeMs = 30 * 1000; // 30 seconds. +const int kBrokerReleaseTimeSeconds = 30; } // namespace @@ -34,5 +34,5 @@ BrokerProcessDispatcher::~BrokerProcessDispatcher() { FROM_HERE, base::Bind(&ChildProcess::ReleaseProcess, base::Unretained(ChildProcess::current())), - kBrokerReleaseTimeMs); + base::TimeDelta::FromSeconds(kBrokerReleaseTimeSeconds)); } diff --git a/content/ppapi_plugin/plugin_process_dispatcher.cc b/content/ppapi_plugin/plugin_process_dispatcher.cc index 1ac23d1..5d33e12 100644 --- a/content/ppapi_plugin/plugin_process_dispatcher.cc +++ b/content/ppapi_plugin/plugin_process_dispatcher.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. @@ -11,7 +11,7 @@ namespace { // How long we wait before releasing the plugin process. -const int kPluginReleaseTimeMs = 30 * 1000; // 30 seconds. +const int kPluginReleaseTimeSeconds = 30; } // namespace @@ -32,5 +32,5 @@ PluginProcessDispatcher::~PluginProcessDispatcher() { FROM_HERE, base::Bind(&ChildProcess::ReleaseProcess, base::Unretained(ChildProcess::current())), - kPluginReleaseTimeMs); + base::TimeDelta::FromSeconds(kPluginReleaseTimeSeconds)); } diff --git a/content/renderer/load_progress_tracker.cc b/content/renderer/load_progress_tracker.cc index cc153f6..b7a14ba 100644 --- a/content/renderer/load_progress_tracker.cc +++ b/content/renderer/load_progress_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. @@ -51,9 +51,11 @@ void LoadProgressTracker::DidChangeLoadProgress(WebKit::WebFrame* frame, // last updates. Also, since the message loop may be pretty busy when a page // is loaded, it might not execute a posted task in a timely manner so we make // sure to immediately send progress report if enough time has passed. + base::TimeDelta min_delay = + base::TimeDelta::FromMilliseconds(kMinimumDelayBetweenUpdatesMS); if (progress == 1.0 || last_time_progress_sent_.is_null() || - (base::TimeTicks::Now() - last_time_progress_sent_).InMilliseconds() > - kMinimumDelayBetweenUpdatesMS) { + base::TimeTicks::Now() - last_time_progress_sent_ > + min_delay) { // If there is a pending task to send progress, it is now obsolete. weak_factory_.InvalidateWeakPtrs(); SendChangeLoadProgress(); @@ -69,7 +71,7 @@ void LoadProgressTracker::DidChangeLoadProgress(WebKit::WebFrame* frame, FROM_HERE, base::Bind(&LoadProgressTracker::SendChangeLoadProgress, weak_factory_.GetWeakPtr()), - kMinimumDelayBetweenUpdatesMS); + min_delay); } void LoadProgressTracker::SendChangeLoadProgress() { diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc index e60c793..dfdae16 100644 --- a/content/renderer/render_widget.cc +++ b/content/renderer/render_widget.cc @@ -676,13 +676,13 @@ void RenderWidget::AnimateIfNeeded() { return; // Target 60FPS if vsync is on. Go as fast as we can if vsync is off. - int animationInterval = IsRenderingVSynced() ? 16 : 0; + base::TimeDelta animationInterval = IsRenderingVSynced() ? + base::TimeDelta::FromMilliseconds(16) : base::TimeDelta(); base::Time now = base::Time::Now(); if (now >= animation_floor_time_ || is_accelerated_compositing_active_) { TRACE_EVENT0("renderer", "RenderWidget::AnimateIfNeeded") - animation_floor_time_ = now + - base::TimeDelta::FromMilliseconds(animationInterval); + animation_floor_time_ = now + animationInterval; // Set a timer to call us back after animationInterval before // running animation callbacks so that if a callback requests another // we'll be sure to run it at the proper time. @@ -705,7 +705,7 @@ void RenderWidget::AnimateIfNeeded() { // base::Time::Now() has advanced past the animation_floor_time_. To // avoid exposing this delay to javascript, we keep posting delayed // tasks until base::Time::Now() has advanced far enough. - int64 delay = (animation_floor_time_ - now).InMillisecondsRoundedUp(); + base::TimeDelta delay = animation_floor_time_ - now; animation_task_posted_ = true; MessageLoop::current()->PostDelayedTask( FROM_HERE, base::Bind(&RenderWidget::AnimationCallback, this), delay); diff --git a/dbus/test_service.cc b/dbus/test_service.cc index ea8e360..714c09b 100644 --- a/dbus/test_service.cc +++ b/dbus/test_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. @@ -190,7 +190,7 @@ void TestService::Echo(MethodCall* method_call, void TestService::SlowEcho( MethodCall* method_call, dbus::ExportedObject::ResponseSender response_sender) { - base::PlatformThread::Sleep(TestTimeouts::tiny_timeout_ms()); + base::PlatformThread::Sleep(TestTimeouts::tiny_timeout()); Echo(method_call, response_sender); } |