Bug 674725 - Part AU - Release message lists in case of GC. r=smaug,cjones

This commit is contained in:
Mounir Lamouri 2012-01-17 19:43:08 +01:00
parent 51107564e9
commit 104c6e72f2
13 changed files with 81 additions and 3 deletions

View File

@ -38,14 +38,14 @@
%{C++
#define SMS_DATABASE_SERVICE_CID \
{ 0xcb971459, 0xe85a, 0x49b3, \
{ 0xbc, 0x1c, 0x10, 0x40, 0x27, 0x1e, 0x04, 0x6c } }
{ 0x2454c2a1, 0xefdd, 0x4d96, \
{ 0x83, 0xbd, 0x51, 0xa2, 0x9a, 0x21, 0xf5, 0xab } }
#define SMS_DATABASE_SERVICE_CONTRACTID "@mozilla.org/sms/smsdatabaseservice;1"
%}
interface nsIDOMMozSmsFilter;
[scriptable, function, uuid(a253ec42-142e-490b-a479-1e9c605c0a58)]
[scriptable, function, uuid(3ddf7dc3-626c-47ee-8b41-3f55d5af49c9)]
interface nsISmsDatabaseService : nsISupports
{
// Takes some information required to save the message and returns its id.
@ -56,4 +56,5 @@ interface nsISmsDatabaseService : nsISupports
void createMessageList(in nsIDOMMozSmsFilter filter, in boolean reverse, in long requestId, [optional] in unsigned long long processId);
void getNextMessageInList(in long listId, in long requestId, in unsigned long long processId);
void clearMessageList(in long listId);
};

View File

@ -72,6 +72,22 @@ SmsCursor::SmsCursor(PRInt32 aListId, nsIDOMMozSmsRequest* aRequest)
{
}
SmsCursor::~SmsCursor()
{
NS_ASSERTION(!mMessage, "mMessage shouldn't be set!");
if (mListId != -1) {
nsCOMPtr<nsISmsDatabaseService> smsDBService =
do_GetService(SMS_DATABASE_SERVICE_CONTRACTID);
if (!smsDBService) {
NS_ERROR("Can't find SmsDBService!");
}
smsDBService->ClearMessageList(mListId);
}
}
void
SmsCursor::Disconnect()
{

View File

@ -60,6 +60,8 @@ public:
SmsCursor();
SmsCursor(PRInt32 aListId, nsIDOMMozSmsRequest* aRequest);
~SmsCursor();
void SetMessage(nsIDOMMozSmsMessage* aMessage);
void Disconnect();

View File

@ -111,6 +111,17 @@ SmsDatabaseService::GetNextMessageInList(PRInt32 aListId, PRInt32 aRequestId,
return NS_OK;
}
NS_IMETHODIMP
SmsDatabaseService::ClearMessageList(PRInt32 aListId)
{
if (!AndroidBridge::Bridge()) {
return NS_OK;
}
AndroidBridge::Bridge()->ClearMessageList(aListId);
return NS_OK;
}
} // namespace sms
} // namespace dom
} // namespace mozilla

View File

@ -86,6 +86,13 @@ SmsDatabaseService::GetNextMessageInList(PRInt32 aListId, PRInt32 aRequestId,
return NS_OK;
}
NS_IMETHODIMP
SmsDatabaseService::ClearMessageList(PRInt32 aListId)
{
NS_ERROR("We should not be here!");
return NS_OK;
}
} // namespace sms
} // namespace dom
} // namespace mozilla

View File

@ -120,6 +120,8 @@ parent:
GetNextMessageInList(PRInt32 aListId, PRInt32 aRequestId, PRUint64 aProcessId);
ClearMessageList(PRInt32 aListId);
__delete__();
};

View File

@ -156,6 +156,13 @@ SmsIPCService::GetNextMessageInList(PRInt32 aListId, PRInt32 aRequestId,
return NS_OK;
}
NS_IMETHODIMP
SmsIPCService::ClearMessageList(PRInt32 aListId)
{
GetSmsChild()->SendClearMessageList(aListId);
return NS_OK;
}
} // namespace sms
} // namespace dom
} // namespace mozilla

View File

@ -247,6 +247,18 @@ SmsParent::RecvGetNextMessageInList(const PRInt32& aListId,
return true;
}
bool
SmsParent::RecvClearMessageList(const PRInt32& aListId)
{
nsCOMPtr<nsISmsDatabaseService> smsDBService =
do_GetService(SMS_DATABASE_SERVICE_CONTRACTID);
NS_ENSURE_TRUE(smsDBService, true);
smsDBService->ClearMessageList(aListId);
return true;
}
} // namespace sms
} // namespace dom
} // namespace mozilla

View File

@ -64,6 +64,7 @@ public:
NS_OVERRIDE virtual bool RecvDeleteMessage(const PRInt32& aMessageId, const PRInt32& aRequestId, const PRUint64& aProcessId);
NS_OVERRIDE virtual bool RecvCreateMessageList(const SmsFilterData& aFilter, const bool& aReverse, const PRInt32& aRequestId, const PRUint64& aProcessId);
NS_OVERRIDE virtual bool RecvGetNextMessageInList(const PRInt32& aListId, const PRInt32& aRequestId, const PRUint64& aProcessId);
NS_OVERRIDE virtual bool RecvClearMessageList(const PRInt32& aListId);
protected:
virtual void ActorDestroy(ActorDestroyReason why);

View File

@ -1728,6 +1728,10 @@ public class GeckoAppShell
GeckoSmsManager.getNextMessageInList(aListId, aRequestId, aProcessId);
}
public static void clearMessageList(int aListId) {
GeckoSmsManager.clearMessageList(aListId);
}
public static boolean isTablet() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
Configuration config = GeckoApp.mAppContext.getResources().getConfiguration();

View File

@ -912,6 +912,10 @@ public class GeckoSmsManager
}
}
public static void clearMessageList(int aListId) {
MessagesListManager.getInstance().remove(aListId);
}
public static void shutdown() {
SmsIOThread.getInstance().interrupt();
MessagesListManager.getInstance().clear();

View File

@ -174,6 +174,7 @@ AndroidBridge::Init(JNIEnv *jEnv,
jDeleteMessage = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "deleteMessage", "(IIJ)V");
jCreateMessageList = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "createMessageList", "(JJ[Ljava/lang/String;IIZIJ)V");
jGetNextMessageinList = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "getNextMessageInList", "(IIJ)V");
jClearMessageList = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "clearMessageList", "(I)V");
jEGLContextClass = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("javax/microedition/khronos/egl/EGLContext"));
jEGL10Class = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("javax/microedition/khronos/egl/EGL10"));
@ -1420,6 +1421,14 @@ AndroidBridge::GetNextMessageInList(PRInt32 aListId, PRInt32 aRequestId, PRUint6
JNI()->CallStaticVoidMethod(mGeckoAppShellClass, jGetNextMessageinList, aListId, aRequestId, aProcessId);
}
void
AndroidBridge::ClearMessageList(PRInt32 aListId)
{
ALOG_BRIDGE("AndroidBridge::ClearMessageList");
JNI()->CallStaticVoidMethod(mGeckoAppShellClass, jClearMessageList, aListId);
}
void *
AndroidBridge::LockBitmap(jobject bitmap)
{

View File

@ -347,6 +347,7 @@ public:
void DeleteMessage(PRInt32 aMessageId, PRInt32 aRequestId, PRUint64 aProcessId);
void CreateMessageList(const dom::sms::SmsFilterData& aFilter, bool aReverse, PRInt32 aRequestId, PRUint64 aProcessId);
void GetNextMessageInList(PRInt32 aListId, PRInt32 aRequestId, PRUint64 aProcessId);
void ClearMessageList(PRInt32 aListId);
bool IsTablet();
@ -442,6 +443,7 @@ protected:
jmethodID jDeleteMessage;
jmethodID jCreateMessageList;
jmethodID jGetNextMessageinList;
jmethodID jClearMessageList;
// stuff we need for CallEglCreateWindowSurface
jclass jEGLSurfaceImplClass;