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

Unified Diff: chromeos/dbus/cryptohome_client.cc

Issue 2082363004: Show notifications on low disk space. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@low-disk-strings
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 side-by-side diff with in-line comments
Download patch
Index: chromeos/dbus/cryptohome_client.cc
diff --git a/chromeos/dbus/cryptohome_client.cc b/chromeos/dbus/cryptohome_client.cc
index a52fe016294ce04866fad7e30b5a3de27141c8de..160ab71e2475b3563b6d3434dc9e353a95c1bcbd 100644
--- a/chromeos/dbus/cryptohome_client.cc
+++ b/chromeos/dbus/cryptohome_client.cc
@@ -63,6 +63,14 @@ class CryptohomeClientImpl : public CryptohomeClient {
}
// CryptohomeClient override.
+ void SetLowDiskSpaceHandler(const LowDiskSpaceHandler& handler) override {
+ low_disk_space_handler_ = handler;
+ }
+
+ // CryptohomeClient override.
+ void ResetLowDiskSpaceHandler() override { low_disk_space_handler_.Reset(); }
+
+ // CryptohomeClient override.
void WaitForServiceToBeAvailable(
const WaitForServiceToBeAvailableCallback& callback) override {
proxy_->WaitForServiceToBeAvailable(callback);
@@ -928,6 +936,12 @@ class CryptohomeClientImpl : public CryptohomeClient {
weak_ptr_factory_.GetWeakPtr()),
base::Bind(&CryptohomeClientImpl::OnSignalConnected,
weak_ptr_factory_.GetWeakPtr()));
+ proxy_->ConnectToSignal(cryptohome::kCryptohomeInterface,
+ cryptohome::kSignalLowDiskSpace,
+ base::Bind(&CryptohomeClientImpl::OnLowDiskSpace,
+ weak_ptr_factory_.GetWeakPtr()),
+ base::Bind(&CryptohomeClientImpl::OnSignalConnected,
+ weak_ptr_factory_.GetWeakPtr()));
}
private:
@@ -1149,6 +1163,17 @@ class CryptohomeClientImpl : public CryptohomeClient {
}
}
+ // Handles LowDiskSpace signal.
+ void OnLowDiskSpace(dbus::Signal* signal) {
+ dbus::MessageReader reader(signal);
+ uint64_t disk_free_bytes = 0;
+ if (!reader.PopUint64(&disk_free_bytes)) {
+ LOG(ERROR) << "Invalid signal: " << signal->ToString();
+ return;
+ }
+ low_disk_space_handler_.Run(disk_free_bytes);
yoshiki 2016/06/23 08:00:45 low_disk_space_handler_ may be null so null check
dspaid 2016/06/27 05:40:04 Using WeakPtr now, which will result in a no-op if
+ }
+
// Handles the result of signal connection setup.
void OnSignalConnected(const std::string& interface,
const std::string& signal,
@@ -1161,6 +1186,7 @@ class CryptohomeClientImpl : public CryptohomeClient {
std::unique_ptr<BlockingMethodCaller> blocking_method_caller_;
AsyncCallStatusHandler async_call_status_handler_;
AsyncCallStatusWithDataHandler async_call_status_data_handler_;
+ LowDiskSpaceHandler low_disk_space_handler_;
// Note: This should remain the last member so it'll be destroyed and
// invalidate its weak pointers before any other members are destroyed.

Powered by Google App Engine
This is Rietveld 408576698