Exemplo n.º 1
0
void // nsresult
Test06_nsCOMPtr00(nsIDOMWindowInternal* aDOMWindow, nsIWebShellWindow** aWebShellWindow)
    // m328, w191/199
{
//  if (!aDOMWindow)
//    return NS_ERROR_NULL_POINTER;
  nsresult status;
  nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject = do_QueryInterface(aDOMWindow, &status);
  nsIDocShell* temp0 = 0;
  if (scriptGlobalObject)
    scriptGlobalObject->GetDocShell(&temp0);
  nsCOMPtr<nsIDocShell> docShell = dont_AddRef(temp0);
  nsCOMPtr<nsIWebShell> webShell;
  if (docShell)
    webShell=do_QueryInterface(docShell, &status);
  nsIWebShellContainer* temp2 = 0;
  if (webShell)
    status = webShell->GetContainer(temp2);
  nsCOMPtr<nsIWebShellContainer> webShellContainer = dont_AddRef(temp2);
  if (webShellContainer)
    status = webShellContainer->QueryInterface(NS_GET_IID(nsIWebShellWindow), (void**)aWebShellWindow);
  else
    (*aWebShellWindow) = 0;
//    return status;
}
Exemplo n.º 2
0
void // nsresult
Test06_nsCOMPtr03(nsIDOMWindowInternal* aDOMWindow, nsCOMPtr<nsIWebShellWindow>* aWebShellWindow)
    // m332, w189/188
{
//    if (!aDOMWindow)
//      return NS_ERROR_NULL_POINTER;
  (*aWebShellWindow) = 0;
  nsresult status;
  nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject = do_QueryInterface(aDOMWindow, &status);
  if (scriptGlobalObject) {
    nsIDocShell* temp0;
    scriptGlobalObject->GetDocShell(&temp0);
    nsCOMPtr<nsIDocShell> docShell = dont_AddRef(temp0);
    if (docShell) {
      nsCOMPtr<nsIWebShell> webShell = do_QueryInterface(docShell, &status);
      if (webShell) {
        nsIWebShellContainer* temp2;
        status = webShell->GetContainer(temp2);
        nsCOMPtr<nsIWebShellContainer> webShellContainer = dont_AddRef(temp2);
        (*aWebShellWindow) = do_QueryInterface(webShellContainer, &status);
      }
    }
  }
//    return status;
}
Exemplo n.º 3
0
void
nsFileView::ReverseArray(nsISupportsArray* aArray)
{
  PRUint32 count;
  aArray->Count(&count);
  for (PRUint32 i = 0; i < count/2; ++i) {
    nsCOMPtr<nsISupports> element = dont_AddRef(aArray->ElementAt(i));
    nsCOMPtr<nsISupports> element2 = dont_AddRef(aArray->ElementAt(count-i-1));
    aArray->ReplaceElementAt(element2, i);
    aArray->ReplaceElementAt(element, count-i-1);
  }
}
NS_INTERFACE_MAP_END

// nsIWindowMediatorListener implementation
// handle notifications from the window mediator and reflect them into
// RDF

/* void onWindowTitleChange (in nsIXULWindow window, in wstring newTitle); */
NS_IMETHODIMP
nsWindowDataSource::OnWindowTitleChange(nsIXULWindow *window,
                                        const PRUnichar *newTitle)
{
    nsresult rv;
    
    nsVoidKey key(window);

    nsCOMPtr<nsISupports> sup =
        dont_AddRef(mWindowResources.Get(&key));

    // oops, make sure this window is in the hashtable!
    if (!sup) {
        OnOpenWindow(window);
        sup = dont_AddRef(mWindowResources.Get(&key));
    }
    
    NS_ENSURE_TRUE(sup, NS_ERROR_UNEXPECTED);

    nsCOMPtr<nsIRDFResource> windowResource =
        do_QueryInterface(sup);

    nsCOMPtr<nsIRDFLiteral> newTitleLiteral;
    rv = gRDFService->GetLiteral(newTitle, getter_AddRefs(newTitleLiteral));
    NS_ENSURE_SUCCESS(rv, rv);

    // get the old title
    nsCOMPtr<nsIRDFNode> oldTitleNode;
    rv = GetTarget(windowResource, kNC_Name, PR_TRUE,
                   getter_AddRefs(oldTitleNode));
    
    // assert the change
    if (NS_SUCCEEDED(rv) && oldTitleNode)
        // has an existing window title, update it
        rv = Change(windowResource, kNC_Name, oldTitleNode, newTitleLiteral);
    else
        // removed from the tasklist
        rv = Assert(windowResource, kNC_Name, newTitleLiteral, PR_TRUE);

    if (rv != NS_RDF_ASSERTION_ACCEPTED)
    {
      NS_ERROR("unable to set window name");
    }
    
    return NS_OK;
}
Exemplo n.º 5
0
already_AddRefed<TransactionItem>
TransactionStack::Pop()
{
  RefPtr<TransactionItem> item =
    dont_AddRef(static_cast<TransactionItem*>(nsDeque::Pop()));
  return item.forget();
}
Exemplo n.º 6
0
nsresult
nsXPTZipLoader::EnumerateEntries(nsILocalFile* aFile,
                                 nsIXPTLoaderSink* aSink)
{
    nsCOMPtr<nsIZipReader> zip = dont_AddRef(GetZipReader(aFile));

    if (!zip) {
        NS_WARNING("Could not get Zip Reader");
        return NS_OK;
    }

    nsCOMPtr<nsIUTF8StringEnumerator> entries;
    if (NS_FAILED(zip->FindEntries("*.xpt", getter_AddRefs(entries))) ||
        !entries) {
        // no problem, just no .xpt files in this archive
        return NS_OK;
    }

    PRBool hasMore;
    int index = 0;
    while (NS_SUCCEEDED(entries->HasMore(&hasMore)) && hasMore) {
        nsCAutoString itemName;
        if (NS_FAILED(entries->GetNext(itemName)))
            return NS_ERROR_UNEXPECTED;

        nsCOMPtr<nsIInputStream> stream;
        if (NS_FAILED(zip->GetInputStream(itemName.get(), getter_AddRefs(stream))))
            return NS_ERROR_FAILURE;

        // ignore the result
        aSink->FoundEntry(itemName.get(), index++, stream);
    }

    return NS_OK;
}
Exemplo n.º 7
0
nsresult
nsExceptionService::DoGetExceptionFromProvider(nsresult errCode, 
                                               nsIException * defaultException,
                                               nsIException **_exc)
{
    // Check for an existing exception
    nsresult nr = GetCurrentException(_exc);
    if (NS_SUCCEEDED(nr) && *_exc) {
        (*_exc)->GetResult(&nr);
        // If it matches our result then use it
        if (nr == errCode)
            return NS_OK;
        NS_RELEASE(*_exc);
    }
    nsProviderKey key(NS_ERROR_GET_MODULE(errCode));
    nsCOMPtr<nsIExceptionProvider> provider =
        dont_AddRef((nsIExceptionProvider *)mProviders.Get(&key));

    // No provider so we'll return the default exception
    if (!provider) {
        *_exc = defaultException;
        NS_IF_ADDREF(*_exc);
        return NS_OK;
    }

    return provider->GetException(errCode, defaultException, _exc);
}
Exemplo n.º 8
0
JSObject *
xpc_NewIDObject(JSContext *cx, JSObject* jsobj, const nsID& aID)
{
    JSObject *obj = nsnull;

    nsCOMPtr<nsIJSID> iid =
            dont_AddRef(static_cast<nsIJSID*>(nsJSID::NewID(aID)));
    if(iid)
    {
        nsXPConnect* xpc = nsXPConnect::GetXPConnect();
        if(xpc)
        {
            nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
            nsresult rv = xpc->WrapNative(cx, jsobj,
                                          static_cast<nsISupports*>(iid),
                                          NS_GET_IID(nsIJSID),
                                          getter_AddRefs(holder));
            if(NS_SUCCEEDED(rv) && holder)
            {
                holder->GetJSObject(&obj);
            }
        }
    }
    return obj;
}
Exemplo n.º 9
0
void
EventTokenBucket::DispatchEvents()
{
    MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
    SOCKET_LOG(("EventTokenBucket::DispatchEvents %p %d\n", this, mPaused));
    if (mPaused || mStopped)
        return;

    while (mEvents.GetSize() && mUnitCost <= mCredit) {
        nsRefPtr<TokenBucketCancelable> cancelable =
            dont_AddRef(static_cast<TokenBucketCancelable *>(mEvents.PopFront()));
        if (cancelable->mEvent) {
            SOCKET_LOG(("EventTokenBucket::DispachEvents [%p] "
                        "Dispatching queue token bucket event cost=%lu credit=%lu\n",
                        this, mUnitCost, mCredit));
            mCredit -= mUnitCost;
            cancelable->Fire();
        }
    }

#ifdef XP_WIN
    if (!mEvents.GetSize())
        WantNormalTimers();
#endif
}
Exemplo n.º 10
0
already_AddRefed<nsTransactionItem>
nsTransactionStack::PopBottom()
{
  RefPtr<nsTransactionItem> item =
    dont_AddRef(static_cast<nsTransactionItem*>(nsDeque::PopFront()));
  return item.forget();
}
Exemplo n.º 11
0
nsresult WebBrowserChrome::CreateBrowser(HWND nativeWnd)
{
	nsresult rv;
	mWebBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID, &rv);
	if(NS_FAILED(rv))
		return NS_ERROR_FAILURE;

	AddRef();
	if(NS_FAILED(mWebBrowser->SetContainerWindow((nsIWebBrowserChrome*)this)))
		return NS_ERROR_FAILURE;
	
	mNativeWindow = nativeWnd;
	RECT area;
	GetClientRect(mNativeWindow, &area);
	nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(mWebBrowser);
	if(NS_FAILED(baseWindow->InitWindow(mNativeWindow, NULL, area.left, area.top, area.right - area.left, area.bottom - area.top)))
		return NS_ERROR_FAILURE;
	if(NS_FAILED(baseWindow->Create()))
		return NS_ERROR_FAILURE;
	baseWindow->SetVisibility(PR_TRUE);

	nsWeakPtr weakling(dont_AddRef(NS_GetWeakReference(static_cast<nsIWebProgressListener*>(this))));
	if(NS_FAILED(mWebBrowser->AddWebBrowserListener(weakling, NS_GET_IID(nsIWebProgressListener))))
		return NS_ERROR_FAILURE;

	return NS_OK;
}
Exemplo n.º 12
0
bool
nsIContentChild::DeallocPIPCBlobInputStreamChild(PIPCBlobInputStreamChild* aActor)
{
  RefPtr<IPCBlobInputStreamChild> actor =
    dont_AddRef(static_cast<IPCBlobInputStreamChild*>(aActor));
  return true;
}
Exemplo n.º 13
0
// (static) Creates a ShellLink that encapsulate a separator.
nsresult JumpListSeparator::GetSeparator(nsRefPtr<IShellLinkW>& aShellLink)
{
  HRESULT hr;
  IShellLinkW* psl;

  // Create a IShellLink.
  hr = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, 
                        IID_IShellLinkW, (LPVOID*)&psl);
  if (FAILED(hr))
    return NS_ERROR_UNEXPECTED;

  IPropertyStore* pPropStore = nullptr;
  hr = psl->QueryInterface(IID_IPropertyStore, (LPVOID*)&pPropStore);
  if (FAILED(hr))
    return NS_ERROR_UNEXPECTED;

  PROPVARIANT pv;
  InitPropVariantFromBoolean(TRUE, &pv);

  pPropStore->SetValue(PKEY_AppUserModel_IsDestListSeparator, pv);
  pPropStore->Commit();
  pPropStore->Release();

  PropVariantClear(&pv);

  aShellLink = dont_AddRef(psl);

  return NS_OK;
}
Exemplo n.º 14
0
NS_IMETHODIMP
nsDirectoryService::Get(const char* prop, const nsIID & uuid, void* *result)
{
    nsCStringKey key(prop);

    nsCOMPtr<nsISupports> value = dont_AddRef(mHashtable.Get(&key));

    if (value)
    {
        nsCOMPtr<nsIFile> cloneFile;
        nsCOMPtr<nsIFile> cachedFile = do_QueryInterface(value);
        NS_ASSERTION(cachedFile, "nsIFile expected");

        cachedFile->Clone(getter_AddRefs(cloneFile));
        return cloneFile->QueryInterface(uuid, result);
    }

    // it is not one of our defaults, lets check any providers
    FileData fileData(prop, uuid);

    mProviders->EnumerateBackwards(FindProviderFile, &fileData);
    if (fileData.data)
    {
        if (fileData.persistent)
        {
            Set(prop, NS_STATIC_CAST(nsIFile*, fileData.data));
        }
        nsresult rv = (fileData.data)->QueryInterface(uuid, result);
        NS_RELEASE(fileData.data);  // addref occurs in FindProviderFile()
        return rv;
    }
Exemplo n.º 15
0
bool
NeckoChild::DeallocPWebSocketEventListenerChild(PWebSocketEventListenerChild* aActor)
{
  RefPtr<WebSocketEventListenerChild> c =
    dont_AddRef(static_cast<WebSocketEventListenerChild*>(aActor));
  MOZ_ASSERT(c);
  return true;
}
Exemplo n.º 16
0
bool
PresentationParent::DeallocPPresentationRequestParent(
  PPresentationRequestParent* aActor)
{
  RefPtr<PresentationRequestParent> actor =
    dont_AddRef(static_cast<PresentationRequestParent*>(aActor));
  return true;
}
Exemplo n.º 17
0
NS_IMETHODIMP
nsEmbedFilePicker::OnMessageReceived(const char* messageName, const PRUnichar* message)
{
  nsCOMPtr<nsIEmbedLiteJSON> json = do_GetService("@mozilla.org/embedlite-json;1");
  nsCOMPtr<nsIPropertyBag2> root;
  NS_ENSURE_SUCCESS(json->ParseJSON(nsDependentString(message), getter_AddRefs(root)), NS_ERROR_FAILURE);

  uint32_t winid = 0;
  root->GetPropertyAsUint32(NS_LITERAL_STRING("winid"), &winid);

  std::map<uint32_t, EmbedFilePickerResponse>::iterator it = mResponseMap.find(winid);
  if (it == mResponseMap.end()) {
    return NS_ERROR_FAILURE;
  }
  EmbedFilePickerResponse& response = it->second;

  root->GetPropertyAsBool(NS_LITERAL_STRING("accepted"), &response.accepted);
  nsCOMPtr<nsIVariant> itemsvar;
  nsresult rv = root->GetProperty(NS_LITERAL_STRING("items"), getter_AddRefs(itemsvar));

  uint16_t dataType = 0;
  itemsvar->GetDataType(&dataType);

  if (dataType == nsIDataType::VTYPE_ARRAY) {
    uint16_t valueType;
    nsIID iid;
    uint32_t valueCount;
    void* rawArray;
    if (NS_SUCCEEDED(itemsvar->GetAsArray(&valueType, &iid, &valueCount, &rawArray))) {
      if (valueType == nsIDataType::VTYPE_INTERFACE ||
          valueType == nsIDataType::VTYPE_INTERFACE_IS) {
        nsISupports** values = static_cast<nsISupports**>(rawArray);
        for (uint32_t i = 0; i < valueCount; ++i) {
          nsCOMPtr<nsISupports> supports = dont_AddRef(values[i]);
          nsCOMPtr<nsIVariant> item = do_QueryInterface(supports);
          nsString itemString;
          if (item && NS_SUCCEEDED(item->GetAsAString(itemString))) {
            response.items.AppendElement(itemString);
          }
        }
      }
      nsMemory::Free(rawArray);
    }
  } else {
    NS_ERROR("Unexpected items type");
  }

  if (mCallback) {
    mCallback->Done(nsIFilePicker::returnOK);
    mCallback = nullptr;
    mService->RemoveMessageListener("promptresponse", this);
  }
  else {
    mModalDepth--;
  }

  return NS_OK;
}
Exemplo n.º 18
0
// returns true if progress was made by shortening the queue
bool
nsPACMan::ProcessPending()
{
  if (mPendingQ.isEmpty())
    return false;

  // queue during normal load, but if we are retrying a failed load then
  // fast fail the queries
  if (mInProgress || (IsLoading() && !mLoadFailureCount))
    return false;

  RefPtr<PendingPACQuery> query(dont_AddRef(mPendingQ.popFirst()));

  if (mShutdown || IsLoading()) {
    query->Complete(NS_ERROR_NOT_AVAILABLE, EmptyCString());
    return true;
  }

  nsAutoCString pacString;
  bool completed = false;
  mInProgress = true;
  nsAutoCString PACURI;

  // first we need to consider the system proxy changing the pac url
  if (mSystemProxySettings &&
      NS_SUCCEEDED(mSystemProxySettings->GetPACURI(PACURI)) &&
      !PACURI.IsEmpty() &&
      !PACURI.Equals(mPACURISpec)) {
    query->UseAlternatePACFile(PACURI);
    LOG(("Use PAC from system settings: %s\n", PACURI.get()));
    completed = true;
  }

  // now try the system proxy settings for this particular url if
  // PAC was not specified
  if (!completed && mSystemProxySettings && PACURI.IsEmpty() &&
      NS_SUCCEEDED(mSystemProxySettings->
                   GetProxyForURI(query->mSpec, query->mScheme,
                                  query->mHost, query->mPort,
                                  pacString))) {
    LOG(("Use proxy from system settings: %s\n", pacString.get()));
    query->Complete(NS_OK, pacString);
    completed = true;
  }

  // the systemproxysettings didn't complete the resolution. try via PAC
  if (!completed) {
    nsresult status = mPAC.GetProxyForURI(query->mSpec, query->mHost,
                                          pacString);
    LOG(("Use proxy from PAC: %s\n", pacString.get()));
    query->Complete(status, pacString);
  }

  mInProgress = false;
  return true;
}
Exemplo n.º 19
0
NS_IMETHODIMP ImportOutlookMailImpl::ImportMailbox(  nsIImportMailboxDescriptor *pSource,
        nsIFile *pDestination,
        PRUnichar **pErrorLog,
        PRUnichar **pSuccessLog,
        PRBool *fatalError)
{
    NS_PRECONDITION(pSource != nsnull, "null ptr");
    NS_PRECONDITION(pDestination != nsnull, "null ptr");
    NS_PRECONDITION(fatalError != nsnull, "null ptr");

    nsCOMPtr<nsIStringBundle>  bundle( dont_AddRef( nsOutlookStringBundle::GetStringBundleProxy()));

    nsString  success;
    nsString  error;
    if (!pSource || !pDestination || !fatalError) {
        nsOutlookStringBundle::GetStringByID( OUTLOOKIMPORT_MAILBOX_BADPARAM, error, bundle);
        if (fatalError)
            *fatalError = PR_TRUE;
        SetLogs( success, error, pErrorLog, pSuccessLog);
        return NS_ERROR_NULL_POINTER;
    }

    PRBool    abort = PR_FALSE;
    nsString  name;
    PRUnichar *  pName;
    if (NS_SUCCEEDED( pSource->GetDisplayName( &pName))) {
        name = pName;
        NS_Free( pName);
    }

    PRUint32 mailSize = 0;
    pSource->GetSize( &mailSize);
    if (mailSize == 0) {
        ReportSuccess( name, 0, &success);
        SetLogs( success, error, pErrorLog, pSuccessLog);
        return( NS_OK);
    }

    PRUint32 index = 0;
    pSource->GetIdentifier( &index);
    PRInt32  msgCount = 0;
    nsresult rv = NS_OK;

    m_bytesDone = 0;

    rv = m_mail.ImportMailbox( &m_bytesDone, &abort, (PRInt32)index, name.get(), pDestination, &msgCount);

    if (NS_SUCCEEDED( rv))
        ReportSuccess( name, msgCount, &success);
    else
        ReportError( OUTLOOKIMPORT_MAILBOX_CONVERTERROR, name, &error);

    SetLogs( success, error, pErrorLog, pSuccessLog);

    return( rv);
}
Exemplo n.º 20
0
nsresult
nsXPTZipLoader::LoadEntry(nsILocalFile* aFile,
                          const char* aName,
                          nsIInputStream** aResult)
{
    nsCOMPtr<nsIZipReader> zip = dont_AddRef(GetZipReader(aFile));

    if (!zip)
        return NS_OK;

    return zip->GetInputStream(aName, aResult);
}
Exemplo n.º 21
0
DIBTextureHost::DIBTextureHost(TextureFlags aFlags,
                               const SurfaceDescriptorDIB& aDescriptor)
  : TextureHostDirectUpload(aFlags, SurfaceFormat::B8G8R8X8, IntSize())
{
  // We added an extra ref for transport, so we shouldn't AddRef now.
  mSurface =
    dont_AddRef(reinterpret_cast<gfxWindowsSurface*>(aDescriptor.surface()));
  MOZ_ASSERT(mSurface);

  mSize = mSurface->GetSize();
  mFormat = mSurface->GetSurfaceFormat();
}
Exemplo n.º 22
0
nsresult
FlushableTaskQueue::FlushAndDispatch(already_AddRefed<nsIRunnable> aRunnable)
{
  MonitorAutoLock mon(mQueueMonitor);
  AutoSetFlushing autoFlush(this);
  FlushLocked();
  nsCOMPtr<nsIRunnable> r = dont_AddRef(aRunnable.take());
  nsresult rv = DispatchLocked(r.forget(), IgnoreFlushing, AssertDispatchSuccess);
  NS_ENSURE_SUCCESS(rv, rv);
  AwaitIdleLocked();
  return NS_OK;
}
Exemplo n.º 23
0
// (static) ShellItems are used to encapsulate links to things. We currently only support URI links,
// but more support could be added, such as local file and directory links.
nsresult JumpListLink::GetShellItem(nsCOMPtr<nsIJumpListItem>& item, nsRefPtr<IShellItem2>& aShellItem)
{
  IShellItem2 *psi = nullptr;
  nsresult rv;

  int16_t type; 
  if (NS_FAILED(item->GetType(&type)))
    return NS_ERROR_INVALID_ARG;

  if (type != nsIJumpListItem::JUMPLIST_ITEM_LINK)
    return NS_ERROR_INVALID_ARG;

  nsCOMPtr<nsIJumpListLink> link = do_QueryInterface(item, &rv);
  NS_ENSURE_SUCCESS(rv, rv);

  nsCOMPtr<nsIURI> uri;
  rv = link->GetUri(getter_AddRefs(uri));
  NS_ENSURE_SUCCESS(rv, rv);

  nsAutoCString spec;
  rv = uri->GetSpec(spec);
  NS_ENSURE_SUCCESS(rv, rv);

  // Create the IShellItem
  if (FAILED(WinUtils::SHCreateItemFromParsingName(
               NS_ConvertASCIItoUTF16(spec).get(), NULL, IID_PPV_ARGS(&psi)))) {
    return NS_ERROR_INVALID_ARG;
  }

  // Set the title
  nsAutoString linkTitle;
  link->GetUriTitle(linkTitle);

  IPropertyStore* pPropStore = nullptr;
  HRESULT hres = psi->GetPropertyStore(GPS_DEFAULT, IID_IPropertyStore, (void**)&pPropStore);
  if (FAILED(hres))
    return NS_ERROR_UNEXPECTED;

  PROPVARIANT pv;
  InitPropVariantFromString(linkTitle.get(), &pv);

  // May fail due to shell item access permissions.
  pPropStore->SetValue(PKEY_ItemName, pv);
  pPropStore->Commit();
  pPropStore->Release();

  PropVariantClear(&pv);

  aShellItem = dont_AddRef(psi);

  return NS_OK;
}
/**
 * Extract the FinalizationEvent from an instance of FinalizationWitness
 * and clear the slot containing the FinalizationEvent.
 */
already_AddRefed<FinalizationEvent>
ExtractFinalizationEvent(JSObject *objSelf)
{
  JS::Value slotEvent = JS_GetReservedSlot(objSelf, WITNESS_SLOT_EVENT);
  if (slotEvent.isUndefined()) {
    // Forget() has been called
    return nullptr;
  }

  JS_SetReservedSlot(objSelf, WITNESS_SLOT_EVENT, JS::UndefinedValue());

  return dont_AddRef(static_cast<FinalizationEvent*>(slotEvent.toPrivate()));
}
Exemplo n.º 25
0
DIBTextureHost::DIBTextureHost(TextureFlags aFlags,
                               const SurfaceDescriptorDIB& aDescriptor)
  : TextureHost(aFlags)
  , mIsLocked(false)
{
  // We added an extra ref for transport, so we shouldn't AddRef now.
  mSurface =
    dont_AddRef(reinterpret_cast<gfxWindowsSurface*>(aDescriptor.surface()));
  MOZ_ASSERT(mSurface);

  mSize = ToIntSize(mSurface->GetSize());
  mFormat = ImageFormatToSurfaceFormat(
    gfxPlatform::GetPlatform()->OptimalFormatForContent(mSurface->GetContentType()));
}
Exemplo n.º 26
0
void
FetchStream::FinalizeCallback(void* aUnderlyingSource, uint8_t aFlags)
{
  MOZ_DIAGNOSTIC_ASSERT(aUnderlyingSource);
  MOZ_DIAGNOSTIC_ASSERT(aFlags == FETCH_STREAM_FLAG);

  // This can be called in any thread.

  // This takes ownership of the ref created in FetchStream::Create().
  RefPtr<FetchStream> stream =
    dont_AddRef(static_cast<FetchStream*>(aUnderlyingSource));

  stream->ReleaseObjects();
}
Exemplo n.º 27
0
void
nsPACMan::CancelPendingQ(nsresult status)
{
  MOZ_ASSERT(!NS_IsMainThread(), "wrong thread");
  RefPtr<PendingPACQuery> query;

  while (!mPendingQ.isEmpty()) {
    query = dont_AddRef(mPendingQ.popLast());
    query->Complete(status, EmptyCString());
  }

  if (mShutdown)
    mPAC.Shutdown();
}
Exemplo n.º 28
0
NS_IMETHODIMP ImportOutlookAddressImpl::ImportAddressBook(nsIImportABDescriptor *source,
        nsIAddrDatabase *destination,
        nsIImportFieldMap *fieldMap,
        nsISupports *aSupportService,
        PRBool isAddrLocHome,
        PRUnichar **pErrorLog,
        PRUnichar **pSuccessLog,
        PRBool *fatalError)
{
    m_msgCount = 0;
    m_msgTotal = 0;
    NS_PRECONDITION(source != nsnull, "null ptr");
    NS_PRECONDITION(destination != nsnull, "null ptr");
    NS_PRECONDITION(fatalError != nsnull, "null ptr");

    nsCOMPtr<nsIStringBundle> bundle( dont_AddRef( nsOutlookStringBundle::GetStringBundleProxy()));

    nsString  success;
    nsString  error;
    if (!source || !destination || !fatalError) {
        IMPORT_LOG0( "*** Bad param passed to outlook address import\n");
        nsOutlookStringBundle::GetStringByID( OUTLOOKIMPORT_ADDRESS_BADPARAM, error, bundle);
        if (fatalError)
            *fatalError = PR_TRUE;
        ImportOutlookMailImpl::SetLogs( success, error, pErrorLog, pSuccessLog);
        return NS_ERROR_NULL_POINTER;
    }

    nsString name;
    source->GetPreferredName(name);

    PRUint32  id;
    if (NS_FAILED( source->GetIdentifier( &id))) {
        ImportOutlookMailImpl::ReportError( OUTLOOKIMPORT_ADDRESS_BADSOURCEFILE, name, &error);
        ImportOutlookMailImpl::SetLogs( success, error, pErrorLog, pSuccessLog);
        return( NS_ERROR_FAILURE);
    }

    nsresult rv = NS_OK;
    rv = m_address.ImportAddresses( &m_msgCount, &m_msgTotal, name.get(), id, destination, error);
    if (NS_SUCCEEDED( rv) && error.IsEmpty())
        ReportSuccess( name, &success);
    else
        ImportOutlookMailImpl::ReportError( OUTLOOKIMPORT_ADDRESS_CONVERTERROR, name, &error);

    ImportOutlookMailImpl::SetLogs( success, error, pErrorLog, pSuccessLog);
    IMPORT_LOG0( "*** Returning from outlook address import\n");
    return destination->Commit(nsAddrDBCommitType::kLargeCommit);
}
Exemplo n.º 29
0
void // nsresult
Test06_nsCOMPtr_optimized(nsIDOMWindowInternal* aDOMWindow, nsCOMPtr<nsIWebShellWindow>* aWebShellWindow)
    // m300, w176/182
{
//    if (!aDOMWindow)
//      return NS_ERROR_NULL_POINTER;
  nsresult status;
  nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject = do_QueryInterface(aDOMWindow, &status);
  nsIDocShell* temp0 = 0;
  if (scriptGlobalObject)
    scriptGlobalObject->GetDocShell(&temp0);
  nsCOMPtr<nsIWebShell> webShell = do_QueryInterface(temp0, &status);
  nsIWebShell* temp2 = 0;
  if (webShell)
  //  status = webShell->GetRootWebShellEvenIfChrome(temp2);
    {}
  nsCOMPtr<nsIWebShell> rootWebShell = dont_AddRef(temp2);
  nsIWebShellContainer* temp3 = 0;
  if (rootWebShell)
    status = rootWebShell->GetContainer(temp3);
  nsCOMPtr<nsIWebShellContainer> webShellContainer = dont_AddRef(temp3);
  (*aWebShellWindow) = do_QueryInterface(webShellContainer, &status);
//    return status;
}
Exemplo n.º 30
0
void // nsresult
Test03_nsCOMPtr_optimized( nsIDOMNode* aDOMNode, nsString* aResult )
		// m112, w50/45
	{
//		if ( !aDOMNode || !aResult )
//			return NS_ERROR_NULL_POINTER;

		nsIDOMNode* temp;
		nsresult status = aDOMNode->GetParentNode(&temp);
		nsCOMPtr<nsIDOMNode> parent( dont_AddRef(temp) );
		if ( parent )
			parent->GetNodeName(*aResult);

//		return status;
	}