diff options
author | kbr@google.com <kbr@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-02 21:53:49 +0000 |
---|---|---|
committer | kbr@google.com <kbr@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-02 21:53:49 +0000 |
commit | ff309b3ff56471cf49b9a95378078ed37437192f (patch) | |
tree | 133f2fc49c70ed9944fdbdf16ac0298ba942e4f4 /o3d | |
parent | 71cb533c8712331906346ddea2fce0c3fccec78c (diff) | |
download | chromium_src-ff309b3ff56471cf49b9a95378078ed37437192f.zip chromium_src-ff309b3ff56471cf49b9a95378078ed37437192f.tar.gz chromium_src-ff309b3ff56471cf49b9a95378078ed37437192f.tar.bz2 |
Prevent Client::Tick() from causing reentrancy in the plugin on Mac OS X.
Tested with client application.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/2451002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48770 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d')
-rw-r--r-- | o3d/core/cross/client.cc | 3 | ||||
-rw-r--r-- | o3d/core/cross/client.h | 9 | ||||
-rw-r--r-- | o3d/plugin/mac/plugin_mac.mm | 7 |
3 files changed, 16 insertions, 3 deletions
diff --git a/o3d/core/cross/client.cc b/o3d/core/cross/client.cc index 0097d67..a6f9c32 100644 --- a/o3d/core/cross/client.cc +++ b/o3d/core/cross/client.cc @@ -82,6 +82,7 @@ Client::Client(ServiceLocator* service_locator) render_mode_(RENDERMODE_CONTINUOUS), texture_on_hold_(false), event_manager_(), + is_ticking_(false), last_tick_time_(0), root_(NULL), #ifdef OS_WIN @@ -175,6 +176,7 @@ void Client::ClearTickCallback() { } bool Client::Tick() { + is_ticking_ = true; ElapsedTimeTimer timer; float seconds_elapsed = tick_elapsed_time_timer_.GetElapsedTimeAndReset(); tick_event_.set_elapsed_time(seconds_elapsed); @@ -216,6 +218,7 @@ bool Client::Tick() { } } + is_ticking_ = false; return message_check_ok; } diff --git a/o3d/core/cross/client.h b/o3d/core/cross/client.h index 158f1eb..1dcb36d 100644 --- a/o3d/core/cross/client.h +++ b/o3d/core/cross/client.h @@ -298,6 +298,12 @@ class Client { // true if message check was ok. bool Tick(); + // Indicates whether a call to Tick() is in progress. This is needed + // to avoid reentrancy problems on some platforms. + bool IsTicking() const { + return is_ticking_; + } + // Searches in the Client for an object by its id. This function is for // Javascript. // Parameters: @@ -497,6 +503,9 @@ class Client { // Timer for getting the elapsed time between tick updates. ElapsedTimeTimer tick_elapsed_time_timer_; + // Whether a call to Tick() is currently active. + bool is_ticking_; + // Used to gather render time from mulitple RenderTree calls. float total_time_to_render_; diff --git a/o3d/plugin/mac/plugin_mac.mm b/o3d/plugin/mac/plugin_mac.mm index 488a7b6..26c8f7c 100644 --- a/o3d/plugin/mac/plugin_mac.mm +++ b/o3d/plugin/mac/plugin_mac.mm @@ -237,9 +237,10 @@ void RenderTimer::TimerCallback(CFRunLoopTimerRef timer, void* info) { NPP instance = instances_[i]; PluginObject* obj = static_cast<PluginObject*>(instance->pdata); - // RenderClient() may cause events to be processed, leading to - // reentrant calling of this code. Detect and avoid this case. - if (obj->client()->IsRendering()) { + // RenderClient() and Tick() may cause events to be processed, + // leading to reentrant calling of this code. Detect and avoid + // this case. + if (obj->client()->IsRendering() || obj->client()->IsTicking()) { continue; } |