Ignore title parameter for navigator.registerProtocolHandler
[chromium-blink-merge.git] / mojo / public / cpp / bindings / sync_dispatcher.h
blob752118023940799d46c3c9e716f81bd9dfd4cbfb
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.
5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_SYNC_DISPATCHER_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_SYNC_DISPATCHER_H_
8 #include "mojo/public/cpp/system/core.h"
10 namespace mojo {
12 class MessageReceiver;
14 // Waits for one message to arrive on the message pipe, and dispatch it to the
15 // receiver. Returns true on success, false on failure.
16 bool WaitForMessageAndDispatch(MessagePipeHandle handle,
17 mojo::MessageReceiver* receiver);
19 template<typename Interface> class SyncDispatcher {
20 public:
21 SyncDispatcher(ScopedMessagePipeHandle message_pipe, Interface* sink)
22 : message_pipe_(message_pipe.Pass()) {
23 stub_.set_sink(sink);
26 bool WaitAndDispatchOneMessage() {
27 return WaitForMessageAndDispatch(message_pipe_.get(), &stub_);
30 private:
31 ScopedMessagePipeHandle message_pipe_;
32 typename Interface::Stub_ stub_;
35 } // namespace mojo
37 #endif // MOJO_PUBLIC_CPP_BINDINGS_SYNC_DISPATCHER_H_