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

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: test cleanup Created 7 years, 5 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
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 a9961f015b5ea5d70bad76c25679fbc6d61acd3d..1dc6d0ebc49fdafbbc340b4fe3ab870e51e4a4e4 100644
--- a/ppapi/shared_impl/tracked_callback_unittest.cc
+++ b/ppapi/shared_impl/tracked_callback_unittest.cc
@@ -7,6 +7,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"
@@ -25,9 +26,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_);
}
@@ -79,6 +83,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).
@@ -196,6 +201,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();
@@ -219,23 +225,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();
@@ -246,21 +262,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

Powered by Google App Engine
This is Rietveld 408576698