Bug 1372405 - Provide names for all runnables in the tree (r=froydnj)
MozReview-Commit-ID: DKR6ROiHRS7
This commit is contained in:
@@ -1830,39 +1830,41 @@ nsUrlClassifierDBService::AsyncClassifyLocalWithTables(nsIURI *aURI,
|
||||
new nsMainThreadPtrHolder<nsIURIClassifierCallback>(
|
||||
"nsIURIClassifierCallback", aCallback));
|
||||
|
||||
nsCOMPtr<nsIRunnable> r =
|
||||
NS_NewRunnableFunction([worker, key, tables, callback, startTime] () -> void {
|
||||
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction(
|
||||
"nsUrlClassifierDBService::AsyncClassifyLocalWithTables",
|
||||
[worker, key, tables, callback, startTime]() -> void {
|
||||
|
||||
nsCString matchedLists;
|
||||
nsAutoPtr<LookupResultArray> results(new LookupResultArray());
|
||||
if (results) {
|
||||
nsresult rv = worker->DoLocalLookup(key, tables, results);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
for (uint32_t i = 0; i < results->Length(); i++) {
|
||||
if (i > 0) {
|
||||
matchedLists.AppendLiteral(",");
|
||||
nsCString matchedLists;
|
||||
nsAutoPtr<LookupResultArray> results(new LookupResultArray());
|
||||
if (results) {
|
||||
nsresult rv = worker->DoLocalLookup(key, tables, results);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
for (uint32_t i = 0; i < results->Length(); i++) {
|
||||
if (i > 0) {
|
||||
matchedLists.AppendLiteral(",");
|
||||
}
|
||||
matchedLists.Append(results->ElementAt(i).mTableName);
|
||||
}
|
||||
matchedLists.Append(results->ElementAt(i).mTableName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIRunnable> cbRunnable =
|
||||
NS_NewRunnableFunction([callback, matchedLists, startTime] () -> void {
|
||||
// Measure the time diff between calling and callback.
|
||||
AccumulateDelta_impl<Millisecond>::compute(
|
||||
Telemetry::URLCLASSIFIER_ASYNC_CLASSIFYLOCAL_TIME, startTime);
|
||||
nsCOMPtr<nsIRunnable> cbRunnable = NS_NewRunnableFunction(
|
||||
"nsUrlClassifierDBService::AsyncClassifyLocalWithTables",
|
||||
[callback, matchedLists, startTime]() -> void {
|
||||
// Measure the time diff between calling and callback.
|
||||
AccumulateDelta_impl<Millisecond>::compute(
|
||||
Telemetry::URLCLASSIFIER_ASYNC_CLASSIFYLOCAL_TIME, startTime);
|
||||
|
||||
// |callback| is captured as const value so ...
|
||||
auto cb = const_cast<nsIURIClassifierCallback*>(callback.get());
|
||||
cb->OnClassifyComplete(NS_OK, // Not used.
|
||||
matchedLists,
|
||||
EmptyCString(), // provider. (Not used)
|
||||
EmptyCString()); // prefix. (Not used)
|
||||
});
|
||||
// |callback| is captured as const value so ...
|
||||
auto cb = const_cast<nsIURIClassifierCallback*>(callback.get());
|
||||
cb->OnClassifyComplete(NS_OK, // Not used.
|
||||
matchedLists,
|
||||
EmptyCString(), // provider. (Not used)
|
||||
EmptyCString()); // prefix. (Not used)
|
||||
});
|
||||
|
||||
NS_DispatchToMainThread(cbRunnable);
|
||||
});
|
||||
NS_DispatchToMainThread(cbRunnable);
|
||||
});
|
||||
|
||||
return gDbBackgroundThread->Dispatch(r, NS_DISPATCH_NORMAL);
|
||||
}
|
||||
@@ -2267,8 +2269,10 @@ nsUrlClassifierDBService::Shutdown()
|
||||
// between main thread and the worker thread. (Both threads
|
||||
// would access Classifier::mUpdateThread.)
|
||||
using Worker = nsUrlClassifierDBServiceWorker;
|
||||
RefPtr<nsIRunnable> r =
|
||||
NewRunnableMethod(mWorker, &Worker::FlushAndDisableAsyncUpdate);
|
||||
RefPtr<nsIRunnable> r = NewRunnableMethod(
|
||||
"nsUrlClassifierDBServiceWorker::FlushAndDisableAsyncUpdate",
|
||||
mWorker,
|
||||
&Worker::FlushAndDisableAsyncUpdate);
|
||||
SyncRunnable::DispatchToThread(gDbBackgroundThread, r);
|
||||
|
||||
// At this point the update thread has been shut down and
|
||||
|
||||
Reference in New Issue
Block a user