OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/arc/test/fake_policy_instance.h" | 5 #include "components/arc/test/fake_policy_instance.h" |
6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
7 | 7 |
8 namespace arc { | 8 namespace arc { |
9 | 9 |
10 FakePolicyInstance::FakePolicyInstance( | 10 FakePolicyInstance::FakePolicyInstance( |
11 mojo::InterfaceRequest<mojom::PolicyInstance> request, | 11 mojo::InterfaceRequest<mojom::PolicyInstance> request, |
12 ArcBridgeService* bridge_service) | 12 ArcBridgeService* bridge_service) |
13 : binding_(this, std::move(request)), bridge_service_(bridge_service) { | 13 : binding_(this, std::move(request)), bridge_service_(bridge_service) { |
14 bridge_service_->AddObserver(this); | 14 bridge_service_->policy()->AddObserver(this); |
15 } | 15 } |
16 | 16 |
17 FakePolicyInstance::~FakePolicyInstance() { | 17 FakePolicyInstance::~FakePolicyInstance() { |
18 bridge_service_->RemoveObserver(this); | 18 bridge_service_->policy()->RemoveObserver(this); |
19 } | 19 } |
20 | 20 |
21 void FakePolicyInstance::OnPolicyUpdated() {} | 21 void FakePolicyInstance::OnPolicyUpdated() {} |
22 | 22 |
23 void FakePolicyInstance::Init(mojom::PolicyHostPtr host_ptr) { | 23 void FakePolicyInstance::Init(mojom::PolicyHostPtr host_ptr) { |
24 host_ptr_ = std::move(host_ptr); | 24 host_ptr_ = std::move(host_ptr); |
25 } | 25 } |
26 | 26 |
27 void FakePolicyInstance::OnPolicyInstanceReady() { | 27 void FakePolicyInstance::OnInstanceReady(mojom::PolicyInstance*, |
| 28 uint32_t version) { |
28 ready_ = true; | 29 ready_ = true; |
29 } | 30 } |
30 | 31 |
31 void FakePolicyInstance::WaitForOnPolicyInstanceReady() { | 32 void FakePolicyInstance::WaitForOnPolicyInstanceReady() { |
32 while (!ready_) { | 33 while (!ready_) { |
33 base::RunLoop().RunUntilIdle(); | 34 base::RunLoop().RunUntilIdle(); |
34 } | 35 } |
35 } | 36 } |
36 | 37 |
37 void FakePolicyInstance::CallGetPolicies( | 38 void FakePolicyInstance::CallGetPolicies( |
38 const mojom::PolicyHost::GetPoliciesCallback& callback) { | 39 const mojom::PolicyHost::GetPoliciesCallback& callback) { |
39 host_ptr_->GetPolicies(callback); | 40 host_ptr_->GetPolicies(callback); |
40 base::RunLoop().RunUntilIdle(); | 41 base::RunLoop().RunUntilIdle(); |
41 } | 42 } |
42 | 43 |
43 } // namespace arc | 44 } // namespace arc |
OLD | NEW |