From 7931f272162d572de3a2374ba1560ac784343210 Mon Sep 17 00:00:00 2001 From: "viettrungluu@chromium.org" Date: Sat, 14 Jun 2014 07:23:15 +0000 Subject: Mojo: Make |MojoAsyncWaiter|s const and remove the MojoAsyncWaiter* argument to AsyncWait/CancelWait. The struct returned by GetDefaultAsyncWaiter() shouldn't be changed, and the MojoAsyncWaiter* argument isn't interested or needed. R=darin@chromium.org Review URL: https://codereview.chromium.org/337813003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277188 0039d316-1c4b-4281-b951-d872f2087c98 --- mojo/android/system/core_impl.cc | 15 ++++++--------- mojo/bindings/js/waiting_callback.cc | 7 ++----- mojo/environment/default_async_waiter.cc | 2 +- mojo/environment/default_async_waiter_impl.cc | 11 +++++------ mojo/environment/default_async_waiter_impl.h | 2 +- mojo/gles2/command_buffer_client_impl.cc | 2 +- mojo/gles2/command_buffer_client_impl.h | 4 ++-- mojo/gles2/gles2_context.cc | 2 +- mojo/gles2/gles2_context.h | 2 +- mojo/gles2/gles2_support_impl.cc | 2 +- mojo/gles2/gles2_support_impl.h | 4 ++-- mojo/public/c/environment/async_waiter.h | 14 ++------------ mojo/public/c/gles2/gles2.h | 2 +- mojo/public/cpp/bindings/interface_impl.h | 6 +++--- mojo/public/cpp/bindings/interface_ptr.h | 4 ++-- mojo/public/cpp/bindings/lib/connector.cc | 9 ++++----- mojo/public/cpp/bindings/lib/connector.h | 4 ++-- mojo/public/cpp/bindings/lib/interface_impl_internal.h | 4 ++-- mojo/public/cpp/bindings/lib/interface_ptr_internal.h | 2 +- mojo/public/cpp/bindings/lib/router.cc | 2 +- mojo/public/cpp/bindings/lib/router.h | 2 +- mojo/public/cpp/environment/default_async_waiter.h | 4 ++-- mojo/public/cpp/environment/lib/default_async_waiter.cc | 11 +++++------ .../cpp/environment/tests/async_waiter_unittest.cc | 16 +++++++--------- mojo/public/cpp/gles2/gles2.h | 2 +- mojo/public/gles2/gles2_private.cc | 2 +- mojo/public/gles2/gles2_private.h | 2 +- 27 files changed, 59 insertions(+), 80 deletions(-) diff --git a/mojo/android/system/core_impl.cc b/mojo/android/system/core_impl.cc index 1d7f879..366573c 100644 --- a/mojo/android/system/core_impl.cc +++ b/mojo/android/system/core_impl.cc @@ -329,13 +329,11 @@ static jobject AsyncWait(JNIEnv* env, new AsyncWaitCallbackData(env, jcaller, callback); MojoAsyncWaitID cancel_id; if (static_cast(mojo_handle) != MOJO_HANDLE_INVALID) { - MojoAsyncWaiter* async_waiter = mojo::GetDefaultAsyncWaiter(); - cancel_id = async_waiter->AsyncWait(async_waiter, - mojo_handle, - flags, - deadline, - AsyncWaitCallback, - callback_data); + cancel_id = mojo::GetDefaultAsyncWaiter()->AsyncWait(mojo_handle, + flags, + deadline, + AsyncWaitCallback, + callback_data); } else { cancel_id = kInvalidHandleCancelID; base::MessageLoop::current()->PostTask( @@ -362,8 +360,7 @@ static void CancelAsyncWait(JNIEnv* env, } scoped_ptr deleter( reinterpret_cast(data_ptr)); - MojoAsyncWaiter* async_waiter = mojo::GetDefaultAsyncWaiter(); - async_waiter->CancelWait(async_waiter, id); + mojo::GetDefaultAsyncWaiter()->CancelWait(id); } bool RegisterCoreImpl(JNIEnv* env) { diff --git a/mojo/bindings/js/waiting_callback.cc b/mojo/bindings/js/waiting_callback.cc index ace0a76..597da44 100644 --- a/mojo/bindings/js/waiting_callback.cc +++ b/mojo/bindings/js/waiting_callback.cc @@ -28,9 +28,7 @@ gin::Handle WaitingCallback::Create( MojoWaitFlags flags) { gin::Handle waiting_callback = gin::CreateHandle(isolate, new WaitingCallback(isolate, callback)); - MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter(); - waiting_callback->wait_id_ = waiter->AsyncWait( - waiter, + waiting_callback->wait_id_ = GetDefaultAsyncWaiter()->AsyncWait( handle.value(), flags, MOJO_DEADLINE_INDEFINITE, @@ -43,8 +41,7 @@ void WaitingCallback::Cancel() { if (!wait_id_) return; - MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter(); - waiter->CancelWait(waiter, wait_id_); + GetDefaultAsyncWaiter()->CancelWait(wait_id_); wait_id_ = 0; } diff --git a/mojo/environment/default_async_waiter.cc b/mojo/environment/default_async_waiter.cc index bbd7229..092caec 100644 --- a/mojo/environment/default_async_waiter.cc +++ b/mojo/environment/default_async_waiter.cc @@ -8,7 +8,7 @@ namespace mojo { -MojoAsyncWaiter* GetDefaultAsyncWaiter() { +const MojoAsyncWaiter* GetDefaultAsyncWaiter() { return internal::GetDefaultAsyncWaiterImpl(); } diff --git a/mojo/environment/default_async_waiter_impl.cc b/mojo/environment/default_async_waiter_impl.cc index 576dd98..5279aad 100644 --- a/mojo/environment/default_async_waiter_impl.cc +++ b/mojo/environment/default_async_waiter_impl.cc @@ -19,8 +19,7 @@ void OnHandleReady(common::HandleWatcher* watcher, callback(closure, result); } -MojoAsyncWaitID AsyncWait(MojoAsyncWaiter* waiter, - MojoHandle handle, +MojoAsyncWaitID AsyncWait(MojoHandle handle, MojoWaitFlags flags, MojoDeadline deadline, MojoAsyncWaitCallback callback, @@ -32,19 +31,19 @@ MojoAsyncWaitID AsyncWait(MojoAsyncWaiter* waiter, return reinterpret_cast(watcher); } -void CancelWait(MojoAsyncWaiter* waiter, MojoAsyncWaitID wait_id) { +void CancelWait(MojoAsyncWaitID wait_id) { delete reinterpret_cast(wait_id); } -MojoAsyncWaiter s_default_async_waiter = { +const MojoAsyncWaiter kDefaultAsyncWaiter = { AsyncWait, CancelWait }; } // namespace -MojoAsyncWaiter* GetDefaultAsyncWaiterImpl() { - return &s_default_async_waiter; +const MojoAsyncWaiter* GetDefaultAsyncWaiterImpl() { + return &kDefaultAsyncWaiter; } } // namespace internal diff --git a/mojo/environment/default_async_waiter_impl.h b/mojo/environment/default_async_waiter_impl.h index 8e697cb..5140e35 100644 --- a/mojo/environment/default_async_waiter_impl.h +++ b/mojo/environment/default_async_waiter_impl.h @@ -11,7 +11,7 @@ namespace mojo { namespace internal { -MOJO_ENVIRONMENT_IMPL_EXPORT MojoAsyncWaiter* GetDefaultAsyncWaiterImpl(); +MOJO_ENVIRONMENT_IMPL_EXPORT const MojoAsyncWaiter* GetDefaultAsyncWaiterImpl(); } // namespace internal } // namespace mojo diff --git a/mojo/gles2/command_buffer_client_impl.cc b/mojo/gles2/command_buffer_client_impl.cc index c051ac2..975233b 100644 --- a/mojo/gles2/command_buffer_client_impl.cc +++ b/mojo/gles2/command_buffer_client_impl.cc @@ -48,7 +48,7 @@ void CommandBufferDelegate::DrawAnimationFrame() {} CommandBufferClientImpl::CommandBufferClientImpl( CommandBufferDelegate* delegate, - MojoAsyncWaiter* async_waiter, + const MojoAsyncWaiter* async_waiter, ScopedMessagePipeHandle command_buffer_handle) : delegate_(delegate), shared_state_(NULL), diff --git a/mojo/gles2/command_buffer_client_impl.h b/mojo/gles2/command_buffer_client_impl.h index e4c7893..6c5c433 100644 --- a/mojo/gles2/command_buffer_client_impl.h +++ b/mojo/gles2/command_buffer_client_impl.h @@ -41,7 +41,7 @@ class CommandBufferClientImpl : public CommandBufferClient, public: explicit CommandBufferClientImpl( CommandBufferDelegate* delegate, - MojoAsyncWaiter* async_waiter, + const MojoAsyncWaiter* async_waiter, ScopedMessagePipeHandle command_buffer_handle); virtual ~CommandBufferClientImpl(); @@ -107,7 +107,7 @@ class CommandBufferClientImpl : public CommandBufferClient, int32 next_transfer_buffer_id_; bool initialize_result_; - MojoAsyncWaiter* async_waiter_; + const MojoAsyncWaiter* async_waiter_; }; } // gles2 diff --git a/mojo/gles2/gles2_context.cc b/mojo/gles2/gles2_context.cc index 78e5168..701b0fe 100644 --- a/mojo/gles2/gles2_context.cc +++ b/mojo/gles2/gles2_context.cc @@ -20,7 +20,7 @@ const size_t kDefaultMinTransferBufferSize = 1 * 256 * 1024; const size_t kDefaultMaxTransferBufferSize = 16 * 1024 * 1024; } -GLES2Context::GLES2Context(MojoAsyncWaiter* async_waiter, +GLES2Context::GLES2Context(const MojoAsyncWaiter* async_waiter, ScopedMessagePipeHandle command_buffer_handle, MojoGLES2ContextLost lost_callback, MojoGLES2DrawAnimationFrame animation_callback, diff --git a/mojo/gles2/gles2_context.h b/mojo/gles2/gles2_context.h index 9f5ff7d..bc73082 100644 --- a/mojo/gles2/gles2_context.h +++ b/mojo/gles2/gles2_context.h @@ -27,7 +27,7 @@ namespace gles2 { class GLES2Context : public CommandBufferDelegate, public MojoGLES2ContextPrivate { public: - explicit GLES2Context(MojoAsyncWaiter* async_waiter, + explicit GLES2Context(const MojoAsyncWaiter* async_waiter, ScopedMessagePipeHandle command_buffer_handle, MojoGLES2ContextLost lost_callback, MojoGLES2DrawAnimationFrame animation_callback, diff --git a/mojo/gles2/gles2_support_impl.cc b/mojo/gles2/gles2_support_impl.cc index c348219..7fd8608 100644 --- a/mojo/gles2/gles2_support_impl.cc +++ b/mojo/gles2/gles2_support_impl.cc @@ -47,7 +47,7 @@ GLES2SupportImpl::~GLES2SupportImpl() {} // static void GLES2SupportImpl::Init() { GLES2Support::Init(new GLES2SupportImpl()); } -void GLES2SupportImpl::Initialize(MojoAsyncWaiter* async_waiter) { +void GLES2SupportImpl::Initialize(const MojoAsyncWaiter* async_waiter) { DCHECK(!async_waiter_); DCHECK(async_waiter); async_waiter_ = async_waiter; diff --git a/mojo/gles2/gles2_support_impl.h b/mojo/gles2/gles2_support_impl.h index a57000d..3305bf6 100644 --- a/mojo/gles2/gles2_support_impl.h +++ b/mojo/gles2/gles2_support_impl.h @@ -18,7 +18,7 @@ class MOJO_GLES2_IMPL_EXPORT GLES2SupportImpl : public GLES2Support { static void Init(); - virtual void Initialize(MojoAsyncWaiter* async_waiter) OVERRIDE; + virtual void Initialize(const MojoAsyncWaiter* async_waiter) OVERRIDE; virtual void Terminate() OVERRIDE; virtual MojoGLES2Context CreateContext( MessagePipeHandle handle, @@ -37,7 +37,7 @@ class MOJO_GLES2_IMPL_EXPORT GLES2SupportImpl : public GLES2Support { private: GLES2SupportImpl(); - MojoAsyncWaiter* async_waiter_; + const MojoAsyncWaiter* async_waiter_; }; } // namespace gles2 diff --git a/mojo/public/c/environment/async_waiter.h b/mojo/public/c/environment/async_waiter.h index a28340a..a330b64 100644 --- a/mojo/public/c/environment/async_waiter.h +++ b/mojo/public/c/environment/async_waiter.h @@ -7,10 +7,6 @@ #include "mojo/public/c/system/types.h" -#ifdef __cplusplus -extern "C" { -#endif - typedef uintptr_t MojoAsyncWaitID; typedef void (*MojoAsyncWaitCallback)(void* closure, MojoResult result); @@ -20,8 +16,7 @@ struct MojoAsyncWaiter { // of MojoWait to the given MojoAsyncWaitCallback on the current thread. // Returns a non-zero MojoAsyncWaitID that can be used with CancelWait to // stop waiting. This identifier becomes invalid once the callback runs. - MojoAsyncWaitID (*AsyncWait)(struct MojoAsyncWaiter* waiter, - MojoHandle handle, + MojoAsyncWaitID (*AsyncWait)(MojoHandle handle, MojoWaitFlags flags, MojoDeadline deadline, MojoAsyncWaitCallback callback, @@ -29,12 +24,7 @@ struct MojoAsyncWaiter { // Cancel an existing call to AsyncWait with the given MojoAsyncWaitID. The // corresponding MojoAsyncWaitCallback will not be called in this case. - void (*CancelWait)(struct MojoAsyncWaiter* waiter, - MojoAsyncWaitID wait_id); + void (*CancelWait)(MojoAsyncWaitID wait_id); }; -#ifdef __cplusplus -} // extern "C" -#endif - #endif // MOJO_PUBLIC_C_ENVIRONMENT_ASYNC_WAITER_H_ diff --git a/mojo/public/c/gles2/gles2.h b/mojo/public/c/gles2/gles2.h index 6b71d65..9763d34 100644 --- a/mojo/public/c/gles2/gles2.h +++ b/mojo/public/c/gles2/gles2.h @@ -19,7 +19,7 @@ extern "C" { #endif -MOJO_GLES2_EXPORT void MojoGLES2Initialize(MojoAsyncWaiter* async_waiter); +MOJO_GLES2_EXPORT void MojoGLES2Initialize(const MojoAsyncWaiter* async_waiter); MOJO_GLES2_EXPORT void MojoGLES2Terminate(); MOJO_GLES2_EXPORT MojoGLES2Context MojoGLES2CreateContext( MojoHandle handle, diff --git a/mojo/public/cpp/bindings/interface_impl.h b/mojo/public/cpp/bindings/interface_impl.h index a7272b6..6e68aa7 100644 --- a/mojo/public/cpp/bindings/interface_impl.h +++ b/mojo/public/cpp/bindings/interface_impl.h @@ -59,7 +59,7 @@ class InterfaceImpl : public internal::InterfaceImplBase { template Impl* BindToPipe(Impl* instance, ScopedMessagePipeHandle handle, - MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter()) { + const MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter()) { instance->internal_state()->Bind(handle.Pass(), waiter); return instance; } @@ -77,7 +77,7 @@ Impl* BindToPipe(Impl* instance, template Impl* BindToProxy(Impl* instance, InterfacePtr* ptr, - MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter()) { + const MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter()) { instance->internal_state()->BindProxy(ptr, waiter); return instance; } @@ -96,7 +96,7 @@ Impl* BindToProxy(Impl* instance, template Impl* BindToRequest(Impl* instance, InterfaceRequest* request, - MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter()) { + const MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter()) { return BindToPipe(instance, request->PassMessagePipe(), waiter); } diff --git a/mojo/public/cpp/bindings/interface_ptr.h b/mojo/public/cpp/bindings/interface_ptr.h index 266cda0..8359319 100644 --- a/mojo/public/cpp/bindings/interface_ptr.h +++ b/mojo/public/cpp/bindings/interface_ptr.h @@ -56,7 +56,7 @@ class InterfacePtr { // thread, and bind the new InterfacePtr<..> to the message pipe on that // thread. void Bind(ScopedMessagePipeHandle handle, - MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter()) { + const MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter()) { reset(); internal_state_.ConfigureProxy(handle.Pass(), waiter); } @@ -110,7 +110,7 @@ class InterfacePtr { template InterfacePtr MakeProxy( ScopedMessagePipeHandle handle, - MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter()) { + const MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter()) { InterfacePtr ptr; if (handle.is_valid()) ptr.Bind(handle.Pass(), waiter); diff --git a/mojo/public/cpp/bindings/lib/connector.cc b/mojo/public/cpp/bindings/lib/connector.cc index f113058..8b97ff7 100644 --- a/mojo/public/cpp/bindings/lib/connector.cc +++ b/mojo/public/cpp/bindings/lib/connector.cc @@ -15,7 +15,7 @@ namespace internal { // ---------------------------------------------------------------------------- Connector::Connector(ScopedMessagePipeHandle message_pipe, - MojoAsyncWaiter* waiter) + const MojoAsyncWaiter* waiter) : error_handler_(NULL), waiter_(waiter), message_pipe_(message_pipe.Pass()), @@ -31,7 +31,7 @@ Connector::Connector(ScopedMessagePipeHandle message_pipe, Connector::~Connector() { if (async_wait_id_) - waiter_->CancelWait(waiter_, async_wait_id_); + waiter_->CancelWait(async_wait_id_); } void Connector::CloseMessagePipe() { @@ -40,7 +40,7 @@ void Connector::CloseMessagePipe() { ScopedMessagePipeHandle Connector::PassMessagePipe() { if (async_wait_id_) { - waiter_->CancelWait(waiter_, async_wait_id_); + waiter_->CancelWait(async_wait_id_); async_wait_id_ = 0; } return message_pipe_.Pass(); @@ -107,8 +107,7 @@ void Connector::OnHandleReady(MojoResult result) { } void Connector::WaitToReadMore() { - async_wait_id_ = waiter_->AsyncWait(waiter_, - message_pipe_.get().value(), + async_wait_id_ = waiter_->AsyncWait(message_pipe_.get().value(), MOJO_WAIT_FLAG_READABLE, MOJO_DEADLINE_INDEFINITE, &Connector::CallOnHandleReady, diff --git a/mojo/public/cpp/bindings/lib/connector.h b/mojo/public/cpp/bindings/lib/connector.h index c7077b6..ef503d4 100644 --- a/mojo/public/cpp/bindings/lib/connector.h +++ b/mojo/public/cpp/bindings/lib/connector.h @@ -26,7 +26,7 @@ class Connector : public MessageReceiver { public: // The Connector takes ownership of |message_pipe|. explicit Connector(ScopedMessagePipeHandle message_pipe, - MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter()); + const MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter()); virtual ~Connector(); // Sets the receiver to handle messages read from the message pipe. The @@ -72,7 +72,7 @@ class Connector : public MessageReceiver { void ReadMore(); ErrorHandler* error_handler_; - MojoAsyncWaiter* waiter_; + const MojoAsyncWaiter* waiter_; ScopedMessagePipeHandle message_pipe_; MessageReceiver* incoming_receiver_; diff --git a/mojo/public/cpp/bindings/lib/interface_impl_internal.h b/mojo/public/cpp/bindings/lib/interface_impl_internal.h index bf770c1..79b598d 100644 --- a/mojo/public/cpp/bindings/lib/interface_impl_internal.h +++ b/mojo/public/cpp/bindings/lib/interface_impl_internal.h @@ -44,14 +44,14 @@ class InterfaceImplState : public ErrorHandler { void BindProxy( InterfacePtr* ptr, - MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter()) { + const MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter()) { MessagePipe pipe; ptr->Bind(pipe.handle0.Pass(), waiter); Bind(pipe.handle1.Pass(), waiter); } void Bind(ScopedMessagePipeHandle handle, - MojoAsyncWaiter* waiter) { + const MojoAsyncWaiter* waiter) { assert(!router_); FilterChain filters; diff --git a/mojo/public/cpp/bindings/lib/interface_ptr_internal.h b/mojo/public/cpp/bindings/lib/interface_ptr_internal.h index 4bcaa64..607791c 100644 --- a/mojo/public/cpp/bindings/lib/interface_ptr_internal.h +++ b/mojo/public/cpp/bindings/lib/interface_ptr_internal.h @@ -38,7 +38,7 @@ class InterfacePtrState { } void ConfigureProxy(ScopedMessagePipeHandle handle, - MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter()) { + const MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter()) { assert(!proxy_); assert(!router_); diff --git a/mojo/public/cpp/bindings/lib/router.cc b/mojo/public/cpp/bindings/lib/router.cc index 7d0d868..27510e7 100644 --- a/mojo/public/cpp/bindings/lib/router.cc +++ b/mojo/public/cpp/bindings/lib/router.cc @@ -51,7 +51,7 @@ bool Router::HandleIncomingMessageThunk::Accept(Message* message) { Router::Router(ScopedMessagePipeHandle message_pipe, FilterChain filters, - MojoAsyncWaiter* waiter) + const MojoAsyncWaiter* waiter) : thunk_(this), filters_(filters.Pass()), connector_(message_pipe.Pass(), waiter), diff --git a/mojo/public/cpp/bindings/lib/router.h b/mojo/public/cpp/bindings/lib/router.h index 4a487d7..e30b924 100644 --- a/mojo/public/cpp/bindings/lib/router.h +++ b/mojo/public/cpp/bindings/lib/router.h @@ -18,7 +18,7 @@ class Router : public MessageReceiverWithResponder { public: Router(ScopedMessagePipeHandle message_pipe, FilterChain filters, - MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter()); + const MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter()); virtual ~Router(); // Sets the receiver to handle messages read from the message pipe that do diff --git a/mojo/public/cpp/environment/default_async_waiter.h b/mojo/public/cpp/environment/default_async_waiter.h index 6edfaaa..fa87648 100644 --- a/mojo/public/cpp/environment/default_async_waiter.h +++ b/mojo/public/cpp/environment/default_async_waiter.h @@ -9,8 +9,8 @@ namespace mojo { -// Returns a default implementation of MojoAsyncWaiter. -MojoAsyncWaiter* GetDefaultAsyncWaiter(); +// Returns a default implementation of |MojoAsyncWaiter|. +const MojoAsyncWaiter* GetDefaultAsyncWaiter(); } // namespace mojo diff --git a/mojo/public/cpp/environment/lib/default_async_waiter.cc b/mojo/public/cpp/environment/lib/default_async_waiter.cc index 73e41de..4dcbe47 100644 --- a/mojo/public/cpp/environment/lib/default_async_waiter.cc +++ b/mojo/public/cpp/environment/lib/default_async_waiter.cc @@ -58,8 +58,7 @@ class RunLoopHandlerImpl : public RunLoopHandler { MOJO_DISALLOW_COPY_AND_ASSIGN(RunLoopHandlerImpl); }; -MojoAsyncWaitID AsyncWait(MojoAsyncWaiter* waiter, - MojoHandle handle, +MojoAsyncWaitID AsyncWait(MojoHandle handle, MojoWaitFlags flags, MojoDeadline deadline, MojoAsyncWaitCallback callback, @@ -75,19 +74,19 @@ MojoAsyncWaitID AsyncWait(MojoAsyncWaiter* waiter, return reinterpret_cast(run_loop_handler); } -void CancelWait(MojoAsyncWaiter* waiter, MojoAsyncWaitID wait_id) { +void CancelWait(MojoAsyncWaitID wait_id) { delete reinterpret_cast(wait_id); } -MojoAsyncWaiter s_default_async_waiter = { +const MojoAsyncWaiter kDefaultAsyncWaiter = { AsyncWait, CancelWait }; } // namespace -MojoAsyncWaiter* GetDefaultAsyncWaiter() { - return &s_default_async_waiter; +const MojoAsyncWaiter* GetDefaultAsyncWaiter() { + return &kDefaultAsyncWaiter; } } // namespace mojo diff --git a/mojo/public/cpp/environment/tests/async_waiter_unittest.cc b/mojo/public/cpp/environment/tests/async_waiter_unittest.cc index 75cefb2..7943a5d 100644 --- a/mojo/public/cpp/environment/tests/async_waiter_unittest.cc +++ b/mojo/public/cpp/environment/tests/async_waiter_unittest.cc @@ -42,18 +42,16 @@ class TestAsyncWaitCallback { MojoAsyncWaitID CallAsyncWait(const Handle& handle, MojoWaitFlags flags, TestAsyncWaitCallback* callback) { - MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter(); - return waiter->AsyncWait(waiter, - handle.value(), - flags, - MOJO_DEADLINE_INDEFINITE, - &TestAsyncWaitCallback::OnHandleReady, - callback); + return GetDefaultAsyncWaiter()->AsyncWait( + handle.value(), + flags, + MOJO_DEADLINE_INDEFINITE, + &TestAsyncWaitCallback::OnHandleReady, + callback); } void CallCancelWait(MojoAsyncWaitID wait_id) { - MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter(); - waiter->CancelWait(waiter, wait_id); + GetDefaultAsyncWaiter()->CancelWait(wait_id); } class AsyncWaiterTest : public testing::Test { diff --git a/mojo/public/cpp/gles2/gles2.h b/mojo/public/cpp/gles2/gles2.h index cf6686c..4c1156e 100644 --- a/mojo/public/cpp/gles2/gles2.h +++ b/mojo/public/cpp/gles2/gles2.h @@ -13,7 +13,7 @@ namespace mojo { class GLES2Initializer { public: explicit GLES2Initializer( - MojoAsyncWaiter* async_waiter = GetDefaultAsyncWaiter()) { + const MojoAsyncWaiter* async_waiter = GetDefaultAsyncWaiter()) { MojoGLES2Initialize(async_waiter); } ~GLES2Initializer() { MojoGLES2Terminate(); } diff --git a/mojo/public/gles2/gles2_private.cc b/mojo/public/gles2/gles2_private.cc index 7887349..52b47d3 100644 --- a/mojo/public/gles2/gles2_private.cc +++ b/mojo/public/gles2/gles2_private.cc @@ -15,7 +15,7 @@ static mojo::GLES2Interface* g_gles2_interface = NULL; extern "C" { -void MojoGLES2Initialize(MojoAsyncWaiter* async_waiter) { +void MojoGLES2Initialize(const MojoAsyncWaiter* async_waiter) { assert(g_gles2_support); return g_gles2_support->Initialize(async_waiter); } diff --git a/mojo/public/gles2/gles2_private.h b/mojo/public/gles2/gles2_private.h index c92f555..f0a336d6 100644 --- a/mojo/public/gles2/gles2_private.h +++ b/mojo/public/gles2/gles2_private.h @@ -24,7 +24,7 @@ class MOJO_GLES2_EXPORT GLES2Support { static void Init(GLES2Support* gles2_support); - virtual void Initialize(MojoAsyncWaiter* async_waiter) = 0; + virtual void Initialize(const MojoAsyncWaiter* async_waiter) = 0; virtual void Terminate() = 0; virtual MojoGLES2Context CreateContext( MessagePipeHandle handle, -- cgit v1.1