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

Side by Side Diff: mojo/edk/system/test_channel_endpoint_client.h

Issue 1408003013: Reland "EDK: Move //mojo/edk/system/waitable_event* to edk/util." (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 1 month 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 | « mojo/edk/system/test/test_io_thread.cc ('k') | mojo/edk/system/test_channel_endpoint_client.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 MOJO_EDK_SYSTEM_TEST_CHANNEL_ENDPOINT_CLIENT_H_ 5 #ifndef MOJO_EDK_SYSTEM_TEST_CHANNEL_ENDPOINT_CLIENT_H_
6 #define MOJO_EDK_SYSTEM_TEST_CHANNEL_ENDPOINT_CLIENT_H_ 6 #define MOJO_EDK_SYSTEM_TEST_CHANNEL_ENDPOINT_CLIENT_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "mojo/edk/system/channel_endpoint.h" 10 #include "mojo/edk/system/channel_endpoint.h"
11 #include "mojo/edk/system/channel_endpoint_client.h" 11 #include "mojo/edk/system/channel_endpoint_client.h"
12 #include "mojo/edk/system/message_in_transit_queue.h" 12 #include "mojo/edk/system/message_in_transit_queue.h"
13 #include "mojo/edk/util/mutex.h" 13 #include "mojo/edk/util/mutex.h"
14 #include "mojo/edk/util/ref_ptr.h" 14 #include "mojo/edk/util/ref_ptr.h"
15 #include "mojo/edk/util/thread_annotations.h" 15 #include "mojo/edk/util/thread_annotations.h"
16 #include "mojo/public/cpp/system/macros.h" 16 #include "mojo/public/cpp/system/macros.h"
17 17
18 namespace mojo { 18 namespace mojo {
19
20 namespace util {
21 class ManualResetWaitableEvent;
22 }
23
19 namespace system { 24 namespace system {
20
21 class ManualResetWaitableEvent;
22
23 namespace test { 25 namespace test {
24 26
25 class TestChannelEndpointClient final : public ChannelEndpointClient { 27 class TestChannelEndpointClient final : public ChannelEndpointClient {
26 public: 28 public:
27 // Note: Use |util::MakeRefCounted<TestChannelEndpointClient>()|. 29 // Note: Use |util::MakeRefCounted<TestChannelEndpointClient>()|.
28 30
29 // Initializes with the given port and endpoint. 31 // Initializes with the given port and endpoint.
30 void Init(unsigned port, util::RefPtr<ChannelEndpoint>&& endpoint); 32 void Init(unsigned port, util::RefPtr<ChannelEndpoint>&& endpoint);
31 33
32 // Returns true if we're detached from the |ChannelEndpoint|. 34 // Returns true if we're detached from the |ChannelEndpoint|.
33 bool IsDetached() const; 35 bool IsDetached() const;
34 36
35 // Gets the current number of messages received (but not dequeued). 37 // Gets the current number of messages received (but not dequeued).
36 size_t NumMessages() const; 38 size_t NumMessages() const;
37 39
38 // Gets/removes a message that was received (|NumMessages()| must be 40 // Gets/removes a message that was received (|NumMessages()| must be
39 // non-zero), in FIFO order. 41 // non-zero), in FIFO order.
40 std::unique_ptr<MessageInTransit> PopMessage(); 42 std::unique_ptr<MessageInTransit> PopMessage();
41 43
42 // Sets an event to signal when we receive a message. (|read_event| must live 44 // Sets an event to signal when we receive a message. (|read_event| must live
43 // until this object is destroyed or the read event is reset to null.) 45 // until this object is destroyed or the read event is reset to null.)
44 void SetReadEvent(ManualResetWaitableEvent* read_event); 46 void SetReadEvent(util::ManualResetWaitableEvent* read_event);
45 47
46 // |ChannelEndpointClient| implementation: 48 // |ChannelEndpointClient| implementation:
47 bool OnReadMessage(unsigned port, MessageInTransit* message) override; 49 bool OnReadMessage(unsigned port, MessageInTransit* message) override;
48 void OnDetachFromChannel(unsigned port) override; 50 void OnDetachFromChannel(unsigned port) override;
49 51
50 private: 52 private:
51 FRIEND_MAKE_REF_COUNTED(TestChannelEndpointClient); 53 FRIEND_MAKE_REF_COUNTED(TestChannelEndpointClient);
52 54
53 TestChannelEndpointClient(); 55 TestChannelEndpointClient();
54 ~TestChannelEndpointClient() override; 56 ~TestChannelEndpointClient() override;
55 57
56 mutable util::Mutex mutex_; 58 mutable util::Mutex mutex_;
57 59
58 unsigned port_ MOJO_GUARDED_BY(mutex_); 60 unsigned port_ MOJO_GUARDED_BY(mutex_);
59 util::RefPtr<ChannelEndpoint> endpoint_ MOJO_GUARDED_BY(mutex_); 61 util::RefPtr<ChannelEndpoint> endpoint_ MOJO_GUARDED_BY(mutex_);
60 62
61 MessageInTransitQueue messages_ MOJO_GUARDED_BY(mutex_); 63 MessageInTransitQueue messages_ MOJO_GUARDED_BY(mutex_);
62 64
63 // Event to trigger if we read a message (may be null). 65 // Event to trigger if we read a message (may be null).
64 ManualResetWaitableEvent* read_event_ MOJO_GUARDED_BY(mutex_); 66 util::ManualResetWaitableEvent* read_event_ MOJO_GUARDED_BY(mutex_);
65 67
66 MOJO_DISALLOW_COPY_AND_ASSIGN(TestChannelEndpointClient); 68 MOJO_DISALLOW_COPY_AND_ASSIGN(TestChannelEndpointClient);
67 }; 69 };
68 70
69 } // namespace test 71 } // namespace test
70 } // namespace system 72 } // namespace system
71 } // namespace mojo 73 } // namespace mojo
72 74
73 #endif // MOJO_EDK_SYSTEM_TEST_CHANNEL_ENDPOINT_CLIENT_H_ 75 #endif // MOJO_EDK_SYSTEM_TEST_CHANNEL_ENDPOINT_CLIENT_H_
OLDNEW
« no previous file with comments | « mojo/edk/system/test/test_io_thread.cc ('k') | mojo/edk/system/test_channel_endpoint_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698