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

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

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

Powered by Google App Engine
This is Rietveld 408576698