summaryrefslogtreecommitdiffstats
path: root/ppapi/example
diff options
context:
space:
mode:
authorcpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-02 19:18:18 +0000
committercpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-02 19:18:18 +0000
commit311ca5fe31d64e660156d2cc84d581e6ee3919dd (patch)
treee7ba3845eb1631bb34d74cd4211be0b643f3d4d7 /ppapi/example
parentfab05e7a2d4c272cf51c5a9cfd245665d96b553a (diff)
downloadchromium_src-311ca5fe31d64e660156d2cc84d581e6ee3919dd.zip
chromium_src-311ca5fe31d64e660156d2cc84d581e6ee3919dd.tar.gz
chromium_src-311ca5fe31d64e660156d2cc84d581e6ee3919dd.tar.bz2
Make FSP work for pepper
Basically cook gettimeofday for win32 BUG=none TEST=none Review URL: http://codereview.chromium.org/6880334 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83757 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/example')
-rw-r--r--ppapi/example/example.cc29
1 files changed, 26 insertions, 3 deletions
diff --git a/ppapi/example/example.cc b/ppapi/example/example.cc
index a47d365..f3965f2 100644
--- a/ppapi/example/example.cc
+++ b/ppapi/example/example.cc
@@ -6,6 +6,8 @@
#include <stdio.h> // FIXME(brettw) erase me.
#ifndef _WIN32
#include <sys/time.h>
+#else
+#include <windows.h>
#endif
#include <time.h>
@@ -275,9 +277,31 @@ class MyInstance : public pp::InstancePrivate, public MyFetcherClient {
Paint();
}
+#if defined(_WIN32)
+struct timeval {
+ long tv_sec;
+ long tv_usec;
+};
+
+struct timezone {
+ long x;
+ long y;
+};
+
+#define EPOCHFILETIME (116444736000000000i64)
+
+int gettimeofday(struct timeval *tv, struct timezone*) {
+ FILETIME ft;
+ ::GetSystemTimeAsFileTime(&ft);
+ LARGE_INTEGER li = {ft.dwLowDateTime, ft.dwHighDateTime};
+ __int64 t = li.QuadPart - EPOCHFILETIME;
+ tv->tv_sec = static_cast<long>(t / 10000000);
+ tv->tv_usec = static_cast<long>(t % 10000000);
+ return 0;
+}
+#endif // if defined(_WIN32)
+
void UpdateFps() {
-// Time code doesn't currently compile on Windows, just skip FPS for now.
-#ifndef _WIN32
pp::VarPrivate window = GetWindowObject();
pp::VarPrivate doc = window.GetProperty("document");
pp::VarPrivate fps = doc.Call("getElementById", "fps");
@@ -296,7 +320,6 @@ class MyInstance : public pp::InstancePrivate, public MyFetcherClient {
}
time_at_last_check_ = time_now;
-#endif
}
// Print interfaces.