PM: RealShillProvider starts even when shill is not available.

The RealShillProvider used to query shill for the default connection
status during its initialization, failing the latter if this query did
not go through. However, we would like this provider to initialize
properly even if shill is not responding (e.g. hasn't started yet). This
change relies on the assumption that, when shill comes up and detects
a connection, it will signal the detected properties via DBus and so
there's no need to reattempt querying.

That said, the RealShillProvider's variables need to be aware of the
possibility that their underlying connection values are not available,
and respond accordingly to GetValue queries. In doing so, we extend the
generic CopyVariable class to also accept a flag (Boolean), indicating
whether the underlying value object is set and available for copying.

BUG=chromium:356949
TEST=Unit tests.

Change-Id: Ibe29b6cd1fb8dce2e227418c721dbc47a75763be
Reviewed-on: https://chromium-review.googlesource.com/193748
Tested-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
diff --git a/policy_manager/real_shill_provider.h b/policy_manager/real_shill_provider.h
index ffb6b0c..a0619e2 100644
--- a/policy_manager/real_shill_provider.h
+++ b/policy_manager/real_shill_provider.h
@@ -91,8 +91,20 @@
   RealShillProvider(DBusWrapperInterface* dbus, ClockInterface* clock)
       : dbus_(dbus), clock_(clock) {}
 
+  virtual inline Variable<bool>* var_is_connected() override {
+    return var_is_connected_.get();
+  }
+
+  virtual inline Variable<ConnectionType>* var_conn_type() override {
+    return var_conn_type_.get();
+  }
+
+  virtual inline Variable<base::Time>* var_conn_last_changed() override {
+    return var_conn_last_changed_.get();
+  }
+
  protected:
-  virtual bool DoInit();
+  virtual bool DoInit() override;
 
  private:
   // Process a default connection value, update last change time as needed.
@@ -105,6 +117,9 @@
                                           GValue* value, void* data);
 
 
+  // Whether the connection status has been properly initialized.
+  bool is_conn_status_init_ = false;
+
   // The time when the connection type last changed.
   base::Time conn_last_changed_;
 
@@ -129,6 +144,11 @@
   // A clock abstraction (mockable).
   ClockInterface* const clock_;
 
+  // Pointers to all variable objects.
+  scoped_ptr<Variable<bool>> var_is_connected_;
+  scoped_ptr<Variable<ConnectionType>> var_conn_type_;
+  scoped_ptr<Variable<base::Time>> var_conn_last_changed_;
+
   friend class ConnTypeVariable;
   DISALLOW_COPY_AND_ASSIGN(RealShillProvider);
 };