summaryrefslogtreecommitdiffstats
path: root/webkit/plugins/ppapi
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-12 20:58:58 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-12 20:58:58 +0000
commit0141ba3ca96fe156474074493b277cf2fd352cc8 (patch)
tree164445cceedac7e91d4b19a0fca8c1c757197020 /webkit/plugins/ppapi
parenta8d4909721756525e14b9429db9c61a63932005d (diff)
downloadchromium_src-0141ba3ca96fe156474074493b277cf2fd352cc8.zip
chromium_src-0141ba3ca96fe156474074493b277cf2fd352cc8.tar.gz
chromium_src-0141ba3ca96fe156474074493b277cf2fd352cc8.tar.bz2
Move the time conversion code to the PPAPI shared_impl directory and use it in
the proxy for converting event times. This also removes the unnecessary GetInterface function from Graphics2D and has the module use the thunk directly. Review URL: http://codereview.chromium.org/7344009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92229 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/plugins/ppapi')
-rw-r--r--webkit/plugins/ppapi/event_conversion.cc4
-rw-r--r--webkit/plugins/ppapi/file_callbacks.cc4
-rw-r--r--webkit/plugins/ppapi/plugin_module.cc5
-rw-r--r--webkit/plugins/ppapi/plugin_module.h1
-rw-r--r--webkit/plugins/ppapi/ppb_file_io_impl.cc4
-rw-r--r--webkit/plugins/ppapi/ppb_file_ref_impl.cc3
-rw-r--r--webkit/plugins/ppapi/ppb_flash_file_impl.cc3
-rw-r--r--webkit/plugins/ppapi/ppb_flash_impl.cc6
-rw-r--r--webkit/plugins/ppapi/ppb_graphics_2d_impl.cc5
-rw-r--r--webkit/plugins/ppapi/ppb_graphics_2d_impl.h4
-rw-r--r--webkit/plugins/ppapi/time_conversion.cc51
-rw-r--r--webkit/plugins/ppapi/time_conversion.h29
-rw-r--r--webkit/plugins/ppapi/time_conversion_unittest.cc16
13 files changed, 28 insertions, 107 deletions
diff --git a/webkit/plugins/ppapi/event_conversion.cc b/webkit/plugins/ppapi/event_conversion.cc
index c0588e3..6632f5b 100644
--- a/webkit/plugins/ppapi/event_conversion.cc
+++ b/webkit/plugins/ppapi/event_conversion.cc
@@ -13,11 +13,13 @@
#include "base/utf_string_conversion_utils.h"
#include "ppapi/c/pp_input_event.h"
#include "ppapi/shared_impl/input_event_impl.h"
+#include "ppapi/shared_impl/time_conversion.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
#include "webkit/plugins/ppapi/common.h"
-#include "webkit/plugins/ppapi/time_conversion.h"
+using ppapi::EventTimeToPPTimeTicks;
using ppapi::InputEventData;
+using ppapi::PPTimeTicksToEventTime;
using WebKit::WebInputEvent;
using WebKit::WebKeyboardEvent;
using WebKit::WebMouseEvent;
diff --git a/webkit/plugins/ppapi/file_callbacks.cc b/webkit/plugins/ppapi/file_callbacks.cc
index d7e00ea..3cb1c08 100644
--- a/webkit/plugins/ppapi/file_callbacks.cc
+++ b/webkit/plugins/ppapi/file_callbacks.cc
@@ -8,13 +8,15 @@
#include "ppapi/c/pp_file_info.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/ppb_file_system.h"
+#include "ppapi/shared_impl/time_conversion.h"
#include "webkit/fileapi/file_system_types.h"
#include "webkit/plugins/ppapi/callbacks.h"
#include "webkit/plugins/ppapi/file_type_conversions.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppb_directory_reader_impl.h"
#include "webkit/plugins/ppapi/ppb_file_system_impl.h"
-#include "webkit/plugins/ppapi/time_conversion.h"
+
+using ppapi::TimeToPPTime;
namespace webkit {
namespace ppapi {
diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc
index 5daf60e..65d702d 100644
--- a/webkit/plugins/ppapi/plugin_module.cc
+++ b/webkit/plugins/ppapi/plugin_module.cc
@@ -73,6 +73,7 @@
#include "ppapi/c/trusted/ppb_file_io_trusted.h"
#include "ppapi/c/trusted/ppb_image_data_trusted.h"
#include "ppapi/c/trusted/ppb_url_loader_trusted.h"
+#include "ppapi/shared_impl/time_conversion.h"
#include "ppapi/thunk/enter.h"
#include "ppapi/thunk/thunk.h"
#include "webkit/plugins/ppapi/callbacks.h"
@@ -106,6 +107,8 @@
using ppapi::thunk::EnterResource;
using ppapi::thunk::PPB_Graphics2D_API;
+using ppapi::TimeTicksToPPTimeTicks;
+using ppapi::TimeToPPTime;
namespace webkit {
namespace ppapi {
@@ -282,7 +285,7 @@ const void* GetInterface(const char* name) {
if (strcmp(name, PPB_FULLSCREEN_DEV_INTERFACE) == 0)
return ::ppapi::thunk::GetPPB_Fullscreen_Thunk();
if (strcmp(name, PPB_GRAPHICS_2D_INTERFACE) == 0)
- return PPB_Graphics2D_Impl::GetInterface();
+ return ::ppapi::thunk::GetPPB_Graphics2D_Thunk();
if (strcmp(name, PPB_IMAGEDATA_INTERFACE) == 0)
return ::ppapi::thunk::GetPPB_ImageData_Thunk();
if (strcmp(name, PPB_IMAGEDATA_TRUSTED_INTERFACE) == 0)
diff --git a/webkit/plugins/ppapi/plugin_module.h b/webkit/plugins/ppapi/plugin_module.h
index e9bf1fe..52865bfc 100644
--- a/webkit/plugins/ppapi/plugin_module.h
+++ b/webkit/plugins/ppapi/plugin_module.h
@@ -21,7 +21,6 @@
#include "ppapi/c/pp_module.h"
#include "ppapi/c/ppb.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
-#include "webkit/plugins/ppapi/time_conversion.h"
class FilePath;
class MessageLoop;
diff --git a/webkit/plugins/ppapi/ppb_file_io_impl.cc b/webkit/plugins/ppapi/ppb_file_io_impl.cc
index 16a438a..9bf407e 100644
--- a/webkit/plugins/ppapi/ppb_file_io_impl.cc
+++ b/webkit/plugins/ppapi/ppb_file_io_impl.cc
@@ -15,6 +15,7 @@
#include "ppapi/c/trusted/ppb_file_io_trusted.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_errors.h"
+#include "ppapi/shared_impl/time_conversion.h"
#include "ppapi/thunk/enter.h"
#include "ppapi/thunk/ppb_file_ref_api.h"
#include "webkit/plugins/ppapi/common.h"
@@ -23,8 +24,9 @@
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/ppb_file_ref_impl.h"
#include "webkit/plugins/ppapi/resource_tracker.h"
-#include "webkit/plugins/ppapi/time_conversion.h"
+using ppapi::PPTimeToTime;
+using ppapi::TimeToPPTime;
using ppapi::thunk::EnterResourceNoLock;
using ppapi::thunk::PPB_FileIO_API;
using ppapi::thunk::PPB_FileRef_API;
diff --git a/webkit/plugins/ppapi/ppb_file_ref_impl.cc b/webkit/plugins/ppapi/ppb_file_ref_impl.cc
index 547218e..aa0f2ed 100644
--- a/webkit/plugins/ppapi/ppb_file_ref_impl.cc
+++ b/webkit/plugins/ppapi/ppb_file_ref_impl.cc
@@ -8,6 +8,7 @@
#include "base/utf_string_conversions.h"
#include "googleurl/src/gurl.h"
#include "ppapi/c/pp_errors.h"
+#include "ppapi/shared_impl/time_conversion.h"
#include "ppapi/thunk/enter.h"
#include "ppapi/thunk/ppb_file_system_api.h"
#include "webkit/plugins/ppapi/common.h"
@@ -17,9 +18,9 @@
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/ppb_directory_reader_impl.h"
#include "webkit/plugins/ppapi/ppb_file_system_impl.h"
-#include "webkit/plugins/ppapi/time_conversion.h"
#include "webkit/plugins/ppapi/var.h"
+using ppapi::PPTimeToTime;
using ppapi::thunk::EnterResourceNoLock;
using ppapi::thunk::PPB_FileRef_API;
using ppapi::thunk::PPB_FileSystem_API;
diff --git a/webkit/plugins/ppapi/ppb_flash_file_impl.cc b/webkit/plugins/ppapi/ppb_flash_file_impl.cc
index 3438cdb..9a1ac5a 100644
--- a/webkit/plugins/ppapi/ppb_flash_file_impl.cc
+++ b/webkit/plugins/ppapi/ppb_flash_file_impl.cc
@@ -11,6 +11,7 @@
#include "ppapi/c/pp_file_info.h"
#include "ppapi/c/ppb_file_io.h"
#include "ppapi/c/private/ppb_flash_file.h"
+#include "ppapi/shared_impl/time_conversion.h"
#include "ppapi/thunk/enter.h"
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/file_path.h"
@@ -20,7 +21,6 @@
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/ppb_file_ref_impl.h"
#include "webkit/plugins/ppapi/resource_tracker.h"
-#include "webkit/plugins/ppapi/time_conversion.h"
#if defined(OS_WIN)
#include "base/utf_string_conversions.h"
@@ -28,6 +28,7 @@
using ppapi::thunk::EnterResource;
using ppapi::thunk::PPB_FileRef_API;
+using ppapi::TimeToPPTime;
namespace webkit {
namespace ppapi {
diff --git a/webkit/plugins/ppapi/ppb_flash_impl.cc b/webkit/plugins/ppapi/ppb_flash_impl.cc
index bf537b5..ffd519d 100644
--- a/webkit/plugins/ppapi/ppb_flash_impl.cc
+++ b/webkit/plugins/ppapi/ppb_flash_impl.cc
@@ -10,6 +10,7 @@
#include "base/time.h"
#include "googleurl/src/gurl.h"
#include "ppapi/c/private/ppb_flash.h"
+#include "ppapi/shared_impl/time_conversion.h"
#include "ppapi/thunk/enter.h"
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
@@ -17,9 +18,9 @@
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/ppb_url_request_info_impl.h"
#include "webkit/plugins/ppapi/resource_tracker.h"
-#include "webkit/plugins/ppapi/time_conversion.h"
#include "webkit/plugins/ppapi/var.h"
+using ppapi::PPTimeToTime;
using ppapi::thunk::EnterResource;
using ppapi::thunk::PPB_URLRequestInfo_API;
@@ -95,8 +96,7 @@ double GetLocalTimeZoneOffset(PP_Instance pp_instance, PP_Time t) {
// We can't do the conversion here because on Linux, the localtime calls
// require filesystem access prohibited by the sandbox.
- return instance->delegate()->GetLocalTimeZoneOffset(
- PPTimeToTime(t));
+ return instance->delegate()->GetLocalTimeZoneOffset(PPTimeToTime(t));
}
PP_Var GetCommandLineArgs(PP_Module pp_module) {
diff --git a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
index 77da1e2..493b344 100644
--- a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
+++ b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
@@ -174,11 +174,6 @@ PP_Resource PPB_Graphics2D_Impl::Create(PluginInstance* instance,
return graphics_2d->GetReference();
}
-// static
-const PPB_Graphics2D* PPB_Graphics2D_Impl::GetInterface() {
- return ::ppapi::thunk::GetPPB_Graphics2D_Thunk();
-}
-
bool PPB_Graphics2D_Impl::Init(int width, int height, bool is_always_opaque) {
// The underlying PPB_ImageData_Impl will validate the dimensions.
image_data_ = new PPB_ImageData_Impl(instance());
diff --git a/webkit/plugins/ppapi/ppb_graphics_2d_impl.h b/webkit/plugins/ppapi/ppb_graphics_2d_impl.h
index 808ab32..2c96584 100644
--- a/webkit/plugins/ppapi/ppb_graphics_2d_impl.h
+++ b/webkit/plugins/ppapi/ppb_graphics_2d_impl.h
@@ -37,10 +37,6 @@ class PPB_Graphics2D_Impl
const PP_Size& size,
PP_Bool is_always_opaque);
- // Returns a pointer to the interface implementing PPB_ImageData that is
- // exposed to the plugin.
- static const PPB_Graphics2D* GetInterface();
-
bool is_always_opaque() const { return is_always_opaque_; }
virtual ::ppapi::thunk::PPB_Graphics2D_API* AsPPB_Graphics2D_API();
diff --git a/webkit/plugins/ppapi/time_conversion.cc b/webkit/plugins/ppapi/time_conversion.cc
deleted file mode 100644
index 089d009..0000000
--- a/webkit/plugins/ppapi/time_conversion.cc
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "webkit/plugins/ppapi/time_conversion.h"
-
-namespace webkit {
-namespace ppapi {
-
-namespace {
-
-// Since WebKit doesn't use ticks for event times, we have to compute what
-// the time ticks would be assuming the wall clock time doesn't change.
-//
-// This should only be used for WebKit times which we can't change the
-// definition of.
-double GetTimeToTimeTicksDeltaInSeconds() {
- static double time_to_ticks_delta_seconds = 0.0;
- if (time_to_ticks_delta_seconds == 0.0) {
- double wall_clock = TimeToPPTime(base::Time::Now());
- double ticks = TimeTicksToPPTimeTicks(base::TimeTicks::Now());
- time_to_ticks_delta_seconds = ticks - wall_clock;
- }
- return time_to_ticks_delta_seconds;
-}
-
-} // namespace
-
-PP_Time TimeToPPTime(base::Time t) {
- return t.ToDoubleT();
-}
-
-base::Time PPTimeToTime(PP_Time t) {
- return base::Time::FromDoubleT(t);
-}
-
-PP_TimeTicks TimeTicksToPPTimeTicks(base::TimeTicks t) {
- return static_cast<double>(t.ToInternalValue()) /
- base::Time::kMicrosecondsPerSecond;
-}
-
-PP_TimeTicks EventTimeToPPTimeTicks(double event_time) {
- return event_time + GetTimeToTimeTicksDeltaInSeconds();
-}
-
-double PPTimeTicksToEventTime(PP_TimeTicks t) {
- return t - GetTimeToTimeTicksDeltaInSeconds();
-}
-
-} // namespace ppapi
-} // namespace webkit
diff --git a/webkit/plugins/ppapi/time_conversion.h b/webkit/plugins/ppapi/time_conversion.h
deleted file mode 100644
index 13050e4..0000000
--- a/webkit/plugins/ppapi/time_conversion.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef WEBKIT_PLUGINS_PPAPI_TIME_CONVERSION_H_
-#define WEBKIT_PLUGINS_PPAPI_TIME_CONVERSION_H_
-
-#include "base/time.h"
-#include "ppapi/c/pp_time.h"
-
-namespace webkit {
-namespace ppapi {
-
-PP_Time TimeToPPTime(base::Time t);
-base::Time PPTimeToTime(PP_Time t);
-
-PP_TimeTicks TimeTicksToPPTimeTicks(base::TimeTicks t);
-
-// Converts between WebKit event times and time ticks. WebKit event times are
-// currently expressed in terms of wall clock time. This function does the
-// proper mapping to time ticks, assuming the wall clock time doesn't change
-// (which isn't necessarily the case).
-PP_TimeTicks EventTimeToPPTimeTicks(double event_time);
-double PPTimeTicksToEventTime(PP_TimeTicks t);
-
-} // namespace ppapi
-} // namespace webkit
-
-#endif // WEBKIT_PLUGINS_PPAPI_TIME_CONVERSION_H_
diff --git a/webkit/plugins/ppapi/time_conversion_unittest.cc b/webkit/plugins/ppapi/time_conversion_unittest.cc
index 4defd96..d94dd22 100644
--- a/webkit/plugins/ppapi/time_conversion_unittest.cc
+++ b/webkit/plugins/ppapi/time_conversion_unittest.cc
@@ -6,9 +6,8 @@
#include <stdlib.h>
#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/plugins/ppapi/time_conversion.h"
+#include "ppapi/shared_impl/time_conversion.h"
-namespace webkit {
namespace ppapi {
// Slop we'll allow in two Time "internal values" to consider them equal.
@@ -30,29 +29,30 @@ static const double kTimeSecondsSlop =
TEST(TimeConversion, MAYBE_Time) {
// Should be able to round-trip.
base::Time now = base::Time::Now();
- base::Time converted = PPTimeToTime(TimeToPPTime(now));
+ base::Time converted = ppapi::PPTimeToTime(TimeToPPTime(now));
EXPECT_GE(kTimeInternalValueSlop,
abs(static_cast<int>((converted - now).ToInternalValue())));
// Units should be in seconds.
base::Time one_second_from_now = now + base::TimeDelta::FromSeconds(1);
- EXPECT_EQ(1.0, TimeToPPTime(one_second_from_now) - TimeToPPTime(now));
+ EXPECT_EQ(1.0, ppapi::TimeToPPTime(one_second_from_now) -
+ ppapi::TimeToPPTime(now));
}
TEST(TimeConversion, EventTime) {
// Should be able to round-trip.
base::Time now = base::Time::Now();
double event_now = now.ToDoubleT();
- double converted = EventTimeToPPTimeTicks(PPTimeTicksToEventTime(event_now));
+ double converted =
+ ppapi::EventTimeToPPTimeTicks(ppapi::PPTimeTicksToEventTime(event_now));
EXPECT_GE(kTimeSecondsSlop, fabs(converted - event_now));
// Units should be in seconds.
base::Time one_second_from_now = now + base::TimeDelta::FromSeconds(1);
double event_one_second_from_now = one_second_from_now.ToDoubleT();
EXPECT_GE(kTimeSecondsSlop,
- 1.0 - EventTimeToPPTimeTicks(event_one_second_from_now) -
- EventTimeToPPTimeTicks(event_now));
+ 1.0 - ppapi::EventTimeToPPTimeTicks(event_one_second_from_now) -
+ ppapi::EventTimeToPPTimeTicks(event_now));
}
} // namespace ppapi
-} // namespace webkit