buffet: Move privetd sources into buffet No functional changes, only renaming, fixed include paths and include guards to avoid resubmit warnings. BUG=brillo:1161 CQ-DEPEND=CL:276521 TEST=none Change-Id: Icacff92aef47fdd46542bc96eba3ffbb4df6241a Reviewed-on: https://chromium-review.googlesource.com/276319 Reviewed-by: Vitaly Buka <vitalybuka@chromium.org> Commit-Queue: Vitaly Buka <vitalybuka@chromium.org> Tested-by: Vitaly Buka <vitalybuka@chromium.org>
diff --git a/buffet/privet/device_delegate.cc b/buffet/privet/device_delegate.cc new file mode 100644 index 0000000..2953284 --- /dev/null +++ b/buffet/privet/device_delegate.cc
@@ -0,0 +1,58 @@ +// Copyright 2014 The Chromium OS Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "buffet/privet/device_delegate.h" + +#include <base/files/file_util.h> +#include <base/guid.h> + +#include "buffet/privet/constants.h" + +namespace privetd { + +namespace { + +class DeviceDelegateImpl : public DeviceDelegate { + public: + DeviceDelegateImpl() = default; + ~DeviceDelegateImpl() override = default; + + std::pair<uint16_t, uint16_t> GetHttpEnpoint() const override { + return std::make_pair(http_port_, http_port_); + } + std::pair<uint16_t, uint16_t> GetHttpsEnpoint() const override { + return std::make_pair(https_port_, https_port_); + } + base::TimeDelta GetUptime() const override { + return base::Time::Now() - start_time_; + } + + void SetHttpPort(uint16_t port) override { + http_port_ = port; + } + + void SetHttpsPort(uint16_t port) override { + https_port_ = port; + } + + private: + uint16_t http_port_{0}; + uint16_t https_port_{0}; + base::Time start_time_{base::Time::Now()}; +}; + +} // namespace + +DeviceDelegate::DeviceDelegate() { +} + +DeviceDelegate::~DeviceDelegate() { +} + +// static +std::unique_ptr<DeviceDelegate> DeviceDelegate::CreateDefault() { + return std::unique_ptr<DeviceDelegate>(new DeviceDelegateImpl()); +} + +} // namespace privetd