Skip to content

Commit

Permalink
Bug 1467889 - Adjust some uses of XPCOM strings. r=mrbkap r=mstange
Browse files Browse the repository at this point in the history
MozReview-Commit-ID: 5AG4WAmbLZz
  • Loading branch information
jld committed Jul 19, 2018
1 parent cf21a1d commit 96c18b6
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions dom/base/nsContentUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7769,8 +7769,8 @@ nsContentUtils::IPCTransferableToTransferable(const IPCDataTransfer& aDataTransf

// The buffer contains the terminating null.
Shmem itemData = item.data().get_Shmem();
const nsDependentCString text(itemData.get<char>(),
itemData.Size<char>());
const nsDependentCSubstring text(itemData.get<char>(),
itemData.Size<char>());
rv = dataWrapper->SetData(text);
NS_ENSURE_SUCCESS(rv, rv);

Expand Down Expand Up @@ -7951,15 +7951,15 @@ ConvertToShmem(mozilla::dom::nsIContentChild* aChild,
: static_cast<IShmemAllocator*>(aParent);

Shmem result;
if (!allocator->AllocShmem(aInput.Length() + 1,
if (!allocator->AllocShmem(aInput.Length(),
SharedMemory::TYPE_BASIC,
&result)) {
return result;
}

memcpy(result.get<char>(),
aInput.BeginReading(),
aInput.Length() + 1);
aInput.Length());

return result;
}
Expand Down
2 changes: 1 addition & 1 deletion dom/ipc/ContentChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3343,7 +3343,7 @@ ContentChild::RecvInvokeDragSession(nsTArray<IPCDataTransfer>&& aTransfers,
variant->SetAsAString(data);
} else if (item.data().type() == IPCDataTransferData::TShmem) {
Shmem data = item.data().get_Shmem();
variant->SetAsACString(nsDependentCString(data.get<char>(), data.Size<char>()));
variant->SetAsACString(nsDependentCSubstring(data.get<char>(), data.Size<char>()));
Unused << DeallocShmem(data);
} else if (item.data().type() == IPCDataTransferData::TIPCBlob) {
RefPtr<BlobImpl> blobImpl =
Expand Down
2 changes: 1 addition & 1 deletion dom/ipc/TabParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3402,7 +3402,7 @@ TabParent::AddInitialDnDDataTo(DataTransfer* aDataTransfer,
variant->SetAsISupports(imageContainer);
} else {
Shmem data = item.data().get_Shmem();
variant->SetAsACString(nsDependentCString(data.get<char>(), data.Size<char>()));
variant->SetAsACString(nsDependentCSubstring(data.get<char>(), data.Size<char>()));
}

mozilla::Unused << DeallocShmem(item.data().get_Shmem());
Expand Down
4 changes: 2 additions & 2 deletions tools/profiler/gecko/nsProfiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,8 +613,8 @@ nsProfiler::StartGathering(double aSinceTime)
for (auto profile : profiles) {
profile->Then(GetMainThreadSerialEventTarget(), __func__,
[self](const mozilla::ipc::Shmem& aResult) {
const nsDependentCString profileString(aResult.get<char>(),
aResult.Size<char>());
const nsDependentCSubstring profileString(aResult.get<char>(),
aResult.Size<char>() - 1);
self->GatheredOOPProfile(profileString);
},
[self](ipc::ResponseRejectReason aReason) {
Expand Down
4 changes: 2 additions & 2 deletions widget/nsClipboardProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ nsClipboardProxy::GetData(nsITransferable *aTransferable, int32_t aWhichClipboar
nsCOMPtr<nsIInputStream> stream;

NS_NewCStringInputStream(getter_AddRefs(stream),
nsDependentCString(data.get<char>(), data.Size<char>()));
nsDependentCSubstring(data.get<char>(), data.Size<char>()));

rv = aTransferable->SetTransferData(flavor.get(), stream, sizeof(nsISupports*));
NS_ENSURE_SUCCESS(rv, rv);
Expand All @@ -110,7 +110,7 @@ nsClipboardProxy::GetData(nsITransferable *aTransferable, int32_t aWhichClipboar
do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);

rv = dataWrapper->SetData(nsDependentCString(data.get<char>(), data.Size<char>()));
rv = dataWrapper->SetData(nsDependentCSubstring(data.get<char>(), data.Size<char>()));
NS_ENSURE_SUCCESS(rv, rv);

rv = aTransferable->SetTransferData(item.flavor().get(), dataWrapper,
Expand Down

0 comments on commit 96c18b6

Please sign in to comment.