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

Side by Side Diff: components/arc/test/fake_arc_bridge_instance.cc

Issue 2379223004: Switch from Delegate to Observer. (Closed)
Patch Set: Rebase Created 4 years, 2 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
(Empty)
1 // Copyright 2015 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 #include "components/arc/test/fake_arc_bridge_instance.h"
6
7 #include <utility>
8
9 #include "base/run_loop.h"
10
11 namespace arc {
12
13 FakeArcBridgeInstance::FakeArcBridgeInstance() : binding_(this) {}
14 FakeArcBridgeInstance::~FakeArcBridgeInstance() {}
15
16 void FakeArcBridgeInstance::Init(mojom::ArcBridgeHostPtr host) {
17 host_ptr_ = std::move(host);
18 init_calls_++;
19
20 // Wake WaitForInitCall().
21 if (!quit_closure_.is_null())
22 quit_closure_.Run();
23 quit_closure_.Reset();
24 }
25
26 void FakeArcBridgeInstance::Unbind() {
27 host_ptr_.reset();
28 if (binding_.is_bound())
29 binding_.Close();
30 }
31
32 void FakeArcBridgeInstance::Bind(
33 mojo::InterfaceRequest<mojom::ArcBridgeInstance> interface_request) {
34 binding_.Bind(std::move(interface_request));
35 }
36
37 void FakeArcBridgeInstance::WaitForInitCall() {
38 base::RunLoop run_loop;
39 quit_closure_ = run_loop.QuitClosure();
40 binding_.set_connection_error_handler(run_loop.QuitClosure());
41 run_loop.Run();
42 }
43
44 void FakeArcBridgeInstance::Stop(ArcBridgeService::StopReason reason) {
45 if (!delegate_)
46 return;
47 delegate_->OnStopped(reason);
48 }
49
50 } // namespace arc
OLDNEW
« no previous file with comments | « components/arc/test/fake_arc_bridge_instance.h ('k') | components/arc/test/fake_intent_helper_instance.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698