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

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

Issue 1420713006: Revert "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 namespace system {
19 20
20 namespace util {
21 class ManualResetWaitableEvent; 21 class ManualResetWaitableEvent;
22 }
23 22
24 namespace system {
25 namespace test { 23 namespace test {
26 24
27 class TestChannelEndpointClient final : public ChannelEndpointClient { 25 class TestChannelEndpointClient final : public ChannelEndpointClient {
28 public: 26 public:
29 // Note: Use |util::MakeRefCounted<TestChannelEndpointClient>()|. 27 // Note: Use |util::MakeRefCounted<TestChannelEndpointClient>()|.
30 28
31 // Initializes with the given port and endpoint. 29 // Initializes with the given port and endpoint.
32 void Init(unsigned port, util::RefPtr<ChannelEndpoint>&& endpoint); 30 void Init(unsigned port, util::RefPtr<ChannelEndpoint>&& endpoint);
33 31
34 // Returns true if we're detached from the |ChannelEndpoint|. 32 // Returns true if we're detached from the |ChannelEndpoint|.
35 bool IsDetached() const; 33 bool IsDetached() const;
36 34
37 // Gets the current number of messages received (but not dequeued). 35 // Gets the current number of messages received (but not dequeued).
38 size_t NumMessages() const; 36 size_t NumMessages() const;
39 37
40 // Gets/removes a message that was received (|NumMessages()| must be 38 // Gets/removes a message that was received (|NumMessages()| must be
41 // non-zero), in FIFO order. 39 // non-zero), in FIFO order.
42 std::unique_ptr<MessageInTransit> PopMessage(); 40 std::unique_ptr<MessageInTransit> PopMessage();
43 41
44 // Sets an event to signal when we receive a message. (|read_event| must live 42 // Sets an event to signal when we receive a message. (|read_event| must live
45 // until this object is destroyed or the read event is reset to null.) 43 // until this object is destroyed or the read event is reset to null.)
46 void SetReadEvent(util::ManualResetWaitableEvent* read_event); 44 void SetReadEvent(ManualResetWaitableEvent* read_event);
47 45
48 // |ChannelEndpointClient| implementation: 46 // |ChannelEndpointClient| implementation:
49 bool OnReadMessage(unsigned port, MessageInTransit* message) override; 47 bool OnReadMessage(unsigned port, MessageInTransit* message) override;
50 void OnDetachFromChannel(unsigned port) override; 48 void OnDetachFromChannel(unsigned port) override;
51 49
52 private: 50 private:
53 FRIEND_MAKE_REF_COUNTED(TestChannelEndpointClient); 51 FRIEND_MAKE_REF_COUNTED(TestChannelEndpointClient);
54 52
55 TestChannelEndpointClient(); 53 TestChannelEndpointClient();
56 ~TestChannelEndpointClient() override; 54 ~TestChannelEndpointClient() override;
57 55
58 mutable util::Mutex mutex_; 56 mutable util::Mutex mutex_;
59 57
60 unsigned port_ MOJO_GUARDED_BY(mutex_); 58 unsigned port_ MOJO_GUARDED_BY(mutex_);
61 util::RefPtr<ChannelEndpoint> endpoint_ MOJO_GUARDED_BY(mutex_); 59 util::RefPtr<ChannelEndpoint> endpoint_ MOJO_GUARDED_BY(mutex_);
62 60
63 MessageInTransitQueue messages_ MOJO_GUARDED_BY(mutex_); 61 MessageInTransitQueue messages_ MOJO_GUARDED_BY(mutex_);
64 62
65 // Event to trigger if we read a message (may be null). 63 // Event to trigger if we read a message (may be null).
66 util::ManualResetWaitableEvent* read_event_ MOJO_GUARDED_BY(mutex_); 64 ManualResetWaitableEvent* read_event_ MOJO_GUARDED_BY(mutex_);
67 65
68 MOJO_DISALLOW_COPY_AND_ASSIGN(TestChannelEndpointClient); 66 MOJO_DISALLOW_COPY_AND_ASSIGN(TestChannelEndpointClient);
69 }; 67 };
70 68
71 } // namespace test 69 } // namespace test
72 } // namespace system 70 } // namespace system
73 } // namespace mojo 71 } // namespace mojo
74 72
75 #endif // MOJO_EDK_SYSTEM_TEST_CHANNEL_ENDPOINT_CLIENT_H_ 73 #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