30 #include <nsAutoLock.h>
31 #include <nsComponentManagerUtils.h>
33 #include <nsServiceManagerUtils.h>
34 #include <nsThreadUtils.h>
35 #include <nsIGenericFactory.h>
38 #include <sbIMediacoreEvent.h>
39 #include <sbIMediacoreEventTarget.h>
56 sbTestMediacoreStressThreads::~sbTestMediacoreStressThreads()
59 nsAutoMonitor::DestroyMonitor(
mMonitor);
65 NS_IMETHODIMP sbTestMediacoreStressThreads::Run()
67 NS_ENSURE_FALSE(
mMonitor, NS_ERROR_ALREADY_INITIALIZED);
69 mMonitor = nsAutoMonitor::NewMonitor(__FILE__);
70 NS_ENSURE_TRUE(
mMonitor, NS_ERROR_OUT_OF_MEMORY);
76 rv =
mBaseEventTarget->AddListener(static_cast<sbIMediacoreEventListener*>(
this));
77 NS_ENSURE_SUCCESS(rv, rv);
81 for (
int i = 0;
i < 100; ++
i) {
83 nsCOMPtr<nsIRunnable>
event =
85 NS_ENSURE_TRUE(
event, NS_ERROR_OUT_OF_MEMORY);
87 nsCOMPtr<nsIThread> thread;
89 rv = NS_NewThread(getter_AddRefs(thread),
event);
90 NS_ENSURE_SUCCESS(rv, rv);
100 nsCOMPtr<nsIThread>
target;
101 rv = NS_GetMainThread(getter_AddRefs(target));
102 NS_ENSURE_SUCCESS(rv, rv);
104 PRBool processed = PR_FALSE;
106 rv = target->ProcessNextEvent(PR_FALSE, &processed);
107 NS_ENSURE_SUCCESS(rv, rv);
112 nsCOMPtr<nsIThread> thread =
mThreads[0];
114 NS_ENSURE_TRUE(succeeded, NS_ERROR_FAILURE);
115 rv = thread->Shutdown();
116 NS_ENSURE_SUCCESS(rv, rv);
119 rv =
mBaseEventTarget->RemoveListener(static_cast<sbIMediacoreEventListener*>(
this));
120 NS_ENSURE_SUCCESS(rv, rv);
122 NS_ENSURE_TRUE(
mCounter == 0, NS_ERROR_FAILURE);
130 NS_IMETHODIMP sbTestMediacoreStressThreads::OnMediacoreEvent(
sbIMediacoreEvent *aEvent)
134 if (!NS_IsMainThread()) {
135 NS_WARNING(
"Not on main thread!");
137 return NS_ERROR_UNEXPECTED;
143 void sbTestMediacoreStressThreads::OnEvent()
147 nsCOMPtr<sbIMediacore> core = do_QueryInterface(NS_ISUPPORTS_CAST(
sbIMediacore*,
this), &rv);
148 NS_ENSURE_SUCCESS(rv, );
150 nsCOMPtr<sbIMediacoreEvent>
event;
155 getter_AddRefs(event));
156 NS_ENSURE_SUCCESS(rv, );
159 NS_ENSURE_SUCCESS(rv, );
163 NS_IMETHODIMP sbTestMediacoreStressThreads::GetInstanceName(nsAString & aInstanceName)
165 return NS_ERROR_NOT_IMPLEMENTED;
171 return NS_ERROR_NOT_IMPLEMENTED;
177 return NS_ERROR_NOT_IMPLEMENTED;
183 return NS_ERROR_NOT_IMPLEMENTED;
188 return NS_ERROR_NOT_IMPLEMENTED;
192 NS_IMETHODIMP sbTestMediacoreStressThreads::Shutdown()
194 return NS_ERROR_NOT_IMPLEMENTED;
function succeeded(ch, cx, status, data)
_getSelectedPageStyle s i