Add support for long-poll HTTP request at /privet/v3/checkForUpdates
Added state/command definition notification mechanism through a long
poll HTTP request as described in:
https://developers.google.com/cloud-devices/v1/reference/local-api/check_for_updates
BUG: 23908251
Change-Id: I5285403f35f23a310404d3324a7a255b77211264
Reviewed-on: https://weave-review.googlesource.com/1533
Reviewed-by: Vitaly Buka <vitalybuka@google.com>
diff --git a/src/privet/device_delegate.h b/src/privet/device_delegate.h
index 3f13b22..1affa1b 100644
--- a/src/privet/device_delegate.h
+++ b/src/privet/device_delegate.h
@@ -8,9 +8,16 @@
#include <memory>
#include <utility>
+#include <base/callback.h>
+#include <base/location.h>
#include <base/time/time.h>
namespace weave {
+
+namespace provider {
+class TaskRunner;
+}
+
namespace privet {
// Interface to provide access to general information about device.
@@ -21,25 +28,31 @@
// Returns HTTP ports for Privet. The first one is the primary port,
// the second is the port for a pooling updates requests. The second value
- // could be 0. In this case the first port would be use for regular and for
+ // could be 0. In this case the first port would be used for regular and for
// updates requests.
virtual std::pair<uint16_t, uint16_t> GetHttpEnpoint() const = 0;
// The same |GetHttpEnpoint| but for HTTPS.
virtual std::pair<uint16_t, uint16_t> GetHttpsEnpoint() const = 0;
- // Returns device update.
+ // Returns device uptime.
virtual base::TimeDelta GetUptime() const = 0;
- // Updates the HTTP port value.
- virtual void SetHttpPort(uint16_t port) = 0;
+ // Returns the max request timeout of http server. Returns TimeDelta::Max() if
+ // no timeout is set.
+ virtual base::TimeDelta GetHttpRequestTimeout() const = 0;
- // Updates the HTTPS port value.
- virtual void SetHttpsPort(uint16_t port) = 0;
+ // Schedules a background task on the embedded TaskRunner.
+ virtual void PostDelayedTask(const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ base::TimeDelta delay) = 0;
// Create default instance.
- static std::unique_ptr<DeviceDelegate> CreateDefault(uint16_t http_port,
- uint16_t https_port);
+ static std::unique_ptr<DeviceDelegate> CreateDefault(
+ provider::TaskRunner* task_runner,
+ uint16_t http_port,
+ uint16_t https_port,
+ base::TimeDelta http_request_timeout);
};
} // namespace privet