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

Unified Diff: ppapi/shared_impl/tracked_callback_unittest.cc

Issue 19492014: PPAPI: Purposely leak ProxyLock, fix shutdown race (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove static initializer Created 7 years, 3 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 | « ppapi/shared_impl/tracked_callback.cc ('k') | ppapi/shared_impl/var_tracker_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/shared_impl/tracked_callback_unittest.cc
diff --git a/ppapi/shared_impl/tracked_callback_unittest.cc b/ppapi/shared_impl/tracked_callback_unittest.cc
index 9ceb96e7cf7734a40d27ee0e0c946b9532f14e51..55db0aaf93ee5fcbc3bb48682aae974f5303838c 100644
--- a/ppapi/shared_impl/tracked_callback_unittest.cc
+++ b/ppapi/shared_impl/tracked_callback_unittest.cc
@@ -8,6 +8,7 @@
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/shared_impl/callback_tracker.h"
+#include "ppapi/shared_impl/proxy_lock.h"
#include "ppapi/shared_impl/resource.h"
#include "ppapi/shared_impl/resource_tracker.h"
#include "ppapi/shared_impl/test_globals.h"
@@ -26,9 +27,12 @@ class TrackedCallbackTest : public testing::Test {
PP_Instance pp_instance() const { return pp_instance_; }
virtual void SetUp() OVERRIDE {
+ ProxyLock::EnableLockingOnThreadForTest();
+ ProxyAutoLock lock;
globals_.GetResourceTracker()->DidCreateInstance(pp_instance_);
}
virtual void TearDown() OVERRIDE {
+ ProxyAutoLock lock;
globals_.GetResourceTracker()->DidDeleteInstance(pp_instance_);
}
@@ -89,6 +93,7 @@ class CallbackShutdownTest : public TrackedCallbackTest {
// Tests that callbacks are properly aborted on module shutdown.
TEST_F(CallbackShutdownTest, AbortOnShutdown) {
+ ProxyAutoLock lock;
scoped_refptr<Resource> resource(new Resource(OBJECT_IS_IMPL, pp_instance()));
// Set up case (1) (see above).
@@ -250,6 +255,7 @@ class CallbackMockResource : public Resource {
// Test that callbacks get aborted on the last resource unref.
TEST_F(CallbackResourceTest, AbortOnNoRef) {
+ ProxyAutoLock lock;
ResourceTracker* resource_tracker =
PpapiGlobals::Get()->GetResourceTracker();
@@ -273,23 +279,33 @@ TEST_F(CallbackResourceTest, AbortOnNoRef) {
// Kill resource #1, spin the message loop to run posted calls, and check that
// things are in the expected states.
resource_tracker->ReleaseResource(resource_1_id);
- base::MessageLoop::current()->RunUntilIdle();
+ {
+ ProxyAutoUnlock unlock;
+ base::MessageLoop::current()->RunUntilIdle();
+ }
resource_1->CheckFinalState();
resource_2->CheckIntermediateState();
// Kill resource #2.
resource_tracker->ReleaseResource(resource_2_id);
- base::MessageLoop::current()->RunUntilIdle();
+ {
+ ProxyAutoUnlock unlock;
+ base::MessageLoop::current()->RunUntilIdle();
+ }
resource_1->CheckFinalState();
resource_2->CheckFinalState();
// This shouldn't be needed, but make sure there are no stranded tasks.
- base::MessageLoop::current()->RunUntilIdle();
+ {
+ ProxyAutoUnlock unlock;
+ base::MessageLoop::current()->RunUntilIdle();
+ }
}
// Test that "resurrecting" a resource (getting a new ID for a |Resource|)
// doesn't resurrect callbacks.
TEST_F(CallbackResourceTest, Resurrection) {
+ ProxyAutoLock lock;
ResourceTracker* resource_tracker =
PpapiGlobals::Get()->GetResourceTracker();
@@ -300,21 +316,33 @@ TEST_F(CallbackResourceTest, Resurrection) {
// Unref it, spin the message loop to run posted calls, and check that things
// are in the expected states.
resource_tracker->ReleaseResource(resource_id);
- base::MessageLoop::current()->RunUntilIdle();
+ {
+ ProxyAutoUnlock unlock;
+ base::MessageLoop::current()->RunUntilIdle();
+ }
resource->CheckFinalState();
// "Resurrect" it and check that the callbacks are still dead.
PP_Resource new_resource_id = resource->GetReference();
- base::MessageLoop::current()->RunUntilIdle();
+ {
+ ProxyAutoUnlock unlock;
+ base::MessageLoop::current()->RunUntilIdle();
+ }
resource->CheckFinalState();
// Unref it again and do the same.
resource_tracker->ReleaseResource(new_resource_id);
- base::MessageLoop::current()->RunUntilIdle();
+ {
+ ProxyAutoUnlock unlock;
+ base::MessageLoop::current()->RunUntilIdle();
+ }
resource->CheckFinalState();
// This shouldn't be needed, but make sure there are no stranded tasks.
- base::MessageLoop::current()->RunUntilIdle();
+ {
+ ProxyAutoUnlock unlock;
+ base::MessageLoop::current()->RunUntilIdle();
+ }
}
} // namespace ppapi
« no previous file with comments | « ppapi/shared_impl/tracked_callback.cc ('k') | ppapi/shared_impl/var_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698