本文整理汇总了C++中ContentChild::GetOrCreateActorForBlob方法的典型用法代码示例。如果您正苦于以下问题:C++ ContentChild::GetOrCreateActorForBlob方法的具体用法?C++ ContentChild::GetOrCreateActorForBlob怎么用?C++ ContentChild::GetOrCreateActorForBlob使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContentChild
的用法示例。
在下文中一共展示了ContentChild::GetOrCreateActorForBlob方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
static bool
SendAsyncMessageToParent(void* aCallbackData,
const nsAString& aMessage,
const StructuredCloneData& aData)
{
TabChild* tabChild = static_cast<TabChild*>(aCallbackData);
ContentChild* cc = static_cast<ContentChild*>(tabChild->Manager());
ClonedMessageData data;
SerializedStructuredCloneBuffer& buffer = data.data();
buffer.data = aData.mData;
buffer.dataLength = aData.mDataLength;
const nsTArray<nsCOMPtr<nsIDOMBlob> >& blobs = aData.mClosure.mBlobs;
if (!blobs.IsEmpty()) {
InfallibleTArray<PBlobChild*>& blobChildList = data.blobsChild();
PRUint32 length = blobs.Length();
blobChildList.SetCapacity(length);
for (PRUint32 i = 0; i < length; ++i) {
BlobChild* blobChild = cc->GetOrCreateActorForBlob(blobs[i]);
if (!blobChild) {
return false;
}
blobChildList.AppendElement(blobChild);
}
}
return tabChild->SendAsyncMessage(nsString(aMessage), data);
}
示例2: BluetoothVoidReplyRunnable
already_AddRefed<Promise>
BluetoothMapRequestHandle::ReplyToMessagesListing(long aMasId,
Blob& aBlob,
bool aNewMessage,
const nsAString& aTimestamp,
int aSize,
ErrorResult& aRv)
{
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetParentObject());
if (!global) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
nsRefPtr<Promise> promise = Promise::Create(global, aRv);
NS_ENSURE_TRUE(!aRv.Failed(), nullptr);
BluetoothService* bs = BluetoothService::Get();
if (!bs) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
if (XRE_GetProcessType() == GeckoProcessType_Default) {
// In-process reply
bs->ReplyToMapMessagesListing(aMasId, &aBlob, aNewMessage, aTimestamp,
aSize, new BluetoothVoidReplyRunnable(nullptr, promise));
} else {
ContentChild *cc = ContentChild::GetSingleton();
if (!cc) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
BlobChild* actor = cc->GetOrCreateActorForBlob(&aBlob);
if (!actor) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
bs->ReplyToMapMessagesListing(nullptr, actor, aMasId, aNewMessage,
aTimestamp, aSize, new BluetoothVoidReplyRunnable(nullptr, promise));
}
return promise.forget();
}
示例3: BluetoothVoidReplyRunnable
already_AddRefed<DOMRequest>
BluetoothPbapRequestHandle::ReplyToPhonebookPulling(Blob& aBlob,
uint16_t phonebookSize,
ErrorResult& aRv)
{
nsCOMPtr<nsPIDOMWindow> win = GetParentObject();
if (!win) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
RefPtr<DOMRequest> request = new DOMRequest(win);
RefPtr<BluetoothVoidReplyRunnable> result =
new BluetoothVoidReplyRunnable(request);
BluetoothService* bs = BluetoothService::Get();
if (!bs) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
if (XRE_GetProcessType() == GeckoProcessType_Default) {
// In-process reply
bs->ReplyToPhonebookPulling(&aBlob, phonebookSize, result);
} else {
ContentChild *cc = ContentChild::GetSingleton();
if (!cc) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
BlobChild* actor = cc->GetOrCreateActorForBlob(&aBlob);
if (!actor) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
bs->ReplyToPhonebookPulling(nullptr, actor, phonebookSize, result);
}
return request.forget();
}
示例4: BluetoothVoidReplyRunnable
already_AddRefed<DOMRequest>
BluetoothAdapter::SendFile(const nsAString& aDeviceAddress,
File& aBlob, ErrorResult& aRv)
{
nsCOMPtr<nsPIDOMWindow> win = GetOwner();
if (!win) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
nsRefPtr<DOMRequest> request = new DOMRequest(win);
nsRefPtr<BluetoothVoidReplyRunnable> results =
new BluetoothVoidReplyRunnable(request);
BluetoothService* bs = BluetoothService::Get();
if (!bs) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
if (XRE_GetProcessType() == GeckoProcessType_Default) {
// In-process transfer
bs->SendFile(aDeviceAddress, &aBlob, results);
} else {
ContentChild *cc = ContentChild::GetSingleton();
if (!cc) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
BlobChild* actor = cc->GetOrCreateActorForBlob(&aBlob);
if (!actor) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
bs->SendFile(aDeviceAddress, nullptr, actor, results);
}
return request.forget();
}