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

Side by Side Diff: mojo/public/cpp/bindings/sync_dispatcher.h

Issue 380123002: Mojo: Eliminate SyncDispatcher in favor of WaitForIncomingMethodCall (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove old TODO comment Created 6 years, 5 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/cpp/bindings/lib/sync_dispatcher.cc ('k') | no next file » | 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_PUBLIC_CPP_BINDINGS_SYNC_DISPATCHER_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_SYNC_DISPATCHER_H_
7
8 #include "mojo/public/cpp/bindings/lib/filter_chain.h"
9 #include "mojo/public/cpp/bindings/lib/message_header_validator.h"
10 #include "mojo/public/cpp/system/core.h"
11
12 namespace mojo {
13
14 class MessageReceiver;
15
16 // Waits for one message to arrive on the message pipe, and dispatch it to the
17 // receiver. Returns true on success, false on failure.
18 //
19 // NOTE: The message hasn't been validated and may be malformed!
20 bool WaitForMessageAndDispatch(MessagePipeHandle handle,
21 mojo::MessageReceiver* receiver);
22
23 template<typename Interface> class SyncDispatcher {
24 public:
25 SyncDispatcher(ScopedMessagePipeHandle message_pipe, Interface* sink)
26 : message_pipe_(message_pipe.Pass()) {
27 stub_.set_sink(sink);
28
29 filters_.Append<internal::MessageHeaderValidator>();
30 filters_.Append<typename Interface::RequestValidator_>();
31 filters_.SetSink(&stub_);
32 }
33
34 bool WaitAndDispatchOneMessage() {
35 return WaitForMessageAndDispatch(message_pipe_.get(),
36 filters_.GetHead());
37 }
38
39 private:
40 ScopedMessagePipeHandle message_pipe_;
41 typename Interface::Stub_ stub_;
42 internal::FilterChain filters_;
43 };
44
45 } // namespace mojo
46
47 #endif // MOJO_PUBLIC_CPP_BINDINGS_SYNC_DISPATCHER_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/sync_dispatcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698