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

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

Issue 1346383004: EDK: Remove MOJO_SYSTEM_IMPL_EXPORT, system_impl_export.h, etc. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 3 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 | « mojo/edk/system/channel_endpoint.h ('k') | mojo/edk/system/channel_endpoint_id.h » ('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 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/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "mojo/edk/system/system_impl_export.h"
10 #include "mojo/public/cpp/system/macros.h" 9 #include "mojo/public/cpp/system/macros.h"
11 10
12 namespace mojo { 11 namespace mojo {
13 namespace system { 12 namespace system {
14 13
15 class MessageInTransit; 14 class MessageInTransit;
16 15
17 // Interface for receivers of messages from |ChannelEndpoint| (hence from 16 // Interface for receivers of messages from |ChannelEndpoint| (hence from
18 // |Channel|). |port| is simply the value passed to |ChannelEndpoint| on 17 // |Channel|). |port| is simply the value passed to |ChannelEndpoint| on
19 // construction, and provides a lightweight way for an object to be the client 18 // construction, and provides a lightweight way for an object to be the client
20 // of multiple |ChannelEndpoint|s. (|MessagePipe| implements this interface, in 19 // of multiple |ChannelEndpoint|s. (|MessagePipe| implements this interface, in
21 // which case |port| is the port number for the |ProxyMessagePipeEndpoint| 20 // which case |port| is the port number for the |ProxyMessagePipeEndpoint|
22 // corresdponding to the |ChannelEndpoint|.) 21 // corresdponding to the |ChannelEndpoint|.)
23 // 22 //
24 // Implementations of this class should be thread-safe. |ChannelEndpointClient| 23 // Implementations of this class should be thread-safe. |ChannelEndpointClient|
25 // *precedes* |ChannelEndpoint| in the lock order, so |ChannelEndpoint| should 24 // *precedes* |ChannelEndpoint| in the lock order, so |ChannelEndpoint| should
26 // never call into this class with its lock held. (Instead, it should take a 25 // never call into this class with its lock held. (Instead, it should take a
27 // reference under its lock, release its lock, and make any needed call(s).) 26 // reference under its lock, release its lock, and make any needed call(s).)
28 // 27 //
29 // Note: As a consequence of this, all the client methods may be called even 28 // Note: As a consequence of this, all the client methods may be called even
30 // after |ChannelEndpoint::DetachFromClient()| has been called (so the 29 // after |ChannelEndpoint::DetachFromClient()| has been called (so the
31 // |ChannelEndpoint| has apparently relinquished its pointer to the 30 // |ChannelEndpoint| has apparently relinquished its pointer to the
32 // |ChannelEndpointClient|). 31 // |ChannelEndpointClient|).
33 class MOJO_SYSTEM_IMPL_EXPORT ChannelEndpointClient 32 class ChannelEndpointClient
34 : public base::RefCountedThreadSafe<ChannelEndpointClient> { 33 : public base::RefCountedThreadSafe<ChannelEndpointClient> {
35 public: 34 public:
36 // Called by |ChannelEndpoint| in response to its |OnReadMessage()|, which is 35 // Called by |ChannelEndpoint| in response to its |OnReadMessage()|, which is
37 // called by |Channel| when it receives a message for the |ChannelEndpoint|. 36 // called by |Channel| when it receives a message for the |ChannelEndpoint|.
38 // (|port| is the value passed to |ChannelEndpoint|'s constructor as 37 // (|port| is the value passed to |ChannelEndpoint|'s constructor as
39 // |client_port|.) 38 // |client_port|.)
40 // 39 //
41 // This should return true if it accepted (and took ownership of) |message|. 40 // This should return true if it accepted (and took ownership of) |message|.
42 virtual bool OnReadMessage(unsigned port, MessageInTransit* message) = 0; 41 virtual bool OnReadMessage(unsigned port, MessageInTransit* message) = 0;
43 42
44 // Called by |ChannelEndpoint| when the |Channel| is relinquishing its pointer 43 // Called by |ChannelEndpoint| when the |Channel| is relinquishing its pointer
45 // to the |ChannelEndpoint| (and vice versa). After this is called, 44 // to the |ChannelEndpoint| (and vice versa). After this is called,
46 // |OnReadMessage()| will no longer be called. 45 // |OnReadMessage()| will no longer be called.
47 virtual void OnDetachFromChannel(unsigned port) = 0; 46 virtual void OnDetachFromChannel(unsigned port) = 0;
48 47
49 protected: 48 protected:
50 ChannelEndpointClient() {} 49 ChannelEndpointClient() {}
51 50
52 virtual ~ChannelEndpointClient() {} 51 virtual ~ChannelEndpointClient() {}
53 friend class base::RefCountedThreadSafe<ChannelEndpointClient>; 52 friend class base::RefCountedThreadSafe<ChannelEndpointClient>;
54 53
55 private: 54 private:
56 MOJO_DISALLOW_COPY_AND_ASSIGN(ChannelEndpointClient); 55 MOJO_DISALLOW_COPY_AND_ASSIGN(ChannelEndpointClient);
57 }; 56 };
58 57
59 } // namespace system 58 } // namespace system
60 } // namespace mojo 59 } // namespace mojo
61 60
62 #endif // MOJO_EDK_SYSTEM_CHANNEL_ENDPOINT_CLIENT_H_ 61 #endif // MOJO_EDK_SYSTEM_CHANNEL_ENDPOINT_CLIENT_H_
OLDNEW
« no previous file with comments | « mojo/edk/system/channel_endpoint.h ('k') | mojo/edk/system/channel_endpoint_id.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698