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

Side by Side Diff: mojo/public/cpp/environment/lib/default_async_waiter.cc

Issue 668663006: Standardize usage of virtual/override/final in mojo/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/public/cpp/environment/lib/default_async_waiter.h" 5 #include "mojo/public/cpp/environment/lib/default_async_waiter.h"
6 6
7 #include <assert.h> 7 #include <assert.h>
8 8
9 #include "mojo/public/c/environment/async_waiter.h" 9 #include "mojo/public/c/environment/async_waiter.h"
10 #include "mojo/public/cpp/utility/run_loop.h" 10 #include "mojo/public/cpp/utility/run_loop.h"
11 #include "mojo/public/cpp/utility/run_loop_handler.h" 11 #include "mojo/public/cpp/utility/run_loop_handler.h"
12 12
13 namespace mojo { 13 namespace mojo {
14 14
15 namespace { 15 namespace {
16 16
17 // RunLoopHandler implementation used for a request to AsyncWait(). There are 17 // RunLoopHandler implementation used for a request to AsyncWait(). There are
18 // two ways RunLoopHandlerImpl is deleted: 18 // two ways RunLoopHandlerImpl is deleted:
19 // . when the handle is ready (or errored). 19 // . when the handle is ready (or errored).
20 // . when CancelWait() is invoked. 20 // . when CancelWait() is invoked.
21 class RunLoopHandlerImpl : public RunLoopHandler { 21 class RunLoopHandlerImpl : public RunLoopHandler {
22 public: 22 public:
23 RunLoopHandlerImpl(const Handle& handle, 23 RunLoopHandlerImpl(const Handle& handle,
24 MojoAsyncWaitCallback callback, 24 MojoAsyncWaitCallback callback,
25 void* closure) 25 void* closure)
26 : handle_(handle), callback_(callback), closure_(closure) {} 26 : handle_(handle), callback_(callback), closure_(closure) {}
27 27
28 virtual ~RunLoopHandlerImpl() { RunLoop::current()->RemoveHandler(handle_); } 28 ~RunLoopHandlerImpl() override { RunLoop::current()->RemoveHandler(handle_); }
29 29
30 // RunLoopHandler: 30 // RunLoopHandler:
31 virtual void OnHandleReady(const Handle& handle) override { 31 void OnHandleReady(const Handle& handle) override {
32 NotifyCallback(MOJO_RESULT_OK); 32 NotifyCallback(MOJO_RESULT_OK);
33 } 33 }
34 34
35 virtual void OnHandleError(const Handle& handle, MojoResult result) override { 35 void OnHandleError(const Handle& handle, MojoResult result) override {
36 NotifyCallback(result); 36 NotifyCallback(result);
37 } 37 }
38 38
39 private: 39 private:
40 void NotifyCallback(MojoResult result) { 40 void NotifyCallback(MojoResult result) {
41 // Delete this to unregister the handle. That way if the callback 41 // Delete this to unregister the handle. That way if the callback
42 // reregisters everything is ok. 42 // reregisters everything is ok.
43 MojoAsyncWaitCallback callback = callback_; 43 MojoAsyncWaitCallback callback = callback_;
44 void* closure = closure_; 44 void* closure = closure_;
45 delete this; 45 delete this;
(...skipping 30 matching lines...) Expand all
76 76
77 } // namespace 77 } // namespace
78 78
79 namespace internal { 79 namespace internal {
80 80
81 const MojoAsyncWaiter kDefaultAsyncWaiter = {AsyncWait, CancelWait}; 81 const MojoAsyncWaiter kDefaultAsyncWaiter = {AsyncWait, CancelWait};
82 82
83 } // namespace internal 83 } // namespace internal
84 84
85 } // namespace mojo 85 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/tests/validation_unittest.cc ('k') | mojo/public/cpp/system/tests/macros_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698