зеркало из https://github.com/mozilla/pjs.git
Bug 674725 - Part AP - Implementation of cursor.continue() in the DOM code. r=smaug
This commit is contained in:
Родитель
f57e963193
Коммит
9a5b88b84e
|
@ -45,7 +45,7 @@
|
|||
|
||||
interface nsIDOMMozSmsFilter;
|
||||
|
||||
[scriptable, function, uuid(33358749-d1b3-4bd6-835c-ef3869f0e966)]
|
||||
[scriptable, function, uuid(a253ec42-142e-490b-a479-1e9c605c0a58)]
|
||||
interface nsISmsDatabaseService : nsISupports
|
||||
{
|
||||
// Takes some information required to save the message and returns its id.
|
||||
|
@ -55,4 +55,5 @@ interface nsISmsDatabaseService : nsISupports
|
|||
void deleteMessage(in long messageId, in long requestId, [optional] in unsigned long long processId);
|
||||
|
||||
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);
|
||||
};
|
||||
|
|
|
@ -41,6 +41,9 @@
|
|||
#include "nsIDOMSmsFilter.h"
|
||||
#include "nsIDOMSmsMessage.h"
|
||||
#include "nsIDOMSmsRequest.h"
|
||||
#include "SmsRequest.h"
|
||||
#include "SmsRequestManager.h"
|
||||
#include "nsISmsDatabaseService.h"
|
||||
|
||||
DOMCI_DATA(MozSmsCursor, mozilla::dom::sms::SmsCursor)
|
||||
|
||||
|
@ -60,12 +63,14 @@ NS_IMPL_CYCLE_COLLECTING_ADDREF(SmsCursor)
|
|||
NS_IMPL_CYCLE_COLLECTING_RELEASE(SmsCursor)
|
||||
|
||||
SmsCursor::SmsCursor(nsIDOMMozSmsFilter* aFilter)
|
||||
: mFilter(aFilter)
|
||||
: mListId(-1)
|
||||
, mFilter(aFilter)
|
||||
{
|
||||
}
|
||||
|
||||
SmsCursor::SmsCursor(nsIDOMMozSmsFilter* aFilter, nsIDOMMozSmsRequest* aRequest)
|
||||
: mFilter(aFilter)
|
||||
SmsCursor::SmsCursor(PRInt32 aListId, nsIDOMMozSmsFilter* aFilter, nsIDOMMozSmsRequest* aRequest)
|
||||
: mListId(aListId)
|
||||
, mFilter(aFilter)
|
||||
, mRequest(aRequest)
|
||||
{
|
||||
}
|
||||
|
@ -92,9 +97,16 @@ SmsCursor::Continue()
|
|||
return NS_ERROR_DOM_INVALID_STATE_ERR;
|
||||
}
|
||||
|
||||
// TODO: ask for the next message and reset the request
|
||||
// TODO: add the associated request to the request manager
|
||||
// and send the id to the backend
|
||||
mMessage = nsnull;
|
||||
static_cast<SmsRequest*>(mRequest.get())->Reset();
|
||||
|
||||
PRInt32 requestId = SmsRequestManager::GetInstance()->AddRequest(mRequest);
|
||||
|
||||
nsCOMPtr<nsISmsDatabaseService> smsDBService =
|
||||
do_GetService(SMS_DATABASE_SERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(smsDBService, NS_ERROR_FAILURE);
|
||||
|
||||
smsDBService->GetNextMessageInList(mListId, requestId, 0);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -59,11 +59,12 @@ public:
|
|||
NS_DECL_CYCLE_COLLECTION_CLASS(SmsCursor)
|
||||
|
||||
SmsCursor(nsIDOMMozSmsFilter* aFilter);
|
||||
SmsCursor(nsIDOMMozSmsFilter* aFilter, nsIDOMMozSmsRequest* aRequest);
|
||||
SmsCursor(PRInt32 aListId, nsIDOMMozSmsFilter* aFilter, nsIDOMMozSmsRequest* aRequest);
|
||||
|
||||
void SetMessage(nsIDOMMozSmsMessage* aMessage);
|
||||
|
||||
private:
|
||||
PRInt32 mListId;
|
||||
nsCOMPtr<nsIDOMMozSmsFilter> mFilter;
|
||||
nsCOMPtr<nsIDOMMozSmsRequest> mRequest;
|
||||
nsCOMPtr<nsIDOMMozSmsMessage> mMessage;
|
||||
|
|
|
@ -105,6 +105,21 @@ SmsRequest::~SmsRequest()
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
SmsRequest::Reset()
|
||||
{
|
||||
NS_ASSERTION(mDone, "mDone should be true if we try to reset!");
|
||||
NS_ASSERTION(mResult != JSVAL_VOID, "mResult should be set if we try to reset!");
|
||||
NS_ASSERTION(mError == eNoError, "There should be no error if we try to reset!");
|
||||
|
||||
if (mResultRooted) {
|
||||
UnrootResult();
|
||||
}
|
||||
|
||||
mResult = JSVAL_VOID;
|
||||
mDone = false;
|
||||
}
|
||||
|
||||
void
|
||||
SmsRequest::RootResult()
|
||||
{
|
||||
|
|
|
@ -75,6 +75,8 @@ public:
|
|||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(SmsRequest,
|
||||
nsDOMEventTargetWrapperCache)
|
||||
|
||||
void Reset();
|
||||
|
||||
private:
|
||||
SmsRequest() MOZ_DELETE;
|
||||
|
||||
|
|
|
@ -76,6 +76,26 @@ SmsRequestManager::GetInstance()
|
|||
return sInstance;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
SmsRequestManager::AddRequest(nsIDOMMozSmsRequest* aRequest)
|
||||
{
|
||||
// TODO: merge with CreateRequest
|
||||
PRInt32 size = mRequests.Count();
|
||||
|
||||
// Look for empty slots.
|
||||
for (PRInt32 i=0; i<size; ++i) {
|
||||
if (mRequests[i]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
mRequests.ReplaceObjectAt(aRequest, i);
|
||||
return i;
|
||||
}
|
||||
|
||||
mRequests.AppendObject(aRequest);
|
||||
return size;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
SmsRequestManager::CreateRequest(nsPIDOMWindow* aWindow,
|
||||
nsIScriptContext* aScriptContext,
|
||||
|
@ -204,7 +224,7 @@ SmsRequestManager::NotifyCreateMessageList(PRInt32 aRequestId, PRInt32 aListId,
|
|||
// TODO: use Filter!
|
||||
SmsRequest* request = GetRequest(aRequestId);
|
||||
|
||||
nsCOMPtr<SmsCursor> cursor = new SmsCursor(nsnull, request);
|
||||
nsCOMPtr<SmsCursor> cursor = new SmsCursor(aListId, nsnull, request);
|
||||
cursor->SetMessage(aMessage);
|
||||
|
||||
NotifySuccess<nsIDOMMozSmsCursor*>(aRequestId, cursor);
|
||||
|
|
|
@ -62,6 +62,8 @@ public:
|
|||
nsIScriptContext* aScriptContext,
|
||||
nsIDOMMozSmsRequest** aRequest);
|
||||
|
||||
PRInt32 AddRequest(nsIDOMMozSmsRequest* aRequest);
|
||||
|
||||
void NotifySmsSent(PRInt32 aRequestId, nsIDOMMozSmsMessage* aMessage);
|
||||
void NotifySmsSendFailed(PRInt32 aRequestId, SmsRequest::ErrorType aError);
|
||||
void NotifyGotSms(PRInt32 aRequestId, nsIDOMMozSmsMessage* aMessage);
|
||||
|
|
|
@ -99,6 +99,14 @@ SmsDatabaseService::CreateMessageList(nsIDOMMozSmsFilter* aFilter,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsDatabaseService::GetNextMessageInList(PRInt32 aListId, PRInt32 aRequestId,
|
||||
PRUint64 aProcessId)
|
||||
{
|
||||
// TODO: implement
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace sms
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -78,6 +78,14 @@ SmsDatabaseService::CreateMessageList(nsIDOMMozSmsFilter* aFilter,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsDatabaseService::GetNextMessageInList(PRInt32 aListId, PRInt32 aRequestId,
|
||||
PRUint64 aProcessId)
|
||||
{
|
||||
NS_ERROR("We should not be here!");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace sms
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -113,6 +113,8 @@ parent:
|
|||
|
||||
CreateMessageList(SmsFilterData aFilter, bool aReverse, PRInt32 aRequestId, PRUint64 aProcessId);
|
||||
|
||||
GetNextMessageInList(PRInt32 aListId, PRInt32 aRequestId, PRUint64 aProcessId);
|
||||
|
||||
__delete__();
|
||||
};
|
||||
|
||||
|
|
|
@ -147,6 +147,15 @@ SmsIPCService::CreateMessageList(nsIDOMMozSmsFilter* aFilter, bool aReverse,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsIPCService::GetNextMessageInList(PRInt32 aListId, PRInt32 aRequestId,
|
||||
PRUint64 aProcessId)
|
||||
{
|
||||
GetSmsChild()->SendGetNextMessageInList(aListId, aRequestId,
|
||||
ContentChild::GetSingleton()->GetID());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace sms
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -233,6 +233,20 @@ SmsParent::RecvCreateMessageList(const SmsFilterData& aFilter,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
SmsParent::RecvGetNextMessageInList(const PRInt32& aListId,
|
||||
const PRInt32& aRequestId,
|
||||
const PRUint64& aProcessId)
|
||||
{
|
||||
nsCOMPtr<nsISmsDatabaseService> smsDBService =
|
||||
do_GetService(SMS_DATABASE_SERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(smsDBService, true);
|
||||
|
||||
smsDBService->GetNextMessageInList(aListId, aRequestId, aProcessId);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace sms
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -63,6 +63,7 @@ public:
|
|||
NS_OVERRIDE virtual bool RecvGetMessage(const PRInt32& aMessageId, const PRInt32& aRequestId, const PRUint64& aProcessId);
|
||||
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);
|
||||
|
||||
protected:
|
||||
virtual void ActorDestroy(ActorDestroyReason why);
|
||||
|
|
Загрузка…
Ссылка в новой задаче