diff --git a/cef_paths2.gypi b/cef_paths2.gypi index eaa902ff0..7f430b829 100644 --- a/cef_paths2.gypi +++ b/cef_paths2.gypi @@ -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', diff --git a/include/capi/cef_download_item_capi.h b/include/capi/cef_download_item_capi.h index 2d52f11b4..38b8d96c2 100644 --- a/include/capi/cef_download_item_capi.h +++ b/include/capi/cef_download_item_capi.h @@ -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. diff --git a/include/capi/cef_navigation_entry_capi.h b/include/capi/cef_navigation_entry_capi.h index 4d4e07f10..29a461eb8 100644 --- a/include/capi/cef_navigation_entry_capi.h +++ b/include/capi/cef_navigation_entry_capi.h @@ -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); /// diff --git a/include/capi/cef_v8_capi.h b/include/capi/cef_v8_capi.h index 622e97daf..49b00b7ca 100644 --- a/include/capi/cef_v8_capi.h +++ b/include/capi/cef_v8_capi.h @@ -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. diff --git a/include/capi/cef_x509_certificate_capi.h b/include/capi/cef_x509_certificate_capi.h index 8650b4055..cd1554c24 100644 --- a/include/capi/cef_x509_certificate_capi.h +++ b/include/capi/cef_x509_certificate_capi.h @@ -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); /// diff --git a/include/capi/cef_zip_reader_capi.h b/include/capi/cef_zip_reader_capi.h index 5d8993533..0382cdbed 100644 --- a/include/capi/cef_zip_reader_capi.h +++ b/include/capi/cef_zip_reader_capi.h @@ -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); /// diff --git a/include/cef_api_hash.h b/include/cef_api_hash.h index 19c22187e..ac6f03409 100644 --- a/include/cef_api_hash.h +++ b/include/cef_api_hash.h @@ -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 diff --git a/include/cef_base.h b/include/cef_base.h index ffcf4740e..d5b0e4ce9 100644 --- a/include/cef_base.h +++ b/include/cef_base.h @@ -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" diff --git a/include/cef_download_item.h b/include/cef_download_item.h index 930f53bb4..48328a2cd 100644 --- a/include/cef_download_item.h +++ b/include/cef_download_item.h @@ -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. diff --git a/include/cef_navigation_entry.h b/include/cef_navigation_entry.h index 292f5b6c3..0ef7ff669 100644 --- a/include/cef_navigation_entry.h +++ b/include/cef_navigation_entry.h @@ -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 diff --git a/include/cef_v8.h b/include/cef_v8.h index 8bbc0288a..e027db638 100644 --- a/include/cef_v8.h +++ b/include/cef_v8.h @@ -478,7 +478,7 @@ class CefV8Value : public virtual CefBaseRefCounted { // on a stored CefV8Context reference. /// /*--cef()--*/ - static CefRefPtr CreateDate(const CefTime& date); + static CefRefPtr 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. diff --git a/include/cef_x509_certificate.h b/include/cef_x509_certificate.h index b466a6adc..c7fe88a89 100644 --- a/include/cef_x509_certificate.h +++ b/include/cef_x509_certificate.h @@ -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. diff --git a/include/cef_zip_reader.h b/include/cef_zip_reader.h index 5dc2efd60..51f10d731 100644 --- a/include/cef_zip_reader.h +++ b/include/cef_zip_reader.h @@ -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 diff --git a/include/internal/cef_time.h b/include/internal/cef_time.h index 5435e5996..9114c31c3 100644 --- a/include/internal/cef_time.h +++ b/include/internal/cef_time.h @@ -36,8 +36,20 @@ extern "C" { #endif #include +#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 diff --git a/include/internal/cef_time_wrappers.h b/include/internal/cef_time_wrappers.h new file mode 100644 index 000000000..e7ddd17a5 --- /dev/null +++ b/include/internal/cef_time_wrappers.h @@ -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_ diff --git a/include/internal/cef_types.h b/include/internal/cef_types.h index 35308316e..3b4ca7d0e 100644 --- a/include/internal/cef_types.h +++ b/include/internal/cef_types.h @@ -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. diff --git a/include/internal/cef_types_wrappers.h b/include/internal/cef_types_wrappers.h index e6981e3fb..acb0f2244 100644 --- a/include/internal/cef_types_wrappers.h +++ b/include/internal/cef_types_wrappers.h @@ -581,45 +581,6 @@ struct CefURLPartsTraits { /// using CefURLParts = CefStructBase; -/// -// 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. /// diff --git a/libcef/browser/download_item_impl.cc b/libcef/browser/download_item_impl.cc index bffb74e32..d5e63981d 100644 --- a/libcef/browser/download_item_impl.cc +++ b/libcef/browser/download_item_impl.cc @@ -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() { diff --git a/libcef/browser/download_item_impl.h b/libcef/browser/download_item_impl.h index 55ea89dc1..8a02e629a 100644 --- a/libcef/browser/download_item_impl.h +++ b/libcef/browser/download_item_impl.h @@ -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; diff --git a/libcef/browser/navigation_entry_impl.cc b/libcef/browser/navigation_entry_impl.cc index f06bb547a..669424be2 100644 --- a/libcef/browser/navigation_entry_impl.cc +++ b/libcef/browser/navigation_entry_impl.cc @@ -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() { diff --git a/libcef/browser/navigation_entry_impl.h b/libcef/browser/navigation_entry_impl.h index c9afbafc6..98e89f395 100644 --- a/libcef/browser/navigation_entry_impl.h +++ b/libcef/browser/navigation_entry_impl.h @@ -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 GetSSLStatus() override; }; diff --git a/libcef/browser/net_service/cookie_manager_impl.cc b/libcef/browser/net_service/cookie_manager_impl.cc index a1849d0c8..bbc386238 100644 --- a/libcef/browser/net_service/cookie_manager_impl.cc +++ b/libcef/browser/net_service/cookie_manager_impl.cc @@ -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); diff --git a/libcef/browser/x509_certificate_impl.cc b/libcef/browser/x509_certificate_impl.cc index 0ae4c42ff..3acf39b1f 100644 --- a/libcef/browser/x509_certificate_impl.cc +++ b/libcef/browser/x509_certificate_impl.cc @@ -56,24 +56,18 @@ CefRefPtr 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 CefX509CertificateImpl::GetDEREncoded() { diff --git a/libcef/browser/x509_certificate_impl.h b/libcef/browser/x509_certificate_impl.h index 1685a8b2a..5178ca392 100644 --- a/libcef/browser/x509_certificate_impl.h +++ b/libcef/browser/x509_certificate_impl.h @@ -28,8 +28,8 @@ class CefX509CertificateImpl : public CefX509Certificate { CefRefPtr GetSubject() override; CefRefPtr GetIssuer() override; CefRefPtr GetSerialNumber() override; - CefTime GetValidStart() override; - CefTime GetValidExpiry() override; + CefBaseTime GetValidStart() override; + CefBaseTime GetValidExpiry() override; CefRefPtr GetDEREncoded() override; CefRefPtr GetPEMEncoded() override; size_t GetIssuerChainSize() override; diff --git a/libcef/browser/zip_reader_impl.cc b/libcef/browser/zip_reader_impl.cc index ff61ba894..b194c604a 100644 --- a/libcef/browser/zip_reader_impl.cc +++ b/libcef/browser/zip_reader_impl.cc @@ -6,6 +6,7 @@ #include #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) { diff --git a/libcef/browser/zip_reader_impl.h b/libcef/browser/zip_reader_impl.h index 722dbf959..3b623a236 100644 --- a/libcef/browser/zip_reader_impl.h +++ b/libcef/browser/zip_reader_impl.h @@ -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; diff --git a/libcef/common/alloy/alloy_main_delegate.cc b/libcef/common/alloy/alloy_main_delegate.cc index 103c82917..8ea9814b5 100644 --- a/libcef/common/alloy/alloy_main_delegate.cc +++ b/libcef/common/alloy/alloy_main_delegate.cc @@ -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(); diff --git a/libcef/common/net_service/net_service_util.cc b/libcef/common/net_service/net_service_util.cc index 1818fd1aa..f47f8f1f6 100644 --- a/libcef/common/net_service/net_service_util.cc +++ b/libcef/common/net_service/net_service_util.cc @@ -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 @@ -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()); diff --git a/libcef/common/time_impl.cc b/libcef/common/time_impl.cc index a2680fa65..e41e92a80 100644 --- a/libcef/common/time_impl.cc +++ b/libcef/common/time_impl.cc @@ -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 #include -#if BUILDFLAG(IS_WIN) -#include +// 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; +} diff --git a/libcef/renderer/v8_impl.cc b/libcef/renderer/v8_impl.cc index 4eb3e9e00..897524f97 100644 --- a/libcef/renderer/v8_impl.cc +++ b/libcef/renderer/v8_impl.cc @@ -1284,7 +1284,7 @@ CefRefPtr CefV8Value::CreateDouble(double value) { } // static -CefRefPtr CefV8Value::CreateDate(const CefTime& value) { +CefRefPtr CefV8Value::CreateDate(CefBaseTime value) { CEF_V8_REQUIRE_ISOLATE_RETURN(nullptr); v8::Isolate* isolate = GetIsolateManager()->isolate(); CefRefPtr impl = new CefV8ValueImpl(isolate); @@ -1522,8 +1522,8 @@ void CefV8ValueImpl::InitFromV8Value(v8::Local 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 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(CefBaseTime(date_value_)) + .ToJsTimeIgnoringNull()) .ToLocalChecked(); case TYPE_STRING: return GetV8String(isolate_, CefString(&string_value_)); @@ -1732,8 +1733,7 @@ bool CefV8ValueImpl::IsSame(CefRefPtr 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() { diff --git a/libcef/renderer/v8_impl.h b/libcef/renderer/v8_impl.h index 3dbb4ffc3..d2cf67435 100644 --- a/libcef/renderer/v8_impl.h +++ b/libcef/renderer/v8_impl.h @@ -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 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_; }; diff --git a/libcef_dll/cpptoc/download_item_cpptoc.cc b/libcef_dll/cpptoc/download_item_cpptoc.cc index 357d285c9..10afe3048 100644 --- a/libcef_dll/cpptoc/download_item_cpptoc.cc +++ b/libcef_dll/cpptoc/download_item_cpptoc.cc @@ -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; diff --git a/libcef_dll/cpptoc/navigation_entry_cpptoc.cc b/libcef_dll/cpptoc/navigation_entry_cpptoc.cc index 9db40c38f..d76373090 100644 --- a/libcef_dll/cpptoc/navigation_entry_cpptoc.cc +++ b/libcef_dll/cpptoc/navigation_entry_cpptoc.cc @@ -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; diff --git a/libcef_dll/cpptoc/v8value_cpptoc.cc b/libcef_dll/cpptoc/v8value_cpptoc.cc index 49dd142b0..2835130d6 100644 --- a/libcef_dll/cpptoc/v8value_cpptoc.cc +++ b/libcef_dll/cpptoc/v8value_cpptoc.cc @@ -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 _retval = CefV8Value::CreateDate(dateVal); + CefRefPtr _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; diff --git a/libcef_dll/cpptoc/x509certificate_cpptoc.cc b/libcef_dll/cpptoc/x509certificate_cpptoc.cc index e510b4d19..1731a8510 100644 --- a/libcef_dll/cpptoc/x509certificate_cpptoc.cc +++ b/libcef_dll/cpptoc/x509certificate_cpptoc.cc @@ -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; diff --git a/libcef_dll/cpptoc/zip_reader_cpptoc.cc b/libcef_dll/cpptoc/zip_reader_cpptoc.cc index a53a7a724..3c322f7ec 100644 --- a/libcef_dll/cpptoc/zip_reader_cpptoc.cc +++ b/libcef_dll/cpptoc/zip_reader_cpptoc.cc @@ -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; diff --git a/libcef_dll/ctocpp/download_item_ctocpp.cc b/libcef_dll/ctocpp/download_item_ctocpp.cc index 66f136e42..d12d311a4 100644 --- a/libcef_dll/ctocpp/download_item_ctocpp.cc +++ b/libcef_dll/ctocpp/download_item_ctocpp.cc @@ -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; diff --git a/libcef_dll/ctocpp/download_item_ctocpp.h b/libcef_dll/ctocpp/download_item_ctocpp.h index 07900a154..dd7ce6402 100644 --- a/libcef_dll/ctocpp/download_item_ctocpp.h +++ b/libcef_dll/ctocpp/download_item_ctocpp.h @@ -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 CefCToCppRefCountedget_completion_time(_struct); + cef_basetime_t _retval = _struct->get_completion_time(_struct); // Return type: simple return _retval; diff --git a/libcef_dll/ctocpp/navigation_entry_ctocpp.h b/libcef_dll/ctocpp/navigation_entry_ctocpp.h index ebaf7230e..5575ff013 100644 --- a/libcef_dll/ctocpp/navigation_entry_ctocpp.h +++ b/libcef_dll/ctocpp/navigation_entry_ctocpp.h @@ -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 GetSSLStatus() override; }; diff --git a/libcef_dll/ctocpp/v8value_ctocpp.cc b/libcef_dll/ctocpp/v8value_ctocpp.cc index 02607cd3c..aeeda972d 100644 --- a/libcef_dll/ctocpp/v8value_ctocpp.cc +++ b/libcef_dll/ctocpp/v8value_ctocpp.cc @@ -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::CreateDouble(double value) { } NO_SANITIZE("cfi-icall") -CefRefPtr CefV8Value::CreateDate(const CefTime& date) { +CefRefPtr 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; diff --git a/libcef_dll/ctocpp/v8value_ctocpp.h b/libcef_dll/ctocpp/v8value_ctocpp.h index c8363ea2b..b24d617a7 100644 --- a/libcef_dll/ctocpp/v8value_ctocpp.h +++ b/libcef_dll/ctocpp/v8value_ctocpp.h @@ -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; diff --git a/libcef_dll/ctocpp/x509certificate_ctocpp.cc b/libcef_dll/ctocpp/x509certificate_ctocpp.cc index 5dc3e32e1..fab26451b 100644 --- a/libcef_dll/ctocpp/x509certificate_ctocpp.cc +++ b/libcef_dll/ctocpp/x509certificate_ctocpp.cc @@ -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 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; diff --git a/libcef_dll/ctocpp/x509certificate_ctocpp.h b/libcef_dll/ctocpp/x509certificate_ctocpp.h index fd0994615..91bc798be 100644 --- a/libcef_dll/ctocpp/x509certificate_ctocpp.h +++ b/libcef_dll/ctocpp/x509certificate_ctocpp.h @@ -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 GetSubject() override; CefRefPtr GetIssuer() override; CefRefPtr GetSerialNumber() override; - CefTime GetValidStart() override; - CefTime GetValidExpiry() override; + CefBaseTime GetValidStart() override; + CefBaseTime GetValidExpiry() override; CefRefPtr GetDEREncoded() override; CefRefPtr GetPEMEncoded() override; size_t GetIssuerChainSize() override; diff --git a/libcef_dll/ctocpp/zip_reader_ctocpp.cc b/libcef_dll/ctocpp/zip_reader_ctocpp.cc index 381241d34..bd9ab1bce 100644 --- a/libcef_dll/ctocpp/zip_reader_ctocpp.cc +++ b/libcef_dll/ctocpp/zip_reader_ctocpp.cc @@ -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; diff --git a/libcef_dll/ctocpp/zip_reader_ctocpp.h b/libcef_dll/ctocpp/zip_reader_ctocpp.h index 5ba830824..390454d41 100644 --- a/libcef_dll/ctocpp/zip_reader_ctocpp.h +++ b/libcef_dll/ctocpp/zip_reader_ctocpp.h @@ -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 @@ -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, diff --git a/tests/cefclient/browser/client_handler.cc b/tests/cefclient/browser/client_handler.cc index d0e813411..2535f81c4 100644 --- a/tests/cefclient/browser/client_handler.cc +++ b/tests/cefclient/browser/client_handler.cc @@ -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 value) { if (!value.get()) return " "; diff --git a/tests/cefclient/renderer/performance_test.cc b/tests/cefclient/renderer/performance_test.cc index b88e3bdb4..51f906181 100644 --- a/tests/cefclient/renderer/performance_test.cc +++ b/tests/cefclient/renderer/performance_test.cc @@ -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!"); diff --git a/tests/cefclient/renderer/performance_test_tests.cc b/tests/cefclient/renderer/performance_test_tests.cc index 43e3879eb..b94df3620 100644 --- a/tests/cefclient/renderer/performance_test_tests.cc +++ b/tests/cefclient/renderer/performance_test_tests.cc @@ -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 value = CefV8Value::CreateDate(time); diff --git a/tests/ceftests/cookie_unittest.cc b/tests/ceftests/cookie_unittest.cc index 846a294ee..e5dfe5953 100644 --- a/tests/ceftests/cookie_unittest.cc +++ b/tests/ceftests/cookie_unittest.cc @@ -173,7 +173,9 @@ void CreateCookie(CefRefPtr 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 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); } diff --git a/tests/ceftests/navigation_unittest.cc b/tests/ceftests/navigation_unittest.cc index b9ef1acb3..edcb283e3 100644 --- a/tests/ceftests/navigation_unittest.cc +++ b/tests/ceftests/navigation_unittest.cc @@ -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_++; diff --git a/tests/ceftests/test_util.cc b/tests/ceftests/test_util.cc index 723c3129e..75b0eff4b 100644 --- a/tests/ceftests/test_util.cc +++ b/tests/ceftests/test_util.cc @@ -6,6 +6,7 @@ #include +#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 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); +} diff --git a/tests/ceftests/test_util.h b/tests/ceftests/test_util.h index 14906b734..e066bc4fa 100644 --- a/tests/ceftests/test_util.h +++ b/tests/ceftests/test_util.h @@ -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 diff --git a/tests/ceftests/time_unittest.cc b/tests/ceftests/time_unittest.cc new file mode 100644 index 000000000..d68beb4e4 --- /dev/null +++ b/tests/ceftests/time_unittest.cc @@ -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::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); +} diff --git a/tests/ceftests/v8_unittest.cc b/tests/ceftests/v8_unittest.cc index a7f392c0c..6605c96c9 100644 --- a/tests/ceftests/v8_unittest.cc +++ b/tests/ceftests/v8_unittest.cc @@ -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 value = CefV8Value::CreateDate(date); + CefRefPtr 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()); diff --git a/tools/cef_api_hash.py b/tools/cef_api_hash.py index 6dbecf5db..6f1eaa4a4 100644 --- a/tools/cef_api_hash.py +++ b/tools/cef_api_hash.py @@ -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", diff --git a/tools/cef_parser.py b/tools/cef_parser.py index 207b63bba..3a85c1d38 100644 --- a/tools/cef_parser.py +++ b/tools/cef_parser.py @@ -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()' ],