Commit 49a2aeb9 authored by Risan's avatar Risan Committed by Commit Bot

Have explicit send-all-mounts in VolumeMounter

This change add a method to request Chrome to send all existing mount
points. This method is called everytime vold is reseting.

Bug: 64500663
Change-Id: If10577a3d40ebd240a2ad242f703a28ecd3c363e
Reviewed-on: https://chromium-review.googlesource.com/938683
Commit-Queue: Risan <risan@chromium.org>
Reviewed-by: default avatarRyo Hashimoto <hashimoto@chromium.org>
Reviewed-by: default avatarMattias Nissler <mnissler@chromium.org>
Reviewed-by: default avatarLuis Hector Chavez <lhchavez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#539785}
parent 4a714378
...@@ -81,6 +81,7 @@ class VoiceInteractionArcHomeHost; ...@@ -81,6 +81,7 @@ class VoiceInteractionArcHomeHost;
class VoiceInteractionArcHomeInstance; class VoiceInteractionArcHomeInstance;
class VoiceInteractionFrameworkHost; class VoiceInteractionFrameworkHost;
class VoiceInteractionFrameworkInstance; class VoiceInteractionFrameworkInstance;
class VolumeMounterHost;
class VolumeMounterInstance; class VolumeMounterInstance;
class WallpaperHost; class WallpaperHost;
class WallpaperInstance; class WallpaperInstance;
...@@ -213,7 +214,8 @@ class ArcBridgeService { ...@@ -213,7 +214,8 @@ class ArcBridgeService {
voice_interaction_framework() { voice_interaction_framework() {
return &voice_interaction_framework_; return &voice_interaction_framework_;
} }
ConnectionHolder<mojom::VolumeMounterInstance>* volume_mounter() { ConnectionHolder<mojom::VolumeMounterInstance, mojom::VolumeMounterHost>*
volume_mounter() {
return &volume_mounter_; return &volume_mounter_;
} }
ConnectionHolder<mojom::WallpaperInstance, mojom::WallpaperHost>* ConnectionHolder<mojom::WallpaperInstance, mojom::WallpaperHost>*
...@@ -274,7 +276,8 @@ class ArcBridgeService { ...@@ -274,7 +276,8 @@ class ArcBridgeService {
ConnectionHolder<mojom::VoiceInteractionFrameworkInstance, ConnectionHolder<mojom::VoiceInteractionFrameworkInstance,
mojom::VoiceInteractionFrameworkHost> mojom::VoiceInteractionFrameworkHost>
voice_interaction_framework_; voice_interaction_framework_;
ConnectionHolder<mojom::VolumeMounterInstance> volume_mounter_; ConnectionHolder<mojom::VolumeMounterInstance, mojom::VolumeMounterHost>
volume_mounter_;
ConnectionHolder<mojom::WallpaperInstance, mojom::WallpaperHost> wallpaper_; ConnectionHolder<mojom::WallpaperInstance, mojom::WallpaperHost> wallpaper_;
DISALLOW_COPY_AND_ASSIGN(ArcBridgeService); DISALLOW_COPY_AND_ASSIGN(ArcBridgeService);
......
...@@ -33,13 +33,24 @@ struct MountPointInfo { ...@@ -33,13 +33,24 @@ struct MountPointInfo {
string fs_uuid; string fs_uuid;
// The file system label. // The file system label.
string label; string label;
// The device type that contains this mount point. If unknown, the event should be ignored. // The device type that contains this mount point. If unknown, the event
// should be ignored.
DeviceType device_type; DeviceType device_type;
}; };
// Next Method ID: 1
interface VolumeMounterHost {
// Requests all recorded MountPointInfos to be sent through a series of
// VolumeMounterInstance::OnMountEvent call.
[MinVersion=0] RequestAllMountPoints@1();
};
// Notifies Android about Mounting events. // Notifies Android about Mounting events.
// Next Method ID: 2
interface VolumeMounterInstance { interface VolumeMounterInstance {
// @0 is reserved for Init(). // Establishes full-duplex communication with the host.
[MinVersion=1] Init@0(VolumeMounterHost host_ptr) => ();
// Triggers a mount event in Android. // Triggers a mount event in Android.
OnMountEvent@1(MountPointInfo mount_point_info); OnMountEvent@1(MountPointInfo mount_point_info);
}; };
...@@ -49,12 +49,14 @@ ArcVolumeMounterBridge::ArcVolumeMounterBridge(content::BrowserContext* context, ...@@ -49,12 +49,14 @@ ArcVolumeMounterBridge::ArcVolumeMounterBridge(content::BrowserContext* context,
ArcBridgeService* bridge_service) ArcBridgeService* bridge_service)
: arc_bridge_service_(bridge_service), weak_ptr_factory_(this) { : arc_bridge_service_(bridge_service), weak_ptr_factory_(this) {
arc_bridge_service_->volume_mounter()->AddObserver(this); arc_bridge_service_->volume_mounter()->AddObserver(this);
arc_bridge_service_->volume_mounter()->SetHost(this);
DCHECK(DiskMountManager::GetInstance()); DCHECK(DiskMountManager::GetInstance());
DiskMountManager::GetInstance()->AddObserver(this); DiskMountManager::GetInstance()->AddObserver(this);
} }
ArcVolumeMounterBridge::~ArcVolumeMounterBridge() { ArcVolumeMounterBridge::~ArcVolumeMounterBridge() {
DiskMountManager::GetInstance()->RemoveObserver(this); DiskMountManager::GetInstance()->RemoveObserver(this);
arc_bridge_service_->volume_mounter()->SetHost(nullptr);
arc_bridge_service_->volume_mounter()->RemoveObserver(this); arc_bridge_service_->volume_mounter()->RemoveObserver(this);
} }
...@@ -147,4 +149,13 @@ void ArcVolumeMounterBridge::OnMountEvent( ...@@ -147,4 +149,13 @@ void ArcVolumeMounterBridge::OnMountEvent(
device_label, device_type)); device_label, device_type));
} }
void ArcVolumeMounterBridge::RequestAllMountPoints() {
// Deferring the SendAllMountEvents as a task to current thread to not
// block the mojo request since SendAllMountEvents might takes non trivial
// amount of time.
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(&ArcVolumeMounterBridge::SendAllMountEvents,
weak_ptr_factory_.GetWeakPtr()));
}
} // namespace arc } // namespace arc
...@@ -28,7 +28,8 @@ class ArcBridgeService; ...@@ -28,7 +28,8 @@ class ArcBridgeService;
class ArcVolumeMounterBridge class ArcVolumeMounterBridge
: public KeyedService, : public KeyedService,
public chromeos::disks::DiskMountManager::Observer, public chromeos::disks::DiskMountManager::Observer,
public ConnectionObserver<mojom::VolumeMounterInstance> { public ConnectionObserver<mojom::VolumeMounterInstance>,
public mojom::VolumeMounterHost {
public: public:
// Returns singleton instance for the given BrowserContext, // Returns singleton instance for the given BrowserContext,
// or nullptr if the browser |context| is not allowed to use ARC. // or nullptr if the browser |context| is not allowed to use ARC.
...@@ -62,6 +63,9 @@ class ArcVolumeMounterBridge ...@@ -62,6 +63,9 @@ class ArcVolumeMounterBridge
chromeos::RenameError error_code, chromeos::RenameError error_code,
const std::string& device_path) override; const std::string& device_path) override;
// mojom::VolumeMounterHost overrides:
void RequestAllMountPoints() override;
private: private:
void SendAllMountEvents(); void SendAllMountEvents();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment