blob: 9d9b186b6d86588ae397a459eb9e4b581811276c [file] [log] [blame]
Vitaly Buka4615e0d2015-10-14 15:35:12 -07001// Copyright 2015 The Weave Authors. All rights reserved.
Vitaly Buka7ce499f2015-06-09 08:04:11 -07002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Vitaly Buka912b6982015-07-06 11:13:03 -07005#ifndef LIBWEAVE_SRC_PRIVET_DEVICE_DELEGATE_H_
6#define LIBWEAVE_SRC_PRIVET_DEVICE_DELEGATE_H_
Vitaly Buka7ce499f2015-06-09 08:04:11 -07007
8#include <memory>
9#include <utility>
10
Alex Vakulenkoefee3a22015-11-17 15:08:38 -080011#include <base/callback.h>
12#include <base/location.h>
Vitaly Buka7ce499f2015-06-09 08:04:11 -070013#include <base/time/time.h>
14
Vitaly Bukab6f015a2015-07-09 14:59:23 -070015namespace weave {
Alex Vakulenkoefee3a22015-11-17 15:08:38 -080016
17namespace provider {
18class TaskRunner;
19}
20
Vitaly Bukab6f015a2015-07-09 14:59:23 -070021namespace privet {
Vitaly Buka7ce499f2015-06-09 08:04:11 -070022
23// Interface to provide access to general information about device.
24class DeviceDelegate {
25 public:
26 DeviceDelegate();
27 virtual ~DeviceDelegate();
28
29 // Returns HTTP ports for Privet. The first one is the primary port,
30 // the second is the port for a pooling updates requests. The second value
Alex Vakulenkoefee3a22015-11-17 15:08:38 -080031 // could be 0. In this case the first port would be used for regular and for
Vitaly Buka7ce499f2015-06-09 08:04:11 -070032 // updates requests.
33 virtual std::pair<uint16_t, uint16_t> GetHttpEnpoint() const = 0;
34
35 // The same |GetHttpEnpoint| but for HTTPS.
36 virtual std::pair<uint16_t, uint16_t> GetHttpsEnpoint() const = 0;
37
Alex Vakulenkoefee3a22015-11-17 15:08:38 -080038 // Returns the max request timeout of http server. Returns TimeDelta::Max() if
39 // no timeout is set.
40 virtual base::TimeDelta GetHttpRequestTimeout() const = 0;
Vitaly Buka7ce499f2015-06-09 08:04:11 -070041
Alex Vakulenkoefee3a22015-11-17 15:08:38 -080042 // Schedules a background task on the embedded TaskRunner.
43 virtual void PostDelayedTask(const tracked_objects::Location& from_here,
44 const base::Closure& task,
45 base::TimeDelta delay) = 0;
Vitaly Buka7ce499f2015-06-09 08:04:11 -070046
47 // Create default instance.
Alex Vakulenkoefee3a22015-11-17 15:08:38 -080048 static std::unique_ptr<DeviceDelegate> CreateDefault(
49 provider::TaskRunner* task_runner,
50 uint16_t http_port,
51 uint16_t https_port,
52 base::TimeDelta http_request_timeout);
Vitaly Buka7ce499f2015-06-09 08:04:11 -070053};
54
Vitaly Bukab6f015a2015-07-09 14:59:23 -070055} // namespace privet
56} // namespace weave
Vitaly Buka7ce499f2015-06-09 08:04:11 -070057
Vitaly Buka912b6982015-07-06 11:13:03 -070058#endif // LIBWEAVE_SRC_PRIVET_DEVICE_DELEGATE_H_