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

Side by Side Diff: webkit/glue/webkitclient_impl.cc

Issue 257044: This is a second attempt at submitting this changelist. The original one was... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « net/socket/tcp_client_socket_pool_unittest.cc ('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 (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>
5 #include "config.h" 6 #include "config.h"
6 7
7 #include "FrameView.h" 8 #include "FrameView.h"
8 #include "ScrollView.h" 9 #include "ScrollView.h"
9 #include <wtf/Assertions.h> 10 #include <wtf/Assertions.h>
10 #undef LOG 11 #undef LOG
11 12
12 #include "webkit/glue/webkitclient_impl.h" 13 #include "webkit/glue/webkitclient_impl.h"
13 14
14 #include "base/file_path.h" 15 #include "base/file_path.h"
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 261
261 double WebKitClientImpl::currentTime() { 262 double WebKitClientImpl::currentTime() {
262 return base::Time::Now().ToDoubleT(); 263 return base::Time::Now().ToDoubleT();
263 } 264 }
264 265
265 void WebKitClientImpl::setSharedTimerFiredFunction(void (*func)()) { 266 void WebKitClientImpl::setSharedTimerFiredFunction(void (*func)()) {
266 shared_timer_func_ = func; 267 shared_timer_func_ = func;
267 } 268 }
268 269
269 void WebKitClientImpl::setSharedTimerFireTime(double fire_time) { 270 void WebKitClientImpl::setSharedTimerFireTime(double fire_time) {
270 int interval = static_cast<int>((fire_time - currentTime()) * 1000); 271 // By converting between double and int64 representation, we run the risk
272 // of losing precision due to rounding errors. Performing computations in
273 // microseconds reduces this risk somewhat. But there still is the potential
274 // of us computing a fire time for the timer that is shorter than what we
275 // need.
276 // As the event loop will check event deadlines prior to actually firing
277 // them, there is a risk of needlessly rescheduling events and of
278 // needlessly looping if sleep times are too short even by small amounts.
279 // This results in measurable performance degradation unless we use ceil() to
280 // always round up the sleep times.
281 int64 interval = static_cast<int64>(
282 ceil((fire_time - currentTime()) * base::Time::kMicrosecondsPerSecond));
271 if (interval < 0) 283 if (interval < 0)
272 interval = 0; 284 interval = 0;
273 285
274 shared_timer_.Stop(); 286 shared_timer_.Stop();
275 shared_timer_.Start(base::TimeDelta::FromMilliseconds(interval), this, 287 shared_timer_.Start(base::TimeDelta::FromMicroseconds(interval), this,
276 &WebKitClientImpl::DoTimeout); 288 &WebKitClientImpl::DoTimeout);
277 } 289 }
278 290
279 void WebKitClientImpl::stopSharedTimer() { 291 void WebKitClientImpl::stopSharedTimer() {
280 shared_timer_.Stop(); 292 shared_timer_.Stop();
281 } 293 }
282 294
283 void WebKitClientImpl::callOnMainThread(void (*func)()) { 295 void WebKitClientImpl::callOnMainThread(void (*func)()) {
284 main_loop_->PostTask(FROM_HERE, NewRunnableFunction(func)); 296 main_loop_->PostTask(FROM_HERE, NewRunnableFunction(func));
285 } 297 }
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 return file_util::DirectoryExists(file_path); 506 return file_util::DirectoryExists(file_path);
495 } 507 }
496 508
497 WebKit::WebURL WebKitClientImpl::filePathToURL(const WebKit::WebString& path) { 509 WebKit::WebURL WebKitClientImpl::filePathToURL(const WebKit::WebString& path) {
498 FilePath file_path(webkit_glue::WebStringToFilePathString(path)); 510 FilePath file_path(webkit_glue::WebStringToFilePathString(path));
499 GURL file_url = net::FilePathToFileURL(file_path); 511 GURL file_url = net::FilePathToFileURL(file_path);
500 return webkit_glue::KURLToWebURL(webkit_glue::GURLToKURL(file_url)); 512 return webkit_glue::KURLToWebURL(webkit_glue::GURLToKURL(file_url));
501 } 513 }
502 514
503 } // namespace webkit_glue 515 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « net/socket/tcp_client_socket_pool_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698