summaryrefslogtreecommitdiffstats
path: root/o3d/core
diff options
context:
space:
mode:
authorapatrick@google.com <apatrick@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-03 19:49:35 +0000
committerapatrick@google.com <apatrick@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-03 19:49:35 +0000
commit91240c947358b33cc19c0923a06d116ab36737dd (patch)
tree7897c99ad9b41d7735c7a42e0ea75fe6f76760b3 /o3d/core
parent2e25a9f4152a90a179ad37206bff79e1198379d7 (diff)
downloadchromium_src-91240c947358b33cc19c0923a06d116ab36737dd.zip
chromium_src-91240c947358b33cc19c0923a06d116ab36737dd.tar.gz
chromium_src-91240c947358b33cc19c0923a06d116ab36737dd.tar.bz2
Asynchronous tick now uses NPN_PluginAsyncCall.URL streaming callbacks are now also asynchronous.Implemented NPN_PluginAsyncCall for IE.Allowed WM_PAINT handler to be reentered because it no longer calls into the browser (except to schedule an asynchronous tick if none is pending).Fixed a bug where the EventManager would crash if an event callback called cleanUp on the client.Cleanup destroys all the packs. Doing this in NPP_Destroy seems to make Chrome timeout and fail to load the next page.Tar and GZ decoding happens on a new thread.
Review URL: http://codereview.chromium.org/155733 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22305 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/core')
-rw-r--r--o3d/core/build.scons1
-rw-r--r--o3d/core/core.gyp3
-rw-r--r--o3d/core/cross/client.cc12
-rw-r--r--o3d/core/cross/client.h4
-rw-r--r--o3d/core/cross/event_manager.cc9
-rw-r--r--o3d/core/cross/event_manager_test.cc78
-rw-r--r--o3d/core/cross/imain_thread_task_poster.cc41
-rw-r--r--o3d/core/cross/imain_thread_task_poster.h57
-rw-r--r--o3d/core/cross/message_queue_test.cc3
9 files changed, 199 insertions, 9 deletions
diff --git a/o3d/core/build.scons b/o3d/core/build.scons
index 088ebce..593b301 100644
--- a/o3d/core/build.scons
+++ b/o3d/core/build.scons
@@ -66,6 +66,7 @@ cross_inputs = [
'cross/iclass_manager.cc',
'cross/ierror_status.cc',
'cross/id_manager.cc',
+ 'cross/imain_thread_task_poster.cc',
'cross/material.cc',
'cross/math_utilities.cc',
'cross/matrix4_axis_rotation.cc',
diff --git a/o3d/core/core.gyp b/o3d/core/core.gyp
index 7bd7926..2099791 100644
--- a/o3d/core/core.gyp
+++ b/o3d/core/core.gyp
@@ -126,6 +126,8 @@
'cross/id_manager.h',
'cross/ierror_status.cc',
'cross/ierror_status.h',
+ 'cross/imain_thread_task_poster.cc',
+ 'cross/imain_thread_task_poster.h',
'cross/install_check.h',
'cross/lost_resource_callback.h',
'cross/material.cc',
@@ -365,6 +367,7 @@
'cross/draw_pass_test.cc',
'cross/effect_test.cc',
'cross/element_test.cc',
+ 'cross/event_manager_test.cc',
'cross/features_test.cc',
'cross/field_test.cc',
'cross/float_n_test.cc',
diff --git a/o3d/core/cross/client.cc b/o3d/core/cross/client.cc
index ed5fea3..7b70496 100644
--- a/o3d/core/cross/client.cc
+++ b/o3d/core/cross/client.cc
@@ -139,6 +139,18 @@ void Client::Cleanup() {
ClearTickCallback();
event_manager_.ClearAll();
counter_manager_.ClearAllCallbacks();
+
+ // Disable continuous rendering because there is nothing to render after
+ // Cleanup is called. This speeds up the the process of unloading the page.
+ // It also preserves the last rendered frame so long as it does not become
+ // invalid.
+ render_mode_ = RENDERMODE_ON_DEMAND;
+
+ // Destroy the packs here if possible. If there are a lot of objects it takes
+ // a long time and seems to make Chrome timeout if it happens in NPP_Destroy.
+ root_.Reset();
+ rendergraph_root_.Reset();
+ object_manager_->DestroyAllPacks();
}
Pack* Client::CreatePack() {
diff --git a/o3d/core/cross/client.h b/o3d/core/cross/client.h
index 16ffbf4..07e60e5 100644
--- a/o3d/core/cross/client.h
+++ b/o3d/core/cross/client.h
@@ -400,7 +400,6 @@ class Client {
// Returns true on success and false on failure.
bool SaveScreen(const String& file_name);
-#ifdef OS_WIN
// This class is intended to be used on the stack, such that the variable gets
// incremented on scope entry and decremented on scope exit. It's currently
// used in WindowProc to determine if we're reentrant or not, but may be
@@ -431,7 +430,6 @@ class Client {
Client *client_;
DISALLOW_COPY_AND_ASSIGN(ScopedIncrement);
};
-#endif
private:
@@ -499,9 +497,7 @@ class Client {
// The id of the client.
Id id_;
-#ifdef OS_WIN
int calls_; // Used to check reentrancy along with ScopedIncrement.
-#endif
DISALLOW_COPY_AND_ASSIGN(Client);
}; // Client
diff --git a/o3d/core/cross/event_manager.cc b/o3d/core/cross/event_manager.cc
index 0712e4c..f20c7c2 100644
--- a/o3d/core/cross/event_manager.cc
+++ b/o3d/core/cross/event_manager.cc
@@ -51,9 +51,14 @@ void EventManager::ProcessQueue() {
DCHECK(!processing_event_queue_);
processing_event_queue_ = true;
#endif
- const Event& event = event_queue_.front();
- event_callbacks_[event.type()].Run(event);
+ Event event = event_queue_.front();
+
+ // Pop the event before invoking the callback; the callback might invoke
+ // Client::CleanUp, which empties the event queue. This can happen in Chrome
+ // if it invokes the unload handler when control enters JavaScript.
event_queue_.pop_front();
+
+ event_callbacks_[event.type()].Run(event);
#ifndef NDEBUG
processing_event_queue_ = false;
#endif
diff --git a/o3d/core/cross/event_manager_test.cc b/o3d/core/cross/event_manager_test.cc
new file mode 100644
index 0000000..c603965
--- /dev/null
+++ b/o3d/core/cross/event_manager_test.cc
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2009, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+// This file implements unit tests for class EventManager.
+
+#include "tests/common/win/testing_common.h"
+#include "core/cross/event_manager.h"
+
+namespace o3d {
+
+class EventManagerTest : public testing::Test {
+ protected:
+ EventManagerTest() {
+ }
+
+ virtual void SetUp();
+ virtual void TearDown();
+
+ EventManager event_manager_;
+};
+
+void EventManagerTest::SetUp() {
+}
+
+void EventManagerTest::TearDown() {
+ event_manager_.ClearAll();
+}
+
+TEST_F(EventManagerTest, CanClearAllFromEventCallback) {
+ class ClearAllEventCallback : public EventCallback {
+ public:
+ explicit ClearAllEventCallback(EventManager* event_manager)
+ : event_manager_(event_manager) {
+ }
+ virtual void Run(const Event& event) {
+ event_manager_->ClearAll();
+ }
+ private:
+ EventManager* event_manager_;
+ };
+
+ event_manager_.SetEventCallback(
+ Event::TYPE_CLICK,
+ new ClearAllEventCallback(&event_manager_));
+ Event event(Event::TYPE_CLICK);
+ event_manager_.AddEventToQueue(event);
+ event_manager_.ProcessQueue();
+}
+} // namespace o3d
diff --git a/o3d/core/cross/imain_thread_task_poster.cc b/o3d/core/cross/imain_thread_task_poster.cc
new file mode 100644
index 0000000..8738efb
--- /dev/null
+++ b/o3d/core/cross/imain_thread_task_poster.cc
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2009, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "core/cross/precompile.h"
+#include "core/cross/imain_thread_task_poster.h"
+
+namespace o3d {
+
+const InterfaceId IMainThreadTaskPoster::kInterfaceId =
+ InterfaceTraits<IMainThreadTaskPoster>::kInterfaceId;
+
+} // namespace o3d
diff --git a/o3d/core/cross/imain_thread_task_poster.h b/o3d/core/cross/imain_thread_task_poster.h
new file mode 100644
index 0000000..cd3d26e
--- /dev/null
+++ b/o3d/core/cross/imain_thread_task_poster.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2009, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#ifndef O3D_CORE_CROSS_IMAIN_THREAD_TASK_POSTER_H_
+#define O3D_CORE_CROSS_IMAIN_THREAD_TASK_POSTER_H_
+
+#include "base/task.h"
+#include "core/cross/service_locator.h"
+
+namespace o3d {
+
+// Allows tasks to be posted from one thread to the main thread.
+class IMainThreadTaskPoster {
+ public:
+ static const InterfaceId kInterfaceId;
+
+ IMainThreadTaskPoster() {}
+ virtual ~IMainThreadTaskPoster() {}
+
+ virtual bool IsSupported() = 0;
+ virtual void PostTask(Task* task) = 0;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(IMainThreadTaskPoster);
+};
+}
+
+#endif // O3D_CORE_CROSS_IMAIN_THREAD_TASK_POSTER_H_
diff --git a/o3d/core/cross/message_queue_test.cc b/o3d/core/cross/message_queue_test.cc
index 77ba145..7fa43e6 100644
--- a/o3d/core/cross/message_queue_test.cc
+++ b/o3d/core/cross/message_queue_test.cc
@@ -36,13 +36,11 @@
#include "core/cross/client.h"
#include "core/cross/types.h"
#include "tests/common/win/testing_common.h"
-#include "base/at_exit.h"
#include "base/condition_variable.h"
#include "base/lock.h"
#include "base/platform_thread.h"
#include "base/time.h"
-using ::base::AtExitManager;
using ::base::Time;
using ::base::TimeDelta;
@@ -286,7 +284,6 @@ void MessageQueueTest::RunTests(int num_threads,
MessageQueue* message_queue = new MessageQueue(g_service_locator);
message_queue->Initialize();
- AtExitManager manager;
TimeSource* time_source = new WallClockTimeSource();
TestWatchdog* watchdog = new TestWatchdog(num_threads,
timeout,