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

Side by Side Diff: chromeos/dbus/blocking_method_caller.cc

Issue 2056493002: clang-tidy WaitableEvent refactor (ChromeOS side) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chromeos/dbus/blocking_method_caller.h" 5 #include "chromeos/dbus/blocking_method_caller.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/task_runner.h" 10 #include "base/task_runner.h"
(...skipping 13 matching lines...) Expand all
24 *response = proxy->CallMethodAndBlock( 24 *response = proxy->CallMethodAndBlock(
25 method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT); 25 method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT);
26 } 26 }
27 27
28 } // namespace 28 } // namespace
29 29
30 BlockingMethodCaller::BlockingMethodCaller(dbus::Bus* bus, 30 BlockingMethodCaller::BlockingMethodCaller(dbus::Bus* bus,
31 dbus::ObjectProxy* proxy) 31 dbus::ObjectProxy* proxy)
32 : bus_(bus), 32 : bus_(bus),
33 proxy_(proxy), 33 proxy_(proxy),
34 on_blocking_method_call_(false /* manual_reset */, 34 on_blocking_method_call_(
35 false /* initially_signaled */) { 35 base::WaitableEvent::ResetPolicy::AUTOMATIC,
36 } 36 base::WaitableEvent::InitialState::NOT_SIGNALED) {}
37 37
38 BlockingMethodCaller::~BlockingMethodCaller() { 38 BlockingMethodCaller::~BlockingMethodCaller() {
39 } 39 }
40 40
41 std::unique_ptr<dbus::Response> BlockingMethodCaller::CallMethodAndBlock( 41 std::unique_ptr<dbus::Response> BlockingMethodCaller::CallMethodAndBlock(
42 dbus::MethodCall* method_call) { 42 dbus::MethodCall* method_call) {
43 // on_blocking_method_call_->Signal() will be called when |signaler| is 43 // on_blocking_method_call_->Signal() will be called when |signaler| is
44 // destroyed. 44 // destroyed.
45 base::Closure signal_task( 45 base::Closure signal_task(
46 base::Bind(&base::WaitableEvent::Signal, 46 base::Bind(&base::WaitableEvent::Signal,
47 base::Unretained(&on_blocking_method_call_))); 47 base::Unretained(&on_blocking_method_call_)));
48 base::ScopedClosureRunner* signaler = 48 base::ScopedClosureRunner* signaler =
49 new base::ScopedClosureRunner(signal_task); 49 new base::ScopedClosureRunner(signal_task);
50 50
51 std::unique_ptr<dbus::Response> response; 51 std::unique_ptr<dbus::Response> response;
52 bus_->GetDBusTaskRunner()->PostTask( 52 bus_->GetDBusTaskRunner()->PostTask(
53 FROM_HERE, 53 FROM_HERE,
54 base::Bind(&CallMethodAndBlockInternal, 54 base::Bind(&CallMethodAndBlockInternal,
55 &response, 55 &response,
56 base::Owned(signaler), 56 base::Owned(signaler),
57 base::Unretained(proxy_), 57 base::Unretained(proxy_),
58 method_call)); 58 method_call));
59 // http://crbug.com/125360 59 // http://crbug.com/125360
60 base::ThreadRestrictions::ScopedAllowWait allow_wait; 60 base::ThreadRestrictions::ScopedAllowWait allow_wait;
61 on_blocking_method_call_.Wait(); 61 on_blocking_method_call_.Wait();
62 return response; 62 return response;
63 } 63 }
64 64
65 } // namespace chromeos 65 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/signin/oauth2_browsertest.cc ('k') | chromeos/system/statistics_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698