Add CefBaseTime and use it instead of CefTime (see issue #2935)

This commit is contained in:
Dmitry Azaraev 2022-05-31 23:28:43 +03:00 committed by Marshall Greenblatt
parent 987b932a19
commit 27d3089804
58 changed files with 502 additions and 228 deletions

View File

@ -42,6 +42,7 @@
'include/internal/cef_export.h',
'include/internal/cef_ptr.h',
'include/internal/cef_string_wrappers.h',
'include/internal/cef_time_wrappers.h',
'include/internal/cef_types_wrappers.h',
],
'includes_common_capi': [
@ -528,6 +529,7 @@
'tests/ceftests/test_suite.h',
'tests/ceftests/test_util.cc',
'tests/ceftests/test_util.h',
'tests/ceftests/time_unittest.cc',
'tests/ceftests/thread_helper.cc',
'tests/ceftests/thread_helper.h',
'tests/ceftests/thread_unittest.cc',

View File

@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=b9f0d91dd2fdb3625365ff8b332b08e1f0ea1187$
// $hash=1c1dd82539e356f15be95b66d824740075c48e4f$
//
#ifndef CEF_INCLUDE_CAPI_CEF_DOWNLOAD_ITEM_CAPI_H_
@ -100,12 +100,13 @@ typedef struct _cef_download_item_t {
///
// Returns the time that the download started.
///
cef_time_t(CEF_CALLBACK* get_start_time)(struct _cef_download_item_t* self);
cef_basetime_t(CEF_CALLBACK* get_start_time)(
struct _cef_download_item_t* self);
///
// Returns the time that the download ended.
///
cef_time_t(CEF_CALLBACK* get_end_time)(struct _cef_download_item_t* self);
cef_basetime_t(CEF_CALLBACK* get_end_time)(struct _cef_download_item_t* self);
///
// Returns the full path to the downloaded or downloading file.

View File

@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=3a7dd4a6a1b5e0d9191be6c4dd2f0135f43de643$
// $hash=6f617dd09dc2abc0c2c7534db2b045aebb595f09$
//
#ifndef CEF_INCLUDE_CAPI_CEF_NAVIGATION_ENTRY_CAPI_H_
@ -108,7 +108,7 @@ typedef struct _cef_navigation_entry_t {
// navigation may be completed more than once if the page is reloaded. May be
// 0 if the navigation has not yet completed.
///
cef_time_t(CEF_CALLBACK* get_completion_time)(
cef_basetime_t(CEF_CALLBACK* get_completion_time)(
struct _cef_navigation_entry_t* self);
///

View File

@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=b7dd2429f492a8f2dd978f9500c63dd0e01035d4$
// $hash=a9050cf4af9b9790088ec4d419775eec083aef4c$
//
#ifndef CEF_INCLUDE_CAPI_CEF_V8_CAPI_H_
@ -484,7 +484,7 @@ typedef struct _cef_v8value_t {
///
// Return a Date value.
///
cef_time_t(CEF_CALLBACK* get_date_value)(struct _cef_v8value_t* self);
cef_basetime_t(CEF_CALLBACK* get_date_value)(struct _cef_v8value_t* self);
///
// Return a string value.
@ -766,7 +766,7 @@ CEF_EXPORT cef_v8value_t* cef_v8value_create_double(double value);
// cef_v8handler_t or cef_v8accessor_t callback, or in combination with calling
// enter() and exit() on a stored cef_v8context_t reference.
///
CEF_EXPORT cef_v8value_t* cef_v8value_create_date(const cef_time_t* date);
CEF_EXPORT cef_v8value_t* cef_v8value_create_date(cef_basetime_t date);
///
// Create a new cef_v8value_t object of type string.

View File

@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=32b942f6b50b842ddec08addc2b5794f2a272dbe$
// $hash=744c34b8608d3678f0a3522ff77f184611a29bf2$
//
#ifndef CEF_INCLUDE_CAPI_CEF_X509_CERTIFICATE_CAPI_H_
@ -154,16 +154,16 @@ typedef struct _cef_x509certificate_t {
///
// Returns the date before which the X.509 certificate is invalid.
// CefTime.GetTimeT() will return 0 if no date was specified.
// CefBaseTime.GetTimeT() will return 0 if no date was specified.
///
cef_time_t(CEF_CALLBACK* get_valid_start)(
cef_basetime_t(CEF_CALLBACK* get_valid_start)(
struct _cef_x509certificate_t* self);
///
// Returns the date after which the X.509 certificate is invalid.
// CefTime.GetTimeT() will return 0 if no date was specified.
// CefBaseTime.GetTimeT() will return 0 if no date was specified.
///
cef_time_t(CEF_CALLBACK* get_valid_expiry)(
cef_basetime_t(CEF_CALLBACK* get_valid_expiry)(
struct _cef_x509certificate_t* self);
///

View File

@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=ac91bcd40e1439ee1e742cc47989530b112c99bd$
// $hash=e16856adecfe81b59b513568b5dcadc851ff07ab$
//
#ifndef CEF_INCLUDE_CAPI_CEF_ZIP_READER_CAPI_H_
@ -102,7 +102,7 @@ typedef struct _cef_zip_reader_t {
///
// Returns the last modified timestamp for the file.
///
cef_time_t(CEF_CALLBACK* get_file_last_modified)(
cef_basetime_t(CEF_CALLBACK* get_file_last_modified)(
struct _cef_zip_reader_t* self);
///

View File

@ -42,13 +42,13 @@
// way that may cause binary incompatibility with other builds. The universal
// hash value will change if any platform is affected whereas the platform hash
// values will change only if that particular platform is affected.
#define CEF_API_HASH_UNIVERSAL "cb946f2cb8bae48182fd520357fbbda4abc746a7"
#define CEF_API_HASH_UNIVERSAL "39f4f2317bfe2012cbc93d007f7b66b051a40801"
#if defined(OS_WIN)
#define CEF_API_HASH_PLATFORM "1982d880b85cd483d4e352796c129586b56638ae"
#define CEF_API_HASH_PLATFORM "69c564c61f449d5121f991027434b904f9da0487"
#elif defined(OS_MAC)
#define CEF_API_HASH_PLATFORM "c34df68ed292774500b591841ccadbc47dddd8c9"
#define CEF_API_HASH_PLATFORM "5304a0e2ad7f12306b20aa68a2393068e3d486e3"
#elif defined(OS_LINUX)
#define CEF_API_HASH_PLATFORM "b6bb9e9f8d0d7ca5bcd8017a575374e08563d7a6"
#define CEF_API_HASH_PLATFORM "dbce3938f92feca03bcf12a183db4e903cd3aa87"
#endif
#ifdef __cplusplus

View File

@ -37,6 +37,7 @@
// Bring in common C++ type definitions used by CEF consumers.
#include "include/internal/cef_ptr.h"
#include "include/internal/cef_time_wrappers.h"
#include "include/internal/cef_types_wrappers.h"
#if defined(OS_WIN)
#include "include/internal/cef_win.h"

View File

@ -100,13 +100,13 @@ class CefDownloadItem : public virtual CefBaseRefCounted {
// Returns the time that the download started.
///
/*--cef()--*/
virtual CefTime GetStartTime() = 0;
virtual CefBaseTime GetStartTime() = 0;
///
// Returns the time that the download ended.
///
/*--cef()--*/
virtual CefTime GetEndTime() = 0;
virtual CefBaseTime GetEndTime() = 0;
///
// Returns the full path to the downloaded or downloading file.

View File

@ -100,7 +100,7 @@ class CefNavigationEntry : public virtual CefBaseRefCounted {
// 0 if the navigation has not yet completed.
///
/*--cef()--*/
virtual CefTime GetCompletionTime() = 0;
virtual CefBaseTime GetCompletionTime() = 0;
///
// Returns the HTTP status code for the last known successful navigation

View File

@ -478,7 +478,7 @@ class CefV8Value : public virtual CefBaseRefCounted {
// on a stored CefV8Context reference.
///
/*--cef()--*/
static CefRefPtr<CefV8Value> CreateDate(const CefTime& date);
static CefRefPtr<CefV8Value> CreateDate(CefBaseTime date);
///
// Create a new CefV8Value object of type string.
@ -649,7 +649,7 @@ class CefV8Value : public virtual CefBaseRefCounted {
// Return a Date value.
///
/*--cef()--*/
virtual CefTime GetDateValue() = 0;
virtual CefBaseTime GetDateValue() = 0;
///
// Return a string value.

View File

@ -137,17 +137,17 @@ class CefX509Certificate : public virtual CefBaseRefCounted {
///
// Returns the date before which the X.509 certificate is invalid.
// CefTime.GetTimeT() will return 0 if no date was specified.
// CefBaseTime.GetTimeT() will return 0 if no date was specified.
///
/*--cef()--*/
virtual CefTime GetValidStart() = 0;
virtual CefBaseTime GetValidStart() = 0;
///
// Returns the date after which the X.509 certificate is invalid.
// CefTime.GetTimeT() will return 0 if no date was specified.
// CefBaseTime.GetTimeT() will return 0 if no date was specified.
///
/*--cef()--*/
virtual CefTime GetValidExpiry() = 0;
virtual CefBaseTime GetValidExpiry() = 0;
///
// Returns the DER encoded data for the X.509 certificate.

View File

@ -102,7 +102,7 @@ class CefZipReader : public virtual CefBaseRefCounted {
// Returns the last modified timestamp for the file.
///
/*--cef()--*/
virtual CefTime GetFileLastModified() = 0;
virtual CefBaseTime GetFileLastModified() = 0;
///
// Opens the file for reading of uncompressed data. A read password may

View File

@ -36,8 +36,20 @@ extern "C" {
#endif
#include <time.h>
#include "include/base/cef_basictypes.h"
#include "include/internal/cef_export.h"
///
// Represents a wall clock time in UTC. Values are not guaranteed to be
// monotonically non-decreasing and are subject to large amounts of skew.
// Time is stored internally as microseconds since the Windows epoch (1601).
//
// This is equivalent of Chromium `base::Time` (see base/time/time.h).
///
typedef struct _cef_basetime_t {
int64 val;
} cef_basetime_t;
///
// Time information. Values should always be in UTC.
///
@ -71,17 +83,37 @@ CEF_EXPORT int cef_time_to_doublet(const cef_time_t* cef_time, double* time);
CEF_EXPORT int cef_time_from_doublet(double time, cef_time_t* cef_time);
///
// Retrieve the current system time.
//
// Retrieve the current system time. Returns true (1) on success and false (0)
// on failure.
///
CEF_EXPORT int cef_time_now(cef_time_t* cef_time);
///
// Retrieve the delta in milliseconds between two time values.
// Retrieve the current system time.
///
CEF_EXPORT cef_basetime_t cef_basetime_now();
///
// Retrieve the delta in milliseconds between two time values. Returns true (1)
// on success and false (0) on failure.
//
CEF_EXPORT int cef_time_delta(const cef_time_t* cef_time1,
const cef_time_t* cef_time2,
long long* delta);
///
// Converts cef_time_t to cef_basetime_t. Returns true (1) on success and
// false (0) on failure.
///
CEF_EXPORT int cef_time_to_basetime(const cef_time_t* from, cef_basetime_t* to);
///
// Converts cef_basetime_t to cef_time_t. Returns true (1) on success and
// false (0) on failure.
///
CEF_EXPORT int cef_time_from_basetime(const cef_basetime_t from,
cef_time_t* to);
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,103 @@
// Copyright (c) 2022 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CEF_INCLUDE_INTERNAL_CEF_TIME_WRAPPERS_H_
#define CEF_INCLUDE_INTERNAL_CEF_TIME_WRAPPERS_H_
#pragma once
#include "include/internal/cef_time.h"
#if defined(USING_CHROMIUM_INCLUDES)
#include "base/time/time.h"
#endif
///
// Represents a wall clock time in UTC. Values are not guaranteed to be
// monotonically non-decreasing and are subject to large amounts of skew.
// Time is stored internally as microseconds since the Windows epoch (1601).
//
// This is equivalent of Chromium `base::Time` (see base/time/time.h).
///
class CefBaseTime : public cef_basetime_t {
public:
CefBaseTime() : cef_basetime_t{} {}
CefBaseTime(const cef_basetime_t& value) : cef_basetime_t(value) {}
#if defined(USING_CHROMIUM_INCLUDES)
CefBaseTime(const base::Time& value)
: cef_basetime_t{value.ToDeltaSinceWindowsEpoch().InMicroseconds()} {}
operator base::Time() const {
return base::Time::FromDeltaSinceWindowsEpoch(base::Microseconds(val));
}
#endif
static CefBaseTime Now() { return cef_basetime_now(); }
};
///
// Class representing a time.
///
class CefTime : public cef_time_t {
public:
CefTime() : cef_time_t{} {}
CefTime(const cef_time_t& r) : cef_time_t(r) {}
explicit CefTime(time_t r) { SetTimeT(r); }
explicit CefTime(double r) { SetDoubleT(r); }
// Converts to/from time_t.
void SetTimeT(time_t r) { cef_time_from_timet(r, this); }
time_t GetTimeT() const {
time_t time = 0;
cef_time_to_timet(this, &time);
return time;
}
// Converts to/from a double which is the number of seconds since epoch
// (Jan 1, 1970). Webkit uses this format to represent time. A value of 0
// means "not initialized".
void SetDoubleT(double r) { cef_time_from_doublet(r, this); }
double GetDoubleT() const {
double time = 0;
cef_time_to_doublet(this, &time);
return time;
}
// Set this object to now.
void Now() { cef_time_now(this); }
// Return the delta between this object and |other| in milliseconds.
long long Delta(const CefTime& other) {
long long delta = 0;
cef_time_delta(this, &other, &delta);
return delta;
}
};
#endif // CEF_INCLUDE_INTERNAL_CEF_TIME_WRAPPERS_H_

View File

@ -783,19 +783,19 @@ typedef struct _cef_cookie_t {
// The cookie creation date. This is automatically populated by the system on
// cookie creation.
///
cef_time_t creation;
cef_basetime_t creation;
///
// The cookie last access date. This is automatically populated by the system
// on access.
///
cef_time_t last_access;
cef_basetime_t last_access;
///
// The cookie expiration date is only valid if |has_expires| is true.
///
int has_expires;
cef_time_t expires;
cef_basetime_t expires;
///
// Same site.

View File

@ -581,45 +581,6 @@ struct CefURLPartsTraits {
///
using CefURLParts = CefStructBase<CefURLPartsTraits>;
///
// Class representing a time.
///
class CefTime : public cef_time_t {
public:
CefTime() : cef_time_t{} {}
CefTime(const cef_time_t& r) : cef_time_t(r) {}
explicit CefTime(time_t r) { SetTimeT(r); }
explicit CefTime(double r) { SetDoubleT(r); }
// Converts to/from time_t.
void SetTimeT(time_t r) { cef_time_from_timet(r, this); }
time_t GetTimeT() const {
time_t time = 0;
cef_time_to_timet(this, &time);
return time;
}
// Converts to/from a double which is the number of seconds since epoch
// (Jan 1, 1970). Webkit uses this format to represent time. A value of 0
// means "not initialized".
void SetDoubleT(double r) { cef_time_from_doublet(r, this); }
double GetDoubleT() const {
double time = 0;
cef_time_to_doublet(this, &time);
return time;
}
// Set this object to now.
void Now() { cef_time_now(this); }
// Return the delta between this object and |other| in milliseconds.
long long Delta(const CefTime& other) {
long long delta = 0;
cef_time_delta(this, &other, &delta);
return delta;
}
};
///
// Class representing the state of a touch handle.
///

View File

@ -59,18 +59,14 @@ int64 CefDownloadItemImpl::GetReceivedBytes() {
return const_value().GetReceivedBytes();
}
CefTime CefDownloadItemImpl::GetStartTime() {
CefTime time;
CEF_VALUE_VERIFY_RETURN(false, time);
cef_time_from_basetime(const_value().GetStartTime(), time);
return time;
CefBaseTime CefDownloadItemImpl::GetStartTime() {
CEF_VALUE_VERIFY_RETURN(false, CefBaseTime());
return const_value().GetStartTime();
}
CefTime CefDownloadItemImpl::GetEndTime() {
CefTime time;
CEF_VALUE_VERIFY_RETURN(false, time);
cef_time_from_basetime(const_value().GetEndTime(), time);
return time;
CefBaseTime CefDownloadItemImpl::GetEndTime() {
CEF_VALUE_VERIFY_RETURN(false, CefBaseTime());
return const_value().GetEndTime();
}
CefString CefDownloadItemImpl::GetFullPath() {

View File

@ -31,8 +31,8 @@ class CefDownloadItemImpl
int GetPercentComplete() override;
int64 GetTotalBytes() override;
int64 GetReceivedBytes() override;
CefTime GetStartTime() override;
CefTime GetEndTime() override;
CefBaseTime GetStartTime() override;
CefBaseTime GetEndTime() override;
CefString GetFullPath() override;
uint32 GetId() override;
CefString GetURL() override;

View File

@ -55,11 +55,9 @@ bool CefNavigationEntryImpl::HasPostData() {
return mutable_value()->GetHasPostData();
}
CefTime CefNavigationEntryImpl::GetCompletionTime() {
CefTime time;
CEF_VALUE_VERIFY_RETURN(false, time);
cef_time_from_basetime(mutable_value()->GetTimestamp(), time);
return time;
CefBaseTime CefNavigationEntryImpl::GetCompletionTime() {
CEF_VALUE_VERIFY_RETURN(false, CefBaseTime());
return mutable_value()->GetTimestamp();
}
int CefNavigationEntryImpl::GetHttpStatusCode() {

View File

@ -30,7 +30,7 @@ class CefNavigationEntryImpl
CefString GetTitle() override;
TransitionType GetTransitionType() override;
bool HasPostData() override;
CefTime GetCompletionTime() override;
CefBaseTime GetCompletionTime() override;
int GetHttpStatusCode() override;
CefRefPtr<CefSSLStatus> GetSSLStatus() override;
};

View File

@ -277,7 +277,7 @@ bool CefCookieManagerImpl::SetCookieInternal(
base::Time expiration_time;
if (cookie.has_expires)
cef_time_to_basetime(cookie.expires, expiration_time);
expiration_time = CefBaseTime(cookie.expires);
net::CookieSameSite same_site =
net_service::MakeCookieSameSite(cookie.same_site);

View File

@ -56,24 +56,18 @@ CefRefPtr<CefBinaryValue> CefX509CertificateImpl::GetSerialNumber() {
return nullptr;
}
CefTime CefX509CertificateImpl::GetValidStart() {
CefTime validity;
CefBaseTime CefX509CertificateImpl::GetValidStart() {
if (cert_) {
const base::Time& valid_time = cert_->valid_start();
if (!valid_time.is_null())
cef_time_from_basetime(valid_time, validity);
return cert_->valid_start();
}
return validity;
return CefBaseTime();
}
CefTime CefX509CertificateImpl::GetValidExpiry() {
CefTime validity;
CefBaseTime CefX509CertificateImpl::GetValidExpiry() {
if (cert_) {
const base::Time& valid_time = cert_->valid_expiry();
if (!valid_time.is_null())
cef_time_from_basetime(valid_time, validity);
return cert_->valid_expiry();
}
return validity;
return CefBaseTime();
}
CefRefPtr<CefBinaryValue> CefX509CertificateImpl::GetDEREncoded() {

View File

@ -28,8 +28,8 @@ class CefX509CertificateImpl : public CefX509Certificate {
CefRefPtr<CefX509CertPrincipal> GetSubject() override;
CefRefPtr<CefX509CertPrincipal> GetIssuer() override;
CefRefPtr<CefBinaryValue> GetSerialNumber() override;
CefTime GetValidStart() override;
CefTime GetValidExpiry() override;
CefBaseTime GetValidStart() override;
CefBaseTime GetValidExpiry() override;
CefRefPtr<CefBinaryValue> GetDEREncoded() override;
CefRefPtr<CefBinaryValue> GetPEMEncoded() override;
size_t GetIssuerChainSize() override;

View File

@ -6,6 +6,7 @@
#include <time.h>
#include "base/logging.h"
#include "base/notreached.h"
#include "base/time/time.h"
#include "include/cef_stream.h"
// Static functions
@ -180,13 +181,11 @@ int64 CefZipReaderImpl::GetFileSize() {
return filesize_;
}
CefTime CefZipReaderImpl::GetFileLastModified() {
CefTime time;
CefBaseTime CefZipReaderImpl::GetFileLastModified() {
if (!VerifyContext() || !GetFileInfo())
return time;
return CefBaseTime();
cef_time_from_timet(filemodified_, &time);
return time;
return base::Time::FromTimeT(filemodified_);
}
bool CefZipReaderImpl::OpenFile(const CefString& password) {

View File

@ -27,7 +27,7 @@ class CefZipReaderImpl : public CefZipReader {
bool Close() override;
CefString GetFileName() override;
int64 GetFileSize() override;
CefTime GetFileLastModified() override;
CefBaseTime GetFileLastModified() override;
bool OpenFile(const CefString& password) override;
bool CloseFile() override;
int ReadFile(void* buffer, size_t bufferSize) override;

View File

@ -77,6 +77,10 @@ AlloyMainDelegate::AlloyMainDelegate(CefMainRunnerHandler* runner,
// in the binary.
extern void base_impl_stub();
base_impl_stub();
// Necessary so that exported functions from time_impl.cc will be included
// in the binary.
extern void time_impl_stub();
time_impl_stub();
#if BUILDFLAG(IS_LINUX)
resource_util::OverrideAssetPath();

View File

@ -5,6 +5,7 @@
#include "libcef/common/net_service/net_service_util.h"
#include "include/internal/cef_time_wrappers.h"
#include "libcef/common/time_util.h"
#include <set>
@ -224,11 +225,11 @@ bool MakeCefCookie(const net::CanonicalCookie& cc, CefCookie& cookie) {
CefString(&cookie.path).FromString(cc.Path());
cookie.secure = cc.IsSecure();
cookie.httponly = cc.IsHttpOnly();
cef_time_from_basetime(cc.CreationDate(), cookie.creation);
cef_time_from_basetime(cc.LastAccessDate(), cookie.last_access);
cookie.creation = CefBaseTime(cc.CreationDate());
cookie.last_access = CefBaseTime(cc.LastAccessDate());
cookie.has_expires = cc.IsPersistent();
if (cookie.has_expires)
cef_time_from_basetime(cc.ExpiryDate(), cookie.expires);
cookie.expires = CefBaseTime(cc.ExpiryDate());
cookie.same_site = MakeCefCookieSameSite(cc.SameSite());
cookie.priority = MakeCefCookiePriority(cc.Priority());
@ -262,11 +263,11 @@ bool MakeCefCookie(const GURL& url,
CefString(&cookie.path).FromString(cookie_path);
cookie.secure = pc.IsSecure();
cookie.httponly = pc.IsHttpOnly();
cef_time_from_basetime(creation_time, cookie.creation);
cef_time_from_basetime(creation_time, cookie.last_access);
cookie.creation = CefBaseTime(creation_time);
cookie.last_access = CefBaseTime(creation_time);
cookie.has_expires = !cookie_expires.is_null();
if (cookie.has_expires)
cef_time_from_basetime(cookie_expires, cookie.expires);
cookie.expires = CefBaseTime(cookie_expires);
cookie.same_site = MakeCefCookieSameSite(pc.SameSite());
cookie.priority = MakeCefCookiePriority(pc.Priority());

View File

@ -2,13 +2,27 @@
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "include/internal/cef_time_wrappers.h"
#include "include/internal/cef_types_wrappers.h"
#include "libcef/common/time_util.h"
#include <limits>
#include <tuple>
#if BUILDFLAG(IS_WIN)
#include <limits>
// The contents of this file are a compilation unit that is not called by other
// functions in the the library. Consiquently MSVS will exclude it during the
// linker stage if we don't call a stub function.
#if defined(COMPILER_MSVC)
#pragma optimize("", off)
#endif
void time_impl_stub() {}
#if defined(COMPILER_MSVC)
#pragma optimize("", on)
#endif
#if BUILDFLAG(IS_WIN)
namespace {
// From MSDN, FILETIME "Contains a 64-bit value representing the number of
@ -102,6 +116,10 @@ CEF_EXPORT int cef_time_now(cef_time_t* cef_time) {
return 1;
}
CEF_EXPORT cef_basetime_t cef_basetime_now() {
return CefBaseTime(base::Time::Now());
}
CEF_EXPORT int cef_time_delta(const cef_time_t* cef_time1,
const cef_time_t* cef_time2,
long long* delta) {
@ -116,3 +134,43 @@ CEF_EXPORT int cef_time_delta(const cef_time_t* cef_time1,
*delta = time_delta.InMilliseconds();
return 1;
}
CEF_EXPORT int cef_time_to_basetime(const cef_time_t* from,
cef_basetime_t* to) {
if (!from || !to)
return 0;
base::Time::Exploded exploded;
exploded.year = from->year;
exploded.month = from->month;
exploded.day_of_week = from->day_of_week;
exploded.day_of_month = from->day_of_month;
exploded.hour = from->hour;
exploded.minute = from->minute;
exploded.second = from->second;
exploded.millisecond = from->millisecond;
base::Time time;
bool result = base::Time::FromUTCExploded(exploded, &time);
*to = CefBaseTime(time);
return result ? 1 : 0;
}
CEF_EXPORT int cef_time_from_basetime(const cef_basetime_t from,
cef_time_t* to) {
if (!to)
return 0;
base::Time time = CefBaseTime(from);
base::Time::Exploded exploded;
time.UTCExplode(&exploded);
to->year = exploded.year;
to->month = exploded.month;
to->day_of_week = exploded.day_of_week;
to->day_of_month = exploded.day_of_month;
to->hour = exploded.hour;
to->minute = exploded.minute;
to->second = exploded.second;
to->millisecond = exploded.millisecond;
return exploded.HasValidValues() ? 1 : 0;
}

View File

@ -1284,7 +1284,7 @@ CefRefPtr<CefV8Value> CefV8Value::CreateDouble(double value) {
}
// static
CefRefPtr<CefV8Value> CefV8Value::CreateDate(const CefTime& value) {
CefRefPtr<CefV8Value> CefV8Value::CreateDate(CefBaseTime value) {
CEF_V8_REQUIRE_ISOLATE_RETURN(nullptr);
v8::Isolate* isolate = GetIsolateManager()->isolate();
CefRefPtr<CefV8ValueImpl> impl = new CefV8ValueImpl(isolate);
@ -1522,8 +1522,8 @@ void CefV8ValueImpl::InitFromV8Value(v8::Local<v8::Context> context,
InitDouble(value->ToNumber(context).ToLocalChecked()->Value());
} else if (value->IsDate()) {
// Convert from milliseconds to seconds.
InitDate(
CefTime(value->ToNumber(context).ToLocalChecked()->Value() / 1000));
InitDate(base::Time::FromJsTime(
value->ToNumber(context).ToLocalChecked()->Value()));
} else if (value->IsString()) {
CefString rv;
GetCefString(context->GetIsolate(),
@ -1568,7 +1568,7 @@ void CefV8ValueImpl::InitDouble(double value) {
double_value_ = value;
}
void CefV8ValueImpl::InitDate(const CefTime& value) {
void CefV8ValueImpl::InitDate(CefBaseTime value) {
DCHECK_EQ(type_, TYPE_INVALID);
type_ = TYPE_DATE;
date_value_ = value;
@ -1614,7 +1614,8 @@ v8::Local<v8::Value> CefV8ValueImpl::GetV8Value(bool should_persist) {
case TYPE_DATE:
// Convert from seconds to milliseconds.
return v8::Date::New(isolate_->GetCurrentContext(),
CefTime(date_value_).GetDoubleT() * 1000)
static_cast<base::Time>(CefBaseTime(date_value_))
.ToJsTimeIgnoringNull())
.ToLocalChecked();
case TYPE_STRING:
return GetV8String(isolate_, CefString(&string_value_));
@ -1732,8 +1733,7 @@ bool CefV8ValueImpl::IsSame(CefRefPtr<CefV8Value> that) {
case TYPE_DOUBLE:
return (double_value_ == thatValue->double_value_);
case TYPE_DATE:
return (CefTime(date_value_).GetTimeT() ==
CefTime(thatValue->date_value_).GetTimeT());
return (date_value_.val == thatValue->date_value_.val);
case TYPE_STRING:
return (CefString(&string_value_) ==
CefString(&thatValue->string_value_));
@ -1780,11 +1780,11 @@ double CefV8ValueImpl::GetDoubleValue() {
return 0.;
}
CefTime CefV8ValueImpl::GetDateValue() {
CEF_V8_REQUIRE_ISOLATE_RETURN(CefTime(0.));
CefBaseTime CefV8ValueImpl::GetDateValue() {
CEF_V8_REQUIRE_ISOLATE_RETURN(CefBaseTime());
if (type_ == TYPE_DATE)
return date_value_;
return CefTime(0.);
return CefBaseTime();
}
CefString CefV8ValueImpl::GetStringValue() {

View File

@ -216,7 +216,7 @@ class CefV8ValueImpl : public CefV8Value {
void InitInt(int32 value);
void InitUInt(uint32 value);
void InitDouble(double value);
void InitDate(const CefTime& value);
void InitDate(CefBaseTime value);
void InitString(CefString& value);
void InitObject(v8::Local<v8::Value> value, CefTrackNode* tracker);
@ -242,7 +242,7 @@ class CefV8ValueImpl : public CefV8Value {
int32 GetIntValue() override;
uint32 GetUIntValue() override;
double GetDoubleValue() override;
CefTime GetDateValue() override;
CefBaseTime GetDateValue() override;
CefString GetStringValue() override;
bool IsUserCreated() override;
bool HasException() override;
@ -346,7 +346,7 @@ class CefV8ValueImpl : public CefV8Value {
int32 int_value_;
uint32 uint_value_;
double double_value_;
cef_time_t date_value_;
cef_basetime_t date_value_;
cef_string_t string_value_;
};

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=64b3cee6b2de98140a1dc6f6aabff6b2c4ac7d78$
// $hash=6ced91f96527ec3d231208e0bcadbbd557f41d65$
//
#include "libcef_dll/cpptoc/download_item_cpptoc.h"
@ -152,7 +152,7 @@ download_item_get_received_bytes(struct _cef_download_item_t* self) {
return _retval;
}
cef_time_t CEF_CALLBACK
cef_basetime_t CEF_CALLBACK
download_item_get_start_time(struct _cef_download_item_t* self) {
shutdown_checker::AssertNotShutdown();
@ -160,16 +160,16 @@ download_item_get_start_time(struct _cef_download_item_t* self) {
DCHECK(self);
if (!self)
return CefTime();
return CefBaseTime();
// Execute
cef_time_t _retval = CefDownloadItemCppToC::Get(self)->GetStartTime();
cef_basetime_t _retval = CefDownloadItemCppToC::Get(self)->GetStartTime();
// Return type: simple
return _retval;
}
cef_time_t CEF_CALLBACK
cef_basetime_t CEF_CALLBACK
download_item_get_end_time(struct _cef_download_item_t* self) {
shutdown_checker::AssertNotShutdown();
@ -177,10 +177,10 @@ download_item_get_end_time(struct _cef_download_item_t* self) {
DCHECK(self);
if (!self)
return CefTime();
return CefBaseTime();
// Execute
cef_time_t _retval = CefDownloadItemCppToC::Get(self)->GetEndTime();
cef_basetime_t _retval = CefDownloadItemCppToC::Get(self)->GetEndTime();
// Return type: simple
return _retval;

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=081579d10d7dd1ad8906d54350c2b63f97930fd2$
// $hash=a824ce871b25f19f2af043bd049d2554bd06232b$
//
#include "libcef_dll/cpptoc/navigation_entry_cpptoc.h"
@ -140,7 +140,7 @@ navigation_entry_has_post_data(struct _cef_navigation_entry_t* self) {
return _retval;
}
cef_time_t CEF_CALLBACK
cef_basetime_t CEF_CALLBACK
navigation_entry_get_completion_time(struct _cef_navigation_entry_t* self) {
shutdown_checker::AssertNotShutdown();
@ -148,10 +148,11 @@ navigation_entry_get_completion_time(struct _cef_navigation_entry_t* self) {
DCHECK(self);
if (!self)
return CefTime();
return CefBaseTime();
// Execute
cef_time_t _retval = CefNavigationEntryCppToC::Get(self)->GetCompletionTime();
cef_basetime_t _retval =
CefNavigationEntryCppToC::Get(self)->GetCompletionTime();
// Return type: simple
return _retval;

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=0cb915346153880872b44bd1f857c24787ed52af$
// $hash=46a80d60441e386e6a8999ecb5fd338f3f6b4319$
//
#include "libcef_dll/cpptoc/v8value_cpptoc.h"
@ -84,19 +84,11 @@ CEF_EXPORT cef_v8value_t* cef_v8value_create_double(double value) {
return CefV8ValueCppToC::Wrap(_retval);
}
CEF_EXPORT cef_v8value_t* cef_v8value_create_date(const cef_time_t* date) {
CEF_EXPORT cef_v8value_t* cef_v8value_create_date(cef_basetime_t date) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: date; type: simple_byref_const
DCHECK(date);
if (!date)
return NULL;
// Translate param: date; type: simple_byref_const
CefTime dateVal = date ? *date : CefTime();
// Execute
CefRefPtr<CefV8Value> _retval = CefV8Value::CreateDate(dateVal);
CefRefPtr<CefV8Value> _retval = CefV8Value::CreateDate(date);
// Return type: refptr_same
return CefV8ValueCppToC::Wrap(_retval);
@ -448,15 +440,16 @@ double CEF_CALLBACK v8value_get_double_value(struct _cef_v8value_t* self) {
return _retval;
}
cef_time_t CEF_CALLBACK v8value_get_date_value(struct _cef_v8value_t* self) {
cef_basetime_t CEF_CALLBACK
v8value_get_date_value(struct _cef_v8value_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return CefTime();
return CefBaseTime();
// Execute
cef_time_t _retval = CefV8ValueCppToC::Get(self)->GetDateValue();
cef_basetime_t _retval = CefV8ValueCppToC::Get(self)->GetDateValue();
// Return type: simple
return _retval;

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=cac3e88ea15965e3a7786500606845b0b6157212$
// $hash=3fbe9313681f3ac9545e5042c76fa2e41db52d3d$
//
#include "libcef_dll/cpptoc/x509certificate_cpptoc.h"
@ -76,7 +76,7 @@ x509certificate_get_serial_number(struct _cef_x509certificate_t* self) {
return CefBinaryValueCppToC::Wrap(_retval);
}
cef_time_t CEF_CALLBACK
cef_basetime_t CEF_CALLBACK
x509certificate_get_valid_start(struct _cef_x509certificate_t* self) {
shutdown_checker::AssertNotShutdown();
@ -84,16 +84,16 @@ x509certificate_get_valid_start(struct _cef_x509certificate_t* self) {
DCHECK(self);
if (!self)
return CefTime();
return CefBaseTime();
// Execute
cef_time_t _retval = CefX509CertificateCppToC::Get(self)->GetValidStart();
cef_basetime_t _retval = CefX509CertificateCppToC::Get(self)->GetValidStart();
// Return type: simple
return _retval;
}
cef_time_t CEF_CALLBACK
cef_basetime_t CEF_CALLBACK
x509certificate_get_valid_expiry(struct _cef_x509certificate_t* self) {
shutdown_checker::AssertNotShutdown();
@ -101,10 +101,11 @@ x509certificate_get_valid_expiry(struct _cef_x509certificate_t* self) {
DCHECK(self);
if (!self)
return CefTime();
return CefBaseTime();
// Execute
cef_time_t _retval = CefX509CertificateCppToC::Get(self)->GetValidExpiry();
cef_basetime_t _retval =
CefX509CertificateCppToC::Get(self)->GetValidExpiry();
// Return type: simple
return _retval;

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=9fe9e9199e284af22669ba2abfb715d0e7ae8de3$
// $hash=d282910b834f9f5076a1310196f326828e41540d$
//
#include "libcef_dll/cpptoc/zip_reader_cpptoc.h"
@ -145,7 +145,7 @@ int64 CEF_CALLBACK zip_reader_get_file_size(struct _cef_zip_reader_t* self) {
return _retval;
}
cef_time_t CEF_CALLBACK
cef_basetime_t CEF_CALLBACK
zip_reader_get_file_last_modified(struct _cef_zip_reader_t* self) {
shutdown_checker::AssertNotShutdown();
@ -153,10 +153,10 @@ zip_reader_get_file_last_modified(struct _cef_zip_reader_t* self) {
DCHECK(self);
if (!self)
return CefTime();
return CefBaseTime();
// Execute
cef_time_t _retval = CefZipReaderCppToC::Get(self)->GetFileLastModified();
cef_basetime_t _retval = CefZipReaderCppToC::Get(self)->GetFileLastModified();
// Return type: simple
return _retval;

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=05c6527a7cdeb9495bca9da965956fb3006a7bdd$
// $hash=6e5538c52ff85f677fb62f4477d60cbb91e8a222$
//
#include "libcef_dll/ctocpp/download_item_ctocpp.h"
@ -145,33 +145,33 @@ NO_SANITIZE("cfi-icall") int64 CefDownloadItemCToCpp::GetReceivedBytes() {
return _retval;
}
NO_SANITIZE("cfi-icall") CefTime CefDownloadItemCToCpp::GetStartTime() {
NO_SANITIZE("cfi-icall") CefBaseTime CefDownloadItemCToCpp::GetStartTime() {
shutdown_checker::AssertNotShutdown();
cef_download_item_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_start_time))
return CefTime();
return CefBaseTime();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_time_t _retval = _struct->get_start_time(_struct);
cef_basetime_t _retval = _struct->get_start_time(_struct);
// Return type: simple
return _retval;
}
NO_SANITIZE("cfi-icall") CefTime CefDownloadItemCToCpp::GetEndTime() {
NO_SANITIZE("cfi-icall") CefBaseTime CefDownloadItemCToCpp::GetEndTime() {
shutdown_checker::AssertNotShutdown();
cef_download_item_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_end_time))
return CefTime();
return CefBaseTime();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_time_t _retval = _struct->get_end_time(_struct);
cef_basetime_t _retval = _struct->get_end_time(_struct);
// Return type: simple
return _retval;

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=800621bf853598aa11673f3c38e5f30858aa1ff1$
// $hash=0c93fdb6b5df295b23100920eee9c26c8caf1442$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_DOWNLOAD_ITEM_CTOCPP_H_
@ -42,8 +42,8 @@ class CefDownloadItemCToCpp : public CefCToCppRefCounted<CefDownloadItemCToCpp,
int GetPercentComplete() override;
int64 GetTotalBytes() override;
int64 GetReceivedBytes() override;
CefTime GetStartTime() override;
CefTime GetEndTime() override;
CefBaseTime GetStartTime() override;
CefBaseTime GetEndTime() override;
CefString GetFullPath() override;
uint32 GetId() override;
CefString GetURL() override;

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=824aed5040e7aee5f9bf2079eafdf6d612b7d2d0$
// $hash=f9bd014f608a1123ee15c3f1f999792ef18523ec$
//
#include "libcef_dll/ctocpp/navigation_entry_ctocpp.h"
@ -140,17 +140,18 @@ NO_SANITIZE("cfi-icall") bool CefNavigationEntryCToCpp::HasPostData() {
return _retval ? true : false;
}
NO_SANITIZE("cfi-icall") CefTime CefNavigationEntryCToCpp::GetCompletionTime() {
NO_SANITIZE("cfi-icall")
CefBaseTime CefNavigationEntryCToCpp::GetCompletionTime() {
shutdown_checker::AssertNotShutdown();
cef_navigation_entry_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_completion_time))
return CefTime();
return CefBaseTime();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_time_t _retval = _struct->get_completion_time(_struct);
cef_basetime_t _retval = _struct->get_completion_time(_struct);
// Return type: simple
return _retval;

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=6f127ca09c0419845e4fc6aec71b0bf9373ff290$
// $hash=dc8fd6995ca7b6ec38887cba0da5330b2dd22e9e$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_NAVIGATION_ENTRY_CTOCPP_H_
@ -42,7 +42,7 @@ class CefNavigationEntryCToCpp
CefString GetTitle() override;
TransitionType GetTransitionType() override;
bool HasPostData() override;
CefTime GetCompletionTime() override;
CefBaseTime GetCompletionTime() override;
int GetHttpStatusCode() override;
CefRefPtr<CefSSLStatus> GetSSLStatus() override;
};

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=7863f5701d466f8d5a5c91962e14b14b500315a3$
// $hash=1dd04012b442aa3ceae8d56653dc499aed1e181f$
//
#include "libcef_dll/ctocpp/v8value_ctocpp.h"
@ -89,11 +89,11 @@ CefRefPtr<CefV8Value> CefV8Value::CreateDouble(double value) {
}
NO_SANITIZE("cfi-icall")
CefRefPtr<CefV8Value> CefV8Value::CreateDate(const CefTime& date) {
CefRefPtr<CefV8Value> CefV8Value::CreateDate(CefBaseTime date) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_v8value_t* _retval = cef_v8value_create_date(&date);
cef_v8value_t* _retval = cef_v8value_create_date(date);
// Return type: refptr_same
return CefV8ValueCToCpp::Wrap(_retval);
@ -448,15 +448,15 @@ NO_SANITIZE("cfi-icall") double CefV8ValueCToCpp::GetDoubleValue() {
return _retval;
}
NO_SANITIZE("cfi-icall") CefTime CefV8ValueCToCpp::GetDateValue() {
NO_SANITIZE("cfi-icall") CefBaseTime CefV8ValueCToCpp::GetDateValue() {
cef_v8value_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_date_value))
return CefTime();
return CefBaseTime();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_time_t _retval = _struct->get_date_value(_struct);
cef_basetime_t _retval = _struct->get_date_value(_struct);
// Return type: simple
return _retval;

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=c9725eb41d50cd0bdbe6f84280e0ed7b62012136$
// $hash=012bb9108d28ddefb6ebc58963be24469b79146f$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_V8VALUE_CTOCPP_H_
@ -52,7 +52,7 @@ class CefV8ValueCToCpp
int32 GetIntValue() override;
uint32 GetUIntValue() override;
double GetDoubleValue() override;
CefTime GetDateValue() override;
CefBaseTime GetDateValue() override;
CefString GetStringValue() override;
bool IsUserCreated() override;
bool HasException() override;

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=b5ab278c54b7ed9046b43a7f362a18ebc8bde146$
// $hash=71bb75d8d84070d9dfbddee9523c80403a60ddf5$
//
#include "libcef_dll/ctocpp/x509certificate_ctocpp.h"
@ -71,33 +71,34 @@ CefRefPtr<CefBinaryValue> CefX509CertificateCToCpp::GetSerialNumber() {
return CefBinaryValueCToCpp::Wrap(_retval);
}
NO_SANITIZE("cfi-icall") CefTime CefX509CertificateCToCpp::GetValidStart() {
NO_SANITIZE("cfi-icall") CefBaseTime CefX509CertificateCToCpp::GetValidStart() {
shutdown_checker::AssertNotShutdown();
cef_x509certificate_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_valid_start))
return CefTime();
return CefBaseTime();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_time_t _retval = _struct->get_valid_start(_struct);
cef_basetime_t _retval = _struct->get_valid_start(_struct);
// Return type: simple
return _retval;
}
NO_SANITIZE("cfi-icall") CefTime CefX509CertificateCToCpp::GetValidExpiry() {
NO_SANITIZE("cfi-icall")
CefBaseTime CefX509CertificateCToCpp::GetValidExpiry() {
shutdown_checker::AssertNotShutdown();
cef_x509certificate_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_valid_expiry))
return CefTime();
return CefBaseTime();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_time_t _retval = _struct->get_valid_expiry(_struct);
cef_basetime_t _retval = _struct->get_valid_expiry(_struct);
// Return type: simple
return _retval;

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=eb95efa4bb7e2ca0696f86390fa32f269eedf9f3$
// $hash=920360dc912cb321d5ff60297269e252845a0499$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_X509CERTIFICATE_CTOCPP_H_
@ -38,8 +38,8 @@ class CefX509CertificateCToCpp
CefRefPtr<CefX509CertPrincipal> GetSubject() override;
CefRefPtr<CefX509CertPrincipal> GetIssuer() override;
CefRefPtr<CefBinaryValue> GetSerialNumber() override;
CefTime GetValidStart() override;
CefTime GetValidExpiry() override;
CefBaseTime GetValidStart() override;
CefBaseTime GetValidExpiry() override;
CefRefPtr<CefBinaryValue> GetDEREncoded() override;
CefRefPtr<CefBinaryValue> GetPEMEncoded() override;
size_t GetIssuerChainSize() override;

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=f01ac0e38723b8786f115a14dbca8d4d3d1a57bf$
// $hash=f14a25ea9d276bbf30500bf0e39c3eb1068f83b9$
//
#include "libcef_dll/ctocpp/zip_reader_ctocpp.h"
@ -146,17 +146,17 @@ NO_SANITIZE("cfi-icall") int64 CefZipReaderCToCpp::GetFileSize() {
return _retval;
}
NO_SANITIZE("cfi-icall") CefTime CefZipReaderCToCpp::GetFileLastModified() {
NO_SANITIZE("cfi-icall") CefBaseTime CefZipReaderCToCpp::GetFileLastModified() {
shutdown_checker::AssertNotShutdown();
cef_zip_reader_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_file_last_modified))
return CefTime();
return CefBaseTime();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_time_t _retval = _struct->get_file_last_modified(_struct);
cef_basetime_t _retval = _struct->get_file_last_modified(_struct);
// Return type: simple
return _retval;

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=995930b1262a99fb14a57dc0af908d292434e00b$
// $hash=e30674976c272e7ae1e9a43b05a139927d21024d$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_ZIP_READER_CTOCPP_H_
@ -40,7 +40,7 @@ class CefZipReaderCToCpp : public CefCToCppRefCounted<CefZipReaderCToCpp,
bool Close() override;
CefString GetFileName() override;
int64 GetFileSize() override;
CefTime GetFileLastModified() override;
CefBaseTime GetFileLastModified() override;
bool OpenFile(const CefString& password) override;
bool CloseFile() override;
int ReadFile(void* buffer, size_t bufferSize) override;

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=c2c4aa508db66d7b185c4f9ed9a89f1cd65107c1$
// $hash=cd24810e169a9b119137caec3f864fdd6327c887$
//
#include <dlfcn.h>
@ -298,7 +298,10 @@ struct libcef_pointers {
decltype(&cef_time_to_doublet) cef_time_to_doublet;
decltype(&cef_time_from_doublet) cef_time_from_doublet;
decltype(&cef_time_now) cef_time_now;
decltype(&cef_basetime_now) cef_basetime_now;
decltype(&cef_time_delta) cef_time_delta;
decltype(&cef_time_to_basetime) cef_time_to_basetime;
decltype(&cef_time_from_basetime) cef_time_from_basetime;
decltype(&cef_trace_event_instant) cef_trace_event_instant;
decltype(&cef_trace_event_begin) cef_trace_event_begin;
decltype(&cef_trace_event_end) cef_trace_event_end;
@ -500,7 +503,10 @@ int libcef_init_pointers(const char* path) {
INIT_ENTRY(cef_time_to_doublet);
INIT_ENTRY(cef_time_from_doublet);
INIT_ENTRY(cef_time_now);
INIT_ENTRY(cef_basetime_now);
INIT_ENTRY(cef_time_delta);
INIT_ENTRY(cef_time_to_basetime);
INIT_ENTRY(cef_time_from_basetime);
INIT_ENTRY(cef_trace_event_instant);
INIT_ENTRY(cef_trace_event_begin);
INIT_ENTRY(cef_trace_event_end);
@ -1051,7 +1057,7 @@ struct _cef_v8value_t* cef_v8value_create_double(double value) {
}
NO_SANITIZE("cfi-icall")
struct _cef_v8value_t* cef_v8value_create_date(const cef_time_t* date) {
struct _cef_v8value_t* cef_v8value_create_date(cef_basetime_t date) {
return g_libcef_pointers.cef_v8value_create_date(date);
}
@ -1608,6 +1614,10 @@ NO_SANITIZE("cfi-icall") int cef_time_now(cef_time_t* cef_time) {
return g_libcef_pointers.cef_time_now(cef_time);
}
NO_SANITIZE("cfi-icall") cef_basetime_t cef_basetime_now() {
return g_libcef_pointers.cef_basetime_now();
}
NO_SANITIZE("cfi-icall")
int cef_time_delta(const cef_time_t* cef_time1,
const cef_time_t* cef_time2,
@ -1615,6 +1625,16 @@ int cef_time_delta(const cef_time_t* cef_time1,
return g_libcef_pointers.cef_time_delta(cef_time1, cef_time2, delta);
}
NO_SANITIZE("cfi-icall")
int cef_time_to_basetime(const cef_time_t* from, cef_basetime_t* to) {
return g_libcef_pointers.cef_time_to_basetime(from, to);
}
NO_SANITIZE("cfi-icall")
int cef_time_from_basetime(const cef_basetime_t from, cef_time_t* to) {
return g_libcef_pointers.cef_time_from_basetime(from, to);
}
NO_SANITIZE("cfi-icall")
void cef_trace_event_instant(const char* category,
const char* name,

View File

@ -78,6 +78,15 @@ std::string GetTimeString(const CefTime& value) {
return ss.str();
}
std::string GetTimeString(const CefBaseTime& value) {
CefTime time;
if (cef_time_from_basetime(value, &time)) {
return GetTimeString(time);
} else {
return "Invalid";
}
}
std::string GetBinaryString(CefRefPtr<CefBinaryValue> value) {
if (!value.get())
return "&nbsp;";

View File

@ -75,7 +75,6 @@ class V8Handler : public CefV8Handler {
retval = CefV8Value::CreateInt(1);
} else if (arguments.size() == 1 && arguments[0]->IsInt()) {
int32 type = arguments[0]->GetIntValue();
CefTime date;
switch (type) {
case 0:
retval = CefV8Value::CreateUndefined();
@ -96,8 +95,7 @@ class V8Handler : public CefV8Handler {
retval = CefV8Value::CreateDouble(1.234);
break;
case 6:
date.Now();
retval = CefV8Value::CreateDate(date);
retval = CefV8Value::CreateDate(CefBaseTime::Now());
break;
case 7:
retval = CefV8Value::CreateString("Hello, world!");

View File

@ -44,7 +44,11 @@ PERF_TEST_FUNC(V8DoubleCreate) {
}
PERF_TEST_FUNC(V8DateCreate) {
static cef_time_t time = {2012, 1, 0, 1};
static cef_time_t time_exploded = {2012, 1, 0, 1};
cef_basetime_t basetime;
cef_time_to_basetime(&time_exploded, &basetime);
CefBaseTime time(basetime);
PERF_ITERATIONS_START()
CefRefPtr<CefV8Value> value = CefV8Value::CreateDate(time);

View File

@ -173,7 +173,9 @@ void CreateCookie(CefRefPtr<CefCookieManager> manager,
cookie.has_expires = true;
// Must choose the expiry date dynamically due to the
// "ClampCookieExpiryTo400Days" feature enabled in M104.
EXPECT_TRUE(cef_time_from_timet(GetExpiryDate(), &cookie.expires));
cef_time_t expiry_time;
EXPECT_TRUE(cef_time_from_timet(GetExpiryDate(), &expiry_time));
EXPECT_TRUE(cef_time_to_basetime(&expiry_time, &cookie.expires));
}
CookieVector cookies;
@ -251,14 +253,7 @@ void GetCookie(CefRefPtr<CefCookieManager> manager,
EXPECT_EQ(CefString(&cookie_read.domain), kTestDomain);
EXPECT_EQ(CefString(&cookie_read.path), kTestPath);
EXPECT_EQ(cookie.has_expires, cookie_read.has_expires);
EXPECT_EQ(cookie.expires.year, cookie_read.expires.year);
EXPECT_EQ(cookie.expires.month, cookie_read.expires.month);
EXPECT_EQ(cookie.expires.day_of_week, cookie_read.expires.day_of_week);
EXPECT_EQ(cookie.expires.day_of_month, cookie_read.expires.day_of_month);
EXPECT_EQ(cookie.expires.hour, cookie_read.expires.hour);
EXPECT_EQ(cookie.expires.minute, cookie_read.expires.minute);
EXPECT_EQ(cookie.expires.second, cookie_read.expires.second);
EXPECT_EQ(cookie.expires.millisecond, cookie_read.expires.millisecond);
EXPECT_EQ(cookie.expires.val, cookie_read.expires.val);
EXPECT_EQ(cookie.same_site, cookie_read.same_site);
EXPECT_EQ(cookie.priority, cookie_read.priority);
}

View File

@ -296,7 +296,7 @@ class NavigationEntryVisitor : public CefNavigationEntryVisitor {
EXPECT_EQ(kTransitionExplicitLoad, transition_type);
EXPECT_FALSE(entry->HasPostData());
EXPECT_GT(entry->GetCompletionTime().GetTimeT(), 0);
EXPECT_GT(CefTimeFrom(entry->GetCompletionTime()).GetTimeT(), 0);
EXPECT_EQ(200, entry->GetHttpStatusCode());
callback_count_++;

View File

@ -6,6 +6,7 @@
#include <algorithm>
#include "include/cef_base.h"
#include "include/cef_command_line.h"
#include "include/cef_request_context_handler.h"
#include "tests/gtest/include/gtest/gtest.h"
@ -356,3 +357,15 @@ CefRefPtr<CefRequestContext> CreateTestRequestContext(
return CefRequestContext::CreateContext(CefRequestContext::GetGlobalContext(),
rc_handler);
}
CefTime CefTimeFrom(CefBaseTime value) {
CefTime time;
cef_time_from_basetime(value, &time);
return time;
}
CefBaseTime CefBaseTimeFrom(const CefTime& value) {
cef_basetime_t temp;
cef_time_to_basetime(&value, &temp);
return CefBaseTime(temp);
}

View File

@ -13,6 +13,9 @@
#include "include/cef_values.h"
#include "tests/ceftests/test_suite.h"
CefTime CefTimeFrom(CefBaseTime value);
CefBaseTime CefBaseTimeFrom(const CefTime& value);
// Test that CefRequest::HeaderMap objects are equal. Multiple values with the
// same key are allowed, but not duplicate entries with the same key/value. If
// |allowExtras| is true then additional header fields will be allowed in

View File

@ -0,0 +1,82 @@
// Copyright (c) 2022 The Chromium Embedded Framework 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 "include/internal/cef_time_wrappers.h"
#include "tests/gtest/include/gtest/gtest.h"
TEST(TimeTest, Now) {
// Sanity check, what it returns something.
cef_basetime_t now = cef_basetime_now();
EXPECT_NE(now.val, 0);
}
TEST(TimeTest, TimeToBaseTime) {
// Choosing some date which should be always representable on any platform.
cef_time_t date{};
date.year = 2001;
date.month = 2;
date.day_of_week = 1;
date.day_of_month = 5;
date.hour = 6;
date.minute = 7;
date.second = 8;
date.millisecond = 9;
cef_basetime_t basetime{};
// Null parameter handling.
ASSERT_FALSE(cef_time_to_basetime(nullptr, nullptr));
ASSERT_FALSE(cef_time_to_basetime(&date, nullptr));
ASSERT_FALSE(cef_time_to_basetime(nullptr, &basetime));
ASSERT_TRUE(cef_time_to_basetime(&date, &basetime));
ASSERT_EQ(basetime.val, 12625826828009000);
}
TEST(TimeTest, BaseTimeToTime) {
cef_basetime_t basetime{12625826828009000};
// Choosing some date which should be always representable on any platform.
cef_time_t date{};
ASSERT_TRUE(cef_time_from_basetime(basetime, &date) != 0);
EXPECT_EQ(date.year, 2001);
EXPECT_EQ(date.month, 2);
EXPECT_EQ(date.day_of_week, 1);
EXPECT_EQ(date.day_of_month, 5);
EXPECT_EQ(date.hour, 6);
EXPECT_EQ(date.minute, 7);
EXPECT_EQ(date.second, 8);
EXPECT_EQ(date.millisecond, 9);
}
TEST(TimeTest, InvalidTimeToBaseTime) {
// Some time which can't be represented
cef_time_t date{};
date.year = 90000;
cef_basetime_t basetime{999999999};
ASSERT_FALSE(cef_time_to_basetime(&date, &basetime) != 0);
ASSERT_EQ(basetime.val, 0); // Output should always be set.
}
TEST(TimeTest, InvalidBaseTimeToTime) {
// Unrepresentable.
cef_basetime_t basetime{std::numeric_limits<int64_t>::max()};
cef_time_t date{};
date.year = 999999999;
ASSERT_FALSE(cef_time_from_basetime(basetime, &date) != 0);
// Output should always be set.
EXPECT_EQ(date.year, 0);
EXPECT_EQ(date.month, 0);
EXPECT_EQ(date.day_of_week, 0);
EXPECT_EQ(date.day_of_month, 0);
EXPECT_EQ(date.hour, 0);
EXPECT_EQ(date.minute, 0);
EXPECT_EQ(date.second, 0);
EXPECT_EQ(date.millisecond, 0);
}

View File

@ -9,6 +9,7 @@
#include "include/cef_v8.h"
#include "include/wrapper/cef_closure_task.h"
#include "tests/ceftests/test_handler.h"
#include "tests/ceftests/test_util.h"
#include "tests/gtest/include/gtest/gtest.h"
#include "tests/shared/browser/client_app_browser.h"
#include "tests/shared/renderer/client_app_renderer.h"
@ -378,10 +379,10 @@ class V8RendererTest : public ClientAppRenderer::Delegate,
// Enter the V8 context.
EXPECT_TRUE(context->Enter());
CefRefPtr<CefV8Value> value = CefV8Value::CreateDate(date);
CefRefPtr<CefV8Value> value = CefV8Value::CreateDate(CefBaseTimeFrom(date));
EXPECT_TRUE(value.get());
EXPECT_TRUE(value->IsDate());
EXPECT_EQ(date.GetTimeT(), value->GetDateValue().GetTimeT());
EXPECT_EQ(date.GetTimeT(), CefTimeFrom(value->GetDateValue()).GetTimeT());
// Exit the V8 context.
EXPECT_TRUE(context->Exit());

View File

@ -64,6 +64,7 @@ class cef_api_hash:
"internal/cef_export.h",
"internal/cef_ptr.h",
"internal/cef_string_wrappers.h",
"internal/cef_time_wrappers.h",
"internal/cef_types_wrappers.h",
# includes_win
"cef_sandbox_win.h",

View File

@ -395,6 +395,7 @@ _simpletypes = {
'cef_color_t': ['cef_color_t', '0'],
'cef_json_parser_error_t': ['cef_json_parser_error_t', 'JSON_NO_ERROR'],
'CefAudioParameters': ['cef_audio_parameters_t', 'CefAudioParameters()'],
'CefBaseTime': ['cef_basetime_t', 'CefBaseTime()'],
'CefBoxLayoutSettings': [
'cef_box_layout_settings_t', 'CefBoxLayoutSettings()'
],