diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-17 17:23:51 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-17 17:23:51 +0000 |
commit | 743ace4213ae3ea93355dff8b57ef33287b32220 (patch) | |
tree | e39fc30e436e0a06790d665878cd91113ba180d4 | |
parent | 8c14a436fe6488c8f647ff79301102e885838c77 (diff) | |
download | chromium_src-743ace4213ae3ea93355dff8b57ef33287b32220.zip chromium_src-743ace4213ae3ea93355dff8b57ef33287b32220.tar.gz chromium_src-743ace4213ae3ea93355dff8b57ef33287b32220.tar.bz2 |
Consistently use int64 for integers holding number of milliseconds.
This applies only to things which use TimeDelta::InMilliseconds, because
it returns int64. Before this patch callers static_casted that to int,
and after this patch they use the returned value as int64.
Review URL: http://codereview.chromium.org/126279
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18626 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/message_loop.cc | 6 | ||||
-rw-r--r-- | base/message_loop.h | 6 | ||||
-rw-r--r-- | base/process_util.h | 8 | ||||
-rw-r--r-- | base/process_util_posix.cc | 12 | ||||
-rw-r--r-- | base/process_util_win.cc | 11 | ||||
-rw-r--r-- | chrome/browser/history/expire_history_backend.cc | 3 | ||||
-rw-r--r-- | chrome/browser/metrics/metrics_service.cc | 2 | ||||
-rw-r--r-- | chrome/browser/net/url_fetcher.cc | 2 | ||||
-rw-r--r-- | chrome/browser/net/url_fetcher_protect.cc | 4 | ||||
-rw-r--r-- | chrome/browser/net/url_fetcher_protect.h | 2 | ||||
-rw-r--r-- | chrome/test/chrome_process_util.cc | 3 |
11 files changed, 28 insertions, 31 deletions
diff --git a/base/message_loop.cc b/base/message_loop.cc index e010c73..89e2a2c 100644 --- a/base/message_loop.cc +++ b/base/message_loop.cc @@ -232,7 +232,7 @@ void MessageLoop::PostTask( } void MessageLoop::PostDelayedTask( - const tracked_objects::Location& from_here, Task* task, int delay_ms) { + const tracked_objects::Location& from_here, Task* task, int64 delay_ms) { PostTask_Helper(from_here, task, delay_ms, true); } @@ -242,13 +242,13 @@ void MessageLoop::PostNonNestableTask( } void MessageLoop::PostNonNestableDelayedTask( - const tracked_objects::Location& from_here, Task* task, int delay_ms) { + const tracked_objects::Location& from_here, Task* task, int64 delay_ms) { PostTask_Helper(from_here, task, delay_ms, false); } // Possibly called on a background thread! void MessageLoop::PostTask_Helper( - const tracked_objects::Location& from_here, Task* task, int delay_ms, + const tracked_objects::Location& from_here, Task* task, int64 delay_ms, bool nestable) { task->SetBirthPlace(from_here); diff --git a/base/message_loop.h b/base/message_loop.h index 01f8c92..e3f07bf 100644 --- a/base/message_loop.h +++ b/base/message_loop.h @@ -103,13 +103,13 @@ class MessageLoop : public base::MessagePump::Delegate { const tracked_objects::Location& from_here, Task* task); void PostDelayedTask( - const tracked_objects::Location& from_here, Task* task, int delay_ms); + const tracked_objects::Location& from_here, Task* task, int64 delay_ms); void PostNonNestableTask( const tracked_objects::Location& from_here, Task* task); void PostNonNestableDelayedTask( - const tracked_objects::Location& from_here, Task* task, int delay_ms); + const tracked_objects::Location& from_here, Task* task, int64 delay_ms); // A variant on PostTask that deletes the given object. This is useful // if the object needs to live until the next run of the MessageLoop (for @@ -331,7 +331,7 @@ class MessageLoop : public base::MessagePump::Delegate { // Post a task to our incomming queue. void PostTask_Helper(const tracked_objects::Location& from_here, Task* task, - int delay_ms, bool nestable); + int64 delay_ms, bool nestable); // base::MessagePump::Delegate methods: virtual bool DoWork(); diff --git a/base/process_util.h b/base/process_util.h index 41d0470..706cf5f 100644 --- a/base/process_util.h +++ b/base/process_util.h @@ -207,17 +207,17 @@ bool WaitForExitCode(ProcessHandle handle, int* exit_code); // Returns after all processes have exited or wait_milliseconds have expired. // Returns true if all the processes exited, false otherwise. bool WaitForProcessesToExit(const std::wstring& executable_name, - int wait_milliseconds, + int64 wait_milliseconds, const ProcessFilter* filter); // Wait for a single process to exit. Return true if it exited cleanly within // the given time limit. bool WaitForSingleProcess(ProcessHandle handle, - int wait_milliseconds); + int64 wait_milliseconds); // Returns true when |wait_milliseconds| have elapsed and the process // is still running. -bool CrashAwareSleep(ProcessHandle handle, int wait_milliseconds); +bool CrashAwareSleep(ProcessHandle handle, int64 wait_milliseconds); // Waits a certain amount of time (can be 0) for all the processes with a given // executable name to exit, then kills off any of them that are still around. @@ -226,7 +226,7 @@ bool CrashAwareSleep(ProcessHandle handle, int wait_milliseconds); // any processes needed to be killed, true if they all exited cleanly within // the wait_milliseconds delay. bool CleanupProcesses(const std::wstring& executable_name, - int wait_milliseconds, + int64 wait_milliseconds, int exit_code, const ProcessFilter* filter); diff --git a/base/process_util_posix.cc b/base/process_util_posix.cc index 840339f..212638f 100644 --- a/base/process_util_posix.cc +++ b/base/process_util_posix.cc @@ -284,7 +284,7 @@ bool WaitForExitCode(ProcessHandle handle, int* exit_code) { namespace { -int WaitpidWithTimeout(ProcessHandle handle, int wait_milliseconds, +int WaitpidWithTimeout(ProcessHandle handle, int64 wait_milliseconds, bool* success) { // This POSIX version of this function only guarantees that we wait no less // than |wait_milliseconds| for the proces to exit. The child process may @@ -339,7 +339,7 @@ int WaitpidWithTimeout(ProcessHandle handle, int wait_milliseconds, } // namespace -bool WaitForSingleProcess(ProcessHandle handle, int wait_milliseconds) { +bool WaitForSingleProcess(ProcessHandle handle, int64 wait_milliseconds) { bool waitpid_success; int status; if (wait_milliseconds == base::kNoTimeout) @@ -354,7 +354,7 @@ bool WaitForSingleProcess(ProcessHandle handle, int wait_milliseconds) { } } -bool CrashAwareSleep(ProcessHandle handle, int wait_milliseconds) { +bool CrashAwareSleep(ProcessHandle handle, int64 wait_milliseconds) { bool waitpid_success; int status = WaitpidWithTimeout(handle, wait_milliseconds, &waitpid_success); if (status != -1) { @@ -503,7 +503,7 @@ bool KillProcesses(const std::wstring& executable_name, int exit_code, } bool WaitForProcessesToExit(const std::wstring& executable_name, - int wait_milliseconds, + int64 wait_milliseconds, const ProcessFilter* filter) { bool result = false; @@ -525,12 +525,12 @@ bool WaitForProcessesToExit(const std::wstring& executable_name, } bool CleanupProcesses(const std::wstring& executable_name, - int wait_milliseconds, + int64 wait_milliseconds, int exit_code, const ProcessFilter* filter) { bool exited_cleanly = WaitForProcessesToExit(executable_name, wait_milliseconds, - filter); + filter); if (!exited_cleanly) KillProcesses(executable_name, exit_code, filter); return exited_cleanly; diff --git a/base/process_util_win.cc b/base/process_util_win.cc index 008cffa..aea8cb9 100644 --- a/base/process_util_win.cc +++ b/base/process_util_win.cc @@ -429,7 +429,7 @@ bool KillProcesses(const std::wstring& executable_name, int exit_code, } bool WaitForProcessesToExit(const std::wstring& executable_name, - int wait_milliseconds, + int64 wait_milliseconds, const ProcessFilter* filter) { const ProcessEntry* entry; bool result = true; @@ -438,8 +438,7 @@ bool WaitForProcessesToExit(const std::wstring& executable_name, NamedProcessIterator iter(executable_name, filter); while (entry = iter.NextProcessEntry()) { DWORD remaining_wait = - std::max(0, wait_milliseconds - - static_cast<int>(GetTickCount() - start_time)); + std::max<int64>(0, wait_milliseconds - (GetTickCount() - start_time)); HANDLE process = OpenProcess(SYNCHRONIZE, FALSE, entry->th32ProcessID); @@ -451,18 +450,18 @@ bool WaitForProcessesToExit(const std::wstring& executable_name, return result; } -bool WaitForSingleProcess(ProcessHandle handle, int wait_milliseconds) { +bool WaitForSingleProcess(ProcessHandle handle, int64 wait_milliseconds) { bool retval = WaitForSingleObject(handle, wait_milliseconds) == WAIT_OBJECT_0; return retval; } -bool CrashAwareSleep(ProcessHandle handle, int wait_milliseconds) { +bool CrashAwareSleep(ProcessHandle handle, int64 wait_milliseconds) { bool retval = WaitForSingleObject(handle, wait_milliseconds) == WAIT_TIMEOUT; return retval; } bool CleanupProcesses(const std::wstring& executable_name, - int wait_milliseconds, + int64 wait_milliseconds, int exit_code, const ProcessFilter* filter) { bool exited_cleanly = WaitForProcessesToExit(executable_name, diff --git a/chrome/browser/history/expire_history_backend.cc b/chrome/browser/history/expire_history_backend.cc index 070722bc..084fa61 100644 --- a/chrome/browser/history/expire_history_backend.cc +++ b/chrome/browser/history/expire_history_backend.cc @@ -416,8 +416,7 @@ void ExpireHistoryBackend::ArchiveURLsAndVisits( void ExpireHistoryBackend::ScheduleArchive(TimeDelta delay) { factory_.RevokeAll(); MessageLoop::current()->PostDelayedTask(FROM_HERE, factory_.NewRunnableMethod( - &ExpireHistoryBackend::DoArchiveIteration), - static_cast<int>(delay.InMilliseconds())); + &ExpireHistoryBackend::DoArchiveIteration), delay.InMilliseconds()); } void ExpireHistoryBackend::DoArchiveIteration() { diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc index fa4d1db..50b3af3 100644 --- a/chrome/browser/metrics/metrics_service.cc +++ b/chrome/browser/metrics/metrics_service.cc @@ -912,7 +912,7 @@ void MetricsService::StartLogTransmissionTimer() { MessageLoop::current()->PostDelayedTask(FROM_HERE, log_sender_factory_. NewRunnableMethod(&MetricsService::LogTransmissionTimerDone), - static_cast<int>(interlog_duration_.InMilliseconds())); + interlog_duration_.InMilliseconds()); } void MetricsService::LogTransmissionTimerDone() { diff --git a/chrome/browser/net/url_fetcher.cc b/chrome/browser/net/url_fetcher.cc index 425cc73..4783aea8 100644 --- a/chrome/browser/net/url_fetcher.cc +++ b/chrome/browser/net/url_fetcher.cc @@ -254,7 +254,7 @@ void URLFetcher::Core::OnCompletedURLRequest(const URLRequestStatus& status) { if (response_code_ >= 500) { // When encountering a server error, we will send the request again // after backoff time. - const int wait = + const int64 wait = protect_entry_->UpdateBackoff(URLFetcherProtectEntry::FAILURE); ++num_retries_; // Restarts the request if we still need to notify the delegate. diff --git a/chrome/browser/net/url_fetcher_protect.cc b/chrome/browser/net/url_fetcher_protect.cc index 22292ab..8798b5a 100644 --- a/chrome/browser/net/url_fetcher_protect.cc +++ b/chrome/browser/net/url_fetcher_protect.cc @@ -52,7 +52,7 @@ URLFetcherProtectEntry::URLFetcherProtectEntry(int sliding_window_period, ResetBackoff(); } -int URLFetcherProtectEntry::UpdateBackoff(EventType event_type) { +int64 URLFetcherProtectEntry::UpdateBackoff(EventType event_type) { // request may be sent in different threads AutoLock lock(lock_); @@ -71,7 +71,7 @@ int URLFetcherProtectEntry::UpdateBackoff(EventType event_type) { NOTREACHED(); } - int wait = static_cast<int>(t.InMilliseconds()); + int64 wait = t.InMilliseconds(); DCHECK(wait >= 0); return wait; } diff --git a/chrome/browser/net/url_fetcher_protect.h b/chrome/browser/net/url_fetcher_protect.h index 7352932..9b121b7 100644 --- a/chrome/browser/net/url_fetcher_protect.h +++ b/chrome/browser/net/url_fetcher_protect.h @@ -53,7 +53,7 @@ class URLFetcherProtectEntry { // the timeout period. It returns the backoff time, in milliseconds, that // indicates to the sender how long should it wait before sending the request. // If the request is allowed to be sent immediately, the backoff time is 0. - int UpdateBackoff(EventType event_type); + int64 UpdateBackoff(EventType event_type); // Returns the max retries allowed. int max_retries() const { diff --git a/chrome/test/chrome_process_util.cc b/chrome/test/chrome_process_util.cc index 9d858e4..8ad6239 100644 --- a/chrome/test/chrome_process_util.cc +++ b/chrome/test/chrome_process_util.cc @@ -42,8 +42,7 @@ void TerminateAllChromeProcesses(const FilePath& data_dir) { for (it = handles.begin(); it != handles.end() && Time::Now() - start < kExitTimeout; ++it) { - // TODO(phajdan.jr): Fix int/int64 problems with TimeDelta::InMilliseconds. - int wait_time_ms = static_cast<int>((Time::Now() - start).InMilliseconds()); + int64 wait_time_ms = (Time::Now() - start).InMilliseconds(); base::WaitForSingleProcess(*it, wait_time_ms); } |