shill: Add metric to track corrupted profiles
New metric Network.Shill.CorruptedProfile.
BUG=chromium-os:38669
TEST=1. Unit tests
2. Stop shill
Corrupt /var/cache/shill/default.profile by adding junk
Start shill
Verify new metric appears in chrome://histograms
Change-Id: I629ed00884ecd2d2fe90744583bd72bf2e9e6af4
Reviewed-on: https://gerrit.chromium.org/gerrit/43556
Reviewed-by: Thieu Le <thieule@chromium.org>
Tested-by: Thieu Le <thieule@chromium.org>
Commit-Queue: Thieu Le <thieule@chromium.org>
diff --git a/profile.cc b/profile.cc
index 51668c0..b88b679 100644
--- a/profile.cc
+++ b/profile.cc
@@ -31,11 +31,13 @@
namespace shill {
Profile::Profile(ControlInterface *control_interface,
+ Metrics *metrics,
Manager *manager,
const Identifier &name,
const string &user_storage_format,
bool connect_to_rpc)
- : manager_(manager),
+ : metrics_(metrics),
+ manager_(manager),
name_(name),
storage_format_(user_storage_format) {
if (connect_to_rpc)
@@ -92,6 +94,7 @@
// this file. Move this file out of the way so a future open attempt
// will succeed, assuming the failure reason was the former.
storage->MarkAsCorrupted();
+ metrics_->NotifyCorruptedProfile();
}
return false;
}