[chromedriver] Drop support for M39 and add support for M42.
[chromium-blink-merge.git] / chromeos / dbus / blocking_method_caller.h
blob6291f47c030b9249d6ae21ad438e486a70a82559
1 // Copyright (c) 2012 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 CHROMEOS_DBUS_BLOCKING_METHOD_CALLER_H_
6 #define CHROMEOS_DBUS_BLOCKING_METHOD_CALLER_H_
8 #include "base/callback.h"
9 #include "base/synchronization/waitable_event.h"
10 #include "chromeos/chromeos_export.h"
11 #include "dbus/message.h"
13 namespace dbus {
15 class Bus;
16 class ObjectProxy;
18 } // namespace dbus
20 namespace chromeos {
22 // A utility class to call D-Bus methods in a synchronous (blocking) way.
23 // Note: Blocking the thread until it returns is not a good idea in most cases.
24 // Avoid using this class as hard as you can.
25 class CHROMEOS_EXPORT BlockingMethodCaller {
26 public:
27 BlockingMethodCaller(dbus::Bus* bus, dbus::ObjectProxy* proxy);
28 virtual ~BlockingMethodCaller();
30 // Calls the method and blocks until it returns.
31 scoped_ptr<dbus::Response> CallMethodAndBlock(dbus::MethodCall* method_call);
33 private:
34 dbus::Bus* bus_;
35 dbus::ObjectProxy* proxy_;
36 base::WaitableEvent on_blocking_method_call_;
38 DISALLOW_COPY_AND_ASSIGN(BlockingMethodCaller);
41 } // namespace chromeos
43 #endif // CHROMEOS_DBUS_BLOCKING_METHOD_CALLER_H_