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

Side by Side Diff: ipc/mojo/async_handle_waiter.h

Issue 973213002: Make AsyncHandleWaiter reenterancy-safe (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Landing Created 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | ipc/mojo/async_handle_waiter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #ifndef IPC_MOJO_ASYNC_HANDLE_WAITER_H_ 5 #ifndef IPC_MOJO_ASYNC_HANDLE_WAITER_H_
6 #define IPC_MOJO_ASYNC_HANDLE_WAITER_H_ 6 #define IPC_MOJO_ASYNC_HANDLE_WAITER_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/message_loop/message_loop.h"
11 #include "ipc/ipc_export.h" 12 #include "ipc/ipc_export.h"
12 #include "third_party/mojo/src/mojo/public/c/system/types.h" 13 #include "third_party/mojo/src/mojo/public/c/system/types.h"
13 14
14 namespace IPC { 15 namespace IPC {
15 namespace internal { 16 namespace internal {
16 17
17 // |AsyncHandleWaiter| waits on a mojo handle asynchronously and 18 // |AsyncHandleWaiter| waits on a mojo handle asynchronously and
18 // invokes the given |callback| through |runner| when it is signaled. 19 // invokes the given |callback| through |runner| when it is signaled.
19 // * To start waiting, the client must call |AsyncHandleWaiter::Wait()|. 20 // * To start waiting, the client must call |AsyncHandleWaiter::Wait()|.
20 // The client can call |Wait()| again once it is signaled and 21 // The client can call |Wait()| again once it is signaled and
21 // the |callback| is invoked. 22 // the |callback| is invoked.
22 // * To cancel waiting, delete the instance. 23 // * To cancel waiting, delete the instance.
23 // 24 //
24 // |AsyncHandleWaiter| must be created, used and deleted only from the IO 25 // |AsyncHandleWaiter| must be created, used and deleted only from the IO
25 // |thread. 26 // |thread.
26 class IPC_MOJO_EXPORT AsyncHandleWaiter { 27 class IPC_MOJO_EXPORT AsyncHandleWaiter {
27 public: 28 public:
28 class Context; 29 class Context;
29 30
30 explicit AsyncHandleWaiter(base::Callback<void(MojoResult)> callback); 31 explicit AsyncHandleWaiter(base::Callback<void(MojoResult)> callback);
31 ~AsyncHandleWaiter(); 32 ~AsyncHandleWaiter();
32 33
33 MojoResult Wait(MojoHandle handle, MojoHandleSignals signals); 34 MojoResult Wait(MojoHandle handle, MojoHandleSignals signals);
34 35
36 base::MessageLoopForIO::IOObserver* GetIOObserverForTest();
37 base::Callback<void(MojoResult)> GetWaitCallbackForTest();
38
35 private: 39 private:
36 void InvokeCallback(MojoResult result); 40 void InvokeCallback(MojoResult result);
37 41
38 scoped_refptr<Context> context_; 42 scoped_refptr<Context> context_;
39 base::Callback<void(MojoResult)> callback_; 43 base::Callback<void(MojoResult)> callback_;
40 base::WeakPtrFactory<AsyncHandleWaiter> weak_factory_; 44 base::WeakPtrFactory<AsyncHandleWaiter> weak_factory_;
41 45
42 DISALLOW_COPY_AND_ASSIGN(AsyncHandleWaiter); 46 DISALLOW_COPY_AND_ASSIGN(AsyncHandleWaiter);
43 }; 47 };
44 48
45 } // namespace internal 49 } // namespace internal
46 } // namespace IPC 50 } // namespace IPC
47 51
48 #endif // IPC_MOJO_ASYNC_HANDLE_WAITER_H_ 52 #endif // IPC_MOJO_ASYNC_HANDLE_WAITER_H_
OLDNEW
« no previous file with comments | « no previous file | ipc/mojo/async_handle_waiter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698