Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1304)

Unified Diff: mojo/public/environment/lib/default_async_waiter.cc

Issue 218043002: Mojo: Move public/environment to public/cpp/environment. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/environment/lib/buffer_tls_setup.h ('k') | mojo/public/environment/lib/environment.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/environment/lib/default_async_waiter.cc
diff --git a/mojo/public/environment/lib/default_async_waiter.cc b/mojo/public/environment/lib/default_async_waiter.cc
deleted file mode 100644
index b6c337c31bd3d923798492b33b059dca0b4bd5f5..0000000000000000000000000000000000000000
--- a/mojo/public/environment/lib/default_async_waiter.cc
+++ /dev/null
@@ -1,93 +0,0 @@
-// Copyright 2014 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.
-
-#include "mojo/public/environment/default_async_waiter.h"
-
-#include <assert.h>
-
-#include "mojo/public/cpp/utility/run_loop.h"
-#include "mojo/public/cpp/utility/run_loop_handler.h"
-
-namespace mojo {
-namespace {
-
-// RunLoopHandler implementation used for a request to AsyncWait(). There are
-// two ways RunLoopHandlerImpl is deleted:
-// . when the handle is ready (or errored).
-// . when CancelWait() is invoked.
-class RunLoopHandlerImpl : public RunLoopHandler {
- public:
- RunLoopHandlerImpl(const Handle& handle,
- MojoAsyncWaitCallback callback,
- void* closure)
- : handle_(handle),
- callback_(callback),
- closure_(closure) {
- }
-
- virtual ~RunLoopHandlerImpl() {
- RunLoop::current()->RemoveHandler(handle_);
- }
-
- // RunLoopHandler:
- virtual void OnHandleReady(const Handle& handle) MOJO_OVERRIDE {
- NotifyCallback(MOJO_RESULT_OK);
- }
-
- virtual void OnHandleError(const Handle& handle,
- MojoResult result) MOJO_OVERRIDE {
- NotifyCallback(result);
- }
-
- private:
- void NotifyCallback(MojoResult result) {
- // Delete this to unregister the handle. That way if the callback
- // reregisters everything is ok.
- MojoAsyncWaitCallback callback = callback_;
- void* closure = closure_;
- delete this;
-
- callback(closure, result);
- }
-
- const Handle handle_;
- MojoAsyncWaitCallback callback_;
- void* closure_;
-
- MOJO_DISALLOW_COPY_AND_ASSIGN(RunLoopHandlerImpl);
-};
-
-MojoAsyncWaitID AsyncWait(MojoAsyncWaiter* waiter,
- MojoHandle handle,
- MojoWaitFlags flags,
- MojoDeadline deadline,
- MojoAsyncWaitCallback callback,
- void* closure) {
- RunLoop* run_loop = RunLoop::current();
- assert(run_loop);
-
- // |run_loop_handler| is destroyed either when the handle is ready or if
- // CancelWait is invoked.
- RunLoopHandlerImpl* run_loop_handler =
- new RunLoopHandlerImpl(Handle(handle), callback, closure);
- run_loop->AddHandler(run_loop_handler, Handle(handle), flags, deadline);
- return reinterpret_cast<MojoAsyncWaitID>(run_loop_handler);
-}
-
-void CancelWait(MojoAsyncWaiter* waiter, MojoAsyncWaitID wait_id) {
- delete reinterpret_cast<RunLoopHandlerImpl*>(wait_id);
-}
-
-MojoAsyncWaiter s_default_async_waiter = {
- AsyncWait,
- CancelWait
-};
-
-} // namespace
-
-MojoAsyncWaiter* GetDefaultAsyncWaiter() {
- return &s_default_async_waiter;
-}
-
-} // namespace mojo
« no previous file with comments | « mojo/public/environment/lib/buffer_tls_setup.h ('k') | mojo/public/environment/lib/environment.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698