shill: Manager: Take over responsibility for device save
Move the responsibility of saving devices from the default
profile to the Manager. This removes an awkward setup where
the DefaultProfile asks for and iterates the Manager's device
list. Instead, call UpdateDevice on each device on
Manager::Stop().
This has a positive side effect that newly created default
profiles (such as those created during autotests) do not
end up with device entries for all devices, but only the
ones persisted while the profile is in use.
This also allows the Manager to take charge of persisting
device state to disk while deregistering, so that the most
recent snapshot of the device is saved before it is removed
from memory.
BUG=chromium-os:31584
TEST=Expanded unit tests.
Change-Id: Id2eb916b0b33d038847248a88312fb6899b3f717
Reviewed-on: https://gerrit.chromium.org/gerrit/27299
Reviewed-by: Ben Chan <benchan@chromium.org>
Reviewed-by: Darin Petkov <petkov@chromium.org>
Commit-Ready: Paul Stewart <pstew@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
diff --git a/default_profile_unittest.cc b/default_profile_unittest.cc
index 9fb583e..adbe161 100644
--- a/default_profile_unittest.cc
+++ b/default_profile_unittest.cc
@@ -133,7 +133,7 @@
.WillOnce(Return(true));
EXPECT_CALL(*storage.get(), Flush()).WillOnce(Return(true));
- EXPECT_CALL(*device_.get(), Save(storage.get())).WillOnce(Return(true));
+ EXPECT_CALL(*device_.get(), Save(storage.get())).Times(0);
profile_->set_storage(storage.release());
manager()->RegisterDevice(device_);