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

Unified Diff: chromeos/dbus/system_clock_client.cc

Issue 2236713002: chromeos: Don't spam logs with tlsdate D-Bus errors at boot. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « chromeos/dbus/system_clock_client.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/dbus/system_clock_client.cc
diff --git a/chromeos/dbus/system_clock_client.cc b/chromeos/dbus/system_clock_client.cc
index 047a29c1c2e7c3b0df46fb1dabaaa5e3a4b74ee8..0b2899e373b26f4b31fd30afd5a5f0faea312897 100644
--- a/chromeos/dbus/system_clock_client.cc
+++ b/chromeos/dbus/system_clock_client.cc
@@ -22,8 +22,7 @@ class SystemClockClientImpl : public SystemClockClient {
public:
SystemClockClientImpl()
: can_set_time_(false),
- can_set_time_initialized_(false),
- system_clock_proxy_(NULL),
+ system_clock_proxy_(nullptr),
weak_ptr_factory_(this) {}
~SystemClockClientImpl() override {}
@@ -58,11 +57,6 @@ class SystemClockClientImpl : public SystemClockClient {
system_clock_proxy_ = bus->GetObjectProxy(
system_clock::kSystemClockServiceName,
dbus::ObjectPath(system_clock::kSystemClockServicePath));
-
- // Check whether the system clock can be set.
- GetCanSet();
-
- // Monitor the D-Bus signal for TimeUpdated changes.
system_clock_proxy_->ConnectToSignal(
system_clock::kSystemClockInterface,
system_clock::kSystemClockUpdated,
@@ -70,9 +64,25 @@ class SystemClockClientImpl : public SystemClockClient {
weak_ptr_factory_.GetWeakPtr()),
base::Bind(&SystemClockClientImpl::TimeUpdatedConnected,
weak_ptr_factory_.GetWeakPtr()));
+ system_clock_proxy_->WaitForServiceToBeAvailable(
+ base::Bind(&SystemClockClientImpl::ProxyAvailabilityChanged,
+ weak_ptr_factory_.GetWeakPtr()));
}
private:
+ void ProxyAvailabilityChanged(bool service_is_available) {
Daniel Erat 2016/08/11 01:15:46 i should rename this and change the code. this is
michaelpg 2016/08/11 03:21:08 what would make the service unavailable after the
+ VLOG(1) << "D-Bus proxy is " << (service_is_available ? "" : "un")
+ << "available";
+
+ if (service_is_available) {
+ GetCanSet();
+ } else if (can_set_time_) {
+ can_set_time_ = false;
+ FOR_EACH_OBSERVER(Observer, observers_,
+ SystemClockCanSetTimeChanged(can_set_time_));
+ }
+ }
+
// Called when a TimeUpdated signal is received.
void TimeUpdatedReceived(dbus::Signal* signal) {
VLOG(1) << "TimeUpdated signal received: " << signal->ToString();
@@ -105,15 +115,11 @@ class SystemClockClientImpl : public SystemClockClient {
return;
}
- // Nothing to do if the CanSetTime response hasn't changed.
- if (can_set_time_initialized_ && can_set_time_ == can_set_time)
- return;
-
- can_set_time_initialized_ = true;
- can_set_time_ = can_set_time;
-
- FOR_EACH_OBSERVER(
- Observer, observers_, SystemClockCanSetTimeChanged(can_set_time));
+ if (can_set_time_ != can_set_time) {
+ can_set_time_ = can_set_time;
+ FOR_EACH_OBSERVER(Observer, observers_,
+ SystemClockCanSetTimeChanged(can_set_time));
+ }
}
// Check whether the time can be set.
@@ -122,8 +128,7 @@ class SystemClockClientImpl : public SystemClockClient {
system_clock::kSystemClockCanSet);
dbus::MessageWriter writer(&method_call);
system_clock_proxy_->CallMethod(
- &method_call,
- dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
+ &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
base::Bind(&SystemClockClientImpl::OnGetCanSet,
weak_ptr_factory_.GetWeakPtr()));
}
@@ -131,7 +136,6 @@ class SystemClockClientImpl : public SystemClockClient {
// Whether the time can be set. Value is false until the first
// CanSetTime response is received.
bool can_set_time_;
- bool can_set_time_initialized_;
dbus::ObjectProxy* system_clock_proxy_;
base::ObserverList<Observer> observers_;
@@ -140,22 +144,11 @@ class SystemClockClientImpl : public SystemClockClient {
DISALLOW_COPY_AND_ASSIGN(SystemClockClientImpl);
};
-void SystemClockClient::Observer::SystemClockUpdated() {
-}
-
-void SystemClockClient::Observer::SystemClockCanSetTimeChanged(
- bool can_set_time) {
-}
-
-SystemClockClient::SystemClockClient() {
-}
-
-SystemClockClient::~SystemClockClient() {
-}
-
// static
SystemClockClient* SystemClockClient::Create() {
return new SystemClockClientImpl();
}
+SystemClockClient::SystemClockClient() {}
+
} // namespace chromeos
« no previous file with comments | « chromeos/dbus/system_clock_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698