diff options
-rw-r--r-- | base/message_loop_proxy_impl.cc | 25 | ||||
-rw-r--r-- | base/message_loop_proxy_impl.h | 9 | ||||
-rw-r--r-- | base/sequenced_task_runner.h | 5 | ||||
-rw-r--r-- | base/task_runner.h | 6 | ||||
-rw-r--r-- | content/browser/browser_thread_impl.cc | 52 | ||||
-rw-r--r-- | content/browser/browser_thread_impl.h | 2 | ||||
-rw-r--r-- | content/public/browser/browser_thread.h | 9 | ||||
-rw-r--r-- | remoting/base/plugin_message_loop_proxy.cc | 18 | ||||
-rw-r--r-- | remoting/base/plugin_message_loop_proxy.h | 10 | ||||
-rw-r--r-- | remoting/client/plugin/pepper_plugin_thread_delegate.cc | 6 | ||||
-rw-r--r-- | remoting/client/plugin/pepper_plugin_thread_delegate.h | 4 | ||||
-rw-r--r-- | remoting/host/plugin/host_plugin.cc | 8 |
12 files changed, 129 insertions, 25 deletions
diff --git a/base/message_loop_proxy_impl.cc b/base/message_loop_proxy_impl.cc index eeeb1db..9f6cb1f 100644 --- a/base/message_loop_proxy_impl.cc +++ b/base/message_loop_proxy_impl.cc @@ -12,18 +12,36 @@ namespace base { MessageLoopProxyImpl::~MessageLoopProxyImpl() { } +// This function will be removed later in the fixing of CR Bug #108171. bool MessageLoopProxyImpl::PostDelayedTask( const tracked_objects::Location& from_here, const base::Closure& task, int64 delay_ms) { - return PostTaskHelper(from_here, task, delay_ms, true); + return PostDelayedTask( + from_here, task, base::TimeDelta::FromMilliseconds(delay_ms)); } +// This function will be removed later in the fixing of CR Bug #108171. bool MessageLoopProxyImpl::PostNonNestableDelayedTask( const tracked_objects::Location& from_here, const base::Closure& task, int64 delay_ms) { - return PostTaskHelper(from_here, task, delay_ms, false); + return PostNonNestableDelayedTask( + from_here, task, base::TimeDelta::FromMilliseconds(delay_ms)); +} + +bool MessageLoopProxyImpl::PostDelayedTask( + const tracked_objects::Location& from_here, + const base::Closure& task, + base::TimeDelta delay) { + return PostTaskHelper(from_here, task, delay, true); +} + +bool MessageLoopProxyImpl::PostNonNestableDelayedTask( + const tracked_objects::Location& from_here, + const base::Closure& task, + base::TimeDelta delay) { + return PostTaskHelper(from_here, task, delay, false); } bool MessageLoopProxyImpl::RunsTasksOnCurrentThread() const { @@ -68,10 +86,9 @@ MessageLoopProxyImpl::MessageLoopProxyImpl() bool MessageLoopProxyImpl::PostTaskHelper( const tracked_objects::Location& from_here, const base::Closure& task, - int64 delay_ms, bool nestable) { + base::TimeDelta delay, 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); } else { diff --git a/base/message_loop_proxy_impl.h b/base/message_loop_proxy_impl.h index 847ee4c..88e1d45 100644 --- a/base/message_loop_proxy_impl.h +++ b/base/message_loop_proxy_impl.h @@ -25,10 +25,17 @@ class BASE_EXPORT MessageLoopProxyImpl virtual bool PostDelayedTask(const tracked_objects::Location& from_here, const base::Closure& task, int64 delay_ms) OVERRIDE; + virtual bool PostDelayedTask(const tracked_objects::Location& from_here, + const base::Closure& task, + base::TimeDelta delay) OVERRIDE; virtual bool PostNonNestableDelayedTask( const tracked_objects::Location& from_here, const base::Closure& task, int64 delay_ms) OVERRIDE; + virtual bool PostNonNestableDelayedTask( + const tracked_objects::Location& from_here, + const base::Closure& task, + base::TimeDelta delay) OVERRIDE; virtual bool RunsTasksOnCurrentThread() const OVERRIDE; protected: @@ -45,7 +52,7 @@ class BASE_EXPORT MessageLoopProxyImpl bool PostTaskHelper(const tracked_objects::Location& from_here, const base::Closure& task, - int64 delay_ms, + base::TimeDelta delay, bool nestable); // Allow the messageLoop to create a MessageLoopProxyImpl. diff --git a/base/sequenced_task_runner.h b/base/sequenced_task_runner.h index a280522..f44b622 100644 --- a/base/sequenced_task_runner.h +++ b/base/sequenced_task_runner.h @@ -116,6 +116,11 @@ class BASE_EXPORT SequencedTaskRunner : public TaskRunner { const Closure& task, int64 delay_ms) = 0; + virtual bool PostNonNestableDelayedTask( + const tracked_objects::Location& from_here, + const Closure& task, + base::TimeDelta delay) = 0; + // Submits a non-nestable task to delete the given object. Returns // true if the object may be deleted at some point in the future, // and false if the object definitely will not be deleted. diff --git a/base/task_runner.h b/base/task_runner.h index 7527031..894eb87 100644 --- a/base/task_runner.h +++ b/base/task_runner.h @@ -10,6 +10,7 @@ #include "base/basictypes.h" #include "base/callback_forward.h" #include "base/memory/ref_counted.h" +#include "base/time.h" namespace tracked_objects { class Location; @@ -72,10 +73,13 @@ class BASE_EXPORT TaskRunner // It is valid for an implementation to ignore |delay_ms|; that is, // to have PostDelayedTask behave the same as PostTask. // - // TODO(akalin): Make PostDelayedTask use TimeDelta instead. + // TODO(tedv): Make PostDelayedTask use TimeDelta instead. virtual bool PostDelayedTask(const tracked_objects::Location& from_here, const Closure& task, int64 delay_ms) = 0; + virtual bool PostDelayedTask(const tracked_objects::Location& from_here, + const Closure& task, + base::TimeDelta delay) = 0; // Returns true if the current thread is a thread on which a task // may be run, and false if no task will be run on the current diff --git a/content/browser/browser_thread_impl.cc b/content/browser/browser_thread_impl.cc index f0aab01..22a2e71 100644 --- a/content/browser/browser_thread_impl.cc +++ b/content/browser/browser_thread_impl.cc @@ -141,7 +141,7 @@ bool BrowserThreadImpl::PostTaskHelper( BrowserThread::ID identifier, const tracked_objects::Location& from_here, const base::Closure& task, - int64 delay_ms, + base::TimeDelta delay, bool nestable) { DCHECK(identifier >= 0 && identifier < ID_COUNT); // Optimization: to avoid unnecessary locks, we listed the ID enumeration in @@ -162,7 +162,6 @@ 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); } else { @@ -187,9 +186,14 @@ class BrowserThreadMessageLoopProxy : public base::MessageLoopProxy { // MessageLoopProxy implementation. virtual bool PostDelayedTask( const tracked_objects::Location& from_here, - const base::Closure& task, int64 delay_ms) OVERRIDE{ + const base::Closure& task, int64 delay_ms) OVERRIDE { return BrowserThread::PostDelayedTask(id_, from_here, task, delay_ms); } + virtual bool PostDelayedTask( + const tracked_objects::Location& from_here, + const base::Closure& task, base::TimeDelta delay) OVERRIDE { + return BrowserThread::PostDelayedTask(id_, from_here, task, delay); + } virtual bool PostNonNestableDelayedTask( const tracked_objects::Location& from_here, @@ -198,6 +202,13 @@ class BrowserThreadMessageLoopProxy : public base::MessageLoopProxy { return BrowserThread::PostNonNestableDelayedTask(id_, from_here, task, delay_ms); } + virtual bool PostNonNestableDelayedTask( + const tracked_objects::Location& from_here, + const base::Closure& task, + base::TimeDelta delay) OVERRIDE { + return BrowserThread::PostNonNestableDelayedTask(id_, from_here, task, + delay); + } virtual bool RunsTasksOnCurrentThread() const OVERRIDE { return BrowserThread::CurrentlyOn(id_); @@ -266,7 +277,7 @@ bool BrowserThread::PostTask(ID identifier, const tracked_objects::Location& from_here, const base::Closure& task) { return BrowserThreadImpl::PostTaskHelper( - identifier, from_here, task, 0, true); + identifier, from_here, task, base::TimeDelta(), true); } // static @@ -275,7 +286,20 @@ bool BrowserThread::PostDelayedTask(ID identifier, const base::Closure& task, int64 delay_ms) { return BrowserThreadImpl::PostTaskHelper( - identifier, from_here, task, delay_ms, true); + identifier, + from_here, + task, + base::TimeDelta::FromMilliseconds(delay_ms), + true); +} + +// static +bool BrowserThread::PostDelayedTask(ID identifier, + const tracked_objects::Location& from_here, + const base::Closure& task, + base::TimeDelta delay) { + return BrowserThreadImpl::PostTaskHelper( + identifier, from_here, task, delay, true); } // static @@ -284,7 +308,7 @@ bool BrowserThread::PostNonNestableTask( const tracked_objects::Location& from_here, const base::Closure& task) { return BrowserThreadImpl::PostTaskHelper( - identifier, from_here, task, 0, false); + identifier, from_here, task, base::TimeDelta(), false); } // static @@ -294,7 +318,21 @@ bool BrowserThread::PostNonNestableDelayedTask( const base::Closure& task, int64 delay_ms) { return BrowserThreadImpl::PostTaskHelper( - identifier, from_here, task, delay_ms, false); + identifier, + from_here, + task, + base::TimeDelta::FromMilliseconds(delay_ms), + false); +} + +// static +bool BrowserThread::PostNonNestableDelayedTask( + ID identifier, + const tracked_objects::Location& from_here, + const base::Closure& task, + base::TimeDelta delay) { + return BrowserThreadImpl::PostTaskHelper( + identifier, from_here, task, delay, false); } // static diff --git a/content/browser/browser_thread_impl.h b/content/browser/browser_thread_impl.h index 4488f85..5650179 100644 --- a/content/browser/browser_thread_impl.h +++ b/content/browser/browser_thread_impl.h @@ -41,7 +41,7 @@ class CONTENT_EXPORT BrowserThreadImpl BrowserThread::ID identifier, const tracked_objects::Location& from_here, const base::Closure& task, - int64 delay_ms, + base::TimeDelta delay, bool nestable); // Common initialization code for the constructors. diff --git a/content/public/browser/browser_thread.h b/content/public/browser/browser_thread.h index f35ec00..61b377d 100644 --- a/content/public/browser/browser_thread.h +++ b/content/public/browser/browser_thread.h @@ -107,6 +107,10 @@ class CONTENT_EXPORT BrowserThread { const tracked_objects::Location& from_here, const base::Closure& task, int64 delay_ms); + static bool PostDelayedTask(ID identifier, + const tracked_objects::Location& from_here, + const base::Closure& task, + base::TimeDelta delay); static bool PostNonNestableTask(ID identifier, const tracked_objects::Location& from_here, const base::Closure& task); @@ -115,6 +119,11 @@ class CONTENT_EXPORT BrowserThread { const tracked_objects::Location& from_here, const base::Closure& task, int64 delay_ms); + static bool PostNonNestableDelayedTask( + ID identifier, + const tracked_objects::Location& from_here, + const base::Closure& task, + base::TimeDelta delay); static bool PostTaskAndReply( ID identifier, diff --git a/remoting/base/plugin_message_loop_proxy.cc b/remoting/base/plugin_message_loop_proxy.cc index 7cd03a4..9d9a599 100644 --- a/remoting/base/plugin_message_loop_proxy.cc +++ b/remoting/base/plugin_message_loop_proxy.cc @@ -28,6 +28,14 @@ bool PluginMessageLoopProxy::PostDelayedTask( const tracked_objects::Location& from_here, const base::Closure& task, int64 delay_ms) { + return PostDelayedTask( + from_here, task, base::TimeDelta::FromMilliseconds(delay_ms)); +} + +bool PluginMessageLoopProxy::PostDelayedTask( + const tracked_objects::Location& from_here, + const base::Closure& task, + base::TimeDelta delay) { base::AutoLock auto_lock(lock_); if (!delegate_) return false; @@ -35,7 +43,7 @@ bool PluginMessageLoopProxy::PostDelayedTask( base::Closure* springpad_closure = new base::Closure(base::Bind( &PluginMessageLoopProxy::RunClosureIf, this, task)); return delegate_->RunOnPluginThread( - delay_ms, &PluginMessageLoopProxy::TaskSpringboard, springpad_closure); + delay, &PluginMessageLoopProxy::TaskSpringboard, springpad_closure); } bool PluginMessageLoopProxy::PostNonNestableDelayedTask( @@ -46,6 +54,14 @@ bool PluginMessageLoopProxy::PostNonNestableDelayedTask( return PostDelayedTask(from_here, task, delay_ms); } +bool PluginMessageLoopProxy::PostNonNestableDelayedTask( + const tracked_objects::Location& from_here, + const base::Closure& task, + base::TimeDelta delay) { + // All tasks running on this message loop are non-nestable. + return PostDelayedTask(from_here, task, delay); +} + bool PluginMessageLoopProxy::RunsTasksOnCurrentThread() const { // In pepper plugins ideally we should use pp::Core::IsMainThread, // but it is problematic because we would need to keep reference to diff --git a/remoting/base/plugin_message_loop_proxy.h b/remoting/base/plugin_message_loop_proxy.h index 855134f..33da94b 100644 --- a/remoting/base/plugin_message_loop_proxy.h +++ b/remoting/base/plugin_message_loop_proxy.h @@ -22,7 +22,7 @@ class PluginMessageLoopProxy : public base::MessageLoopProxy { virtual ~Delegate() { } virtual bool RunOnPluginThread( - int delay_ms, void(function)(void*), void* data) = 0; + base::TimeDelta delay, void(function)(void*), void* data) = 0; }; // Caller keeps ownership of delegate. @@ -36,10 +36,18 @@ class PluginMessageLoopProxy : public base::MessageLoopProxy { const tracked_objects::Location& from_here, const base::Closure& task, int64 delay_ms) OVERRIDE; + virtual bool PostDelayedTask( + const tracked_objects::Location& from_here, + const base::Closure& task, + base::TimeDelta delay) OVERRIDE; virtual bool PostNonNestableDelayedTask( const tracked_objects::Location& from_here, const base::Closure& task, int64 delay_ms) OVERRIDE; + virtual bool PostNonNestableDelayedTask( + const tracked_objects::Location& from_here, + const base::Closure& task, + base::TimeDelta delay) OVERRIDE; virtual bool RunsTasksOnCurrentThread() const OVERRIDE; diff --git a/remoting/client/plugin/pepper_plugin_thread_delegate.cc b/remoting/client/plugin/pepper_plugin_thread_delegate.cc index 730c09e..e14a93c 100644 --- a/remoting/client/plugin/pepper_plugin_thread_delegate.cc +++ b/remoting/client/plugin/pepper_plugin_thread_delegate.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,14 +16,14 @@ PepperPluginThreadDelegate::PepperPluginThreadDelegate() PepperPluginThreadDelegate::~PepperPluginThreadDelegate() { } bool PepperPluginThreadDelegate::RunOnPluginThread( - int delay_ms, void(CDECL function)(void*), void* data) { + base::TimeDelta delay, void(CDECL function)(void*), void* data) { // It is safe to cast |function| to PP_CompletionCallback_Func, // which is defined as void(*)(void*, int). The callee will just // ignore the last argument. The only case when it may be unsafe is // with VS when default calling convention is set to __stdcall, but // this code will not typecheck in that case. core_->CallOnMainThread( - delay_ms, pp::CompletionCallback( + delay.InMilliseconds(), pp::CompletionCallback( reinterpret_cast<PP_CompletionCallback_Func>(function), data), 0); return true; } diff --git a/remoting/client/plugin/pepper_plugin_thread_delegate.h b/remoting/client/plugin/pepper_plugin_thread_delegate.h index a111e6d6..8b4bd7b 100644 --- a/remoting/client/plugin/pepper_plugin_thread_delegate.h +++ b/remoting/client/plugin/pepper_plugin_thread_delegate.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. @@ -26,7 +26,7 @@ class PepperPluginThreadDelegate : public PluginMessageLoopProxy::Delegate { virtual ~PepperPluginThreadDelegate(); virtual bool RunOnPluginThread( - int delay_ms, void(CDECL function)(void*), void* data) OVERRIDE; + base::TimeDelta delay, void(CDECL function)(void*), void* data) OVERRIDE; private: pp::Core* core_; diff --git a/remoting/host/plugin/host_plugin.cc b/remoting/host/plugin/host_plugin.cc index f001afb..9482615 100644 --- a/remoting/host/plugin/host_plugin.cc +++ b/remoting/host/plugin/host_plugin.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. @@ -148,13 +148,13 @@ class HostNPPlugin : public remoting::PluginMessageLoopProxy::Delegate { // PluginMessageLoopProxy::Delegate implementation. virtual bool RunOnPluginThread( - int delay_ms, void(function)(void*), void* data) OVERRIDE { - if (delay_ms == 0) { + base::TimeDelta delay, void(function)(void*), void* data) OVERRIDE { + if (delay == base::TimeDelta()) { g_npnetscape_funcs->pluginthreadasynccall(instance_, function, data); } else { base::AutoLock auto_lock(timers_lock_); uint32_t timer_id = g_npnetscape_funcs->scheduletimer( - instance_, delay_ms, false, &NPDelayedTaskSpringboard); + instance_, delay.InMilliseconds(), false, &NPDelayedTaskSpringboard); DelayedTask task = {function, data}; timers_[timer_id] = task; } |