Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(664)

Side by Side Diff: content/browser/devtools/protocol/input_handler.cc

Issue 1747383002: Convert Devtools protocol Input timestamp to monotonic clock (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/inspector-protocol/input/eventTimestamp.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/devtools/protocol/input_handler.h" 5 #include "content/browser/devtools/protocol/input_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 event->modifiers |= blink::WebInputEvent::AltKey; 62 event->modifiers |= blink::WebInputEvent::AltKey;
63 if (*modifiers & 2) 63 if (*modifiers & 2)
64 event->modifiers |= blink::WebInputEvent::ControlKey; 64 event->modifiers |= blink::WebInputEvent::ControlKey;
65 if (*modifiers & 4) 65 if (*modifiers & 4)
66 event->modifiers |= blink::WebInputEvent::MetaKey; 66 event->modifiers |= blink::WebInputEvent::MetaKey;
67 if (*modifiers & 8) 67 if (*modifiers & 8)
68 event->modifiers |= blink::WebInputEvent::ShiftKey; 68 event->modifiers |= blink::WebInputEvent::ShiftKey;
69 } 69 }
70 70
71 void SetEventTimestamp(blink::WebInputEvent* event, const double* timestamp) { 71 void SetEventTimestamp(blink::WebInputEvent* event, const double* timestamp) {
72 event->timeStampSeconds = 72 // Convert timestamp, in seconds since unix epoch, to an event timestamp
73 timestamp ? *timestamp : base::Time::Now().ToDoubleT(); 73 // which is time ticks since platform start time.
74 base::TimeTicks ticks = timestamp
75 ? base::TimeDelta::FromSecondsD(*timestamp) +
76 base::TimeTicks::UnixEpoch()
77 : base::TimeTicks::Now();
78 event->timeStampSeconds = (ticks - base::TimeTicks()).InSecondsF();
74 } 79 }
75 80
76 bool SetKeyboardEventText(blink::WebUChar* to, const std::string* from) { 81 bool SetKeyboardEventText(blink::WebUChar* to, const std::string* from) {
77 if (!from) 82 if (!from)
78 return true; 83 return true;
79 84
80 base::string16 text16 = base::UTF8ToUTF16(*from); 85 base::string16 text16 = base::UTF8ToUTF16(*from);
81 if (text16.size() > blink::WebKeyboardEvent::textLengthCap) 86 if (text16.size() > blink::WebKeyboardEvent::textLengthCap)
82 return false; 87 return false;
83 88
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 } else { 517 } else {
513 client_->SendError(command_id, 518 client_->SendError(command_id,
514 Response::InternalError(base::StringPrintf( 519 Response::InternalError(base::StringPrintf(
515 "Synthetic tap failed, result was %d", result))); 520 "Synthetic tap failed, result was %d", result)));
516 } 521 }
517 } 522 }
518 523
519 } // namespace input 524 } // namespace input
520 } // namespace devtools 525 } // namespace devtools
521 } // namespace content 526 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/inspector-protocol/input/eventTimestamp.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698