/* static */ already_AddRefed<PresentationRequest> PresentationRequest::Constructor(const GlobalObject& aGlobal, const nsAString& aUrl, ErrorResult& aRv) { nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aGlobal.GetAsSupports()); if (!window) { aRv.Throw(NS_ERROR_UNEXPECTED); return nullptr; } // Ensure the URL is not empty. if (NS_WARN_IF(aUrl.IsEmpty())) { aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR); return nullptr; } RefPtr<PresentationRequest> request = new PresentationRequest(window, aUrl); return NS_WARN_IF(!request->Init()) ? nullptr : request.forget(); }
/*static*/ already_AddRefed<FetchEvent> FetchEvent::Constructor(const GlobalObject& aGlobal, const nsAString& aType, const FetchEventInit& aOptions, ErrorResult& aRv) { RefPtr<EventTarget> owner = do_QueryObject(aGlobal.GetAsSupports()); MOZ_ASSERT(owner); RefPtr<FetchEvent> e = new FetchEvent(owner); bool trusted = e->Init(owner); e->InitEvent(aType, aOptions.mBubbles, aOptions.mCancelable); e->SetTrusted(trusted); e->mRequest = aOptions.mRequest.WasPassed() ? &aOptions.mRequest.Value() : nullptr; e->mIsReload = aOptions.mIsReload.WasPassed() ? aOptions.mIsReload.Value() : false; e->mClient = aOptions.mClient.WasPassed() ? &aOptions.mClient.Value() : nullptr; return e.forget(); }
static already_AddRefed<OSFileSystem> MakeOrReuseFileSystem(const nsAString& aNewLocalRootPath, OSFileSystem* aFS, nsPIDOMWindow* aWindow) { MOZ_ASSERT(aWindow); RefPtr<OSFileSystem> fs; if (aFS) { const nsAString& prevLocalRootPath = aFS->GetLocalRootPath(); if (aNewLocalRootPath == prevLocalRootPath) { fs = aFS; } } if (!fs) { fs = new OSFileSystem(aNewLocalRootPath); fs->Init(aWindow); } return fs.forget(); }
already_AddRefed<MouseEvent> MouseEvent::Constructor(const GlobalObject& aGlobal, const nsAString& aType, const MouseEventInit& aParam, ErrorResult& aRv) { nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports()); RefPtr<MouseEvent> e = new MouseEvent(t, nullptr, nullptr); bool trusted = e->Init(t); e->InitMouseEvent(aType, aParam.mBubbles, aParam.mCancelable, aParam.mView, aParam.mDetail, aParam.mScreenX, aParam.mScreenY, aParam.mClientX, aParam.mClientY, aParam.mCtrlKey, aParam.mAltKey, aParam.mShiftKey, aParam.mMetaKey, aParam.mButton, aParam.mRelatedTarget, aRv); e->InitializeExtraMouseEventDictionaryMembers(aParam); e->SetTrusted(trusted); return e.forget(); }
HRESULT EnumDebugPropertyInfo2::Clone( IEnumDebugPropertyInfo2** ppEnum ) { HRESULT hr = S_OK; RefPtr<MagoEE::IEEDEnumValues> eeEnumCopy; RefPtr<EnumDebugPropertyInfo2> enumCopy; hr = mEEEnum->Clone( eeEnumCopy.Ref() ); if ( FAILED( hr ) ) return hr; hr = MakeCComObject( enumCopy ); if ( FAILED( hr ) ) return hr; hr = enumCopy->Init( eeEnumCopy, mExprContext, mFields, mFormatOpt ); if ( FAILED( hr ) ) return hr; return S_OK; }
// static already_AddRefed<GamepadManager> GamepadManager::GetService() { if (sShutdown) { return nullptr; } if (!gGamepadManagerSingleton) { RefPtr<GamepadManager> manager = new GamepadManager(); nsresult rv = manager->Init(); if(NS_WARN_IF(NS_FAILED(rv))) { return nullptr; } gGamepadManagerSingleton = manager; ClearOnShutdown(&gGamepadManagerSingleton); } RefPtr<GamepadManager> service(gGamepadManagerSingleton); return service.forget(); }
nsresult nsInputStreamPump::Create(nsInputStreamPump **result, nsIInputStream *stream, int64_t streamPos, int64_t streamLen, uint32_t segsize, uint32_t segcount, bool closeWhenDone) { nsresult rv = NS_ERROR_OUT_OF_MEMORY; RefPtr<nsInputStreamPump> pump = new nsInputStreamPump(); if (pump) { rv = pump->Init(stream, streamPos, streamLen, segsize, segcount, closeWhenDone); if (NS_SUCCEEDED(rv)) { pump.forget(result); } } return rv; }
/*static*/ already_AddRefed<GLContextEGL> GLContextEGL::CreateEGLPBufferOffscreenContext(CreateContextFlags flags, const mozilla::gfx::IntSize& size, const SurfaceCaps& minCaps) { SurfaceCaps configCaps; EGLConfig config = ChooseConfig(&sEGLLibrary, flags, minCaps, &configCaps); if (config == EGL_NO_CONFIG) { NS_WARNING("Failed to find a compatible config."); return nullptr; } if (GLContext::ShouldSpew()) sEGLLibrary.DumpEGLConfig(config); mozilla::gfx::IntSize pbSize(size); EGLSurface surface = GLContextEGL::CreatePBufferSurfaceTryingPowerOfTwo(config, LOCAL_EGL_NONE, pbSize); if (!surface) { NS_WARNING("Failed to create PBuffer for context!"); return nullptr; } RefPtr<GLContextEGL> gl = GLContextEGL::CreateGLContext(flags, configCaps, nullptr, true, config, surface); if (!gl) { NS_WARNING("Failed to create GLContext from PBuffer"); sEGLLibrary.fDestroySurface(sEGLLibrary.Display(), surface); return nullptr; } if (!gl->Init()) { NS_WARNING("Failed to initialize GLContext!"); // GLContextEGL::dtor will destroy |surface| for us. return nullptr; } return gl.forget(); }
nsresult imgRequestProxy::PerformClone(imgINotificationObserver* aObserver, imgRequestProxy* (aAllocFn)(imgRequestProxy*), imgRequestProxy** aClone) { NS_PRECONDITION(aClone, "Null out param"); LOG_SCOPE(gImgLog, "imgRequestProxy::Clone"); *aClone = nullptr; RefPtr<imgRequestProxy> clone = aAllocFn(this); // It is important to call |SetLoadFlags()| before calling |Init()| because // |Init()| adds the request to the loadgroup. // When a request is added to a loadgroup, its load flags are merged // with the load flags of the loadgroup. // XXXldb That's not true anymore. Stuff from imgLoader adds the // request to the loadgroup. clone->SetLoadFlags(mLoadFlags); nsresult rv = clone->Init(mBehaviour->GetOwner(), mLoadGroup, mURI, aObserver); if (NS_FAILED(rv)) { return rv; } if (GetOwner() && GetOwner()->GetValidator()) { clone->SetNotificationsDeferred(true); GetOwner()->GetValidator()->AddProxy(clone); } // Assign to *aClone before calling Notify so that if the caller expects to // only be notified for requests it's already holding pointers to it won't be // surprised. NS_ADDREF(*aClone = clone); // This is wrong!!! We need to notify asynchronously, but there's code that // assumes that we don't. This will be fixed in bug 580466. clone->SyncNotifyListener(); return NS_OK; }
// Test setting prefix set with only 5~32 bytes prefixes TEST(VariableLengthPrefixSet, VariableLengthSet) { RefPtr<VariableLengthPrefixSet> pset = new VariableLengthPrefixSet; pset->Init(NS_LITERAL_CSTRING("test")); PrefixStringMap map; _PrefixArray array = { _Prefix("bravo"), _Prefix("charlie"), _Prefix("delta"), _Prefix("EchoEchoEchoEchoEcho"), _Prefix("foxtrot"), _Prefix("GolfGolfGolfGolfGolfGolfGolfGolf"), _Prefix("hotel"), _Prefix("november"), _Prefix("oscar"), _Prefix("quebec"), _Prefix("romeo"), _Prefix("sierrasierrasierrasierrasierra"), _Prefix("Tango"), _Prefix("whiskey"), _Prefix("yankee"), _Prefix("ZuluZuluZuluZulu") }; SetupPrefixMap(array, map); pset->SetPrefixes(map); DoExpectedLookup(pset, array); DoRandomLookup(pset, 1000, array); CheckContent(pset, map); // Run random test array.Clear(); map.Clear(); RandomPrefixes(1500, 5, 32, array); SetupPrefixMap(array, map); pset->SetPrefixes(map); DoExpectedLookup(pset, array); DoRandomLookup(pset, 1000, array); CheckContent(pset, map); }
HRESULT PendingBreakpoint::SendErrorEvent( ErrorBreakpoint* errorBP ) { HRESULT hr = S_OK; CComPtr<IDebugEngine2> engine; CComPtr<IDebugErrorBreakpoint2> ad7ErrorBP; RefPtr<BreakpointErrorEvent> event; hr = errorBP->QueryInterface( __uuidof( IDebugErrorBreakpoint2 ), (void**) &ad7ErrorBP ); _ASSERT( hr == S_OK ); hr = mEngine->QueryInterface( __uuidof( IDebugEngine2 ), (void**) &engine ); _ASSERT( hr == S_OK ); hr = MakeCComObject( event ); if ( FAILED( hr ) ) return hr; event->Init( ad7ErrorBP ); return event->Send( mCallback, engine, NULL, NULL ); }
HRESULT PendingBreakpoint::SendBoundEvent( IEnumDebugBoundBreakpoints2* enumBPs ) { HRESULT hr = S_OK; CComPtr<IDebugPendingBreakpoint2> pendBP; CComPtr<IDebugEngine2> engine; RefPtr<BreakpointBoundEvent> event; hr = QueryInterface( __uuidof( IDebugPendingBreakpoint2 ), (void**) &pendBP ); _ASSERT( hr == S_OK ); hr = mEngine->QueryInterface( __uuidof( IDebugEngine2 ), (void**) &engine ); _ASSERT( hr == S_OK ); hr = MakeCComObject( event ); if ( FAILED( hr ) ) return hr; event->Init( enumBPs, pendBP ); return event->Send( mCallback, engine, NULL, NULL ); }
void EventCallback::OnProcessExit( DWORD uniquePid, DWORD exitCode ) { OutputDebugStringA( "EventCallback::OnProcessExit\n" ); HRESULT hr = S_OK; RefPtr<ProgramDestroyEvent> event; RefPtr<Program> prog; if ( !mEngine->FindProgram( uniquePid, prog ) ) return; mEngine->DeleteProgram( prog.Get() ); hr = MakeCComObject( event ); if ( FAILED( hr ) ) return; event->Init( exitCode ); SendEvent( event.Get(), prog.Get(), NULL ); }
already_AddRefed<InputEvent> InputEvent::Constructor( const GlobalObject& aGlobal, const nsAString& aType, const InputEventInit& aParam, ErrorResult& aRv) { nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports()); RefPtr<InputEvent> e = new InputEvent(t, nullptr, nullptr); bool trusted = e->Init(t); e->InitUIEvent(aType, aParam.mBubbles, aParam.mCancelable, aParam.mView, aParam.mDetail); InternalEditorInputEvent* internalEvent = e->mEvent->AsEditorInputEvent(); internalEvent->mInputType = InternalEditorInputEvent::GetEditorInputType(aParam.mInputType); if (internalEvent->mInputType == EditorInputType::eUnknown) { e->mInputTypeValue = aParam.mInputType; } internalEvent->mData = aParam.mData; internalEvent->mDataTransfer = aParam.mDataTransfer; internalEvent->mIsComposing = aParam.mIsComposing; e->SetTrusted(trusted); e->SetComposed(aParam.mComposed); return e.forget(); }
nsresult DeleteRangeTransaction::CreateTxnsToDeleteNodesBetween() { nsCOMPtr<nsIContentIterator> iter = NS_NewContentSubtreeIterator(); nsresult res = iter->Init(mRange); NS_ENSURE_SUCCESS(res, res); while (!iter->IsDone()) { nsCOMPtr<nsINode> node = iter->GetCurrentNode(); NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER); RefPtr<DeleteNodeTransaction> transaction = new DeleteNodeTransaction(); res = transaction->Init(mEditorBase, node, mRangeUpdater); NS_ENSURE_SUCCESS(res, res); AppendChild(transaction); iter->Next(); } return NS_OK; }
/* static */ already_AddRefed<AudioContext> AudioContext::Constructor(const GlobalObject& aGlobal, AudioChannel aChannel, ErrorResult& aRv) { nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aGlobal.GetAsSupports()); if (!window) { aRv.Throw(NS_ERROR_FAILURE); return nullptr; } RefPtr<AudioContext> object = new AudioContext(window, false, aChannel); aRv = object->Init(); if (NS_WARN_IF(aRv.Failed())) { return nullptr; } RegisterWeakMemoryReporter(object); return object.forget(); }
already_AddRefed<TCPServerSocket> TCPServerSocket::Constructor(const GlobalObject& aGlobal, uint16_t aPort, const ServerSocketOptions& aOptions, uint16_t aBacklog, mozilla::ErrorResult& aRv) { nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports()); if (!global) { aRv = NS_ERROR_FAILURE; return nullptr; } bool useArrayBuffers = aOptions.mBinaryType == TCPSocketBinaryType::Arraybuffer; RefPtr<TCPServerSocket> socket = new TCPServerSocket(global, aPort, useArrayBuffers, aBacklog); nsresult rv = socket->Init(); if (NS_WARN_IF(NS_FAILED(rv))) { aRv = NS_ERROR_FAILURE; return nullptr; } return socket.forget(); }
already_AddRefed<WheelEvent> WheelEvent::Constructor(const GlobalObject& aGlobal, const nsAString& aType, const WheelEventInit& aParam, ErrorResult& aRv) { nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports()); RefPtr<WheelEvent> e = new WheelEvent(t, nullptr, nullptr); bool trusted = e->Init(t); e->InitWheelEvent(aType, aParam.mBubbles, aParam.mCancelable, aParam.mView, aParam.mDetail, aParam.mScreenX, aParam.mScreenY, aParam.mClientX, aParam.mClientY, aParam.mButton, aParam.mRelatedTarget, EmptyString(), aParam.mDeltaX, aParam.mDeltaY, aParam.mDeltaZ, aParam.mDeltaMode); e->InitializeExtraMouseEventDictionaryMembers(aParam); e->SetTrusted(trusted); e->SetComposed(aParam.mComposed); return e.forget(); }
// Test setting prefix set with both 4-bytes prefixes and 5~32 bytes prefixes TEST(VariableLengthPrefixSet, MixedPrefixSet) { RefPtr<VariableLengthPrefixSet> pset = new VariableLengthPrefixSet; pset->Init(NS_LITERAL_CSTRING("test")); PrefixStringMap map; _PrefixArray array = { _Prefix("enus"), _Prefix("apollo"), _Prefix("mars"), _Prefix("Hecatonchires cyclopes"), _Prefix("vesta"), _Prefix("neptunus"), _Prefix("jupiter"), _Prefix("diana"), _Prefix("minerva"), _Prefix("ceres"), _Prefix("Aidos,Adephagia,Adikia,Aletheia"), _Prefix("hecatonchires"), _Prefix("alcyoneus"), _Prefix("hades"), _Prefix("vulcanus"), _Prefix("juno"), _Prefix("mercury"), _Prefix("Stheno, Euryale and Medusa") }; SetupPrefixMap(array, map); pset->SetPrefixes(map); DoExpectedLookup(pset, array); DoRandomLookup(pset, 1000, array); CheckContent(pset, map); // Run random test array.Clear(); map.Clear(); RandomPrefixes(1500, 4, 32, array); SetupPrefixMap(array, map); pset->SetPrefixes(map); DoExpectedLookup(pset, array); DoRandomLookup(pset, 1000, array); CheckContent(pset, map); }
bool MediaDecodeTask::CreateReader() { MOZ_ASSERT(NS_IsMainThread()); nsPIDOMWindowInner* parent = mDecodeJob.mContext->GetParentObject(); MOZ_ASSERT(parent); nsCOMPtr<nsIPrincipal> principal; nsCOMPtr<nsIScriptObjectPrincipal> sop = do_QueryInterface(parent); if (sop) { principal = sop->GetPrincipal(); } RefPtr<BufferMediaResource> resource = new BufferMediaResource(static_cast<uint8_t*> (mBuffer), mLength, principal, mContainerType); MOZ_ASSERT(!mBufferDecoder); RefPtr<AbstractThread> mainThread = mDecodeJob.mContext->GetOwnerGlobal()->AbstractMainThreadFor(TaskCategory::Other); mBufferDecoder = new BufferDecoder(resource, mainThread, new BufferDecoderGMPCrashHelper(parent)); // If you change this list to add support for new decoders, please consider // updating HTMLMediaElement::CreateDecoder as well. mDecoderReader = DecoderTraits::CreateReader(mContainerType, mBufferDecoder); if (!mDecoderReader) { return false; } nsresult rv = mDecoderReader->Init(); if (NS_FAILED(rv)) { return false; } return true; }
/*static*/ already_AddRefed<GLContextEGL> GLContextEGL::CreateEGLPixmapOffscreenContext(const mozilla::gfx::IntSize& size) { gfxASurface *thebesSurface = nullptr; EGLNativePixmapType pixmap = 0; if (!pixmap) { return nullptr; } EGLSurface surface = 0; EGLConfig config = 0; if (!config) { return nullptr; } MOZ_ASSERT(surface); SurfaceCaps dummyCaps = SurfaceCaps::Any(); RefPtr<GLContextEGL> glContext = GLContextEGL::CreateGLContext(CreateContextFlags::NONE, dummyCaps, nullptr, true, config, surface); if (!glContext) { NS_WARNING("Failed to create GLContext from XSurface"); sEGLLibrary.fDestroySurface(EGL_DISPLAY(), surface); return nullptr; } if (!glContext->Init()) { NS_WARNING("Failed to initialize GLContext!"); // GLContextEGL::dtor will destroy |surface| for us. return nullptr; } glContext->HoldSurface(thebesSurface); return glContext.forget(); }
/* static */ already_AddRefed<PresentationConnection> PresentationConnection::Create(nsPIDOMWindowInner* aWindow, const nsAString& aId, const nsAString& aUrl, const uint8_t aRole, PresentationConnectionList* aList) { MOZ_ASSERT(aRole == nsIPresentationService::ROLE_CONTROLLER || aRole == nsIPresentationService::ROLE_RECEIVER); RefPtr<PresentationConnection> connection = new PresentationConnection(aWindow, aId, aUrl, aRole, aList); if (NS_WARN_IF(!connection->Init())) { return nullptr; } if (aRole == nsIPresentationService::ROLE_CONTROLLER) { ControllerConnectionCollection::GetSingleton()->AddConnection(connection, aRole); } return connection.forget(); }
NS_IMETHODIMP nsSocketTransportService::CreateRoutedTransport(const char **types, uint32_t typeCount, const nsACString &host, int32_t port, const nsACString &hostRoute, int32_t portRoute, nsIProxyInfo *proxyInfo, nsISocketTransport **result) { NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED); NS_ENSURE_TRUE(port >= 0 && port <= 0xFFFF, NS_ERROR_ILLEGAL_VALUE); RefPtr<nsSocketTransport> trans = new nsSocketTransport(); nsresult rv = trans->Init(types, typeCount, host, port, hostRoute, portRoute, proxyInfo); if (NS_FAILED(rv)) { return rv; } trans.forget(result); return NS_OK; }
/* static */ already_AddRefed<IDecodingTask> DecoderFactory::CreateDecoder(DecoderType aType, NotNull<RasterImage*> aImage, NotNull<SourceBuffer*> aSourceBuffer, const Maybe<IntSize>& aTargetSize, DecoderFlags aDecoderFlags, SurfaceFlags aSurfaceFlags, int aSampleSize) { if (aType == DecoderType::UNKNOWN) { return nullptr; } RefPtr<Decoder> decoder = GetDecoder(aType, aImage, bool(aDecoderFlags & DecoderFlags::IS_REDECODE)); MOZ_ASSERT(decoder, "Should have a decoder now"); // Initialize the decoder. decoder->SetMetadataDecode(false); decoder->SetIterator(aSourceBuffer->Iterator()); decoder->SetDecoderFlags(aDecoderFlags | DecoderFlags::FIRST_FRAME_ONLY); decoder->SetSurfaceFlags(aSurfaceFlags); decoder->SetSampleSize(aSampleSize); // Set a target size for downscale-during-decode if applicable. if (aTargetSize) { DebugOnly<nsresult> rv = decoder->SetTargetSize(*aTargetSize); MOZ_ASSERT(NS_SUCCEEDED(rv), "Bad downscale-during-decode target size?"); } decoder->Init(); if (NS_FAILED(decoder->GetDecoderError())) { return nullptr; } RefPtr<IDecodingTask> task = new DecodingTask(WrapNotNull(decoder)); return task.forget(); }
/* static */ already_AddRefed<Decoder> DecoderFactory::CreateAnonymousMetadataDecoder(DecoderType aType, NotNull<SourceBuffer*> aSourceBuffer) { if (aType == DecoderType::UNKNOWN) { return nullptr; } RefPtr<Decoder> decoder = GetDecoder(aType, /* aImage = */ nullptr, /* aIsRedecode = */ false); MOZ_ASSERT(decoder, "Should have a decoder now"); // Initialize the decoder. decoder->SetMetadataDecode(true); decoder->SetIterator(aSourceBuffer->Iterator()); decoder->SetDecoderFlags(DecoderFlags::FIRST_FRAME_ONLY); if (NS_FAILED(decoder->Init())) { return nullptr; } return decoder.forget(); }
HRESULT StackFrame::GetCodeContext( IDebugCodeContext2** ppCodeCxt ) { if ( ppCodeCxt == NULL ) return E_INVALIDARG; HRESULT hr = S_OK; RefPtr<CodeContext> codeContext; hr = MakeCComObject( codeContext ); if ( FAILED( hr ) ) return hr; CComPtr<IDebugDocumentContext2> docContext; hr = GetDocumentContext( &docContext ); // there doesn't have to be a document context hr = codeContext->Init( mPC, mModule, docContext, mPtrSize ); if ( FAILED( hr ) ) return hr; return codeContext->QueryInterface( __uuidof( IDebugCodeContext2 ), (void**) ppCodeCxt ); }
HRESULT RemoteDebuggerProxy::Attach( uint32_t pid, ICoreProcess*& process ) { HRESULT hr = S_OK; RefPtr<RemoteProcess> coreProc; RefPtr<ArchData> archData; MagoRemote_ProcInfo cmdProcInfo = { 0 }; coreProc = new RemoteProcess(); if ( coreProc.Get() == NULL ) return E_OUTOFMEMORY; hr = AttachNoException( pid, cmdProcInfo ); if ( FAILED( hr ) ) return hr; hr = ArchData::MakeArchData( cmdProcInfo.MachineType, cmdProcInfo.MachineFeatures, archData.Ref() ); if ( FAILED( hr ) ) { MIDL_user_free( cmdProcInfo.ExePath ); return hr; } coreProc->Init( cmdProcInfo.Pid, cmdProcInfo.ExePath, Create_Attach, cmdProcInfo.MachineType, archData.Get() ); process = coreProc.Detach(); MIDL_user_free( cmdProcInfo.ExePath ); return S_OK; }
NS_IMETHODIMP PresentationDeviceRequest::Select(nsIPresentationDevice* aDevice) { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(aDevice); nsCOMPtr<nsIPresentationService> service = do_GetService(PRESENTATION_SERVICE_CONTRACTID); if (NS_WARN_IF(!service)) { return NS_ERROR_NOT_AVAILABLE; } // Update device in the session info. RefPtr<PresentationSessionInfo> info = static_cast<PresentationService*>(service.get())-> GetSessionInfo(mId, nsIPresentationService::ROLE_CONTROLLER); if (NS_WARN_IF(!info)) { return NS_ERROR_NOT_AVAILABLE; } info->SetDevice(aDevice); // Establish a control channel. If we failed to do so, the callback is called // with an error message. nsCOMPtr<nsIPresentationControlChannel> ctrlChannel; nsresult rv = aDevice->EstablishControlChannel(mRequestUrl, mId, getter_AddRefs(ctrlChannel)); if (NS_WARN_IF(NS_FAILED(rv))) { return info->ReplyError(NS_ERROR_DOM_OPERATION_ERR); } // Initialize the session info with the control channel. rv = info->Init(ctrlChannel); if (NS_WARN_IF(NS_FAILED(rv))) { return info->ReplyError(NS_ERROR_DOM_OPERATION_ERR); } return NS_OK; }
nsresult PresentationDeviceRequest::CreateSessionInfo( nsIPresentationDevice* aDevice, const nsAString& aSelectedRequestUrl) { nsCOMPtr<nsIPresentationService> service = do_GetService(PRESENTATION_SERVICE_CONTRACTID); if (NS_WARN_IF(!service)) { return NS_ERROR_NOT_AVAILABLE; } // Create the controlling session info RefPtr<PresentationSessionInfo> info = static_cast<PresentationService*>(service.get())-> CreateControllingSessionInfo(aSelectedRequestUrl, mId, mWindowId); if (NS_WARN_IF(!info)) { return NS_ERROR_NOT_AVAILABLE; } info->SetDevice(aDevice); // Establish a control channel. If we failed to do so, the callback is called // with an error message. nsCOMPtr<nsIPresentationControlChannel> ctrlChannel; nsresult rv = aDevice->EstablishControlChannel(getter_AddRefs(ctrlChannel)); if (NS_WARN_IF(NS_FAILED(rv))) { return info->ReplyError(NS_ERROR_DOM_OPERATION_ERR); } // Initialize the session info with the control channel. rv = info->Init(ctrlChannel); if (NS_WARN_IF(NS_FAILED(rv))) { return info->ReplyError(NS_ERROR_DOM_OPERATION_ERR); } info->SetTransportBuilderConstructor(mBuilderConstructor); return NS_OK; }
TEST(MP4Reader, Normalised) { RefPtr<TestBinding> b = new TestBinding("mediasource_test.mp4"); b->Init(); // The first 5 video samples of this file are: // Video timescale=2500 // Frame Start Size Time Duration Sync // 1 48 5455 166 83 Yes // 2 5503 145 249 83 // 3 6228 575 581 83 // 4 7383 235 415 83 // 5 8779 183 332 83 // 6 9543 191 498 83 // // Audio timescale=44100 // 1 5648 580 0 1024 Yes // 2 6803 580 1024 1058 Yes // 3 7618 581 2082 1014 Yes // 4 8199 580 3096 1015 Yes // 5 8962 581 4111 1014 Yes // 6 9734 580 5125 1014 Yes // 7 10314 581 6139 1059 Yes // 8 11207 580 7198 1014 Yes // 9 12035 581 8212 1014 Yes // 10 12616 580 9226 1015 Yes // 11 13220 581 10241 1014 Yes b->resource->MockClearBufferedRanges(); b->resource->MockAddBufferedRange(48, 13901); media::TimeIntervals ranges = b->reader->GetBuffered(); EXPECT_EQ(1U, ranges.Length()); EXPECT_NEAR(166.0 / 2500.0, ranges.Start(0).ToSeconds(), 0.000001); EXPECT_NEAR(11255.0 / 44100.0, ranges.End(0).ToSeconds(), 0.000001); }