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

Side by Side Diff: sky/viewer/platform/platform_impl.cc

Issue 887883002: WTF should get time from base directly (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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 | « sky/viewer/platform/platform_impl.h ('k') | no next file » | 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 "sky/viewer/platform/platform_impl.h" 5 #include "sky/viewer/platform/platform_impl.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 network_service_->GetCookieStore(GetProxy(&cookie_store)); 52 network_service_->GetCookieStore(GetProxy(&cookie_store));
53 } 53 }
54 54
55 PlatformImpl::~PlatformImpl() { 55 PlatformImpl::~PlatformImpl() {
56 } 56 }
57 57
58 blink::WebString PlatformImpl::defaultLocale() { 58 blink::WebString PlatformImpl::defaultLocale() {
59 return blink::WebString::fromUTF8("en-US"); 59 return blink::WebString::fromUTF8("en-US");
60 } 60 }
61 61
62 double PlatformImpl::currentTime() {
63 return base::Time::Now().ToDoubleT();
64 }
65
66 double PlatformImpl::monotonicallyIncreasingTime() {
67 return base::TimeTicks::Now().ToInternalValue() /
68 static_cast<double>(base::Time::kMicrosecondsPerSecond);
69 }
70
71 void PlatformImpl::setSharedTimerFiredFunction(void (*func)()) { 62 void PlatformImpl::setSharedTimerFiredFunction(void (*func)()) {
72 shared_timer_func_ = func; 63 shared_timer_func_ = func;
73 } 64 }
74 65
75 void PlatformImpl::setSharedTimerFireInterval( 66 void PlatformImpl::setSharedTimerFireInterval(
76 double interval_seconds) { 67 double interval_seconds) {
77 shared_timer_fire_time_ = interval_seconds + monotonicallyIncreasingTime(); 68 double now = base::TimeTicks::Now().ToInternalValue() /
69 static_cast<double>(base::Time::kMicrosecondsPerSecond);
70
71 shared_timer_fire_time_ = interval_seconds + now;
78 if (shared_timer_suspended_) { 72 if (shared_timer_suspended_) {
79 shared_timer_fire_time_was_set_while_suspended_ = true; 73 shared_timer_fire_time_was_set_while_suspended_ = true;
80 return; 74 return;
81 } 75 }
82 76
83 // By converting between double and int64 representation, we run the risk 77 // By converting between double and int64 representation, we run the risk
84 // of losing precision due to rounding errors. Performing computations in 78 // of losing precision due to rounding errors. Performing computations in
85 // microseconds reduces this risk somewhat. But there still is the potential 79 // microseconds reduces this risk somewhat. But there still is the potential
86 // of us computing a fire time for the timer that is shorter than what we 80 // of us computing a fire time for the timer that is shorter than what we
87 // need. 81 // need.
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 const unsigned char* category_group_enabled, 207 const unsigned char* category_group_enabled,
214 const char* name, 208 const char* name,
215 TraceEventHandle handle) { 209 TraceEventHandle handle) {
216 base::debug::TraceEventHandle traceEventHandle; 210 base::debug::TraceEventHandle traceEventHandle;
217 memcpy(&traceEventHandle, &handle, sizeof(handle)); 211 memcpy(&traceEventHandle, &handle, sizeof(handle));
218 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION( 212 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(
219 category_group_enabled, name, traceEventHandle); 213 category_group_enabled, name, traceEventHandle);
220 } 214 }
221 215
222 } // namespace sky 216 } // namespace sky
OLDNEW
« no previous file with comments | « sky/viewer/platform/platform_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698