mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 674725 - Part AT - Handle failures for getMessages(). r=smaug,cjones
This commit is contained in:
parent
22f67f0dc2
commit
edac6a0193
@ -212,6 +212,7 @@ SmsRequest::SetError(ErrorType aError)
|
||||
|
||||
mDone = true;
|
||||
mError = aError;
|
||||
mCursor = nsnull;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -247,6 +247,20 @@ SmsRequestManager::NotifyGotNextMessage(PRInt32 aRequestId, nsIDOMMozSmsMessage*
|
||||
NotifySuccess<nsIDOMMozSmsCursor*>(aRequestId, cursor);
|
||||
}
|
||||
|
||||
void
|
||||
SmsRequestManager::NotifyReadMessageListFailed(PRInt32 aRequestId,
|
||||
SmsRequest::ErrorType aError)
|
||||
{
|
||||
SmsRequest* request = GetRequest(aRequestId);
|
||||
|
||||
nsCOMPtr<nsIDOMMozSmsCursor> cursor = request->GetCursor();
|
||||
if (cursor) {
|
||||
static_cast<SmsCursor*>(cursor.get())->Disconnect();
|
||||
}
|
||||
|
||||
NotifyError(aRequestId, aError);
|
||||
}
|
||||
|
||||
} // namespace sms
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
@ -73,6 +73,7 @@ public:
|
||||
void NotifyNoMessageInList(PRInt32 aRequestId);
|
||||
void NotifyCreateMessageList(PRInt32 aRequestId, PRInt32 aListId, nsIDOMMozSmsMessage* aMessage);
|
||||
void NotifyGotNextMessage(PRInt32 aRequestId, nsIDOMMozSmsMessage* aMessage);
|
||||
void NotifyReadMessageListFailed(PRInt32 aRequestId, SmsRequest::ErrorType aError);
|
||||
|
||||
private:
|
||||
static SmsRequestManager* sInstance;
|
||||
|
@ -96,6 +96,9 @@ child:
|
||||
|
||||
NotifyRequestGotNextMessage(SmsMessageData aMessageData, PRInt32 aRequestId, PRUint64 aProcessId);
|
||||
|
||||
NotifyRequestReadListFailed(PRInt32 aError, PRInt32 aRequestId,
|
||||
PRUint64 aProcessId);
|
||||
|
||||
parent:
|
||||
sync HasSupport()
|
||||
returns (bool aHasSupport);
|
||||
|
@ -220,6 +220,20 @@ SmsChild::RecvNotifyRequestGotNextMessage(const SmsMessageData& aMessageData,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
SmsChild::RecvNotifyRequestReadListFailed(const PRInt32& aError,
|
||||
const PRInt32& aRequestId,
|
||||
const PRUint64& aProcessId)
|
||||
{
|
||||
if (ContentChild::GetSingleton()->GetID() != aProcessId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
SmsRequestManager::GetInstance()->NotifyReadMessageListFailed(aRequestId,
|
||||
SmsRequest::ErrorType(aError));
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace sms
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
@ -59,6 +59,7 @@ public:
|
||||
NS_OVERRIDE virtual bool RecvNotifyRequestNoMessageInList(const PRInt32& aRequestId, const PRUint64& aProcessId);
|
||||
NS_OVERRIDE virtual bool RecvNotifyRequestCreateMessageList(const PRInt32& aListId, const SmsMessageData& aMessage, const PRInt32& aRequestId, const PRUint64& aProcessId);
|
||||
NS_OVERRIDE virtual bool RecvNotifyRequestGotNextMessage(const SmsMessageData& aMessage, const PRInt32& aRequestId, const PRUint64& aProcessId);
|
||||
NS_OVERRIDE virtual bool RecvNotifyRequestReadListFailed(const PRInt32& aError, const PRInt32& aRequestId, const PRUint64& aProcessId);
|
||||
};
|
||||
|
||||
} // namespace sms
|
||||
|
@ -133,6 +133,7 @@ public class GeckoAppShell
|
||||
public static native void notifyNoMessageInList(int aRequestId, long aProcessId);
|
||||
public static native void notifyListCreated(int aListId, int aMessageId, String aReceiver, String aSender, String aBody, long aTimestamp, int aRequestId, long aProcessId);
|
||||
public static native void notifyGotNextMessage(int aMessageId, String aReceiver, String aSender, String aBody, long aTimestamp, int aRequestId, long aProcessId);
|
||||
public static native void notifyReadingMessageListFailed(int aError, int aRequestId, long aProcessId);
|
||||
|
||||
// A looper thread, accessed by GeckoAppShell.getHandler
|
||||
private static class LooperThread extends Thread {
|
||||
|
@ -832,10 +832,10 @@ public class GeckoSmsManager
|
||||
mRequestId, mProcessId);
|
||||
} catch (UnexpectedDeliveryStateException e) {
|
||||
Log.e("GeckoSmsManager", "Unexcepted delivery state type: " + e);
|
||||
// TODO: send an error notification
|
||||
GeckoAppShell.notifyReadingMessageListFailed(kUnknownError, mRequestId, mProcessId);
|
||||
} catch (Exception e) {
|
||||
Log.e("GeckoSmsManager", "Error while trying to create a message list cursor: " + e);
|
||||
// TODO: send an error notification
|
||||
GeckoAppShell.notifyReadingMessageListFailed(kUnknownError, mRequestId, mProcessId);
|
||||
} finally {
|
||||
// Close the cursor if MessagesListManager isn't taking care of it.
|
||||
// We could also just check if it is in the MessagesListManager list but
|
||||
@ -849,7 +849,7 @@ public class GeckoSmsManager
|
||||
|
||||
if (!SmsIOThread.getInstance().execute(new CreateMessageListRunnable(aStartDate, aEndDate, aNumbers, aNumbersCount, aDeliveryState, aReverse, aRequestId, aProcessId))) {
|
||||
Log.e("GeckoSmsManager", "Failed to add CreateMessageListRunnable to the SmsIOThread");
|
||||
// TODO: send an error notification
|
||||
GeckoAppShell.notifyReadingMessageListFailed(kUnknownError, aRequestId, aProcessId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -898,17 +898,17 @@ public class GeckoSmsManager
|
||||
mRequestId, mProcessId);
|
||||
} catch (UnexpectedDeliveryStateException e) {
|
||||
Log.e("GeckoSmsManager", "Unexcepted delivery state type: " + e);
|
||||
// TODO: send an error notification
|
||||
GeckoAppShell.notifyReadingMessageListFailed(kUnknownError, mRequestId, mProcessId);
|
||||
} catch (Exception e) {
|
||||
Log.e("GeckoSmsManager", "Error while trying to get the next message of a list: " + e);
|
||||
// TODO: send an error notification
|
||||
GeckoAppShell.notifyReadingMessageListFailed(kUnknownError, mRequestId, mProcessId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!SmsIOThread.getInstance().execute(new GetNextMessageInListRunnable(aListId, aRequestId, aProcessId))) {
|
||||
Log.e("GeckoSmsManager", "Failed to add GetNextMessageInListRunnable to the SmsIOThread");
|
||||
// TODO: send an error notification
|
||||
GeckoAppShell.notifyReadingMessageListFailed(kUnknownError, aRequestId, aProcessId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -299,6 +299,7 @@ SHELL_WRAPPER3(notifySmsDeleteFailed, jint, jint, jlong);
|
||||
SHELL_WRAPPER2(notifyNoMessageInList, jint, jlong);
|
||||
SHELL_WRAPPER8(notifyListCreated, jint, jint, jstring, jstring, jstring, jlong, jint, jlong);
|
||||
SHELL_WRAPPER7(notifyGotNextMessage, jint, jstring, jstring, jstring, jlong, jint, jlong);
|
||||
SHELL_WRAPPER3(notifyReadingMessageListFailed, jint, jint, jlong);
|
||||
|
||||
static void * xul_handle = NULL;
|
||||
static time_t apk_mtime = 0;
|
||||
@ -697,6 +698,7 @@ loadLibs(const char *apkName)
|
||||
GETFUNC(notifyNoMessageInList);
|
||||
GETFUNC(notifyListCreated);
|
||||
GETFUNC(notifyGotNextMessage);
|
||||
GETFUNC(notifyReadingMessageListFailed);
|
||||
#undef GETFUNC
|
||||
sStartupTimeline = (uint64_t *)__wrap_dlsym(xul_handle, "_ZN7mozilla15StartupTimeline16sStartupTimelineE");
|
||||
gettimeofday(&t1, 0);
|
||||
|
@ -102,6 +102,7 @@ extern "C" {
|
||||
NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_notifyNoMessageInList(JNIEnv* jenv, jclass, jint, jlong);
|
||||
NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_notifyListCreated(JNIEnv* jenv, jclass, jint, jint, jstring, jstring, jstring, jlong, jint, jlong);
|
||||
NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_notifyGotNextMessage(JNIEnv* jenv, jclass, jint, jstring, jstring, jstring, jlong, jint, jlong);
|
||||
NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_notifyReadingMessageListFailed(JNIEnv* jenv, jclass, jint, jint, jlong);
|
||||
|
||||
#ifdef MOZ_JAVA_COMPOSITOR
|
||||
NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_bindWidgetTexture(JNIEnv* jenv, jclass);
|
||||
@ -798,6 +799,50 @@ Java_org_mozilla_gecko_GeckoAppShell_notifyGotNextMessage(JNIEnv* jenv, jclass,
|
||||
NS_DispatchToMainThread(runnable);
|
||||
}
|
||||
|
||||
NS_EXPORT void JNICALL
|
||||
Java_org_mozilla_gecko_GeckoAppShell_notifyReadingMessageListFailed(JNIEnv* jenv, jclass,
|
||||
jint aError,
|
||||
jint aRequestId,
|
||||
jlong aProcessId)
|
||||
{
|
||||
class NotifyReadListFailedRunnable : public nsRunnable {
|
||||
public:
|
||||
NotifyReadListFailedRunnable(SmsRequest::ErrorType aError,
|
||||
PRInt32 aRequestId, PRUint64 aProcessId)
|
||||
: mError(aError)
|
||||
, mRequestId(aRequestId)
|
||||
, mProcessId(aProcessId)
|
||||
{}
|
||||
|
||||
NS_IMETHODIMP Run() {
|
||||
if (mProcessId == 0) { // Parent process.
|
||||
SmsRequestManager::GetInstance()->NotifyReadMessageListFailed(mRequestId, mError);
|
||||
} else { // Content process.
|
||||
nsTArray<SmsParent*> spList;
|
||||
SmsParent::GetAll(spList);
|
||||
|
||||
for (PRUint32 i=0; i<spList.Length(); ++i) {
|
||||
unused << spList[i]->SendNotifyRequestReadListFailed(mError,
|
||||
mRequestId,
|
||||
mProcessId);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
SmsRequest::ErrorType mError;
|
||||
PRInt32 mRequestId;
|
||||
PRUint64 mProcessId;
|
||||
};
|
||||
|
||||
|
||||
nsCOMPtr<nsIRunnable> runnable =
|
||||
new NotifyReadListFailedRunnable(SmsRequest::ErrorType(aError), aRequestId, aProcessId);
|
||||
NS_DispatchToMainThread(runnable);
|
||||
}
|
||||
|
||||
#ifdef MOZ_JAVA_COMPOSITOR
|
||||
|
||||
NS_EXPORT void JNICALL
|
||||
|
Loading…
Reference in New Issue
Block a user