-// Copyright 2019 The Chromium Authors. All rights reserved.
+// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
absl::optional<int64_t> integer = ValueToInt64(value);
if (!integer)
return absl::nullopt;
- return TimeDelta::FromMicroseconds(*integer);
+ return Microseconds(*integer);
}
Value TimeToValue(Time time) {
UnguessableTokenRepresentation repr;
if (!HexStringToSpan(value.GetString(), repr.buffer))
return absl::nullopt;
- return UnguessableToken::Deserialize(repr.field.high, repr.field.low);
+ absl::optional<base::UnguessableToken> token =
+ UnguessableToken::Deserialize(repr.field.high, repr.field.low);
+ if (!token.has_value()) {
+ return absl::nullopt;
+ }
+ return token;
}
} // namespace base