本文整理汇总了C++中Blob::GetSize方法的典型用法代码示例。如果您正苦于以下问题:C++ Blob::GetSize方法的具体用法?C++ Blob::GetSize怎么用?C++ Blob::GetSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Blob
的用法示例。
在下文中一共展示了Blob::GetSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Send
void
nsDOMDataChannel::Send(Blob& aData, ErrorResult& aRv)
{
MOZ_ASSERT(NS_IsMainThread(), "Not running on main thread");
nsCOMPtr<nsIInputStream> msgStream;
aData.GetInternalStream(getter_AddRefs(msgStream), aRv);
if (NS_WARN_IF(aRv.Failed())){
return;
}
uint64_t msgLength = aData.GetSize(aRv);
if (NS_WARN_IF(aRv.Failed())){
return;
}
if (msgLength > UINT32_MAX) {
aRv.Throw(NS_ERROR_FILE_TOO_BIG);
return;
}
Send(msgStream, EmptyCString(), msgLength, true, aRv);
}
示例2: OnAutoFocusComplete
NS_IMETHODIMP
TestGonkCameraHardwareListener::HandleEvent(nsIDOMEvent* aEvent)
{
nsString eventType;
aEvent->GetType(eventType);
DOM_CAMERA_LOGI("Inject '%s' event",
NS_ConvertUTF16toUTF8(eventType).get());
if (eventType.EqualsLiteral("focus")) {
CameraStateChangeEvent* event = aEvent->InternalDOMEvent()->AsCameraStateChangeEvent();
if (!NS_WARN_IF(!event)) {
nsString state;
event->GetNewState(state);
if (state.EqualsLiteral("focused")) {
OnAutoFocusComplete(mTarget, true);
} else if (state.EqualsLiteral("unfocused")) {
OnAutoFocusComplete(mTarget, false);
} else if (state.EqualsLiteral("focusing")) {
OnAutoFocusMoving(mTarget, true);
} else if (state.EqualsLiteral("not_focusing")) {
OnAutoFocusMoving(mTarget, false);
} else {
DOM_CAMERA_LOGE("Unhandled focus state '%s'\n",
NS_ConvertUTF16toUTF8(state).get());
}
}
} else if (eventType.EqualsLiteral("shutter")) {
DOM_CAMERA_LOGI("Inject shutter event");
OnShutter(mTarget);
} else if (eventType.EqualsLiteral("picture")) {
BlobEvent* event = aEvent->InternalDOMEvent()->AsBlobEvent();
if (!NS_WARN_IF(!event)) {
Blob* blob = event->GetData();
if (blob) {
static const uint64_t MAX_FILE_SIZE = 2147483647;
ErrorResult rv;
uint64_t dataLength = blob->GetSize(rv);
if (NS_WARN_IF(rv.Failed()) || NS_WARN_IF(dataLength > MAX_FILE_SIZE)) {
rv.SuppressException();
return NS_OK;
}
nsCOMPtr<nsIInputStream> inputStream;
blob->GetInternalStream(getter_AddRefs(inputStream), rv);
if (NS_WARN_IF(rv.Failed())) {
rv.SuppressException();
return NS_OK;
}
uint8_t* data = new uint8_t[dataLength];
rv = NS_ReadInputStreamToBuffer(inputStream,
reinterpret_cast<void**>(&data),
static_cast<uint32_t>(dataLength));
if (NS_WARN_IF(rv.Failed())) {
rv.SuppressException();
delete [] data;
return NS_OK;
}
OnTakePictureComplete(mTarget, data, dataLength);
delete [] data;
} else {
OnTakePictureComplete(mTarget, nullptr, 0);
}
}
} else if(eventType.EqualsLiteral("error")) {
ErrorEvent* event = aEvent->InternalDOMEvent()->AsErrorEvent();
if (!NS_WARN_IF(!event)) {
nsString errorType;
event->GetMessage(errorType);
if (errorType.EqualsLiteral("picture")) {
OnTakePictureError(mTarget);
} else if (errorType.EqualsLiteral("system")) {
if (!NS_WARN_IF(!mCameraThread)) {
class DeferredSystemFailure : public nsRunnable
{
public:
DeferredSystemFailure(nsGonkCameraControl* aTarget)
: mTarget(aTarget)
{ }
NS_IMETHODIMP
Run()
{
OnSystemError(mTarget, CameraControlListener::kSystemService, 100, 0);
return NS_OK;
}
protected:
nsRefPtr<nsGonkCameraControl> mTarget;
};
//.........这里部分代码省略.........