OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
3 // LICENSE file. | 3 // LICENSE file. |
4 | 4 |
5 #include <math.h> | |
6 #include "config.h" | 5 #include "config.h" |
7 | 6 |
8 #include "FrameView.h" | 7 #include "FrameView.h" |
9 #include "ScrollView.h" | 8 #include "ScrollView.h" |
10 #include <wtf/Assertions.h> | 9 #include <wtf/Assertions.h> |
11 #undef LOG | 10 #undef LOG |
12 | 11 |
13 #include "webkit/glue/webkitclient_impl.h" | 12 #include "webkit/glue/webkitclient_impl.h" |
14 | 13 |
15 #include "base/file_path.h" | 14 #include "base/file_path.h" |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 | 258 |
260 double WebKitClientImpl::currentTime() { | 259 double WebKitClientImpl::currentTime() { |
261 return base::Time::Now().ToDoubleT(); | 260 return base::Time::Now().ToDoubleT(); |
262 } | 261 } |
263 | 262 |
264 void WebKitClientImpl::setSharedTimerFiredFunction(void (*func)()) { | 263 void WebKitClientImpl::setSharedTimerFiredFunction(void (*func)()) { |
265 shared_timer_func_ = func; | 264 shared_timer_func_ = func; |
266 } | 265 } |
267 | 266 |
268 void WebKitClientImpl::setSharedTimerFireTime(double fire_time) { | 267 void WebKitClientImpl::setSharedTimerFireTime(double fire_time) { |
269 // By converting between double and int64 representation, we run the risk | 268 int interval = static_cast<int>((fire_time - currentTime()) * 1000); |
270 // of losing precision due to rounding errors. Performing computations in | |
271 // microseconds reduces this risk somewhat. But there still is the potential | |
272 // of us computing a fire time for the timer that is shorter than what we | |
273 // need. | |
274 // As the event loop will check event deadlines prior to actually firing | |
275 // them, there is a risk of needlessly rescheduling events and of | |
276 // needlessly looping if sleep times are too short even by small amounts. | |
277 // This results in measurable performance degradation unless we use ceil() to | |
278 // always round up the sleep times. | |
279 int64 interval = static_cast<int64>( | |
280 ceil((fire_time - currentTime()) * base::Time::kMicrosecondsPerSecond)); | |
281 if (interval < 0) | 269 if (interval < 0) |
282 interval = 0; | 270 interval = 0; |
283 | 271 |
284 shared_timer_.Stop(); | 272 shared_timer_.Stop(); |
285 shared_timer_.Start(base::TimeDelta::FromMicroseconds(interval), this, | 273 shared_timer_.Start(base::TimeDelta::FromMilliseconds(interval), this, |
286 &WebKitClientImpl::DoTimeout); | 274 &WebKitClientImpl::DoTimeout); |
287 } | 275 } |
288 | 276 |
289 void WebKitClientImpl::stopSharedTimer() { | 277 void WebKitClientImpl::stopSharedTimer() { |
290 shared_timer_.Stop(); | 278 shared_timer_.Stop(); |
291 } | 279 } |
292 | 280 |
293 void WebKitClientImpl::callOnMainThread(void (*func)()) { | 281 void WebKitClientImpl::callOnMainThread(void (*func)()) { |
294 main_loop_->PostTask(FROM_HERE, NewRunnableFunction(func)); | 282 main_loop_->PostTask(FROM_HERE, NewRunnableFunction(func)); |
295 } | 283 } |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 ChromeClientImpl* chrome_client = ToChromeClient(widget); | 456 ChromeClientImpl* chrome_client = ToChromeClient(widget); |
469 if (chrome_client) | 457 if (chrome_client) |
470 chrome_client->focus(); | 458 chrome_client->focus(); |
471 } | 459 } |
472 | 460 |
473 WebCore::WorkerContextProxy* WebKitClientImpl::createWorkerContextProxy( | 461 WebCore::WorkerContextProxy* WebKitClientImpl::createWorkerContextProxy( |
474 WebCore::Worker* worker) { | 462 WebCore::Worker* worker) { |
475 return WebWorkerClientImpl::createWorkerContextProxy(worker); | 463 return WebWorkerClientImpl::createWorkerContextProxy(worker); |
476 } | 464 } |
477 } // namespace webkit_glue | 465 } // namespace webkit_glue |
OLD | NEW |