OLD | NEW |
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 #ifndef MOJO_EDK_SYSTEM_CHANNEL_ENDPOINT_CLIENT_H_ | 5 #ifndef MOJO_EDK_SYSTEM_CHANNEL_ENDPOINT_CLIENT_H_ |
6 #define MOJO_EDK_SYSTEM_CHANNEL_ENDPOINT_CLIENT_H_ | 6 #define MOJO_EDK_SYSTEM_CHANNEL_ENDPOINT_CLIENT_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 // after |ChannelEndpoint::DetachFromClient()| has been called (so the | 31 // after |ChannelEndpoint::DetachFromClient()| has been called (so the |
32 // |ChannelEndpoint| has apparently relinquished its pointer to the | 32 // |ChannelEndpoint| has apparently relinquished its pointer to the |
33 // |ChannelEndpointClient|). | 33 // |ChannelEndpointClient|). |
34 class MOJO_SYSTEM_IMPL_EXPORT ChannelEndpointClient | 34 class MOJO_SYSTEM_IMPL_EXPORT ChannelEndpointClient |
35 : public base::RefCountedThreadSafe<ChannelEndpointClient> { | 35 : public base::RefCountedThreadSafe<ChannelEndpointClient> { |
36 public: | 36 public: |
37 // Called by |ChannelEndpoint| in response to its |OnReadMessage()|, which is | 37 // Called by |ChannelEndpoint| in response to its |OnReadMessage()|, which is |
38 // called by |Channel| when it receives a message for the |ChannelEndpoint|. | 38 // called by |Channel| when it receives a message for the |ChannelEndpoint|. |
39 // (|port| is the value passed to |ChannelEndpoint|'s constructor as | 39 // (|port| is the value passed to |ChannelEndpoint|'s constructor as |
40 // |client_port|.) | 40 // |client_port|.) |
41 virtual void OnReadMessage(unsigned port, | 41 // |
42 scoped_ptr<MessageInTransit> message) = 0; | 42 // This should return true if it accepted (and took ownership of) |message|. |
| 43 virtual bool OnReadMessage(unsigned port, MessageInTransit* message) = 0; |
43 | 44 |
44 // Called by |ChannelEndpoint| when the |Channel| is relinquishing its pointer | 45 // Called by |ChannelEndpoint| when the |Channel| is relinquishing its pointer |
45 // to the |ChannelEndpoint| (and vice versa). After this is called, | 46 // to the |ChannelEndpoint| (and vice versa). After this is called, |
46 // |OnReadMessage()| will no longer be called. | 47 // |OnReadMessage()| will no longer be called. |
47 virtual void OnDetachFromChannel(unsigned port) = 0; | 48 virtual void OnDetachFromChannel(unsigned port) = 0; |
48 | 49 |
49 protected: | 50 protected: |
50 ChannelEndpointClient() {} | 51 ChannelEndpointClient() {} |
51 | 52 |
52 virtual ~ChannelEndpointClient() {} | 53 virtual ~ChannelEndpointClient() {} |
53 friend class base::RefCountedThreadSafe<ChannelEndpointClient>; | 54 friend class base::RefCountedThreadSafe<ChannelEndpointClient>; |
54 | 55 |
55 private: | 56 private: |
56 DISALLOW_COPY_AND_ASSIGN(ChannelEndpointClient); | 57 DISALLOW_COPY_AND_ASSIGN(ChannelEndpointClient); |
57 }; | 58 }; |
58 | 59 |
59 } // namespace system | 60 } // namespace system |
60 } // namespace mojo | 61 } // namespace mojo |
61 | 62 |
62 #endif // MOJO_EDK_SYSTEM_CHANNEL_ENDPOINT_CLIENT_H_ | 63 #endif // MOJO_EDK_SYSTEM_CHANNEL_ENDPOINT_CLIENT_H_ |
OLD | NEW |