示例#1
0
void
nsWyciwygChannel::SetCharsetAndSourceInternal()
{
    NS_ASSERTION(IsOnCacheIOThread(), "wrong thread");

    if (mCacheEntry) {
        WriteCharsetAndSourceToCache(mCharsetSource, mCharset);
    } else {
        mNeedToWriteCharset = true;
    }
}
示例#2
0
nsresult
nsWyciwygChannel::WriteToCacheEntryInternal(const nsAString &aData)
{
    LOG(("nsWyciwygChannel::WriteToCacheEntryInternal [this=%p]", this));
    NS_ASSERTION(IsOnCacheIOThread(), "wrong thread");

    nsresult rv;

    // With the new cache entry this will just pass as a no-op since we
    // are opening the entry in WriteToCacheEntry.
    rv = EnsureWriteCacheEntry();
    if (NS_WARN_IF(NS_FAILED(rv))) {
        return rv;
    }

    if (mLoadFlags & INHIBIT_PERSISTENT_CACHING) {
        rv = mCacheEntry->SetMetaDataElement("inhibit-persistent-caching", "1");
        if (NS_FAILED(rv)) return rv;
    }

    if (mSecurityInfo) {
        mCacheEntry->SetSecurityInfo(mSecurityInfo);
    }

    if (mNeedToWriteCharset) {
        WriteCharsetAndSourceToCache(mCharsetSource, mCharset);
        mNeedToWriteCharset = false;
    }

    uint32_t out;
    if (!mCacheOutputStream) {
        // Get the outputstream from the cache entry.
        rv = mCacheEntry->OpenOutputStream(0, getter_AddRefs(mCacheOutputStream));
        if (NS_FAILED(rv)) return rv;

        // Write out a Byte Order Mark, so that we'll know if the data is
        // BE or LE when we go to read it.
        char16_t bom = 0xFEFF;
        rv = mCacheOutputStream->Write((char *)&bom, sizeof(bom), &out);
        if (NS_FAILED(rv)) return rv;
    }

    return mCacheOutputStream->Write((const char *)PromiseFlatString(aData).get(),
                                     aData.Length() * sizeof(char16_t), &out);
}
示例#3
0
nsresult
nsWyciwygChannel::WriteToCacheEntryInternal(const nsAString &aData, const nsACString& spec)
{
  NS_ASSERTION(IsOnCacheIOThread(), "wrong thread");

  nsresult rv;

  if (!mCacheEntry) {
    rv = OpenCacheEntry(spec, nsICache::ACCESS_WRITE);
    if (NS_FAILED(rv)) return rv;
  }

  if (mLoadFlags & INHIBIT_PERSISTENT_CACHING) {
    rv = mCacheEntry->SetMetaDataElement("inhibit-persistent-caching", "1");
    if (NS_FAILED(rv)) return rv;
  }

  if (mSecurityInfo) {
    mCacheEntry->SetSecurityInfo(mSecurityInfo);
  }

  if (mNeedToWriteCharset) {
    WriteCharsetAndSourceToCache(mCharsetSource, mCharset);
    mNeedToWriteCharset = false;
  }
  
  PRUint32 out;
  if (!mCacheOutputStream) {
    // Get the outputstream from the cache entry.
    rv = mCacheEntry->OpenOutputStream(0, getter_AddRefs(mCacheOutputStream));    
    if (NS_FAILED(rv)) return rv;

    // Write out a Byte Order Mark, so that we'll know if the data is
    // BE or LE when we go to read it.
    PRUnichar bom = 0xFEFF;
    rv = mCacheOutputStream->Write((char *)&bom, sizeof(bom), &out);
    if (NS_FAILED(rv)) return rv;
  }

  return mCacheOutputStream->Write((char *)PromiseFlatString(aData).get(),
                                   aData.Length() * sizeof(PRUnichar), &out);
}