PM: RealShillProvider should properly cache the connection type.
This exposes (in unit test) and fixes a bug where the RealShillProvider
neglected to update the cached value of the connection type, although it
was marking this value as valid and used it in subsequent calls.
BUG=None
TEST=Unit test added; fails before, passes after.
Change-Id: Ifbb206adcc82706a786ba1828220bb015badbfbc
Reviewed-on: https://chromium-review.googlesource.com/193872
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
diff --git a/policy_manager/real_shill_provider.cc b/policy_manager/real_shill_provider.cc
index 46d8958..a503bc2 100644
--- a/policy_manager/real_shill_provider.cc
+++ b/policy_manager/real_shill_provider.cc
@@ -158,12 +158,9 @@
return NULL;
}
- ConnectionType conn_type;
- if (provider_->is_conn_type_valid_) {
- conn_type = provider_->conn_type_;
- } else {
+ if (!provider_->is_conn_type_valid_) {
if (!connector_->GetConnectionType(provider_->default_service_path_,
- &conn_type)) {
+ &provider_->conn_type_)) {
if (errmsg)
*errmsg = base::StringPrintf(
"Could not retrieve type of default connection (%s)",
@@ -173,7 +170,7 @@
provider_->is_conn_type_valid_ = true;
}
- return new ConnectionType(conn_type);
+ return new ConnectionType(provider_->conn_type_);
}
private: