Input.TimeSinceEpoch question

37 views
Skip to first unread message

Niranjan Rao

unread,
Apr 22, 2024, 5:06:58 PMApr 22
to chrome-debugging-protocol

Greetings,


Input.TimeSinceEpoch object as defined at https://chromedevtools.github.io/devtools-protocol/tot/Input/#type-TimeSinceEpoch says UTC time in seconds, counted from January 1, 1970.


Looking at https://source.chromium.org/chromium/chromium/src/+/main:content/browser/devtools/protocol/input_handler.cc;drc=aac75e1d42c143ae268bd6adfdec9191f2cc1c33;l=125, it looks like base::TimeTicks::UnixEpoch() is being added to the value.


My understanding is this will cause the value to be almost doubled as input parameter is UTC time in seconds.


Is my understanding correct?


Regards,

Niranjan

--
Niranjan Rao | Sr.Architect
he/his
Paymentus
Paymentus Corporation The Real-Time Bill Payment CompanyTM
860 Hillview Court Suite 220 Milpitas CA 95035
www.paymentus.com

Benedikt Meurer

unread,
Apr 23, 2024, 1:12:16 AMApr 23
to Niranjan Rao, chrome-debugging-protocol
Hey Niranjan,

I'm not sure I understand the question correctly, so my response might not necessarily help you.

In DispatchKeyEvent(), you see that timestamp is expected to be passed as UTC time in seconds since the epoch, which is translated by the call to GetEventTimeTicks() to proper base::TimeTicks that Chromium uses internally.

HTH,
Benedikt

--
You received this message because you are subscribed to the Google Groups "chrome-debugging-protocol" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chrome-debugging-p...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/chrome-debugging-protocol/8aac7387-9c1a-493c-9ccf-918b88c62d7d%40paymentus.com.


--

Benedikt Meurer

Chrome DevTools Manager

bme...@google.com


Google Germany GmbH

Erika-Mann-Straße 33

80636 München


Geschäftsführer: Paul Manicle, Liana Sebastian

Registergericht und -nummer: Hamburg, HRB 86891

Sitz der Gesellschaft: Hamburg


Diese E-Mail ist vertraulich. Falls Sie diese fälschlicherweise erhalten haben sollten, leiten Sie diese bitte nicht an jemand anderes weiter, löschen Sie alle Kopien und Anhänge davon und lassen Sie mich bitte wissen, dass die E-Mail an die falsche Person gesendet wurde. 

     

This e-mail is confidential. If you received this communication by mistake, please don't forward it to anyone else, please erase all copies and attachments, and please let me know that it has gone to the wrong person.

Niranjan Rao

unread,
Apr 23, 2024, 7:07:29 PMApr 23
to Benedikt Meurer, chrome-debugging-protocol

Hi Benedikt,


Thank you for the response. You can blame it on my lack of understanding of chromium code.

Here is what I am trying to say

As per documentation, I need to send epoch seconds - number of seconds since Jan 1st, 1970.


If I look at input_handler.cc, it has following code. To me this looks like timeStamp value which is already epoch seconds and you are adding UnixEpoch to that. Not sure if there's is other base functions/macros creating magic.


base::TimeTicks GetEventTimeTicks(const Maybe<double>& timestamp) {
// Convert timestamp, in seconds since unix epoch, to an event timestamp
// which is time ticks since platform start time.
return timestamp.has_value()
? base::Seconds(timestamp.value()) + base::TimeTicks::UnixEpoch()
: base::TimeTicks::Now();
}



Regards,


Niranjan

On 4/22/24 22:11, Benedikt Meurer wrote:
Hey Niranjan, I'm not sure I understand the question correctly, so my response might not necessarily help you. In DispatchKeyEvent(), you see that timestamp is expected to be passed as UTC time in seconds since the epoch, which is translated
ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
 
ZjQcmQRYFpfptBannerEnd

Andrey Kosyakov

unread,
Apr 23, 2024, 10:04:17 PMApr 23
to Niranjan Rao, chrome-debugging-protocol
On Mon, Apr 22, 2024 at 2:06 PM Niranjan Rao <nr...@paymentus.com> wrote:

Greetings,

Input.TimeSinceEpoch object as defined at https://chromedevtools.github.io/devtools-protocol/tot/Input/#type-TimeSinceEpoch says UTC time in seconds, counted from January 1, 1970.

Looking at https://source.chromium.org/chromium/chromium/src/+/main:content/browser/devtools/protocol/input_handler.cc;drc=aac75e1d42c143ae268bd6adfdec9191f2cc1c33;l=125, it looks like base::TimeTicks::UnixEpoch() is being added to the value.

My understanding is this will cause the value to be almost doubled as input parameter is UTC time in seconds.

Is my understanding correct?

base::TimeTicks::UnixEpoch() is a value of TimeTicks at Epoch. So if you were to sent 0, adding base::TimeTicks::UnixEpoch() would yield TimeTicks value for January 1, 1970, and if you were to send 1713830400, adding base::TimeTicks::UnixEpoch() would yield time ticks representation equal to April, 23, 2024. Note the resulting value is of a TimeTicks type and may as well use some internal time base (and the value of base::TimeTicks::UnixEpoch() is not necessarily positive).

Here's a test that covers how timestamps are interpreted, you can use it as a base if you'd like to explore how things work.

Best regards,
Andrey. 
Reply all
Reply to author
Forward
0 new messages