| 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/obb_mounter/arc_obb_mounter_bridge.h" | 5 #include "components/arc/obb_mounter/arc_obb_mounter_bridge.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "chromeos/dbus/arc_obb_mounter_client.h" | 8 #include "chromeos/dbus/arc_obb_mounter_client.h" |
| 9 #include "chromeos/dbus/dbus_thread_manager.h" | 9 #include "chromeos/dbus/dbus_thread_manager.h" |
| 10 #include "components/arc/arc_bridge_service.h" | 10 #include "components/arc/arc_bridge_service.h" |
| 11 | 11 |
| 12 namespace arc { | 12 namespace arc { |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 // Used to convert mojo Callback to VoidDBusMethodCallback. | 16 // Used to convert mojo Callback to VoidDBusMethodCallback. |
| 17 void RunObbCallback(const base::Callback<void(bool)>& callback, | 17 void RunObbCallback(const base::Callback<void(bool)>& callback, |
| 18 chromeos::DBusMethodCallStatus result) { | 18 chromeos::DBusMethodCallStatus result) { |
| 19 callback.Run(result == chromeos::DBUS_METHOD_CALL_SUCCESS); | 19 callback.Run(result == chromeos::DBUS_METHOD_CALL_SUCCESS); |
| 20 } | 20 } |
| 21 | 21 |
| 22 } // namespace | 22 } // namespace |
| 23 | 23 |
| 24 ArcObbMounterBridge::ArcObbMounterBridge(ArcBridgeService* bridge_service) | 24 ArcObbMounterBridge::ArcObbMounterBridge(ArcBridgeService* bridge_service) |
| 25 : ArcService(bridge_service), | 25 : ArcService(bridge_service), binding_(this) { |
| 26 binding_(this) { | 26 arc_bridge_service()->obb_mounter()->AddObserver(this); |
| 27 arc_bridge_service()->AddObserver(this); | |
| 28 } | 27 } |
| 29 | 28 |
| 30 ArcObbMounterBridge::~ArcObbMounterBridge() { | 29 ArcObbMounterBridge::~ArcObbMounterBridge() { |
| 31 arc_bridge_service()->RemoveObserver(this); | 30 arc_bridge_service()->obb_mounter()->RemoveObserver(this); |
| 32 } | 31 } |
| 33 | 32 |
| 34 void ArcObbMounterBridge::OnObbMounterInstanceReady() { | 33 void ArcObbMounterBridge::OnInstanceReady() { |
| 35 mojom::ObbMounterInstance* obb_mounter_instance = | 34 mojom::ObbMounterInstance* obb_mounter_instance = |
| 36 arc_bridge_service()->obb_mounter_instance(); | 35 arc_bridge_service()->obb_mounter()->instance(); |
| 37 obb_mounter_instance->Init(binding_.CreateInterfacePtrAndBind()); | 36 obb_mounter_instance->Init(binding_.CreateInterfacePtrAndBind()); |
| 38 } | 37 } |
| 39 | 38 |
| 40 void ArcObbMounterBridge::MountObb(const mojo::String& obb_file, | 39 void ArcObbMounterBridge::MountObb(const mojo::String& obb_file, |
| 41 const mojo::String& target_path, | 40 const mojo::String& target_path, |
| 42 int32_t owner_gid, | 41 int32_t owner_gid, |
| 43 const MountObbCallback& callback) { | 42 const MountObbCallback& callback) { |
| 44 chromeos::DBusThreadManager::Get()->GetArcObbMounterClient()->MountObb( | 43 chromeos::DBusThreadManager::Get()->GetArcObbMounterClient()->MountObb( |
| 45 obb_file.get(), target_path.get(), owner_gid, | 44 obb_file.get(), target_path.get(), owner_gid, |
| 46 base::Bind(&RunObbCallback, callback)); | 45 base::Bind(&RunObbCallback, callback)); |
| 47 } | 46 } |
| 48 | 47 |
| 49 void ArcObbMounterBridge::UnmountObb(const mojo::String& target_path, | 48 void ArcObbMounterBridge::UnmountObb(const mojo::String& target_path, |
| 50 const UnmountObbCallback& callback) { | 49 const UnmountObbCallback& callback) { |
| 51 chromeos::DBusThreadManager::Get()->GetArcObbMounterClient()->UnmountObb( | 50 chromeos::DBusThreadManager::Get()->GetArcObbMounterClient()->UnmountObb( |
| 52 target_path.get(), base::Bind(&RunObbCallback, callback)); | 51 target_path.get(), base::Bind(&RunObbCallback, callback)); |
| 53 } | 52 } |
| 54 | 53 |
| 55 } // namespace arc | 54 } // namespace arc |
| OLD | NEW |