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

Side by Side Diff: mojo/public/bindings/lib/connector.h

Issue 220243007: Mojo: Move mojo/public/bindings/lib to mojo/public/cpp/bindings/lib. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « mojo/public/bindings/lib/callback_internal.h ('k') | mojo/public/bindings/lib/connector.cc » ('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 2013 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_PUBLIC_BINDINGS_LIB_CONNECTOR_H_
6 #define MOJO_PUBLIC_BINDINGS_LIB_CONNECTOR_H_
7
8 #include "mojo/public/bindings/lib/message_queue.h"
9 #include "mojo/public/cpp/bindings/message.h"
10 #include "mojo/public/cpp/environment/default_async_waiter.h"
11 #include "mojo/public/cpp/system/core.h"
12
13 namespace mojo {
14 class ErrorHandler;
15
16 namespace internal {
17
18 // The Connector class is responsible for performing read/write operations on a
19 // MessagePipe. It writes messages it receives through the MessageReceiver
20 // interface that it subclasses, and it forwards messages it reads through the
21 // MessageReceiver interface assigned as its incoming receiver.
22 //
23 // NOTE: MessagePipe I/O is non-blocking.
24 //
25 class Connector : public MessageReceiver {
26 public:
27 // The Connector takes ownership of |message_pipe|.
28 explicit Connector(ScopedMessagePipeHandle message_pipe,
29 MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter());
30 virtual ~Connector();
31
32 // Sets the receiver to handle messages read from the message pipe. The
33 // Connector will read messages from the pipe regardless of whether or not an
34 // incoming receiver has been set.
35 void set_incoming_receiver(MessageReceiver* receiver) {
36 incoming_receiver_ = receiver;
37 }
38
39 // Sets the error handler to receive notifications when an error is
40 // encountered while reading from the pipe or waiting to read from the pipe.
41 void set_error_handler(ErrorHandler* error_handler) {
42 error_handler_ = error_handler;
43 }
44
45 // Returns true if an error was encountered while reading from the pipe or
46 // waiting to read from the pipe.
47 bool encountered_error() const { return error_; }
48
49 // Closes the pipe, triggering the error state.
50 void CloseMessagePipe();
51
52 // MessageReceiver implementation:
53 virtual bool Accept(Message* message) MOJO_OVERRIDE;
54 virtual bool AcceptWithResponder(Message* message, MessageReceiver* responder)
55 MOJO_OVERRIDE;
56
57 private:
58 static void CallOnHandleReady(void* closure, MojoResult result);
59 void OnHandleReady(MojoResult result);
60
61 void WaitToReadMore();
62 void ReadMore();
63
64 ErrorHandler* error_handler_;
65 MojoAsyncWaiter* waiter_;
66
67 ScopedMessagePipeHandle message_pipe_;
68 MessageReceiver* incoming_receiver_;
69
70 MojoAsyncWaitID async_wait_id_;
71 bool error_;
72 bool drop_writes_;
73
74 MOJO_DISALLOW_COPY_AND_ASSIGN(Connector);
75 };
76
77 } // namespace internal
78 } // namespace mojo
79
80 #endif // MOJO_PUBLIC_BINDINGS_LIB_CONNECTOR_H_
OLDNEW
« no previous file with comments | « mojo/public/bindings/lib/callback_internal.h ('k') | mojo/public/bindings/lib/connector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698