0
Files
src/components/ntp_snippets/time_serialization.cc
Sky Malice 0ef461ea24 [NTP Snippets] Switch RemoteSuggestionsSchedulerImpl to Time and TimeDelta pref methods.
Because time_serialization.cc stored Time and DeltaTime in
microseconds, and Time since the windows epoch, which is the exact
same way that PrefService is storing these time fields, this change
should be fully backwards compatible.

Bug: 853755
Change-Id: I22d734d030ca550a654319e37abf6653890c1bdb
Reviewed-on: https://chromium-review.googlesource.com/1104581
Reviewed-by: Filip Gorski <fgorski@chromium.org>
Commit-Queue: Sky Malice <skym@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568282}
2018-06-19 01:28:21 +00:00

18 lines
511 B
C++

// Copyright 2016 The Chromium 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 "components/ntp_snippets/time_serialization.h"
namespace ntp_snippets {
int64_t SerializeTime(const base::Time& time) {
return (time - base::Time()).InMicroseconds();
}
base::Time DeserializeTime(int64_t serialized_time) {
return base::Time() + base::TimeDelta::FromMicroseconds(serialized_time);
}
} // namespace ntp_snippets