buffet: StartDevice automatically after a short delay
BUG=brillo:15
TEST=buffet_Registration confirms that we StartDevice
automatically shortly after registering.
Change-Id: I6c903e67f0556c7db817e126c72711f7d781592d
Reviewed-on: https://chromium-review.googlesource.com/249441
Tested-by: Christopher Wiley <wiley@chromium.org>
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Christopher Wiley <wiley@chromium.org>
diff --git a/buffet/device_registration_info.h b/buffet/device_registration_info.h
index 4c9cfaa..31cc508 100644
--- a/buffet/device_registration_info.h
+++ b/buffet/device_registration_info.h
@@ -12,6 +12,7 @@
#include <base/callback.h>
#include <base/macros.h>
+#include <base/memory/weak_ptr.h>
#include <base/time/time.h>
#include <chromeos/data_encoding.h>
#include <chromeos/errors/error.h>
@@ -89,6 +90,9 @@
// Loads the device registration information from cache.
bool Load();
+ // Cause DeviceRegistrationInfo to attempt to StartDevice on its own later.
+ void ScheduleStartDevice(const base::TimeDelta& later);
+
// Checks for the valid device registration as well as refreshes
// the device access token, if available.
bool CheckRegistration(chromeos::ErrorPtr* error);
@@ -207,6 +211,7 @@
std::unique_ptr<chromeos::KeyValueStore> config_store_;
friend class TestHelper;
+ base::WeakPtrFactory<DeviceRegistrationInfo> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(DeviceRegistrationInfo);
};