| OLD | NEW |
| 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 "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/synchronization/lock.h" | |
| 11 #include "mojo/edk/system/channel_endpoint.h" | 10 #include "mojo/edk/system/channel_endpoint.h" |
| 12 #include "mojo/edk/system/channel_endpoint_client.h" | 11 #include "mojo/edk/system/channel_endpoint_client.h" |
| 13 #include "mojo/edk/system/message_in_transit_queue.h" | 12 #include "mojo/edk/system/message_in_transit_queue.h" |
| 13 #include "mojo/edk/system/mutex.h" |
| 14 #include "mojo/public/cpp/system/macros.h" | 14 #include "mojo/public/cpp/system/macros.h" |
| 15 | 15 |
| 16 namespace base { | 16 namespace base { |
| 17 class WaitableEvent; | 17 class WaitableEvent; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace mojo { | 20 namespace mojo { |
| 21 namespace system { | 21 namespace system { |
| 22 namespace test { | 22 namespace test { |
| 23 | 23 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 42 // until this object is destroyed or the read event is reset to null.) | 42 // until this object is destroyed or the read event is reset to null.) |
| 43 void SetReadEvent(base::WaitableEvent* read_event); | 43 void SetReadEvent(base::WaitableEvent* read_event); |
| 44 | 44 |
| 45 // |ChannelEndpointClient| implementation: | 45 // |ChannelEndpointClient| implementation: |
| 46 bool OnReadMessage(unsigned port, MessageInTransit* message) override; | 46 bool OnReadMessage(unsigned port, MessageInTransit* message) override; |
| 47 void OnDetachFromChannel(unsigned port) override; | 47 void OnDetachFromChannel(unsigned port) override; |
| 48 | 48 |
| 49 private: | 49 private: |
| 50 ~TestChannelEndpointClient() override; | 50 ~TestChannelEndpointClient() override; |
| 51 | 51 |
| 52 mutable base::Lock lock_; // Protects the members below. | 52 mutable Mutex mutex_; |
| 53 | 53 |
| 54 unsigned port_; | 54 unsigned port_ MOJO_GUARDED_BY(mutex_); |
| 55 scoped_refptr<ChannelEndpoint> endpoint_; | 55 scoped_refptr<ChannelEndpoint> endpoint_ MOJO_GUARDED_BY(mutex_); |
| 56 | 56 |
| 57 MessageInTransitQueue messages_; | 57 MessageInTransitQueue messages_ MOJO_GUARDED_BY(mutex_); |
| 58 | 58 |
| 59 // Event to trigger if we read a message (may be null). | 59 // Event to trigger if we read a message (may be null). |
| 60 base::WaitableEvent* read_event_; | 60 base::WaitableEvent* read_event_ MOJO_GUARDED_BY(mutex_); |
| 61 | 61 |
| 62 MOJO_DISALLOW_COPY_AND_ASSIGN(TestChannelEndpointClient); | 62 MOJO_DISALLOW_COPY_AND_ASSIGN(TestChannelEndpointClient); |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 } // namespace test | 65 } // namespace test |
| 66 } // namespace system | 66 } // namespace system |
| 67 } // namespace mojo | 67 } // namespace mojo |
| 68 | 68 |
| 69 #endif // MOJO_EDK_SYSTEM_TEST_CHANNEL_ENDPOINT_CLIENT_H_ | 69 #endif // MOJO_EDK_SYSTEM_TEST_CHANNEL_ENDPOINT_CLIENT_H_ |
| OLD | NEW |