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

Unified Diff: webkit/extensions/v8/interval_extension.cc

Issue 40132: Refactor v8 extensions to make registration avoid having to use ChromiumBridg... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/extensions/v8/interval_extension.h ('k') | webkit/extensions/v8/playback_extension.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/extensions/v8/interval_extension.cc
===================================================================
--- webkit/extensions/v8/interval_extension.cc (revision 0)
+++ webkit/extensions/v8/interval_extension.cc (working copy)
@@ -2,56 +2,58 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "config.h"
-#include "Interval.h"
-#include "wtf/CurrentTime.h"
+#include "base/time.h"
+#include "webkit/extensions/v8/interval_extension.h"
darin (slow to review) 2009/03/05 17:42:25 minor style nit: foo.cc should list the foo.h incl
-namespace WebCore {
+namespace extensions_v8 {
const char* kIntervalExtensionName = "v8/Interval";
class IntervalExtensionWrapper : public v8::Extension {
-public:
- IntervalExtensionWrapper() :
- v8::Extension(kIntervalExtensionName,
- "var chromium;"
- "if (!chromium)"
- " chromium = {};"
- "chromium.Interval = function() {"
- " var start_ = 0;"
- " var stop_ = 0;"
- " native function HiResTime();"
- " this.start = function() {"
- " stop_ = 0;"
- " start_ = HiResTime();"
- " };"
- " this.stop = function() {"
- " stop_ = HiResTime();"
- " if (start_ == 0)"
- " stop_ = 0;"
- " };"
- " this.microseconds = function() {"
- " var stop = stop_;"
- " if (stop == 0 && start_ != 0)"
- " stop = HiResTime();"
- " return Math.ceil((stop - start_) * 1000000);"
- " };"
- "}") {};
+ public:
+ IntervalExtensionWrapper()
+ : v8::Extension(
+ kIntervalExtensionName,
+ "var chromium;"
+ "if (!chromium)"
+ " chromium = {};"
+ "chromium.Interval = function() {"
+ " var start_ = 0;"
+ " var stop_ = 0;"
+ " native function HiResTime();"
+ " this.start = function() {"
+ " stop_ = 0;"
+ " start_ = HiResTime();"
+ " };"
+ " this.stop = function() {"
+ " stop_ = HiResTime();"
+ " if (start_ == 0)"
+ " stop_ = 0;"
+ " };"
+ " this.microseconds = function() {"
+ " var stop = stop_;"
+ " if (stop == 0 && start_ != 0)"
+ " stop = HiResTime();"
+ " return Math.ceil((stop - start_) * 1000000);"
+ " };"
+ "}") {}
- virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(v8::Handle<v8::String> name) {
- if (name->Equals(v8::String::New("HiResTime")))
- return v8::FunctionTemplate::New(HiResTime);
- return v8::Handle<v8::FunctionTemplate>();
+ virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
+ v8::Handle<v8::String> name) {
+ if (name->Equals(v8::String::New("HiResTime"))) {
+ return v8::FunctionTemplate::New(HiResTime);
+ }
+ return v8::Handle<v8::FunctionTemplate>();
}
static v8::Handle<v8::Value> HiResTime(const v8::Arguments& args) {
- return v8::Number::New(WTF::currentTime());
+ return v8::Number::New(base::Time::Now().ToDoubleT());
}
};
v8::Extension* IntervalExtension::Get() {
- return new IntervalExtensionWrapper();
+ return new IntervalExtensionWrapper();
}
-}
+} // namespace extensions_v8
Property changes on: webkit\extensions\v8\interval_extension.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « webkit/extensions/v8/interval_extension.h ('k') | webkit/extensions/v8/playback_extension.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698