Backout the latest cedar merge wholesale until I test the correctness of the merge locally. This commit takes the tree state back to changeset 8d3f6093c425 (the last known good changeset before the merge)

This commit is contained in:
Ehsan Akhgari 2011-04-01 12:23:48 -04:00
parent db5f4dbf03
commit 49fceed112
72 changed files with 884 additions and 982 deletions

View File

@ -567,15 +567,7 @@ nsBrowserContentHandler.prototype = {
#endif
},
helpInfo : " -browser Open a browser window.\n" +
" -new-window <url> Open <url> in a new window.\n" +
" -new-tab <url> Open <url> in a new tab.\n" +
#ifdef XP_WIN
" -preferences Open Options dialog.\n" +
#else
" -preferences Open Preferences dialog.\n" +
#endif
" -search <term> Search <term> with your default search engine.\n",
helpInfo : " -browser Open a browser window.\n",
/* nsIBrowserHandler */

View File

@ -1466,6 +1466,11 @@ ContentPermissionPrompt.prototype = {
},
};
// XXX Bug 573536
// browserBundle.GetStringFromName("geolocation.learnMore")
//var formatter = Cc["@mozilla.org/toolkit/URLFormatterService;1"].getService(Ci.nsIURLFormatter);
//link.href = formatter.formatURLPref("browser.geolocation.warning.infoURL");
var message;
var secondaryActions = [];

View File

@ -474,12 +474,8 @@
// Save the current value in the form history
if (textValue) {
try {
textBox._formHistSvc.addEntry(textBox.getAttribute("autocompletesearchparam"),
textValue);
} catch (ex) {
Components.utils.reportError("Saving search to form history failed: " + ex);
}
textBox._formHistSvc.addEntry(textBox.getAttribute("autocompletesearchparam"),
textValue);
}
this.doSearch(textValue, where);

View File

@ -1,4 +1,6 @@
nv_done=Done
nv_timeout=Timed Out
nv_stopped=Stopped
openFile=Open File
droponhometitle=Set Home Page

View File

@ -1382,48 +1382,20 @@ GK_ATOM(accent_, "accent")
GK_ATOM(accentunder_, "accentunder")
GK_ATOM(actiontype_, "actiontype")
GK_ATOM(alignmentscope_, "alignmentscope")
GK_ATOM(altimg_, "altimg")
GK_ATOM(altimg_height_, "altimg-height")
GK_ATOM(altimg_valign_, "altimg-valign")
GK_ATOM(altimg_width_, "altimg-width")
GK_ATOM(annotation_, "annotation")
GK_ATOM(annotation_xml_, "annotation-xml")
GK_ATOM(apply_, "apply")
GK_ATOM(approx_, "approx")
GK_ATOM(arccos_, "arccos")
GK_ATOM(arccosh_, "arccosh")
GK_ATOM(arccot_, "arccot")
GK_ATOM(arccoth_, "arccoth")
GK_ATOM(arccsc_, "arccsc")
GK_ATOM(arccsch_, "arccsch")
GK_ATOM(arcsec_, "arcsec")
GK_ATOM(arcsech_, "arcsech")
GK_ATOM(arcsin_, "arcsin")
GK_ATOM(arcsinh_, "arcsinh")
GK_ATOM(arctan_, "arctan")
GK_ATOM(arctanh_, "arctanh")
GK_ATOM(arg_, "arg")
GK_ATOM(bevelled_, "bevelled")
GK_ATOM(bind_, "bind")
GK_ATOM(bvar_, "bvar")
GK_ATOM(card_, "card")
GK_ATOM(cartesianproduct_, "cartesianproduct")
GK_ATOM(cbytes_, "cbytes")
GK_ATOM(cd_, "cd")
GK_ATOM(cdgroup_, "cdgroup")
GK_ATOM(cerror_, "cerror")
GK_ATOM(charalign_, "charalign")
GK_ATOM(ci_, "ci")
GK_ATOM(closure_, "closure")
GK_ATOM(cn_, "cn")
GK_ATOM(codomain_, "codomain")
GK_ATOM(columnalign_, "columnalign")
GK_ATOM(columnalignment_, "columnalignment")
GK_ATOM(columnlines_, "columnlines")
GK_ATOM(columnspacing_, "columnspacing")
GK_ATOM(columnspan_, "columnspan")
GK_ATOM(columnwidth_, "columnwidth")
GK_ATOM(complexes_, "complexes")
GK_ATOM(compose_, "compose")
GK_ATOM(condition_, "condition")
GK_ATOM(conjugate_, "conjugate")
@ -1431,37 +1403,22 @@ GK_ATOM(cos_, "cos")
GK_ATOM(cosh_, "cosh")
GK_ATOM(cot_, "cot")
GK_ATOM(coth_, "coth")
GK_ATOM(crossout_, "crossout")
GK_ATOM(csc_, "csc")
GK_ATOM(csch_, "csch")
GK_ATOM(cs_, "cs")
GK_ATOM(csymbol_, "csymbol")
GK_ATOM(curl_, "curl")
GK_ATOM(decimalpoint_, "decimalpoint")
GK_ATOM(definitionURL_, "definitionURL")
GK_ATOM(degree_, "degree")
GK_ATOM(denomalign_, "denomalign")
GK_ATOM(depth_, "depth")
GK_ATOM(determinant_, "determinant")
GK_ATOM(diff_, "diff")
GK_ATOM(displaystyle_, "displaystyle")
GK_ATOM(divergence_, "divergence")
GK_ATOM(divide_, "divide")
GK_ATOM(domain_, "domain")
GK_ATOM(domainofapplication_, "domainofapplication")
GK_ATOM(edge_, "edge")
GK_ATOM(el_, "el")
GK_ATOM(emptyset_, "emptyset")
GK_ATOM(eq_, "eq")
GK_ATOM(equalcolumns_, "equalcolumns")
GK_ATOM(equalrows_, "equalrows")
GK_ATOM(equivalent_, "equivalent")
GK_ATOM(eulergamma_, "eulergamma")
GK_ATOM(exists_, "exists")
GK_ATOM(exp_, "exp")
GK_ATOM(exponentiale_, "exponentiale")
GK_ATOM(factorial_, "factorial")
GK_ATOM(factorof_, "factorof")
GK_ATOM(fence_, "fence")
GK_ATOM(fn_, "fn")
GK_ATOM(fontfamily_, "fontfamily")
@ -1470,50 +1427,32 @@ GK_ATOM(fontstyle_, "fontstyle")
GK_ATOM(fontweight_, "fontweight")
GK_ATOM(forall_, "forall")
GK_ATOM(framespacing_, "framespacing")
GK_ATOM(gcd_, "gcd")
GK_ATOM(geq_, "geq")
GK_ATOM(groupalign_, "groupalign")
GK_ATOM(gt_, "gt")
GK_ATOM(ident_, "ident")
GK_ATOM(imaginaryi_, "imaginaryi")
GK_ATOM(imaginary_, "imaginary")
GK_ATOM(implies_, "implies")
GK_ATOM(indentalignfirst_, "indentalignfirst")
GK_ATOM(indentalign_, "indentalign")
GK_ATOM(indentalignlast_, "indentalignlast")
GK_ATOM(indentshiftfirst_, "indentshiftfirst")
GK_ATOM(indentshift_, "indentshift")
GK_ATOM(indenttarget_, "indenttarget")
GK_ATOM(integers_, "integers")
GK_ATOM(int_, "int")
GK_ATOM(intersect_, "intersect")
GK_ATOM(interval_, "interval")
GK_ATOM(int_, "int")
GK_ATOM(inverse_, "inverse")
GK_ATOM(lambda_, "lambda")
GK_ATOM(laplacian_, "laplacian")
GK_ATOM(largeop_, "largeop")
GK_ATOM(lcm_, "lcm")
GK_ATOM(leq_, "leq")
GK_ATOM(limit_, "limit")
GK_ATOM(linebreak_, "linebreak")
GK_ATOM(linebreakmultchar_, "linebreakmultchar")
GK_ATOM(linebreakstyle_, "linebreakstyle")
GK_ATOM(linethickness_, "linethickness")
GK_ATOM(list_, "list")
GK_ATOM(ln_, "ln")
GK_ATOM(location_, "location")
GK_ATOM(logbase_, "logbase")
GK_ATOM(log_, "log")
GK_ATOM(longdivstyle_, "longdivstyle")
GK_ATOM(logbase_, "logbase")
GK_ATOM(lowlimit_, "lowlimit")
GK_ATOM(lquote_, "lquote")
GK_ATOM(lspace_, "lspace")
GK_ATOM(lt_, "lt")
GK_ATOM(maction_, "maction")
GK_ATOM(maligngroup_, "maligngroup")
GK_ATOM(malign_, "malign")
GK_ATOM(malignmark_, "malignmark")
GK_ATOM(malignscope_, "malignscope")
GK_ATOM(mathbackground_, "mathbackground")
GK_ATOM(mathcolor_, "mathcolor")
GK_ATOM(mathsize_, "mathsize")
@ -1527,20 +1466,15 @@ GK_ATOM(menclose_, "menclose")
GK_ATOM(merror_, "merror")
GK_ATOM(mfenced_, "mfenced")
GK_ATOM(mfrac_, "mfrac")
GK_ATOM(mfraction_, "mfraction")
GK_ATOM(mglyph_, "mglyph")
GK_ATOM(mi_, "mi")
GK_ATOM(minlabelspacing_, "minlabelspacing")
GK_ATOM(minsize_, "minsize")
GK_ATOM(minus_, "minus")
GK_ATOM(mlabeledtr_, "mlabeledtr")
GK_ATOM(mlongdiv_, "mlongdiv")
GK_ATOM(mmultiscripts_, "mmultiscripts")
GK_ATOM(mn_, "mn")
GK_ATOM(momentabout_, "momentabout")
GK_ATOM(moment_, "moment")
GK_ATOM(mo_, "mo")
GK_ATOM(monospaced_, "monospaced")
GK_ATOM(moment_, "moment")
GK_ATOM(movablelimits_, "movablelimits")
GK_ATOM(mover_, "mover")
GK_ATOM(mpadded_, "mpadded")
@ -1548,15 +1482,9 @@ GK_ATOM(mphantom_, "mphantom")
GK_ATOM(mprescripts_, "mprescripts")
GK_ATOM(mroot_, "mroot")
GK_ATOM(mrow_, "mrow")
GK_ATOM(mscarries_, "mscarries")
GK_ATOM(mscarry_, "mscarry")
GK_ATOM(msgroup_, "msgroup")
GK_ATOM(msline_, "msline")
GK_ATOM(ms_, "ms")
GK_ATOM(mspace_, "mspace")
GK_ATOM(msqrt_, "msqrt")
GK_ATOM(msrow_, "msrow")
GK_ATOM(mstack_, "mstack")
GK_ATOM(mstyle_, "mstyle")
GK_ATOM(msub_, "msub")
GK_ATOM(msubsup_, "msubsup")
@ -1567,37 +1495,19 @@ GK_ATOM(mtext_, "mtext")
GK_ATOM(mtr_, "mtr")
GK_ATOM(munder_, "munder")
GK_ATOM(munderover_, "munderover")
GK_ATOM(naturalnumbers_, "naturalnumbers")
GK_ATOM(negativemediummathspace_, "negativemediummathspace")
GK_ATOM(negativethickmathspace_, "negativethickmathspace")
GK_ATOM(negativethinmathspace_, "negativethinmathspace")
GK_ATOM(negativeverythickmathspace_, "negativeverythickmathspace")
GK_ATOM(negativeverythinmathspace_, "negativeverythinmathspace")
GK_ATOM(negativeveryverythickmathspace_, "negativeveryverythickmathspace")
GK_ATOM(negativeveryverythinmathspace_, "negativeveryverythinmathspace")
GK_ATOM(neq_, "neq")
GK_ATOM(notanumber_, "notanumber")
GK_ATOM(notation_, "notation")
GK_ATOM(note_, "note")
GK_ATOM(notin_, "notin")
GK_ATOM(notprsubset_, "notprsubset")
GK_ATOM(notsubset_, "notsubset")
GK_ATOM(numalign_, "numalign")
GK_ATOM(other_, "other")
GK_ATOM(outerproduct_, "outerproduct")
GK_ATOM(partialdiff_, "partialdiff")
GK_ATOM(piece_, "piece")
GK_ATOM(piecewise_, "piecewise")
GK_ATOM(pi_, "pi")
GK_ATOM(plus_, "plus")
GK_ATOM(power_, "power")
GK_ATOM(primes_, "primes")
GK_ATOM(product_, "product")
GK_ATOM(prsubset_, "prsubset")
GK_ATOM(quotient_, "quotient")
GK_ATOM(rationals_, "rationals")
GK_ATOM(real_, "real")
GK_ATOM(reals_, "reals")
GK_ATOM(reln_, "reln")
GK_ATOM(root_, "root")
GK_ATOM(rowalign_, "rowalign")
@ -1605,36 +1515,29 @@ GK_ATOM(rowlines_, "rowlines")
GK_ATOM(rowspacing_, "rowspacing")
GK_ATOM(rquote_, "rquote")
GK_ATOM(rspace_, "rspace")
GK_ATOM(scalarproduct_, "scalarproduct")
GK_ATOM(schemaLocation_, "schemaLocation")
GK_ATOM(scriptlevel_, "scriptlevel")
GK_ATOM(scriptminsize_, "scriptminsize")
GK_ATOM(scriptsizemultiplier_, "scriptsizemultiplier")
GK_ATOM(scriptsize_, "scriptsize")
GK_ATOM(sdev_, "sdev")
GK_ATOM(sech_, "sech")
GK_ATOM(sec_, "sec")
GK_ATOM(sech_, "sech")
GK_ATOM(selection_, "selection")
GK_ATOM(selector_, "selector")
GK_ATOM(semantics_, "semantics")
GK_ATOM(sep_, "sep")
GK_ATOM(separator_, "separator")
GK_ATOM(separators_, "separators")
GK_ATOM(sep_, "sep")
GK_ATOM(setdiff_, "setdiff")
GK_ATOM(set_, "set")
GK_ATOM(share_, "share")
GK_ATOM(shift_, "shift")
GK_ATOM(setdiff_, "setdiff")
GK_ATOM(side_, "side")
GK_ATOM(sinh_, "sinh")
GK_ATOM(sin_, "sin")
GK_ATOM(stackalign_, "stackalign")
GK_ATOM(sinh_, "sinh")
GK_ATOM(stretchy_, "stretchy")
GK_ATOM(subscriptshift_, "subscriptshift")
GK_ATOM(subset_, "subset")
GK_ATOM(superscriptshift_, "superscriptshift")
GK_ATOM(symmetric_, "symmetric")
GK_ATOM(tanh_, "tanh")
GK_ATOM(tan_, "tan")
GK_ATOM(tanh_, "tanh")
GK_ATOM(tendsto_, "tendsto")
GK_ATOM(thickmathspace_, "thickmathspace")
GK_ATOM(thinmathspace_, "thinmathspace")
@ -1642,15 +1545,12 @@ GK_ATOM(times_, "times")
GK_ATOM(transpose_, "transpose")
GK_ATOM(union_, "union")
GK_ATOM(uplimit_, "uplimit")
GK_ATOM(variance_, "variance")
GK_ATOM(vectorproduct_, "vectorproduct")
GK_ATOM(var_, "var")
GK_ATOM(vector_, "vector")
GK_ATOM(verythickmathspace_, "verythickmathspace")
GK_ATOM(verythinmathspace_, "verythinmathspace")
GK_ATOM(veryverythickmathspace_, "veryverythickmathspace")
GK_ATOM(veryverythinmathspace_, "veryverythinmathspace")
GK_ATOM(voffset_, "voffset")
GK_ATOM(xref_, "xref")
GK_ATOM(math, "math") // the only one without an underscore
#endif

View File

@ -3365,9 +3365,7 @@ nsCanvasRenderingContext2D::DrawImage(nsIDOMElement *imgElt, float a1,
float a6, float a7, float a8,
PRUint8 optional_argc)
{
if (!imgElt) {
return NS_ERROR_DOM_TYPE_MISMATCH_ERR;
}
NS_ENSURE_ARG(imgElt);
double sx,sy,sw,sh;
double dx,dy,dw,dh;

View File

@ -3497,7 +3497,7 @@ var ctx = canvas.getContext('2d');
var _thrown = undefined; try {
ctx.drawImage(null, 0, 0);
} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.TYPE_MISMATCH_ERR, "should throw TYPE_MISMATCH_ERR");
} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.TYPE_MISMATCH_ERR, "should throw TYPE_MISMATCH_ERR");
}
@ -3669,7 +3669,7 @@ var ctx = canvas.getContext('2d');
var _thrown = undefined; try {
ctx.drawImage(undefined, 0, 0);
} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.TYPE_MISMATCH_ERR, "should throw TYPE_MISMATCH_ERR");
} catch (e) { _thrown = e }; ok(_thrown && _thrown.result == Components.results.NS_ERROR_INVALID_ARG, "should throw NS_ERROR_INVALID_ARG");
var _thrown = undefined; try {
ctx.drawImage(0, 0, 0);
} catch (e) { _thrown = e }; ok(_thrown && _thrown.result == Components.results.NS_ERROR_XPC_BAD_CONVERT_JS_ZERO_ISNOT_NULL, "should throw NS_ERROR_XPC_BAD_CONVERT_JS_ZERO_ISNOT_NULL");

View File

@ -60,6 +60,7 @@
#include "nsCRT.h"
#include "prtime.h"
#include "prlog.h"
#include "nsInt64.h"
#include "nsNodeUtils.h"
#include "nsIContent.h"
#include "mozilla/dom/Element.h"

View File

@ -38,7 +38,6 @@
* ***** END LICENSE BLOCK ***** */
#include "mozilla/dom/AudioParent.h"
#include "mozilla/unused.h"
#include "nsThreadUtils.h"
// C++ file contents
@ -160,7 +159,7 @@ AudioParent::Notify(nsITimer* timer)
NS_ASSERTION(mStream, "AudioStream not initialized.");
PRInt64 offset = mStream->GetSampleOffset();
unused << SendSampleOffsetUpdate(offset, PR_IntervalNow());
SendSampleOffsetUpdate(offset, PR_IntervalNow());
return NS_OK;
}
@ -223,7 +222,7 @@ bool
AudioParent::RecvShutdown()
{
Shutdown();
unused << PAudioParent::Send__delete__(this);
PAudioParent::Send__delete__(this);
return true;
}

View File

@ -52,6 +52,5 @@ const WorkerTest = {
worker.onmessage = messageCallback;
worker.onerror = errorCallback;
worker.postMessage(message);
return worker;
}
};

View File

@ -54,28 +54,19 @@
{
SimpleTest.waitForExplicitFinish();
var worker;
function done()
{
worker = null;
SimpleTest.finish();
}
function messageCallback(event) {
is(event.data, "Done", "Correct message");
done();
SimpleTest.finish();
}
function errorCallback(event) {
ok(false, "Worker had an error: " + event.message);
done();
SimpleTest.finish();
}
Components.utils.import("resource://gre/modules/WorkerTest.jsm");
worker = WorkerTest.go(window.location.href, messageCallback,
errorCallback);
WorkerTest.go(window.location.href, messageCallback, errorCallback);
}
]]>

View File

@ -62,6 +62,7 @@
#include "nsIStringEnumerator.h"
#include "nsCRT.h"
#include "nsSupportsArray.h"
#include "nsInt64.h"
#include "nsContentCID.h"
#include "nsStreamUtils.h"
@ -167,8 +168,8 @@ struct OutputData
nsCOMPtr<nsIURI> mFile;
nsCOMPtr<nsIURI> mOriginalLocation;
nsCOMPtr<nsIOutputStream> mStream;
PRInt64 mSelfProgress;
PRInt64 mSelfProgressMax;
nsInt64 mSelfProgress;
nsInt64 mSelfProgressMax;
PRPackedBool mCalcFileExt;
OutputData(nsIURI *aFile, nsIURI *aOriginalLocation, PRBool aCalcFileExt) :
@ -191,8 +192,8 @@ struct OutputData
struct UploadData
{
nsCOMPtr<nsIURI> mFile;
PRInt64 mSelfProgress;
PRInt64 mSelfProgressMax;
nsInt64 mSelfProgress;
nsInt64 mSelfProgressMax;
UploadData(nsIURI *aFile) :
mFile(aFile),
@ -243,8 +244,6 @@ nsWebBrowserPersist::nsWebBrowserPersist() :
mPersistFlags(kDefaultPersistFlags),
mPersistResult(NS_OK),
mWrapColumn(72),
mTotalCurrentProgress(0),
mTotalMaxProgress(0),
mEncodingFlags(0)
{
}

View File

@ -58,6 +58,7 @@
#include "nsHashtable.h"
#include "nsTArray.h"
#include "nsInt64.h"
#include "nsCWebBrowserPersist.h"
@ -239,8 +240,8 @@ private:
PRPackedBool mSerializingOutput;
PRUint32 mPersistFlags;
PRUint32 mPersistResult;
PRInt64 mTotalCurrentProgress;
PRInt64 mTotalMaxProgress;
nsInt64 mTotalCurrentProgress;
nsInt64 mTotalMaxProgress;
PRInt16 mWrapColumn;
PRUint32 mEncodingFlags;
nsString mContentType;

View File

@ -2067,9 +2067,6 @@ public:
inline PRBool
DoesVendorStringMatch(const char* aVendorString, const char *aWantedVendor)
{
if (!aVendorString || !aWantedVendor)
return PR_FALSE;
const char *occurrence = strstr(aVendorString, aWantedVendor);
// aWantedVendor not found

View File

@ -42,6 +42,7 @@
#include "nsJARProtocolHandler.h"
#include "nsMimeTypes.h"
#include "nsNetUtil.h"
#include "nsInt64.h"
#include "nsEscape.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"

View File

@ -56,6 +56,7 @@
#include "plstr.h"
#include "nsILocalFileMac.h"
#include "nsIFileURL.h"
#include "nsInt64.h"
#include "nsTArray.h"
#include "nsObjCExceptions.h"
@ -219,7 +220,7 @@ NS_IMETHODIMP nsIconChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports
NS_ENSURE_SUCCESS(rv, rv);
// Init our stream pump
rv = mPump->Init(inStream, PRInt64(-1), PRInt64(-1), 0, 0, PR_FALSE);
rv = mPump->Init(inStream, nsInt64(-1), nsInt64(-1), 0, 0, PR_FALSE);
NS_ENSURE_SUCCESS(rv, rv);
rv = mPump->AsyncRead(this, ctxt);

View File

@ -47,6 +47,7 @@
#include "nsReadableUtils.h"
#include "nsMemory.h"
#include "nsNetUtil.h"
#include "nsInt64.h"
#include "nsILocalFile.h"
#include "nsIFileURL.h"
#include "nsDirectoryServiceDefs.h"
@ -202,7 +203,7 @@ NS_IMETHODIMP nsIconChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports
return rv;
// Init our streampump
rv = mPump->Init(inStream, PRInt64(-1), PRInt64(-1), 0, 0, PR_FALSE);
rv = mPump->Init(inStream, nsInt64(-1), nsInt64(-1), 0, 0, PR_FALSE);
if (NS_FAILED(rv))
return rv;

View File

@ -53,6 +53,7 @@
#include "nsIStringStream.h"
#include "nsIURL.h"
#include "nsNetUtil.h"
#include "nsInt64.h"
#include "nsIFile.h"
#include "nsIFileURL.h"
#include "nsIMIMEService.h"
@ -248,7 +249,7 @@ NS_IMETHODIMP nsIconChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports
return rv;
// Init our streampump
rv = mPump->Init(inStream, PRInt64(-1), PRInt64(-1), 0, 0, PR_FALSE);
rv = mPump->Init(inStream, nsInt64(-1), nsInt64(-1), 0, 0, PR_FALSE);
if (NS_FAILED(rv))
return rv;

View File

@ -753,11 +753,6 @@ pref("network.http.prompt-temp-redirect", true);
// Section 4.8 "High-Throughput Data Service Class"
pref("network.http.qos", 0);
// The number of milliseconds after sending a SYN for an HTTP connection,
// to wait before trying a different connection. 0 means do not use a second
// connection.
pref("network.http.connection-retry-timeout", 250);
// default values for FTP
// in a DSCP environment this should be 40 (0x28, or AF11), per RFC-4594,
// Section 4.8 "High-Throughput Data Service Class", and 80 (0x50, or AF22)

View File

@ -133,6 +133,7 @@
#include "nsAppDirectoryServiceDefs.h"
#include "nsIFile.h"
#include "nsPluginDirServiceProvider.h"
#include "nsInt64.h"
#include "nsPluginError.h"
#include "nsUnicharUtils.h"
@ -2889,7 +2890,7 @@ nsPluginHost::ReadPluginInfo()
if (NS_FAILED(rv))
return rv;
PRInt32 flen = PRInt64(fileSize);
PRInt32 flen = nsInt64(fileSize);
if (flen == 0) {
NS_WARNING("Plugins Registry Empty!");
return NS_OK; // ERROR CONDITION

View File

@ -969,7 +969,7 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnDataAvailable(nsIRequest *request,
brr->GetStartRange(&absoluteOffset64);
// XXX handle 64-bit for real
PRInt32 absoluteOffset = (PRInt32)PRInt64(absoluteOffset64);
PRInt32 absoluteOffset = (PRInt32)nsInt64(absoluteOffset64);
// we need to track how much data we have forwarded to the
// plugin.
@ -1049,7 +1049,7 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnStopRequest(nsIRequest *request,
PRInt64 absoluteOffset64 = LL_ZERO;
brr->GetStartRange(&absoluteOffset64);
// XXX support 64-bit offsets
PRInt32 absoluteOffset = (PRInt32)PRInt64(absoluteOffset64);
PRInt32 absoluteOffset = (PRInt32)nsInt64(absoluteOffset64);
nsPRUintKey key(absoluteOffset);

View File

@ -90,6 +90,7 @@
#include "nsIPersistentProperties2.h"
#include "nsISyncStreamListener.h"
#include "nsInterfaceRequestorAgg.h"
#include "nsInt64.h"
#include "nsINetUtil.h"
#include "nsIURIWithPrincipal.h"
#include "nsIAuthPrompt.h"
@ -489,8 +490,8 @@ NS_NewInputStreamChannel(nsIChannel **result,
inline nsresult
NS_NewInputStreamPump(nsIInputStreamPump **result,
nsIInputStream *stream,
PRInt64 streamPos = PRInt64(-1),
PRInt64 streamLen = PRInt64(-1),
PRInt64 streamPos = nsInt64(-1),
PRInt64 streamLen = nsInt64(-1),
PRUint32 segsize = 0,
PRUint32 segcount = 0,
PRBool closeWhenDone = PR_FALSE)
@ -1039,7 +1040,7 @@ NS_BackgroundInputStream(nsIInputStream **result,
do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsITransport> inTransport;
rv = sts->CreateInputTransport(stream, PRInt64(-1), PRInt64(-1),
rv = sts->CreateInputTransport(stream, nsInt64(-1), nsInt64(-1),
PR_TRUE, getter_AddRefs(inTransport));
if (NS_SUCCEEDED(rv))
rv = inTransport->OpenInputStream(nsITransport::OPEN_BLOCKING,
@ -1063,7 +1064,7 @@ NS_BackgroundOutputStream(nsIOutputStream **result,
do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsITransport> inTransport;
rv = sts->CreateOutputTransport(stream, PRInt64(-1), PRInt64(-1),
rv = sts->CreateOutputTransport(stream, nsInt64(-1), nsInt64(-1),
PR_TRUE, getter_AddRefs(inTransport));
if (NS_SUCCEEDED(rv))
rv = inTransport->OpenOutputStream(nsITransport::OPEN_BLOCKING,

View File

@ -165,7 +165,7 @@ nsBufferedStream::Seek(PRInt32 whence, PRInt64 offset)
nsCOMPtr<nsISeekableStream> ras = do_QueryInterface(mStream, &rv);
if (NS_FAILED(rv)) return rv;
PRInt64 absPos = 0;
nsInt64 absPos;
switch (whence) {
case nsISeekableStream::NS_SEEK_SET:
absPos = offset;
@ -205,8 +205,8 @@ nsBufferedStream::Seek(PRInt32 whence, PRInt64 offset)
METER(if (bufstats.mBigSeekIndex < MAX_BIG_SEEKS)
bufstats.mBigSeek[bufstats.mBigSeekIndex].mOldOffset =
mBufferStartOffset + PRInt64(mCursor));
const PRInt64 minus1 = -1;
mBufferStartOffset + nsInt64(mCursor));
const nsInt64 minus1 = -1;
if (absPos == minus1) {
// then we had the SEEK_END case, above
PRInt64 tellPos;
@ -231,7 +231,7 @@ nsBufferedStream::Tell(PRInt64 *result)
if (mStream == nsnull)
return NS_BASE_STREAM_CLOSED;
PRInt64 result64 = mBufferStartOffset;
nsInt64 result64 = mBufferStartOffset;
result64 += mCursor;
*result = result64;
return NS_OK;

View File

@ -45,6 +45,7 @@
#include "nsISeekableStream.h"
#include "nsIStreamBufferAccess.h"
#include "nsCOMPtr.h"
#include "nsInt64.h"
#include "nsIIPCSerializable.h"
////////////////////////////////////////////////////////////////////////////////
@ -69,7 +70,7 @@ protected:
char* mBuffer;
// mBufferStartOffset is the offset relative to the start of mStream.
PRInt64 mBufferStartOffset;
nsInt64 mBufferStartOffset;
// mCursor is the read cursor for input streams, or write cursor for
// output streams, and is relative to mBufferStartOffset.

View File

@ -57,6 +57,7 @@
#include "nsXPIDLString.h"
#include "prerror.h"
#include "nsCRT.h"
#include "nsInt64.h"
#include "nsIFile.h"
#include "nsDirectoryIndexStream.h"
#include "nsMimeTypes.h"
@ -106,8 +107,8 @@ nsFileStream::Seek(PRInt32 whence, PRInt64 offset)
if (mFD == nsnull)
return NS_BASE_STREAM_CLOSED;
PRInt64 cnt = PR_Seek64(mFD, offset, (PRSeekWhence)whence);
if (cnt == PRInt64(-1)) {
nsInt64 cnt = PR_Seek64(mFD, offset, (PRSeekWhence)whence);
if (cnt == nsInt64(-1)) {
return NS_ErrorAccordingToNSPR();
}
return NS_OK;
@ -122,8 +123,8 @@ nsFileStream::Tell(PRInt64 *result)
if (mFD == nsnull)
return NS_BASE_STREAM_CLOSED;
PRInt64 cnt = PR_Seek64(mFD, 0, PR_SEEK_CUR);
if (cnt == PRInt64(-1)) {
nsInt64 cnt = PR_Seek64(mFD, 0, PR_SEEK_CUR);
if (cnt == nsInt64(-1)) {
return NS_ErrorAccordingToNSPR();
}
*result = cnt;

View File

@ -48,6 +48,7 @@
#include "nsIServiceManager.h"
#include "nsILocalFile.h"
#include "nsITimer.h"
#include "nsInt64.h"
#include "nsNetUtil.h"
#include "nsAutoPtr.h"
#include "nsWeakReference.h"
@ -100,7 +101,7 @@ AppendToFile(nsILocalFile *lf, const char *data, PRUint32 len)
// maxSize may be -1 if unknown
static void
MakeRangeSpec(const PRInt64 &size, const PRInt64 &maxSize, PRInt32 chunkSize,
MakeRangeSpec(const nsInt64 &size, const nsInt64 &maxSize, PRInt32 chunkSize,
PRBool fetchRemaining, nsCString &rangeSpec)
{
rangeSpec.AssignLiteral("bytes=");
@ -110,8 +111,8 @@ MakeRangeSpec(const PRInt64 &size, const PRInt64 &maxSize, PRInt32 chunkSize,
if (fetchRemaining)
return;
PRInt64 end = size + PRInt64(chunkSize);
if (maxSize != PRInt64(-1) && end > maxSize)
nsInt64 end = size + nsInt64(chunkSize);
if (maxSize != nsInt64(-1) && end > maxSize)
end = maxSize;
end -= 1;
@ -164,8 +165,8 @@ private:
PRInt32 mChunkLen;
PRInt32 mChunkSize;
PRInt32 mInterval;
PRInt64 mTotalSize;
PRInt64 mCurrentSize;
nsInt64 mTotalSize;
nsInt64 mCurrentSize;
PRUint32 mLoadFlags;
PRInt32 mNonPartialCount;
nsresult mStatus;
@ -196,7 +197,7 @@ nsIncrementalDownload::nsIncrementalDownload()
nsresult
nsIncrementalDownload::FlushChunk()
{
NS_ASSERTION(mTotalSize != PRInt64(-1), "total size should be known");
NS_ASSERTION(mTotalSize != nsInt64(-1), "total size should be known");
if (mChunkLen == 0)
return NS_OK;
@ -205,7 +206,7 @@ nsIncrementalDownload::FlushChunk()
if (NS_FAILED(rv))
return rv;
mCurrentSize += PRInt64(mChunkLen);
mCurrentSize += nsInt64(mChunkLen);
mChunkLen = 0;
return NS_OK;
@ -284,7 +285,7 @@ nsIncrementalDownload::ProcessTimeout()
if (NS_FAILED(rv))
return rv;
NS_ASSERTION(mCurrentSize != PRInt64(-1),
NS_ASSERTION(mCurrentSize != nsInt64(-1),
"we should know the current file size by now");
rv = ClearRequestHeader(http);
@ -293,7 +294,7 @@ nsIncrementalDownload::ProcessTimeout()
// Don't bother making a range request if we are just going to fetch the
// entire document.
if (mInterval || mCurrentSize != PRInt64(0)) {
if (mInterval || mCurrentSize != nsInt64(0)) {
nsCAutoString range;
MakeRangeSpec(mCurrentSize, mTotalSize, mChunkSize, mInterval == 0, range);
@ -318,7 +319,7 @@ nsIncrementalDownload::ProcessTimeout()
nsresult
nsIncrementalDownload::ReadCurrentSize()
{
PRInt64 size;
nsInt64 size;
nsresult rv = mDest->GetFileSize((PRInt64 *) &size);
if (rv == NS_ERROR_FILE_NOT_FOUND ||
rv == NS_ERROR_FILE_TARGET_DOES_NOT_EXIST) {
@ -552,7 +553,7 @@ nsIncrementalDownload::OnStartRequest(nsIRequest *request,
// We may already have the entire file downloaded, in which case
// our request for a range beyond the end of the file would have
// been met with an error response code.
if (code == 416 && mTotalSize == PRInt64(-1)) {
if (code == 416 && mTotalSize == nsInt64(-1)) {
mTotalSize = mCurrentSize;
// Return an error code here to suppress OnDataAvailable.
return NS_ERROR_DOWNLOAD_COMPLETE;
@ -586,7 +587,7 @@ nsIncrementalDownload::OnStartRequest(nsIRequest *request,
}
// Do special processing after the first response.
if (mTotalSize == PRInt64(-1)) {
if (mTotalSize == nsInt64(-1)) {
// Update knowledge of mFinalURI
rv = http->GetURI(getter_AddRefs(mFinalURI));
if (NS_FAILED(rv))
@ -613,9 +614,9 @@ nsIncrementalDownload::OnStartRequest(nsIRequest *request,
if (NS_FAILED(rv))
return rv;
rv = props->GetPropertyAsInt64(NS_CHANNEL_PROP_CONTENT_LENGTH,
&mTotalSize);
&mTotalSize.mValue);
// We need to know the total size of the thing we're trying to download.
if (mTotalSize == PRInt64(-1)) {
if (mTotalSize == nsInt64(-1)) {
NS_WARNING("server returned no content-length header!");
return NS_ERROR_UNEXPECTED;
}
@ -632,13 +633,13 @@ nsIncrementalDownload::OnStartRequest(nsIRequest *request,
}
// Adjust mChunkSize accordingly if mCurrentSize is close to mTotalSize.
PRInt64 diff = mTotalSize - mCurrentSize;
if (diff <= PRInt64(0)) {
nsInt64 diff = mTotalSize - mCurrentSize;
if (diff <= nsInt64(0)) {
NS_WARNING("about to set a bogus chunk size; giving up");
return NS_ERROR_UNEXPECTED;
}
if (diff < PRInt64(mChunkSize))
if (diff < nsInt64(mChunkSize))
mChunkSize = PRUint32(diff);
mChunk = new char[mChunkSize];

View File

@ -287,7 +287,7 @@ nsInputStreamPump::Init(nsIInputStream *stream,
NS_ENSURE_TRUE(mState == STATE_IDLE, NS_ERROR_IN_PROGRESS);
mStreamOffset = PRUint64(streamPos);
if (PRInt64(streamLen) >= PRInt64(0))
if (nsInt64(streamLen) >= nsInt64(0))
mStreamLength = PRUint64(streamLen);
mStream = stream;
mSegSize = segsize;

View File

@ -53,6 +53,7 @@
#include "nsAutoPtr.h"
#include "nsCOMPtr.h"
#include "netCore.h"
#include "nsInt64.h"
#include "prmem.h"
#include "plstr.h"
#include "prnetdb.h"
@ -1788,21 +1789,9 @@ nsSocketTransport::GetSecurityCallbacks(nsIInterfaceRequestor **callbacks)
NS_IMETHODIMP
nsSocketTransport::SetSecurityCallbacks(nsIInterfaceRequestor *callbacks)
{
nsCOMPtr<nsISupports> secinfo;
{
MutexAutoLock lock(mLock);
mCallbacks = callbacks;
SOCKET_LOG(("Reset callbacks for secinfo=%p callbacks=%p\n",
mSecInfo.get(), mCallbacks.get()));
secinfo = mSecInfo;
}
// don't call into PSM while holding mLock!!
nsCOMPtr<nsISSLSocketControl> secCtrl(do_QueryInterface(secinfo));
if (secCtrl)
secCtrl->SetNotificationCallbacks(callbacks);
MutexAutoLock lock(mLock);
mCallbacks = callbacks;
// XXX should we tell PSM about this?
return NS_OK;
}

View File

@ -46,6 +46,7 @@
#include "nsSocketTransportService2.h"
#include "nsString.h"
#include "nsCOMPtr.h"
#include "nsInt64.h"
#include "nsISocketTransport.h"
#include "nsIInterfaceRequestor.h"

View File

@ -38,6 +38,7 @@
#include "nsStreamTransportService.h"
#include "nsXPCOMCIDInternal.h"
#include "nsNetSegmentUtils.h"
#include "nsInt64.h"
#include "nsTransportUtils.h"
#include "nsStreamUtils.h"
#include "nsNetError.h"

View File

@ -43,6 +43,7 @@
#include "nsFTPChannel.h"
#include "nsBaseContentStream.h"
#include "nsInt64.h"
#include "nsIThread.h"
#include "nsIRunnable.h"
#include "nsISocketTransportService.h"

View File

@ -44,7 +44,6 @@ class nsAHttpConnection;
class nsAHttpSegmentReader;
class nsAHttpSegmentWriter;
class nsIInterfaceRequestor;
class nsIEventTarget;
//----------------------------------------------------------------------------
// Abstract base class for a HTTP transaction:
@ -63,8 +62,7 @@ public:
// called by the connection to get security callbacks to set on the
// socket transport.
virtual void GetSecurityCallbacks(nsIInterfaceRequestor **,
nsIEventTarget **) = 0;
virtual void GetSecurityCallbacks(nsIInterfaceRequestor **) = 0;
// called to report socket status (see nsITransportEventSink)
virtual void OnTransportStatus(nsresult status, PRUint64 progress) = 0;
@ -90,8 +88,7 @@ public:
#define NS_DECL_NSAHTTPTRANSACTION \
void SetConnection(nsAHttpConnection *); \
void GetSecurityCallbacks(nsIInterfaceRequestor **, \
nsIEventTarget **); \
void GetSecurityCallbacks(nsIInterfaceRequestor **); \
void OnTransportStatus(nsresult status, PRUint64 progress); \
PRBool IsDone(); \
nsresult Status(); \

View File

@ -64,6 +64,7 @@
#include "prprf.h"
#include "prnetdb.h"
#include "nsEscape.h"
#include "nsInt64.h"
#include "nsStreamUtils.h"
#include "nsIOService.h"
#include "nsICacheService.h"
@ -2500,20 +2501,20 @@ nsHttpChannel::CheckCache()
// size of the cached content, then the cached response is partial...
// either we need to issue a byte range request or we need to refetch
// the entire document.
PRInt64 contentLength = mCachedResponseHead->ContentLength();
if (contentLength != PRInt64(-1)) {
nsInt64 contentLength = mCachedResponseHead->ContentLength();
if (contentLength != nsInt64(-1)) {
PRUint32 size;
rv = mCacheEntry->GetDataSize(&size);
NS_ENSURE_SUCCESS(rv, rv);
if (PRInt64(size) != contentLength) {
if (nsInt64(size) != contentLength) {
LOG(("Cached data size does not match the Content-Length header "
"[content-length=%lld size=%u]\n", PRInt64(contentLength), size));
PRBool hasContentEncoding =
mCachedResponseHead->PeekHeader(nsHttp::Content_Encoding)
!= nsnull;
if ((PRInt64(size) < contentLength) &&
if ((nsInt64(size) < contentLength) &&
size > 0 &&
!hasContentEncoding &&
mCachedResponseHead->IsResumable() &&
@ -2833,7 +2834,7 @@ nsHttpChannel::ReadFromCache()
if (NS_FAILED(rv)) return rv;
rv = nsInputStreamPump::Create(getter_AddRefs(mCachePump),
stream, PRInt64(-1), PRInt64(-1), 0, 0,
stream, nsInt64(-1), nsInt64(-1), 0, 0,
PR_TRUE);
if (NS_FAILED(rv)) return rv;

View File

@ -50,8 +50,6 @@
#include "nsStringStream.h"
#include "netCore.h"
#include "nsNetCID.h"
#include "nsAutoLock.h"
#include "nsProxyRelease.h"
#include "prmem.h"
#ifdef DEBUG
@ -67,10 +65,9 @@ static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
nsHttpConnection::nsHttpConnection()
: mTransaction(nsnull)
, mConnInfo(nsnull)
, mLastReadTime(0)
, mIdleTimeout(0)
, mConsiderReusedAfterInterval(0)
, mConsiderReusedAfterEpoch(0)
, mKeepAlive(PR_TRUE) // assume to keep-alive by default
, mKeepAliveMask(PR_TRUE)
, mSupportsPipelining(PR_FALSE) // assume low-grade server
@ -88,12 +85,9 @@ nsHttpConnection::nsHttpConnection()
nsHttpConnection::~nsHttpConnection()
{
LOG(("Destroying nsHttpConnection @%x\n", this));
if (mCallbacks) {
nsIInterfaceRequestor *cbs = nsnull;
mCallbacks.swap(cbs);
NS_ProxyRelease(mCallbackTarget, cbs);
}
NS_IF_RELEASE(mConnInfo);
NS_IF_RELEASE(mTransaction);
// release our reference to the handler
nsHttpHandler *handler = gHttpHandler;
@ -101,38 +95,18 @@ nsHttpConnection::~nsHttpConnection()
}
nsresult
nsHttpConnection::Init(nsHttpConnectionInfo *info,
PRUint16 maxHangTime,
nsISocketTransport *transport,
nsIAsyncInputStream *instream,
nsIAsyncOutputStream *outstream,
nsIInterfaceRequestor *callbacks,
nsIEventTarget *callbackTarget)
nsHttpConnection::Init(nsHttpConnectionInfo *info, PRUint16 maxHangTime)
{
NS_ABORT_IF_FALSE(transport && instream && outstream,
"invalid socket information");
LOG(("nsHttpConnection::Init [this=%p "
"transport=%p instream=%p outstream=%p]\n",
this, transport, instream, outstream));
LOG(("nsHttpConnection::Init [this=%x]\n", this));
NS_ENSURE_ARG_POINTER(info);
NS_ENSURE_TRUE(!mConnInfo, NS_ERROR_ALREADY_INITIALIZED);
mConnInfo = info;
NS_ADDREF(mConnInfo);
mMaxHangTime = maxHangTime;
mLastReadTime = NowInSeconds();
mSocketTransport = transport;
mSocketIn = instream;
mSocketOut = outstream;
nsresult rv = mSocketTransport->SetEventSink(this, nsnull);
NS_ENSURE_SUCCESS(rv, rv);
mCallbacks = callbacks;
mCallbackTarget = callbackTarget;
rv = mSocketTransport->SetSecurityCallbacks(this);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
@ -142,7 +116,6 @@ nsHttpConnection::Activate(nsAHttpTransaction *trans, PRUint8 caps)
{
nsresult rv;
NS_ABORT_IF_FALSE(PR_GetCurrentThread() == gSocketThread, "wrong thread");
LOG(("nsHttpConnection::Activate [this=%x trans=%x caps=%x]\n",
this, trans, caps));
@ -151,24 +124,32 @@ nsHttpConnection::Activate(nsAHttpTransaction *trans, PRUint8 caps)
// take ownership of the transaction
mTransaction = trans;
NS_ADDREF(mTransaction);
// set mKeepAlive according to what will be requested
mKeepAliveMask = mKeepAlive = (caps & NS_HTTP_ALLOW_KEEPALIVE);
// if we don't have a socket transport then create a new one
if (!mSocketTransport) {
rv = CreateTransport(caps);
if (NS_FAILED(rv))
goto loser;
}
// need to handle SSL proxy CONNECT if this is the first time.
if (mConnInfo->UsingSSL() && mConnInfo->UsingHttpProxy() && !mCompletedSSLConnect) {
rv = SetupSSLProxyConnect();
if (NS_FAILED(rv))
goto failed_activation;
goto loser;
}
rv = OnOutputStreamReady(mSocketOut);
failed_activation:
if (NS_FAILED(rv)) {
mTransaction = nsnull;
}
// wait for the output stream to be readable
rv = mSocketOut->AsyncWait(this, 0, 0, nsnull);
if (NS_SUCCEEDED(rv))
return rv;
loser:
NS_RELEASE(mTransaction);
return rv;
}
@ -177,7 +158,7 @@ nsHttpConnection::Close(nsresult reason)
{
LOG(("nsHttpConnection::Close [this=%x reason=%x]\n", this, reason));
NS_ABORT_IF_FALSE(PR_GetCurrentThread() == gSocketThread, "wrong thread");
NS_ASSERTION(PR_GetCurrentThread() == gSocketThread, "wrong thread");
if (NS_FAILED(reason)) {
if (mSocketTransport) {
@ -211,25 +192,8 @@ nsHttpConnection::ProxyStartSSL()
PRBool
nsHttpConnection::CanReuse()
{
PRBool canReuse = IsKeepAlive() &&
(NowInSeconds() - mLastReadTime < mIdleTimeout) &&
IsAlive();
// An idle persistent connection should not have data waiting to be read
// before a request is sent. Data here is likely a 408 timeout response
// which we would deal with later on through the restart logic, but that
// path is more expensive than just closing the socket now. SSL check can
// be removed with fixing of 631801
PRUint32 dataSize;
if (canReuse && mSocketIn && !mConnInfo->UsingSSL() &&
NS_SUCCEEDED(mSocketIn->Available(&dataSize)) && dataSize) {
LOG(("nsHttpConnection::CanReuse %p %s"
"Socket not reusable because read data pending (%d) on it.\n",
this, mConnInfo->Host(), dataSize));
canReuse = PR_FALSE;
}
return canReuse;
return IsKeepAlive() && (NowInSeconds() - mLastReadTime < mIdleTimeout)
&& IsAlive();
}
PRUint32 nsHttpConnection::TimeToLive()
@ -422,7 +386,7 @@ nsHttpConnection::OnHeadersAvailable(nsAHttpTransaction *trans,
// processing a transaction pipeline until after the first HTTP/1.1
// response.
nsHttpTransaction *trans =
static_cast<nsHttpTransaction *>(mTransaction.get());
static_cast<nsHttpTransaction *>(mTransaction);
trans->SetSSLConnectFailed();
}
}
@ -430,27 +394,6 @@ nsHttpConnection::OnHeadersAvailable(nsAHttpTransaction *trans,
return NS_OK;
}
PRBool
nsHttpConnection::IsReused()
{
if (mIsReused)
return PR_TRUE;
if (!mConsiderReusedAfterInterval)
return PR_FALSE;
// ReusedAfter allows a socket to be consider reused only after a certain
// interval of time has passed
return (PR_IntervalNow() - mConsiderReusedAfterEpoch) >=
mConsiderReusedAfterInterval;
}
void
nsHttpConnection::SetIsReusedAfter(PRUint32 afterMilliseconds)
{
mConsiderReusedAfterEpoch = PR_IntervalNow();
mConsiderReusedAfterInterval = PR_MillisecondsToInterval(afterMilliseconds);
}
void
nsHttpConnection::GetSecurityInfo(nsISupports **secinfo)
{
@ -494,6 +437,69 @@ nsHttpConnection::ResumeRecv()
// nsHttpConnection <private>
//-----------------------------------------------------------------------------
nsresult
nsHttpConnection::CreateTransport(PRUint8 caps)
{
nsresult rv;
NS_PRECONDITION(!mSocketTransport, "unexpected");
nsCOMPtr<nsISocketTransportService> sts =
do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
// configure the socket type based on the connection type requested.
const char* types[1];
if (mConnInfo->UsingSSL())
types[0] = "ssl";
else
types[0] = gHttpHandler->DefaultSocketType();
nsCOMPtr<nsISocketTransport> strans;
PRUint32 typeCount = (types[0] != nsnull);
rv = sts->CreateTransport(types, typeCount,
nsDependentCString(mConnInfo->Host()),
mConnInfo->Port(),
mConnInfo->ProxyInfo(),
getter_AddRefs(strans));
if (NS_FAILED(rv)) return rv;
PRUint32 tmpFlags = 0;
if (caps & NS_HTTP_REFRESH_DNS)
tmpFlags = nsISocketTransport::BYPASS_CACHE;
if (caps & NS_HTTP_LOAD_ANONYMOUS)
tmpFlags |= nsISocketTransport::ANONYMOUS_CONNECT;
strans->SetConnectionFlags(tmpFlags);
strans->SetQoSBits(gHttpHandler->GetQoSBits());
// NOTE: these create cyclical references, which we break inside
// nsHttpConnection::Close
rv = strans->SetEventSink(this, nsnull);
if (NS_FAILED(rv)) return rv;
rv = strans->SetSecurityCallbacks(this);
if (NS_FAILED(rv)) return rv;
// next open the socket streams
nsCOMPtr<nsIOutputStream> sout;
rv = strans->OpenOutputStream(nsITransport::OPEN_UNBUFFERED, 0, 0,
getter_AddRefs(sout));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIInputStream> sin;
rv = strans->OpenInputStream(nsITransport::OPEN_UNBUFFERED, 0, 0,
getter_AddRefs(sin));
if (NS_FAILED(rv)) return rv;
mSocketTransport = strans;
mSocketIn = do_QueryInterface(sin);
mSocketOut = do_QueryInterface(sout);
return NS_OK;
}
void
nsHttpConnection::CloseTransaction(nsAHttpTransaction *trans, nsresult reason)
{
@ -508,7 +514,9 @@ nsHttpConnection::CloseTransaction(nsAHttpTransaction *trans, nsresult reason)
reason = NS_OK;
mTransaction->Close(reason);
mTransaction = nsnull;
NS_RELEASE(mTransaction);
mTransaction = 0;
if (NS_FAILED(reason))
Close(reason);
@ -719,8 +727,7 @@ nsHttpConnection::SetupSSLProxyConnect()
// NOTE: this cast is valid since this connection cannot be processing a
// transaction pipeline until after the first HTTP/1.1 response.
nsHttpTransaction *trans =
static_cast<nsHttpTransaction *>(mTransaction.get());
nsHttpTransaction *trans = static_cast<nsHttpTransaction *>(mTransaction);
val = trans->RequestHead()->PeekHeader(nsHttp::Host);
if (val) {
@ -784,8 +791,8 @@ nsHttpConnection::OnInputStreamReady(nsIAsyncInputStream *in)
NS_IMETHODIMP
nsHttpConnection::OnOutputStreamReady(nsIAsyncOutputStream *out)
{
NS_ABORT_IF_FALSE(PR_GetCurrentThread() == gSocketThread, "wrong thread");
NS_ABORT_IF_FALSE(out == mSocketOut, "unexpected socket");
NS_ASSERTION(out == mSocketOut, "unexpected stream");
NS_ASSERTION(PR_GetCurrentThread() == gSocketThread, "wrong thread");
// if the transaction was dropped...
if (!mTransaction) {
@ -827,14 +834,14 @@ nsHttpConnection::GetInterface(const nsIID &iid, void **result)
// the socket transport thread. If that weren't the case, then we'd
// have to worry about the possibility of mTransaction going away
// part-way through this function call. See CloseTransaction.
// NOTE - there is a bug here, the call to getinterface is proxied off the
// nss thread, not the ui thread as the above comment says. So there is
// indeed a chance of mTransaction going away. bug 615342
NS_ASSERTION(PR_GetCurrentThread() != gSocketThread, "wrong thread");
if (mTransaction) {
nsCOMPtr<nsIInterfaceRequestor> callbacks;
mTransaction->GetSecurityCallbacks(getter_AddRefs(callbacks));
if (callbacks)
return callbacks->GetInterface(iid, result);
}
if (mCallbacks)
return mCallbacks->GetInterface(iid, result);
return NS_ERROR_NO_INTERFACE;
}

View File

@ -46,14 +46,12 @@
#include "nsXPIDLString.h"
#include "nsCOMPtr.h"
#include "nsAutoPtr.h"
#include "prinrval.h"
#include "nsIStreamListener.h"
#include "nsISocketTransport.h"
#include "nsIAsyncInputStream.h"
#include "nsIAsyncOutputStream.h"
#include "nsIInterfaceRequestor.h"
#include "nsIEventTarget.h"
//-----------------------------------------------------------------------------
// nsHttpConnection - represents a connection to a HTTP server (or proxy)
@ -86,10 +84,7 @@ public:
// maxHangTime - limits the amount of time this connection can spend on a
// single transaction before it should no longer be kept
// alive. a value of 0xffff indicates no limit.
nsresult Init(nsHttpConnectionInfo *info, PRUint16 maxHangTime,
nsISocketTransport *, nsIAsyncInputStream *,
nsIAsyncOutputStream *, nsIInterfaceRequestor *,
nsIEventTarget *);
nsresult Init(nsHttpConnectionInfo *info, PRUint16 maxHangTime);
// Activate causes the given transaction to be processed on this
// connection. It fails if there is already an existing transaction.
@ -132,9 +127,7 @@ public:
void GetConnectionInfo(nsHttpConnectionInfo **ci) { NS_IF_ADDREF(*ci = mConnInfo); }
void GetSecurityInfo(nsISupports **);
PRBool IsPersistent() { return IsKeepAlive(); }
PRBool IsReused();
void SetIsReusedAfter(PRUint32 afterMilliseconds);
void SetIdleTimeout(PRUint16 val) {mIdleTimeout = val;}
PRBool IsReused() { return mIsReused; }
nsresult PushBack(const char *data, PRUint32 length) { NS_NOTREACHED("PushBack"); return NS_ERROR_UNEXPECTED; }
nsresult ResumeSend();
nsresult ResumeRecv();
@ -146,6 +139,7 @@ private:
// called to cause the underlying socket to start speaking SSL
nsresult ProxyStartSSL();
nsresult CreateTransport(PRUint8 caps);
nsresult OnTransactionDone(nsresult reason);
nsresult OnSocketWritable();
nsresult OnSocketReadable();
@ -166,20 +160,12 @@ private:
nsCOMPtr<nsIInputStream> mSSLProxyConnectStream;
nsCOMPtr<nsIInputStream> mRequestStream;
// mTransaction only points to the HTTP Transaction callbacks if the
// transaction is open, otherwise it is null.
nsRefPtr<nsAHttpTransaction> mTransaction;
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
nsCOMPtr<nsIEventTarget> mCallbackTarget;
nsRefPtr<nsHttpConnectionInfo> mConnInfo;
nsAHttpTransaction *mTransaction; // hard ref
nsHttpConnectionInfo *mConnInfo; // hard ref
PRUint32 mLastReadTime;
PRUint16 mMaxHangTime; // max download time before dropping keep-alive status
PRUint16 mIdleTimeout; // value of keep-alive: timeout=
PRIntervalTime mConsiderReusedAfterInterval;
PRIntervalTime mConsiderReusedAfterEpoch;
PRPackedBool mKeepAlive;
PRPackedBool mKeepAliveMask;

View File

@ -398,21 +398,13 @@ nsHttpConnectionMgr::ProcessOneTransactionCB(nsHashKey *key, void *data, void *c
return kHashEnumerateNext;
}
// If the global number of idle connections is preventing the opening of
// new connections to a host without idle connections, then
// close them regardless of their TTL
PRIntn
nsHttpConnectionMgr::PurgeExcessIdleConnectionsCB(nsHashKey *key,
void *data, void *closure)
nsHttpConnectionMgr::PurgeOneIdleConnectionCB(nsHashKey *key, void *data, void *closure)
{
nsHttpConnectionMgr *self = (nsHttpConnectionMgr *) closure;
nsConnectionEntry *ent = (nsConnectionEntry *) data;
while (self->mNumIdleConns + self->mNumActiveConns + 1 >= self->mMaxConns) {
if (!ent->mIdleConns.Length()) {
// There are no idle conns left in this connection entry
return kHashEnumerateNext;
}
if (ent->mIdleConns.Length() > 0) {
nsHttpConnection *conn = ent->mIdleConns[0];
ent->mIdleConns.RemoveElementAt(0);
conn->Close(NS_ERROR_ABORT);
@ -420,8 +412,10 @@ nsHttpConnectionMgr::PurgeExcessIdleConnectionsCB(nsHashKey *key,
self->mNumIdleConns--;
if (0 == self->mNumIdleConns)
self->StopPruneDeadConnectionsTimer();
return kHashEnumerateStop;
}
return kHashEnumerateStop;
return kHashEnumerateNext;
}
PRIntn
@ -478,7 +472,6 @@ nsHttpConnectionMgr::PruneDeadConnectionsCB(nsHashKey *key, void *data, void *cl
// if this entry is empty, then we can remove it.
if (ent->mIdleConns.Length() == 0 &&
ent->mActiveConns.Length() == 0 &&
ent->mHalfOpens.Length() == 0 &&
ent->mPendingQ.Length() == 0) {
LOG((" removing empty connection entry\n"));
delete ent;
@ -538,10 +531,6 @@ nsHttpConnectionMgr::ShutdownPassCB(nsHashKey *key, void *data, void *closure)
NS_RELEASE(trans);
}
// close all half open tcp connections
for (PRInt32 i = ((PRInt32) ent->mHalfOpens.Length()) - 1; i >= 0; i--)
ent->mHalfOpens[i]->Abandon();
delete ent;
return kHashEnumerateRemove;
}
@ -561,7 +550,7 @@ nsHttpConnectionMgr::ProcessPendingQForEntry(nsConnectionEntry *ent)
nsHttpConnection *conn = nsnull;
for (i=0; i<count; ++i) {
trans = ent->mPendingQ[i];
GetConnection(ent, trans, &conn);
GetConnection(ent, trans->Caps(), &conn);
if (conn)
break;
}
@ -601,8 +590,8 @@ nsHttpConnectionMgr::AtActiveConnectionLimit(nsConnectionEntry *ent, PRUint8 cap
LOG(("nsHttpConnectionMgr::AtActiveConnectionLimit [ci=%s caps=%x]\n",
ci->HashKey().get(), caps));
// If there are more active connections than the global limit, then we're
// done. Purging idle connections won't get us below it.
// If we have more active connections than the limit, then we're done --
// purging idle connections won't get us below it.
if (mNumActiveConns >= mMaxConns) {
LOG((" num active conns == max conns\n"));
return PR_TRUE;
@ -620,11 +609,6 @@ nsHttpConnectionMgr::AtActiveConnectionLimit(nsConnectionEntry *ent, PRUint8 cap
persistCount++;
}
// Add in the in-progress tcp connections, we will assume they are
// keepalive enabled.
totalCount += ent->mHalfOpens.Length();
persistCount += ent->mHalfOpens.Length();
LOG((" total=%d, persist=%d\n", totalCount, persistCount));
PRUint16 maxConns;
@ -645,26 +629,18 @@ nsHttpConnectionMgr::AtActiveConnectionLimit(nsConnectionEntry *ent, PRUint8 cap
}
void
nsHttpConnectionMgr::GetConnection(nsConnectionEntry *ent,
nsHttpTransaction *trans,
nsHttpConnectionMgr::GetConnection(nsConnectionEntry *ent, PRUint8 caps,
nsHttpConnection **result)
{
LOG(("nsHttpConnectionMgr::GetConnection [ci=%s caps=%x]\n",
ent->mConnInfo->HashKey().get(), PRUint32(trans->Caps())));
// First, see if an idle persistent connection may be reused instead of
// establishing a new socket. We do not need to check the connection limits
// yet as they govern the maximum number of open connections and reusing
// an old connection never increases that.
ent->mConnInfo->HashKey().get(), PRUint32(caps)));
*result = nsnull;
nsHttpConnection *conn = nsnull;
if (trans->Caps() & NS_HTTP_ALLOW_KEEPALIVE) {
// search the idle connection list. Each element in the list
// has a reference, so if we remove it from the list into a local
// ptr, that ptr now owns the reference
if (caps & NS_HTTP_ALLOW_KEEPALIVE) {
// search the idle connection list
while (!conn && (ent->mIdleConns.Length() > 0)) {
conn = ent->mIdleConns[0];
// we check if the connection can be reused before even checking if
@ -694,68 +670,31 @@ nsHttpConnectionMgr::GetConnection(nsConnectionEntry *ent,
// XXX this just purges a random idle connection. we should instead
// enumerate the entire hash table to find the eldest idle connection.
if (mNumIdleConns && mNumIdleConns + mNumActiveConns + 1 >= mMaxConns)
mCT.Enumerate(PurgeExcessIdleConnectionsCB, this);
mCT.Enumerate(PurgeOneIdleConnectionCB, this);
// Need to make a new TCP connection. First, we check if we've hit
// either the maximum connection limit globally or for this particular
// host or proxy. If we have, we're done.
if (AtActiveConnectionLimit(ent, trans->Caps())) {
LOG(("nsHttpConnectionMgr::GetConnection [ci = %s]"
"at active connection limit - will queue\n",
ent->mConnInfo->HashKey().get()));
if (AtActiveConnectionLimit(ent, caps)) {
LOG((" at active connection limit!\n"));
return;
}
nsresult rv = CreateTransport(ent, trans);
if (NS_FAILED(rv))
trans->Close(rv);
return;
conn = new nsHttpConnection();
if (!conn)
return;
NS_ADDREF(conn);
nsresult rv = conn->Init(ent->mConnInfo, mMaxRequestDelay);
if (NS_FAILED(rv)) {
NS_RELEASE(conn);
return;
}
}
// hold an owning ref to this connection
ent->mActiveConns.AppendElement(conn);
mNumActiveConns++;
NS_ADDREF(conn);
*result = conn;
}
void
nsHttpConnectionMgr::AddActiveConn(nsHttpConnection *conn,
nsConnectionEntry *ent)
{
NS_ADDREF(conn);
ent->mActiveConns.AppendElement(conn);
mNumActiveConns++;
}
void
nsHttpConnectionMgr::StartedConnect()
{
mNumActiveConns++;
}
void
nsHttpConnectionMgr::RecvdConnect()
{
mNumActiveConns--;
}
nsresult
nsHttpConnectionMgr::CreateTransport(nsConnectionEntry *ent,
nsHttpTransaction *trans)
{
NS_ABORT_IF_FALSE(PR_GetCurrentThread() == gSocketThread, "wrong thread");
nsRefPtr<nsHalfOpenSocket> sock = new nsHalfOpenSocket(ent, trans);
nsresult rv = sock->SetupPrimaryStreams();
NS_ENSURE_SUCCESS(rv, rv);
sock->SetupBackupTimer();
ent->mHalfOpens.AppendElement(sock);
return NS_OK;
}
nsresult
nsHttpConnectionMgr::DispatchTransaction(nsConnectionEntry *ent,
nsAHttpTransaction *trans,
@ -777,6 +716,11 @@ nsHttpConnectionMgr::DispatchTransaction(nsConnectionEntry *ent,
trans = pipeline;
}
// hold an owning ref to this connection
ent->mActiveConns.AppendElement(conn);
mNumActiveConns++;
NS_ADDREF(conn);
// give the transaction the indirect reference to the connection.
trans->SetConnection(handle);
@ -849,8 +793,6 @@ nsHttpConnectionMgr::BuildPipeline(nsConnectionEntry *ent,
nsresult
nsHttpConnectionMgr::ProcessNewTransaction(nsHttpTransaction *trans)
{
NS_ABORT_IF_FALSE(PR_GetCurrentThread() == gSocketThread, "wrong thread");
// since "adds" and "cancels" are processed asynchronously and because
// various events might trigger an "add" directly on the socket thread,
// we must take care to avoid dispatching a transaction that has already
@ -893,9 +835,18 @@ nsHttpConnectionMgr::ProcessNewTransaction(nsHttpTransaction *trans)
// destroy connection handle.
trans->SetConnection(nsnull);
// remove sticky connection from active connection list; we'll add it
// right back in DispatchTransaction.
if (ent->mActiveConns.RemoveElement(conn))
mNumActiveConns--;
else {
NS_ERROR("sticky connection not found in active list");
return NS_ERROR_UNEXPECTED;
}
}
else
GetConnection(ent, trans, &conn);
GetConnection(ent, caps, &conn);
nsresult rv;
if (!conn) {
@ -1045,22 +996,13 @@ nsHttpConnectionMgr::OnMsgReclaimConnection(PRInt32, void *param)
NS_ASSERTION(ent, "no connection entry");
if (ent) {
// If the connection is in the active list, remove that entry
// and the reference held by the mActiveConns list.
// This is never the final reference on conn as the event context
// is also holding one that is released at the end of this function.
if (ent->mActiveConns.RemoveElement(conn)) {
nsHttpConnection *temp = conn;
NS_RELEASE(temp);
mNumActiveConns--;
}
ent->mActiveConns.RemoveElement(conn);
mNumActiveConns--;
if (conn->CanReuse()) {
LOG((" adding connection to idle list\n"));
// hold onto this connection in the idle list. we push it to
// the end of the list so as to ensure that we'll visit older
// connections first before getting to this one.
NS_ADDREF(conn);
ent->mIdleConns.AppendElement(conn);
mNumIdleConns++;
// If the added connection was first idle connection or has shortest
@ -1074,6 +1016,8 @@ nsHttpConnectionMgr::OnMsgReclaimConnection(PRInt32, void *param)
LOG((" connection cannot be reused; closing connection\n"));
// make sure the connection is closed and release our reference.
conn->Close(NS_ERROR_ABORT);
nsHttpConnection *temp = conn;
NS_RELEASE(temp);
}
}
@ -1184,323 +1128,6 @@ nsHttpConnectionMgr::nsConnectionHandle::PushBack(const char *buf, PRUint32 bufL
return mConn->PushBack(buf, bufLen);
}
//////////////////////// nsHalfOpenSocket
NS_IMPL_THREADSAFE_ISUPPORTS4(nsHttpConnectionMgr::nsHalfOpenSocket,
nsIOutputStreamCallback,
nsITransportEventSink,
nsIInterfaceRequestor,
nsITimerCallback)
nsHttpConnectionMgr::
nsHalfOpenSocket::nsHalfOpenSocket(nsConnectionEntry *ent,
nsHttpTransaction *trans)
: mEnt(ent),
mTransaction(trans)
{
NS_ABORT_IF_FALSE(ent && trans, "constructor with null arguments");
LOG(("Creating nsHalfOpenSocket [this=%p trans=%p ent=%s]\n",
this, trans, ent->mConnInfo->Host()));
}
nsHttpConnectionMgr::nsHalfOpenSocket::~nsHalfOpenSocket()
{
NS_ABORT_IF_FALSE(!mStreamOut, "streamout not null");
NS_ABORT_IF_FALSE(!mBackupStreamOut, "backupstreamout not null");
NS_ABORT_IF_FALSE(!mSynTimer, "syntimer not null");
LOG(("Destroying nsHalfOpenSocket [this=%p]\n", this));
if (mEnt) {
PRInt32 index = mEnt->mHalfOpens.IndexOf(this);
NS_ABORT_IF_FALSE(index != -1, "half open complete but no item");
mEnt->mHalfOpens.RemoveElementAt(index);
}
}
nsresult
nsHttpConnectionMgr::
nsHalfOpenSocket::SetupStreams(nsISocketTransport **transport,
nsIAsyncInputStream **instream,
nsIAsyncOutputStream **outstream)
{
nsresult rv;
const char* types[1];
types[0] = (mEnt->mConnInfo->UsingSSL()) ?
"ssl" : gHttpHandler->DefaultSocketType();
PRUint32 typeCount = (types[0] != nsnull);
nsCOMPtr<nsISocketTransport> socketTransport;
nsCOMPtr<nsISocketTransportService> sts;
sts = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = sts->CreateTransport(types, typeCount,
nsDependentCString(mEnt->mConnInfo->Host()),
mEnt->mConnInfo->Port(),
mEnt->mConnInfo->ProxyInfo(),
getter_AddRefs(socketTransport));
NS_ENSURE_SUCCESS(rv, rv);
PRUint32 tmpFlags = 0;
if (mTransaction->Caps() & NS_HTTP_REFRESH_DNS)
tmpFlags = nsISocketTransport::BYPASS_CACHE;
if (mTransaction->Caps() & NS_HTTP_LOAD_ANONYMOUS)
tmpFlags |= nsISocketTransport::ANONYMOUS_CONNECT;
socketTransport->SetConnectionFlags(tmpFlags);
socketTransport->SetQoSBits(gHttpHandler->GetQoSBits());
rv = socketTransport->SetEventSink(this, nsnull);
NS_ENSURE_SUCCESS(rv, rv);
rv = socketTransport->SetSecurityCallbacks(this);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIOutputStream> sout;
rv = socketTransport->OpenOutputStream(nsITransport::OPEN_UNBUFFERED,
0, 0,
getter_AddRefs(sout));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIInputStream> sin;
rv = socketTransport->OpenInputStream(nsITransport::OPEN_UNBUFFERED,
0, 0,
getter_AddRefs(sin));
NS_ENSURE_SUCCESS(rv, rv);
socketTransport.forget(transport);
CallQueryInterface(sin, instream);
CallQueryInterface(sout, outstream);
rv = (*outstream)->AsyncWait(this, 0, 0, nsnull);
if (NS_SUCCEEDED(rv))
gHttpHandler->ConnMgr()->StartedConnect();
return rv;
}
nsresult
nsHttpConnectionMgr::nsHalfOpenSocket::SetupPrimaryStreams()
{
nsresult rv = SetupStreams(getter_AddRefs(mSocketTransport),
getter_AddRefs(mStreamIn),
getter_AddRefs(mStreamOut));
LOG(("nsHalfOpenSocket::SetupPrimaryStream [this=%p ent=%s rv=%x]",
this, mEnt->mConnInfo->Host(), rv));
if (NS_FAILED(rv)) {
if (mStreamOut)
mStreamOut->AsyncWait(nsnull, 0, 0, nsnull);
mStreamOut = nsnull;
mStreamIn = nsnull;
mSocketTransport = nsnull;
}
return rv;
}
nsresult
nsHttpConnectionMgr::nsHalfOpenSocket::SetupBackupStreams()
{
nsresult rv = SetupStreams(getter_AddRefs(mBackupTransport),
getter_AddRefs(mBackupStreamIn),
getter_AddRefs(mBackupStreamOut));
LOG(("nsHalfOpenSocket::SetupBackupStream [this=%p ent=%s rv=%x]",
this, mEnt->mConnInfo->Host(), rv));
if (NS_FAILED(rv)) {
if (mBackupStreamOut)
mBackupStreamOut->AsyncWait(nsnull, 0, 0, nsnull);
mBackupStreamOut = nsnull;
mBackupStreamIn = nsnull;
mBackupTransport = nsnull;
}
return rv;
}
void
nsHttpConnectionMgr::nsHalfOpenSocket::SetupBackupTimer()
{
PRUint16 timeout = gHttpHandler->GetIdleSynTimeout();
NS_ABORT_IF_FALSE(!mSynTimer, "timer already initd");
if (timeout) {
// Setup the timer that will establish a backup socket
// if we do not get a writable event on the main one.
// We do this because a lost SYN takes a very long time
// to repair at the TCP level.
//
// Failure to setup the timer is something we can live with,
// so don't return an error in that case.
nsresult rv;
mSynTimer = do_CreateInstance(NS_TIMER_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv))
mSynTimer->InitWithCallback(this, timeout, nsITimer::TYPE_ONE_SHOT);
}
}
void
nsHttpConnectionMgr::nsHalfOpenSocket::Abandon()
{
LOG(("nsHalfOpenSocket::Abandon [this=%p ent=%s]",
this, mEnt->mConnInfo->Host()));
nsRefPtr<nsHalfOpenSocket> deleteProtector(this);
if (mStreamOut) {
gHttpHandler->ConnMgr()->RecvdConnect();
mStreamOut->AsyncWait(nsnull, 0, 0, nsnull);
mStreamOut = nsnull;
}
if (mBackupStreamOut) {
gHttpHandler->ConnMgr()->RecvdConnect();
mBackupStreamOut->AsyncWait(nsnull, 0, 0, nsnull);
mBackupStreamOut = nsnull;
}
if (mSynTimer) {
mSynTimer->Cancel();
mSynTimer = nsnull;
}
mEnt = nsnull;
}
NS_IMETHODIMP // method for nsITimerCallback
nsHttpConnectionMgr::nsHalfOpenSocket::Notify(nsITimer *timer)
{
NS_ABORT_IF_FALSE(PR_GetCurrentThread() == gSocketThread, "wrong thread");
NS_ABORT_IF_FALSE(timer == mSynTimer, "wrong timer");
mSynTimer = nsnull;
if (!gHttpHandler->ConnMgr()->
AtActiveConnectionLimit(mEnt, mTransaction->Caps())) {
SetupBackupStreams();
}
return NS_OK;
}
// method for nsIAsyncOutputStreamCallback
NS_IMETHODIMP
nsHttpConnectionMgr::
nsHalfOpenSocket::OnOutputStreamReady(nsIAsyncOutputStream *out)
{
NS_ABORT_IF_FALSE(PR_GetCurrentThread() == gSocketThread, "wrong thread");
NS_ABORT_IF_FALSE(out == mStreamOut ||
out == mBackupStreamOut, "stream mismatch");
LOG(("nsHalfOpenSocket::OnOutputStreamReady [this=%p ent=%s %s]\n",
this, mEnt->mConnInfo->Host(),
out == mStreamOut ? "primary" : "backup"));
PRInt32 index;
nsresult rv;
gHttpHandler->ConnMgr()->RecvdConnect();
// If the syntimer is still armed, we can cancel it because no backup
// socket should be formed at this point
if (mSynTimer) {
NS_ABORT_IF_FALSE (out == mStreamOut, "timer for non existant stream");
LOG(("nsHalfOpenSocket::OnOutputStreamReady "
"Backup connection timer canceled\n"));
mSynTimer->Cancel();
mSynTimer = nsnull;
}
// assign the new socket to the http connection
nsRefPtr<nsHttpConnection> conn = new nsHttpConnection();
LOG(("nsHalfOpenSocket::OnOutputStreamReady "
"Created new nshttpconnection %p\n", conn));
nsCOMPtr<nsIInterfaceRequestor> callbacks;
nsCOMPtr<nsIEventTarget> callbackTarget;
mTransaction->GetSecurityCallbacks(getter_AddRefs(callbacks),
getter_AddRefs(callbackTarget));
if (out == mStreamOut) {
rv = conn->Init(mEnt->mConnInfo,
gHttpHandler->ConnMgr()->mMaxRequestDelay,
mSocketTransport, mStreamIn, mStreamOut,
callbacks, callbackTarget);
// The nsHttpConnection object now owns these streams and sockets
mStreamOut = nsnull;
mStreamIn = nsnull;
mSocketTransport = nsnull;
}
else {
rv = conn->Init(mEnt->mConnInfo,
gHttpHandler->ConnMgr()->mMaxRequestDelay,
mBackupTransport, mBackupStreamIn, mBackupStreamOut,
callbacks, callbackTarget);
// The nsHttpConnection object now owns these streams and sockets
mBackupStreamOut = nsnull;
mBackupStreamIn = nsnull;
mBackupTransport = nsnull;
}
if (NS_FAILED(rv)) {
LOG(("nsHalfOpenSocket::OnOutputStreamReady "
"conn->init (%p) failed %x\n", conn, rv));
return rv;
}
// if this is still in the pending list, remove it and dispatch it
index = mEnt->mPendingQ.IndexOf(mTransaction);
if (index != -1) {
mEnt->mPendingQ.RemoveElementAt(index);
nsHttpTransaction *temp = mTransaction;
NS_RELEASE(temp);
gHttpHandler->ConnMgr()->AddActiveConn(conn, mEnt);
rv = gHttpHandler->ConnMgr()->DispatchTransaction(mEnt, mTransaction,
mTransaction->Caps(),
conn);
}
else {
// this transaction was dispatched off the pending q before all the
// sockets established themselves.
// We need to establish a small non-zero idle timeout so the connection
// mgr perceives this socket as suitable for persistent connection reuse
conn->SetIdleTimeout(NS_MIN((PRUint16) 5, gHttpHandler->IdleTimeout()));
// After about 1 second allow for the possibility of restarting a
// transaction due to server close. Keep at sub 1 second as that is the
// minimum granularity we can expect a server to be timing out with.
conn->SetIsReusedAfter(950);
NS_ADDREF(conn); // because onmsg*() expects to drop a reference
gHttpHandler->ConnMgr()->OnMsgReclaimConnection(NS_OK, conn);
}
return rv;
}
// method for nsITransportEventSink
NS_IMETHODIMP
nsHttpConnectionMgr::nsHalfOpenSocket::OnTransportStatus(nsITransport *trans,
nsresult status,
PRUint64 progress,
PRUint64 progressMax)
{
if (mTransaction)
mTransaction->OnTransportStatus(status, progress);
return NS_OK;
}
// method for nsIInterfaceRequestor
NS_IMETHODIMP
nsHttpConnectionMgr::nsHalfOpenSocket::GetInterface(const nsIID &iid,
void **result)
{
if (mTransaction) {
nsCOMPtr<nsIInterfaceRequestor> callbacks;
mTransaction->GetSecurityCallbacks(getter_AddRefs(callbacks), nsnull);
if (callbacks)
return callbacks->GetInterface(iid, result);
}
return NS_ERROR_NO_INTERFACE;
}
PRBool
nsHttpConnectionMgr::nsConnectionHandle::LastTransactionExpectedNoContent()
{

View File

@ -46,8 +46,6 @@
#include "nsThreadUtils.h"
#include "nsHashtable.h"
#include "nsAutoPtr.h"
#include "prmon.h"
#include "nsISocketTransportService.h"
#include "mozilla/Monitor.h"
#include "nsIObserver.h"
@ -141,8 +139,7 @@ public:
private:
virtual ~nsHttpConnectionMgr();
class nsHalfOpenSocket;
// nsConnectionEntry
//
// mCT maps connection info hash key to nsConnectionEntry object, which
@ -162,7 +159,6 @@ private:
nsTArray<nsHttpTransaction*> mPendingQ; // pending transaction queue
nsTArray<nsHttpConnection*> mActiveConns; // active connections
nsTArray<nsHttpConnection*> mIdleConns; // idle persistent connections
nsTArray<nsHalfOpenSocket*> mHalfOpens;
};
// nsConnectionHandle
@ -186,48 +182,6 @@ private:
nsHttpConnection *mConn;
};
// nsHalfOpenSocket is used to hold the state of an opening TCP socket
// while we wait for it to establish and bind it to a connection
class nsHalfOpenSocket : public nsIOutputStreamCallback,
public nsITransportEventSink,
public nsIInterfaceRequestor,
public nsITimerCallback
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOUTPUTSTREAMCALLBACK
NS_DECL_NSITRANSPORTEVENTSINK
NS_DECL_NSIINTERFACEREQUESTOR
NS_DECL_NSITIMERCALLBACK
nsHalfOpenSocket(nsConnectionEntry *ent,
nsHttpTransaction *trans);
~nsHalfOpenSocket();
nsresult SetupStreams(nsISocketTransport **,
nsIAsyncInputStream **,
nsIAsyncOutputStream **);
nsresult SetupPrimaryStreams();
nsresult SetupBackupStreams();
void SetupBackupTimer();
void Abandon();
private:
nsConnectionEntry *mEnt;
nsRefPtr<nsHttpTransaction> mTransaction;
nsCOMPtr<nsISocketTransport> mSocketTransport;
nsCOMPtr<nsIAsyncOutputStream> mStreamOut;
nsCOMPtr<nsIAsyncInputStream> mStreamIn;
// for syn retry
nsCOMPtr<nsITimer> mSynTimer;
nsCOMPtr<nsISocketTransport> mBackupTransport;
nsCOMPtr<nsIAsyncOutputStream> mBackupStreamOut;
nsCOMPtr<nsIAsyncInputStream> mBackupStreamIn;
};
friend class nsHalfOpenSocket;
//-------------------------------------------------------------------------
// NOTE: these members may be accessed from any thread (use mMonitor)
//-------------------------------------------------------------------------
@ -252,24 +206,19 @@ private:
//-------------------------------------------------------------------------
static PRIntn ProcessOneTransactionCB(nsHashKey *, void *, void *);
static PRIntn PurgeOneIdleConnectionCB(nsHashKey *, void *, void *);
static PRIntn PruneDeadConnectionsCB(nsHashKey *, void *, void *);
static PRIntn ShutdownPassCB(nsHashKey *, void *, void *);
static PRIntn PurgeExcessIdleConnectionsCB(nsHashKey *, void *, void *);
PRBool ProcessPendingQForEntry(nsConnectionEntry *);
PRBool AtActiveConnectionLimit(nsConnectionEntry *, PRUint8 caps);
void GetConnection(nsConnectionEntry *, nsHttpTransaction *,
nsHttpConnection **);
void GetConnection(nsConnectionEntry *, PRUint8 caps, nsHttpConnection **);
nsresult DispatchTransaction(nsConnectionEntry *, nsAHttpTransaction *,
PRUint8 caps, nsHttpConnection *);
PRBool BuildPipeline(nsConnectionEntry *, nsAHttpTransaction *, nsHttpPipeline **);
nsresult ProcessNewTransaction(nsHttpTransaction *);
nsresult EnsureSocketThreadTargetIfOnline();
nsresult CreateTransport(nsConnectionEntry *, nsHttpTransaction *);
void AddActiveConn(nsHttpConnection *, nsConnectionEntry *);
void StartedConnect();
void RecvdConnect();
// message handlers have this signature
typedef void (nsHttpConnectionMgr:: *nsConnEventHandler)(PRInt32, void *);

View File

@ -178,7 +178,6 @@ nsHttpHandler::nsHttpHandler()
, mIdleTimeout(10)
, mMaxRequestAttempts(10)
, mMaxRequestDelay(10)
, mIdleSynTimeout(250)
, mMaxConnections(24)
, mMaxConnectionsPerServer(8)
, mMaxPersistentConnectionsPerServer(2)
@ -926,12 +925,6 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref)
mRedirectionLimit = (PRUint8) NS_CLAMP(val, 0, 0xff);
}
if (PREF_CHANGED(HTTP_PREF("connection-retry-timeout"))) {
rv = prefs->GetIntPref(HTTP_PREF("connection-retry-timeout"), &val);
if (NS_SUCCEEDED(rv))
mIdleSynTimeout = (PRUint16) NS_CLAMP(val, 0, 3000);
}
if (PREF_CHANGED(HTTP_PREF("version"))) {
nsXPIDLCString httpVersion;
prefs->GetCharPref(HTTP_PREF("version"), getter_Copies(httpVersion));

View File

@ -107,7 +107,6 @@ public:
nsIIDNService *IDNConverter() { return mIDNConverter; }
PRUint32 PhishyUserPassLength() { return mPhishyUserPassLength; }
PRUint8 GetQoSBits() { return mQoSBits; }
PRUint16 GetIdleSynTimeout() { return mIdleSynTimeout; }
PRBool IsPersistentHttpsCachingEnabled() { return mEnablePersistentHttpsCaching; }
@ -264,7 +263,6 @@ private:
PRUint16 mIdleTimeout;
PRUint16 mMaxRequestAttempts;
PRUint16 mMaxRequestDelay;
PRUint16 mIdleSynTimeout;
PRUint16 mMaxConnections;
PRUint8 mMaxConnectionsPerServer;

View File

@ -323,20 +323,16 @@ nsHttpPipeline::SetConnection(nsAHttpConnection *conn)
}
void
nsHttpPipeline::GetSecurityCallbacks(nsIInterfaceRequestor **result,
nsIEventTarget **target)
nsHttpPipeline::GetSecurityCallbacks(nsIInterfaceRequestor **result)
{
NS_ASSERTION(PR_GetCurrentThread() == gSocketThread, "wrong thread");
// return security callbacks from first request
nsAHttpTransaction *trans = Request(0);
if (trans)
trans->GetSecurityCallbacks(result, target);
else {
trans->GetSecurityCallbacks(result);
else
*result = nsnull;
if (target)
*target = nsnull;
}
}
void

View File

@ -332,12 +332,9 @@ nsHttpTransaction::SetConnection(nsAHttpConnection *conn)
}
void
nsHttpTransaction::GetSecurityCallbacks(nsIInterfaceRequestor **cb,
nsIEventTarget **target)
nsHttpTransaction::GetSecurityCallbacks(nsIInterfaceRequestor **cb)
{
NS_IF_ADDREF(*cb = mCallbacks);
if (target)
NS_IF_ADDREF(*target = mConsumerTarget);
}
void
@ -565,7 +562,7 @@ nsHttpTransaction::Close(nsresult reason)
NS_HTTP_ACTIVITY_TYPE_HTTP_TRANSACTION,
NS_HTTP_ACTIVITY_SUBTYPE_RESPONSE_COMPLETE,
PR_Now(),
static_cast<PRUint64>(mContentRead),
static_cast<PRUint64>(mContentRead.mValue),
EmptyCString());
// report that this transaction is closing
@ -987,7 +984,7 @@ nsHttpTransaction::HandleContentStart()
mContentLength = -1;
}
#if defined(PR_LOGGING)
else if (mContentLength == PRInt64(-1))
else if (mContentLength == nsInt64(-1))
LOG(("waiting for the server to close the connection.\n"));
#endif
}
@ -1027,21 +1024,21 @@ nsHttpTransaction::HandleContent(char *buf,
rv = mChunkedDecoder->HandleChunkedContent(buf, count, contentRead, contentRemaining);
if (NS_FAILED(rv)) return rv;
}
else if (mContentLength >= PRInt64(0)) {
else if (mContentLength >= nsInt64(0)) {
// HTTP/1.0 servers have been known to send erroneous Content-Length
// headers. So, unless the connection is persistent, we must make
// allowances for a possibly invalid Content-Length header. Thus, if
// NOT persistent, we simply accept everything in |buf|.
if (mConnection->IsPersistent()) {
PRInt64 remaining = mContentLength - mContentRead;
PRInt64 count64 = count;
nsInt64 remaining = mContentLength - mContentRead;
nsInt64 count64 = count;
*contentRead = PR_MIN(count64, remaining);
*contentRemaining = count - *contentRead;
}
else {
*contentRead = count;
// mContentLength might need to be increased...
PRInt64 position = mContentRead + PRInt64(count);
nsInt64 position = mContentRead + nsInt64(count);
if (position > mContentLength) {
mContentLength = position;
//mResponseHead->SetContentLength(mContentLength);
@ -1064,7 +1061,7 @@ nsHttpTransaction::HandleContent(char *buf,
}
LOG(("nsHttpTransaction::HandleContent [this=%x count=%u read=%u mContentRead=%lld mContentLength=%lld]\n",
this, count, *contentRead, mContentRead, mContentLength));
this, count, *contentRead, mContentRead.mValue, mContentLength.mValue));
// check for end-of-file
if ((mContentRead == mContentLength) ||
@ -1080,7 +1077,7 @@ nsHttpTransaction::HandleContent(char *buf,
NS_HTTP_ACTIVITY_TYPE_HTTP_TRANSACTION,
NS_HTTP_ACTIVITY_SUBTYPE_RESPONSE_COMPLETE,
PR_Now(),
static_cast<PRUint64>(mContentRead),
static_cast<PRUint64>(mContentRead.mValue),
EmptyCString());
}

View File

@ -44,6 +44,7 @@
#include "nsAHttpTransaction.h"
#include "nsAHttpConnection.h"
#include "nsCOMPtr.h"
#include "nsInt64.h"
#include "nsIPipe.h"
#include "nsIInputStream.h"
@ -178,8 +179,8 @@ private:
nsCString mLineBuf; // may contain a partial line
PRInt64 mContentLength; // equals -1 if unknown
PRInt64 mContentRead; // count of consumed content bytes
nsInt64 mContentLength; // equals -1 if unknown
nsInt64 mContentRead; // count of consumed content bytes
// After a 304/204 or other "no-content" style response we will skip over
// up to MAX_INVALID_RESPONSE_BODY_SZ bytes when looking for the next
@ -197,22 +198,21 @@ private:
PRUint16 mRestartCount; // the number of times this transaction has been restarted
PRUint8 mCaps;
// state flags, all logically boolean, but not packed together into a
// bitfield so as to avoid bitfield-induced races. See bug 560579.
PRPackedBool mClosed;
PRPackedBool mConnected;
PRPackedBool mHaveStatusLine;
PRPackedBool mHaveAllHeaders;
PRPackedBool mTransactionDone;
PRPackedBool mResponseIsComplete;
PRPackedBool mDidContentStart;
PRPackedBool mNoContent; // expecting an empty entity body
PRPackedBool mSentData;
PRPackedBool mReceivedData;
PRPackedBool mStatusEventPending;
PRPackedBool mHasRequestBody;
PRPackedBool mSSLConnectFailed;
PRPackedBool mHttpResponseMatched;
// state flags
PRUint32 mClosed : 1;
PRUint32 mConnected : 1;
PRUint32 mHaveStatusLine : 1;
PRUint32 mHaveAllHeaders : 1;
PRUint32 mTransactionDone : 1;
PRUint32 mResponseIsComplete : 1;
PRUint32 mDidContentStart : 1;
PRUint32 mNoContent : 1; // expecting an empty entity body
PRUint32 mSentData : 1;
PRUint32 mReceivedData : 1;
PRUint32 mStatusEventPending : 1;
PRUint32 mHasRequestBody : 1;
PRUint32 mSSLConnectFailed : 1;
PRUint32 mHttpResponseMatched: 1;
// mClosed := transaction has been explicitly closed
// mTransactionDone := transaction ran to completion or was interrupted

View File

@ -37,6 +37,7 @@
#include "nsMultiMixedConv.h"
#include "nsMemory.h"
#include "nsInt64.h"
#include "plstr.h"
#include "nsIHttpChannel.h"
#include "nsIServiceManager.h"
@ -979,7 +980,7 @@ nsMultiMixedConv::ParseHeaders(nsIChannel *aChannel, char *&aPtr,
mIsByteRangeRequest = PR_TRUE;
if (mContentLength == LL_MAXUINT)
mContentLength = PRUint64(PRInt64(mByteRangeEnd - mByteRangeStart + PRInt64(1)));
mContentLength = PRUint64(PRInt64(mByteRangeEnd - mByteRangeStart + nsInt64(1)));
}
}
*newLine = tmpChar;

View File

@ -43,6 +43,7 @@
#include "nsString.h"
#include "nsXPIDLString.h"
#include "nsCOMPtr.h"
#include "nsInt64.h"
#include "nsIByteRangeRequest.h"
#include "nsIMultiPartChannel.h"
#include "nsAutoPtr.h"
@ -101,8 +102,8 @@ protected:
PRUint64 mContentLength;
PRBool mIsByteRangeRequest;
PRInt64 mByteRangeStart;
PRInt64 mByteRangeEnd;
nsInt64 mByteRangeStart;
nsInt64 mByteRangeEnd;
PRUint32 mPartID; // unique ID that can be used to identify
// this part of the multipart document
@ -189,8 +190,8 @@ protected:
// The following members are for tracking the byte ranges in
// multipart/mixed content which specified the 'Content-Range:'
// header...
PRInt64 mByteRangeStart;
PRInt64 mByteRangeEnd;
nsInt64 mByteRangeStart;
nsInt64 mByteRangeEnd;
PRBool mIsByteRangeRequest;
PRUint32 mCurrentPartID;

View File

@ -87,6 +87,8 @@
#include "prlog.h"
#include "prtime.h"
#include "nsInt64.h"
namespace TestProtocols {
#if defined(PR_LOGGING)
@ -193,7 +195,7 @@ public:
NS_DECL_ISUPPORTS
const char* Name() { return mURLString.get(); }
PRInt64 mBytesRead;
nsInt64 mBytesRead;
PRTime mTotalTime;
PRTime mConnectTime;
nsCString mURLString;
@ -539,9 +541,9 @@ InputTestConsumer::OnStopRequest(nsIRequest *request, nsISupports* context,
LOG(("\tTime to connect: %.3f seconds\n", connectTime));
LOG(("\tTime to read: %.3f seconds.\n", readTime));
LOG(("\tRead: %lld bytes.\n", info->mBytesRead.mValue));
if (info->mBytesRead == PRInt64(0)) {
if (info->mBytesRead == nsInt64(0)) {
} else if (readTime > 0.0) {
LOG(("\tThroughput: %.0f bps.\n", (PRFloat64)(info->mBytesRead*PRInt64(8))/readTime));
LOG(("\tThroughput: %.0f bps.\n", (PRFloat64)(info->mBytesRead*nsInt64(8))/readTime));
} else {
LOG(("\tThroughput: REAL FAST!!\n"));
}

View File

@ -225,12 +225,12 @@ RunTest(nsIFile *srcFile, nsIFile *destFile)
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsITransport> srcTransport;
rv = sts->CreateInputTransport(srcStr, PRInt64(-1), PRInt64(-1), PR_TRUE,
rv = sts->CreateInputTransport(srcStr, nsInt64(-1), nsInt64(-1), PR_TRUE,
getter_AddRefs(srcTransport));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsITransport> destTransport;
rv = sts->CreateOutputTransport(destStr, PRInt64(-1), PRInt64(-1), PR_TRUE,
rv = sts->CreateOutputTransport(destStr, nsInt64(-1), nsInt64(-1), PR_TRUE,
getter_AddRefs(destTransport));
if (NS_FAILED(rv)) return rv;
@ -270,7 +270,7 @@ RunBlockingTest(nsIFile *srcFile, nsIFile *destFile)
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsITransport> destTransport;
rv = sts->CreateOutputTransport(fileOut, PRInt64(-1), PRInt64(-1),
rv = sts->CreateOutputTransport(fileOut, nsInt64(-1), nsInt64(-1),
PR_TRUE, getter_AddRefs(destTransport));
if (NS_FAILED(rv)) return rv;

View File

@ -1,7 +1,5 @@
var timer;
function armTimer(response) {
timer = Components.classes["@mozilla.org/timer;1"]
var timer = Components.classes["@mozilla.org/timer;1"]
.createInstance(Components.interfaces.nsITimer);
timer.initWithCallback(function() {
if (getState("docwritepreloadssecond") == "second" && getState("docwritepreloadsthird") == "third") {

View File

@ -45,6 +45,7 @@
#include "nsISSLStatusProvider.h"
#include "nsStrictTransportSecurityService.h"
#include "nsIURI.h"
#include "nsInt64.h"
#include "nsNetUtil.h"
#include "nsThreadUtils.h"
#include "nsStringGlue.h"

View File

@ -93,6 +93,7 @@
#include "nsReadableUtils.h"
#include "nsIDateTimeFormat.h"
#include "prtypes.h"
#include "nsInt64.h"
#include "nsTime.h"
#include "nsIEntropyCollector.h"
#include "nsIBufEntropyCollector.h"

View File

@ -65,9 +65,7 @@
#include "mozilla/Omnijar.h"
#include "prenv.h"
#include "mozilla/FunctionTimer.h"
#include "nsThreadUtils.h"
#include "nsXULAppAPI.h"
#ifdef IS_BIG_ENDIAN
#define SC_ENDIAN "big"
#else
@ -128,9 +126,11 @@ StartupCache::~StartupCache()
}
// Generally, the in-memory table should be empty here,
// but an early shutdown means either mTimer didn't run
// or the write thread is still running.
WaitOnWriteThread();
// but in special cases (like Talos Ts tests) we
// could shut down before we write.
// This mechanism will change when IO is moved off-thread
// (bug 586859) or when Talos first-run is changed to allow
// our timer to work (bug 591471).
WriteToDisk();
gStartupCache = nsnull;
}
@ -138,11 +138,6 @@ StartupCache::~StartupCache()
nsresult
StartupCache::Init()
{
if (XRE_GetProcessType() != GeckoProcessType_Default) {
NS_WARNING("Startup cache is only available in the chrome process");
return NS_ERROR_NOT_AVAILABLE;
}
nsresult rv;
mTable.Init();
#ifdef DEBUG
@ -206,12 +201,10 @@ StartupCache::Init()
return NS_OK;
}
/**
* LoadArchive can be called from the main thread or while reloading cache on write thread.
*/
nsresult
StartupCache::LoadArchive()
{
WaitOnWriteThread();
PRBool exists;
mArchive = NULL;
nsresult rv = mFile->Exists(&exists);
@ -227,7 +220,6 @@ StartupCache::LoadArchive()
nsresult
StartupCache::GetBuffer(const char* id, char** outbuf, PRUint32* length)
{
NS_ASSERTION(NS_IsMainThread(), "Startup cache only available on main thread");
WaitOnWriteThread();
if (!mStartupWriteInitiated) {
CacheEntry* entry;
@ -268,7 +260,6 @@ StartupCache::GetBuffer(const char* id, char** outbuf, PRUint32* length)
nsresult
StartupCache::PutBuffer(const char* id, const char* inbuf, PRUint32 len)
{
NS_ASSERTION(NS_IsMainThread(), "Startup cache only available on main thread");
WaitOnWriteThread();
if (StartupCache::gShutdownInitiated) {
return NS_ERROR_NOT_AVAILABLE;
@ -329,14 +320,10 @@ CacheCloseHelper(const nsACString& key, nsAutoPtr<CacheEntry>& data,
return PL_DHASH_REMOVE;
}
/**
* WriteToDisk writes the cache out to disk. Callers of WriteToDisk need to call WaitOnWriteThread
* to make sure there isn't a write happening on another thread
*/
void
StartupCache::WriteToDisk()
{
WaitOnWriteThread();
nsresult rv;
mStartupWriteInitiated = PR_TRUE;
@ -395,12 +382,13 @@ StartupCache::InvalidateCache()
void
StartupCache::WaitOnWriteThread()
{
NS_ASSERTION(NS_IsMainThread(), "Startup cache should only wait for io thread on main thread");
if (!mWriteThread || mWriteThread == PR_GetCurrentThread())
PRThread* writeThread = mWriteThread;
if (!writeThread || writeThread == PR_GetCurrentThread())
return;
NS_TIME_FUNCTION_MIN(30);
PR_JoinThread(mWriteThread);
//NS_WARNING("Waiting on startupcache write");
PR_JoinThread(writeThread);
mWriteThread = NULL;
}

View File

@ -477,7 +477,7 @@
aNewTab.focus();
}
else if (this.getAttribute("setfocus") != "false") {
document.commandDispatcher.advanceFocusIntoSubtree(this.tabbox.selectedPanel);
document.commandDispatcher.advanceFocusIntoSubtree(aNewTab);
// Make sure that the focus doesn't move outside the tabbox
if (this.tabbox) {

View File

@ -107,8 +107,8 @@ struct nsRequestInfo : public PLDHashEntryHdr
}
const void* mKey; // Must be first for the pldhash stubs to work
PRInt64 mCurrentProgress;
PRInt64 mMaxProgress;
nsInt64 mCurrentProgress;
nsInt64 mMaxProgress;
PRBool mUploading;
PRBool mIsDone;
@ -151,11 +151,6 @@ struct nsListenerInfo {
nsDocLoader::nsDocLoader()
: mParent(nsnull),
mListenerInfoList(8),
mCurrentSelfProgress(0),
mMaxSelfProgress(0),
mCurrentTotalProgress(0),
mMaxTotalProgress(0),
mCompletedTotalProgress(0),
mIsLoadingDocument(PR_FALSE),
mIsRestoringDocument(PR_FALSE),
mDontFlushLayout(PR_FALSE),
@ -603,7 +598,7 @@ nsDocLoader::OnStopRequest(nsIRequest *aRequest,
if (info) {
info->mIsDone = PR_TRUE;
PRInt64 oldMax = info->mMaxProgress;
nsInt64 oldMax = info->mMaxProgress;
info->mMaxProgress = info->mCurrentProgress;
@ -612,7 +607,7 @@ nsDocLoader::OnStopRequest(nsIRequest *aRequest,
// finished loading, then use this new data to try to calculate a
// mMaxSelfProgress...
//
if ((oldMax < PRInt64(0)) && (mMaxSelfProgress < PRInt64(0))) {
if ((oldMax < nsInt64(0)) && (mMaxSelfProgress < nsInt64(0))) {
mMaxSelfProgress = CalculateMaxProgress();
}
@ -1020,31 +1015,31 @@ nsDocLoader::GetIsLoadingDocument(PRBool *aIsLoadingDocument)
PRInt64 nsDocLoader::GetMaxTotalProgress()
{
PRInt64 newMaxTotal = 0;
nsInt64 newMaxTotal = 0;
PRInt32 count = mChildList.Count();
nsCOMPtr<nsIWebProgress> webProgress;
for (PRInt32 i=0; i < count; i++)
{
PRInt64 individualProgress = 0;
nsInt64 individualProgress = 0;
nsIDocumentLoader* docloader = ChildAt(i);
if (docloader)
{
// Cast is safe since all children are nsDocLoader too
individualProgress = ((nsDocLoader *) docloader)->GetMaxTotalProgress();
}
if (individualProgress < PRInt64(0)) // if one of the elements doesn't know it's size
if (individualProgress < nsInt64(0)) // if one of the elements doesn't know it's size
// then none of them do
{
newMaxTotal = PRInt64(-1);
newMaxTotal = nsInt64(-1);
break;
}
else
newMaxTotal += individualProgress;
}
PRInt64 progress = -1;
if (mMaxSelfProgress >= PRInt64(0) && newMaxTotal >= PRInt64(0))
nsInt64 progress = -1;
if (mMaxSelfProgress >= nsInt64(0) && newMaxTotal >= nsInt64(0))
progress = newMaxTotal + mMaxSelfProgress;
return progress;
@ -1060,7 +1055,7 @@ NS_IMETHODIMP nsDocLoader::OnProgress(nsIRequest *aRequest, nsISupports* ctxt,
PRUint64 aProgress, PRUint64 aProgressMax)
{
nsRequestInfo *info;
PRInt64 progressDelta = 0;
nsInt64 progressDelta = 0;
//
// Update the RequestInfo entry with the new progress data
@ -1068,7 +1063,7 @@ NS_IMETHODIMP nsDocLoader::OnProgress(nsIRequest *aRequest, nsISupports* ctxt,
info = GetRequestInfo(aRequest);
if (info) {
// suppress sending STATE_TRANSFERRING if this is upload progress (see bug 240053)
if (!info->mUploading && (PRInt64(0) == info->mCurrentProgress) && (PRInt64(0) == info->mMaxProgress)) {
if (!info->mUploading && (nsInt64(0) == info->mCurrentProgress) && (nsInt64(0) == info->mMaxProgress)) {
//
// If we receive an OnProgress event from a toplevel channel that the URI Loader
// has not yet targeted, then we must suppress the event. This is necessary to
@ -1093,8 +1088,8 @@ NS_IMETHODIMP nsDocLoader::OnProgress(nsIRequest *aRequest, nsISupports* ctxt,
mMaxSelfProgress += PRInt64(aProgressMax);
info->mMaxProgress = PRInt64(aProgressMax);
} else {
mMaxSelfProgress = PRInt64(-1);
info->mMaxProgress = PRInt64(-1);
mMaxSelfProgress = nsInt64(-1);
info->mMaxProgress = nsInt64(-1);
}
// Send a STATE_TRANSFERRING notification for the request.
@ -1116,7 +1111,7 @@ NS_IMETHODIMP nsDocLoader::OnProgress(nsIRequest *aRequest, nsISupports* ctxt,
}
// Update the current progress count...
progressDelta = PRInt64(aProgress) - info->mCurrentProgress;
progressDelta = nsInt64(PRInt64(aProgress)) - info->mCurrentProgress;
mCurrentSelfProgress += progressDelta;
info->mCurrentProgress = PRInt64(aProgress);
@ -1570,10 +1565,10 @@ CalcMaxProgressCallback(PLDHashTable *table, PLDHashEntryHdr *hdr,
PRUint32 number, void *arg)
{
const nsRequestInfo *info = static_cast<const nsRequestInfo *>(hdr);
PRInt64 *max = static_cast<PRInt64 *>(arg);
nsInt64 *max = static_cast<nsInt64 *>(arg);
if (info->mMaxProgress < info->mCurrentProgress) {
*max = PRInt64(-1);
*max = nsInt64(-1);
return PL_DHASH_STOP;
}
@ -1585,7 +1580,7 @@ CalcMaxProgressCallback(PLDHashTable *table, PLDHashEntryHdr *hdr,
PRInt64 nsDocLoader::CalculateMaxProgress()
{
PRInt64 max = mCompletedTotalProgress;
nsInt64 max = mCompletedTotalProgress;
PL_DHashTableEnumerate(&mRequestInfoHash, CalcMaxProgressCallback, &max);
return max;
}

View File

@ -57,6 +57,7 @@
#include "nsIChannelEventSink.h"
#include "nsISecurityEventSink.h"
#include "nsISupportsPriority.h"
#include "nsInt64.h"
#include "nsCOMPtr.h"
#include "pldhash.h"
@ -225,14 +226,14 @@ protected:
// feedback interfaces that travis cooked up.
PRInt32 mProgressStateFlags;
PRInt64 mCurrentSelfProgress;
PRInt64 mMaxSelfProgress;
nsInt64 mCurrentSelfProgress;
nsInt64 mMaxSelfProgress;
PRInt64 mCurrentTotalProgress;
PRInt64 mMaxTotalProgress;
nsInt64 mCurrentTotalProgress;
nsInt64 mMaxTotalProgress;
PLDHashTable mRequestInfoHash;
PRInt64 mCompletedTotalProgress;
nsInt64 mCompletedTotalProgress;
/*
* This flag indicates that the loader is loading a document. It is set

View File

@ -1579,7 +1579,7 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest *request, nsISuppo
mIsFileChannel = fileChan != nsnull;
// Get content length
mContentLength = GetContentLengthAsInt64(request);
mContentLength.mValue = GetContentLengthAsInt64(request);
nsCOMPtr<nsIPropertyBag2> props(do_QueryInterface(request, &rv));
// Determine whether a new window was opened specifically for this request

View File

@ -49,6 +49,8 @@
#include "prlog.h"
#include "prtime.h"
#include "nsInt64.h"
#include "nsIExternalHelperAppService.h"
#include "nsIExternalProtocolService.h"
#include "nsIWebProgressListener2.h"
@ -339,8 +341,8 @@ protected:
PRBool mTempFileIsExecutable;
PRTime mTimeDownloadStarted;
PRInt64 mContentLength;
PRInt64 mProgress; /**< Number of bytes received (for sending progress notifications). */
nsInt64 mContentLength;
nsInt64 mProgress; /**< Number of bytes received (for sending progress notifications). */
/**
* When we are told to save the temp file to disk (in a more permament

View File

@ -53,6 +53,7 @@
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsRegion.h"
#include "nsInt64.h"
#include "nsHashtable.h"
#include "nsCOMArray.h"
#include "nsThreadUtils.h"

View File

@ -635,9 +635,7 @@ class nsIWidget : public nsISupports {
NS_IMETHOD SetFocus(PRBool aRaise = PR_FALSE) = 0;
/**
* Get this widget's outside dimensions relative to its parent widget. For
* popup widgets the returned rect is in screen coordinates and not
* relative to its parent widget.
* Get this widget's outside dimensions relative to its parent widget
*
* @param aRect On return it holds the x, y, width and height of
* this widget.

View File

@ -3448,11 +3448,6 @@ NSEvent* gLastDragMouseDownEvent = nil;
nsAutoRetainCocoaObject kungFuDeathGrip(self);
#ifndef NP_NO_CARBON
EventRecord carbonEvent;
#endif // ifndef NP_NO_CARBON
NPCocoaEvent cocoaEvent;
nsMouseEvent geckoEvent(PR_TRUE, NS_MOUSE_BUTTON_UP, nsnull, nsMouseEvent::eReal);
[self convertCocoaMouseEvent:theEvent toGeckoEvent:&geckoEvent];
if ([theEvent modifierFlags] & NSControlKeyMask)
@ -3465,6 +3460,7 @@ NSEvent* gLastDragMouseDownEvent = nil;
// event type.
if (mIsPluginView) {
#ifndef NP_NO_CARBON
EventRecord carbonEvent;
if (mPluginEventModel == NPEventModelCarbon) {
carbonEvent.what = mouseUp;
carbonEvent.message = 0;
@ -3474,6 +3470,7 @@ NSEvent* gLastDragMouseDownEvent = nil;
geckoEvent.pluginEvent = &carbonEvent;
}
#endif
NPCocoaEvent cocoaEvent;
if (mPluginEventModel == NPEventModelCocoa) {
InitNPCocoaEvent(&cocoaEvent);
NSPoint point = [self convertPoint:[theEvent locationInWindow] fromView:nil];
@ -3641,17 +3638,13 @@ NSEvent* gLastDragMouseDownEvent = nil;
gLastDragView = self;
#ifndef NP_NO_CARBON
EventRecord carbonEvent;
#endif // ifndef NP_NO_CARBON
NPCocoaEvent cocoaEvent;
nsMouseEvent geckoEvent(PR_TRUE, NS_MOUSE_MOVE, nsnull, nsMouseEvent::eReal);
[self convertCocoaMouseEvent:theEvent toGeckoEvent:&geckoEvent];
// create event for use by plugins
if (mIsPluginView) {
#ifndef NP_NO_CARBON
EventRecord carbonEvent;
if (mPluginEventModel == NPEventModelCarbon) {
carbonEvent.what = NPEventType_AdjustCursorEvent;
carbonEvent.message = 0;
@ -3661,6 +3654,7 @@ NSEvent* gLastDragMouseDownEvent = nil;
geckoEvent.pluginEvent = &carbonEvent;
}
#endif
NPCocoaEvent cocoaEvent;
if (mPluginEventModel == NPEventModelCocoa) {
InitNPCocoaEvent(&cocoaEvent);
NSPoint point = [self convertPoint:[theEvent locationInWindow] fromView:nil];
@ -3749,11 +3743,6 @@ NSEvent* gLastDragMouseDownEvent = nil;
if (!mGeckoChild)
return;
#ifndef NP_NO_CARBON
EventRecord carbonEvent;
#endif // ifndef NP_NO_CARBON
NPCocoaEvent cocoaEvent;
nsMouseEvent geckoEvent(PR_TRUE, NS_MOUSE_BUTTON_UP, nsnull, nsMouseEvent::eReal);
[self convertCocoaMouseEvent:theEvent toGeckoEvent:&geckoEvent];
geckoEvent.button = nsMouseEvent::eRightButton;
@ -3762,6 +3751,7 @@ NSEvent* gLastDragMouseDownEvent = nil;
// create event for use by plugins
if (mIsPluginView) {
#ifndef NP_NO_CARBON
EventRecord carbonEvent;
if (mPluginEventModel == NPEventModelCarbon) {
carbonEvent.what = mouseUp;
carbonEvent.message = 0;
@ -3771,6 +3761,7 @@ NSEvent* gLastDragMouseDownEvent = nil;
geckoEvent.pluginEvent = &carbonEvent;
}
#endif
NPCocoaEvent cocoaEvent;
if (mPluginEventModel == NPEventModelCocoa) {
InitNPCocoaEvent(&cocoaEvent);
NSPoint point = [self convertPoint:[theEvent locationInWindow] fromView:nil];
@ -5852,11 +5843,6 @@ static const char* ToEscapedString(NSString* aString, nsCAutoString& aBuf)
PRUint32 message = isKeyDown ? NS_KEY_DOWN : NS_KEY_UP;
#ifndef NP_NO_CARBON
EventRecord carbonEvent;
#endif // ifndef NP_NO_CARBON
NPCocoaEvent cocoaEvent;
// Fire a key event.
nsKeyEvent geckoEvent(PR_TRUE, message, nsnull);
[self convertCocoaKeyEvent:theEvent toGeckoEvent:&geckoEvent];
@ -5864,11 +5850,13 @@ static const char* ToEscapedString(NSString* aString, nsCAutoString& aBuf)
// create event for use by plugins
if (mIsPluginView) {
#ifndef NP_NO_CARBON
EventRecord carbonEvent;
if (mPluginEventModel == NPEventModelCarbon) {
ConvertCocoaKeyEventToCarbonEvent(theEvent, carbonEvent, message);
geckoEvent.pluginEvent = &carbonEvent;
}
#endif
NPCocoaEvent cocoaEvent;
if (mPluginEventModel == NPEventModelCocoa) {
ConvertCocoaKeyEventToNPCocoaEvent(theEvent, cocoaEvent, message);
geckoEvent.pluginEvent = &cocoaEvent;

View File

@ -44,14 +44,13 @@
#include "nsPrimitiveHelpers.h"
#include "nsXPIDLString.h"
#include "prmem.h"
#include "nsIObserverService.h"
#include "nsIServiceManager.h"
#include "nsOS2Uni.h"
#include "nsClipboard.h"
#include "mozilla/Services.h"
#define INCL_DOSERRORS
#define INCL_WIN
#include <os2.h>
inline PRUint32 RegisterClipboardFormat(PCSZ pcszFormat)
inline ULONG RegisterClipboardFormat(PCSZ pcszFormat)
{
ATOM atom = WinFindAtom(WinQuerySystemAtomTable(), pcszFormat);
if (!atom) {
@ -73,11 +72,20 @@ nsClipboard::nsClipboard() : nsBaseClipboard()
RegisterClipboardFormat(kURLMime);
RegisterClipboardFormat(kNativeImageMime);
RegisterClipboardFormat(kNativeHTMLMime);
// Register for a shutdown notification so that we can flush data
// to the OS clipboard.
nsCOMPtr<nsIObserverService> observerService =
mozilla::services::GetObserverService();
if (observerService)
observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE);
}
nsClipboard::~nsClipboard()
{}
NS_IMPL_ISUPPORTS_INHERITED1(nsClipboard, nsBaseClipboard, nsIObserver)
nsresult nsClipboard::SetNativeClipboardData(PRInt32 aWhichClipboard)
{
if (aWhichClipboard != kGlobalClipboard)
@ -102,7 +110,7 @@ nsresult nsClipboard::GetNativeClipboardData(nsITransferable *aTransferable, PRI
// Get some data from the clipboard
PRBool nsClipboard::GetClipboardData(const char *aFlavor)
{
PRUint32 ulFormatID = GetFormatID(aFlavor);
ULONG ulFormatID = GetFormatID( aFlavor );
PRBool found = GetClipboardDataByID( ulFormatID, aFlavor );
@ -121,13 +129,13 @@ PRBool nsClipboard::GetClipboardData(const char *aFlavor)
return found;
}
PRBool nsClipboard::GetClipboardDataByID(PRUint32 aFormatID, const char *aFlavor)
PRBool nsClipboard::GetClipboardDataByID(ULONG ulFormatID, const char *aFlavor)
{
PVOID pDataMem;
PRUint32 NumOfBytes;
PRBool TempBufAllocated = PR_FALSE;
PVOID pClipboardData = reinterpret_cast<PVOID>(WinQueryClipbrdData(0, aFormatID));
PVOID pClipboardData = reinterpret_cast<PVOID>(WinQueryClipbrdData( 0, ulFormatID ));
if (!pClipboardData)
return PR_FALSE;
@ -136,7 +144,7 @@ PRBool nsClipboard::GetClipboardDataByID(PRUint32 aFormatID, const char *aFlavor
{
pDataMem = pClipboardData;
if (aFormatID == CF_TEXT) // CF_TEXT is one byte character set
if (ulFormatID == CF_TEXT) // CF_TEXT is one byte character set
{
PRUint32 NumOfChars = strlen( static_cast<char*>(pDataMem) );
NumOfBytes = NumOfChars;
@ -170,7 +178,7 @@ PRBool nsClipboard::GetClipboardDataByID(PRUint32 aFormatID, const char *aFlavor
}
else // Assume rest of flavors are binary data
{
if (aFormatID == CF_BITMAP)
if (ulFormatID == CF_BITMAP)
{
if (!strcmp( aFlavor, kJPEGImageMime ))
{
@ -242,7 +250,7 @@ void nsClipboard::SetClipboardData(const char *aFlavor)
return;
}
PRUint32 ulFormatID = GetFormatID(aFlavor);
ULONG ulFormatID = GetFormatID( aFlavor );
if (strstr( aFlavor, "text/" )) // All text/.. flavors are null-terminated
{
@ -398,7 +406,7 @@ nsresult nsClipboard::DoClipboardAction(ClipboardAction aAction)
}
// get the format ID for a given mimetype
PRUint32 nsClipboard::GetFormatID(const char *aMimeStr)
ULONG nsClipboard::GetFormatID(const char *aMimeStr)
{
if (strcmp(aMimeStr, kTextMime) == 0)
return CF_TEXT;
@ -406,6 +414,46 @@ PRUint32 nsClipboard::GetFormatID(const char *aMimeStr)
return RegisterClipboardFormat(aMimeStr);
}
// nsIObserver
NS_IMETHODIMP
nsClipboard::Observe(nsISupports *aSubject, const char *aTopic,
const PRUnichar *aData)
{
// This will be called on shutdown.
// make sure we have a good transferable
if (!mTransferable)
return NS_ERROR_FAILURE;
if (WinOpenClipbrd(0/*hab*/)) {
WinEmptyClipbrd(0/*hab*/);
// get flavor list that includes all flavors that can be written (including ones
// obtained through conversion)
nsCOMPtr<nsISupportsArray> flavorList;
nsresult errCode = mTransferable->FlavorsTransferableCanExport(getter_AddRefs(flavorList));
if (NS_FAILED(errCode))
return NS_ERROR_FAILURE;
// Walk through flavors and put data on to clipboard
PRUint32 i;
PRUint32 cnt;
flavorList->Count(&cnt);
for (i = 0; i < cnt; i++) {
nsCOMPtr<nsISupports> genericFlavor;
flavorList->GetElementAt(i, getter_AddRefs(genericFlavor));
nsCOMPtr<nsISupportsCString> currentFlavor(do_QueryInterface(genericFlavor));
if (currentFlavor) {
nsXPIDLCString flavorStr;
currentFlavor->ToString(getter_Copies(flavorStr));
SetClipboardData(flavorStr);
}
}
WinCloseClipbrd(0/*hab*/);
}
return NS_OK;
}
NS_IMETHODIMP nsClipboard::HasDataMatchingFlavors(const char** aFlavorList,
PRUint32 aLength,
PRInt32 aWhichClipboard,
@ -417,7 +465,7 @@ NS_IMETHODIMP nsClipboard::HasDataMatchingFlavors(const char** aFlavorList,
for (PRUint32 i = 0; i < aLength; ++i) {
ULONG fmtInfo = 0;
PRUint32 format = GetFormatID(aFlavorList[i]);
ULONG format = GetFormatID(aFlavorList[i]);
if (WinQueryClipbrdFmtInfo(0/*hab*/, format, &fmtInfo)) {
*_retval = PR_TRUE;

View File

@ -39,6 +39,12 @@
#define _nsClipboard_h
#include "nsBaseClipboard.h"
#include "nsIObserver.h"
#define INCL_DOSERRORS
#define INCL_WIN
#include <os2.h>
class nsITransferable;
/**
@ -47,13 +53,20 @@ class nsITransferable;
struct FormatRecord;
class nsClipboard : public nsBaseClipboard
class nsClipboard : public nsBaseClipboard,
public nsIObserver
{
public:
nsClipboard();
virtual ~nsClipboard();
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
// nsIObserver
NS_DECL_NSIOBSERVER
// nsIClipboard
NS_IMETHOD HasDataMatchingFlavors(const char** aFlavorList, PRUint32 aLength,
PRInt32 aWhichClipboard, PRBool *_retval);
@ -68,9 +81,9 @@ protected:
Write
};
PRUint32 GetFormatID(const char *aMimeStr);
ULONG GetFormatID(const char *aMimeStr);
PRBool GetClipboardData(const char *aFlavour);
PRBool GetClipboardDataByID(PRUint32 aFormatID, const char *aFlavor);
PRBool GetClipboardDataByID(ULONG ulFormatID, const char *aFlavor);
void SetClipboardData(const char *aFlavour);
nsresult DoClipboardAction(ClipboardAction aAction);
};

View File

@ -1972,14 +1972,6 @@ NS_METHOD nsWindow::GetBounds(nsIntRect &aRect)
aRect.width = r.right - r.left;
aRect.height = r.bottom - r.top;
// popup window bounds' are in screen coordinates, not relative to parent
// window
if (mWindowType == eWindowType_popup) {
aRect.x = r.left;
aRect.y = r.top;
return NS_OK;
}
// chrome on parent:
// ___ 5,5 (chrome start)
// | ____ 10,10 (client start)

View File

@ -90,6 +90,7 @@
#include "mozilla/FunctionTimer.h"
#include "ManifestParser.h"
#include "nsInt64.h"
#include "nsManifestLineReader.h"
#include "mozilla/GenericFactory.h"
#include "nsSupportsPrimitives.h"

View File

@ -100,6 +100,7 @@ EXPORTS = \
nsHashtable.h \
nsIByteBuffer.h \
nsIUnicharBuffer.h \
nsInt64.h \
nsMathUtils.h \
nsObserverService.h \
nsRecyclingAllocator.h \

417
xpcom/ds/nsInt64.h Normal file
View File

@ -0,0 +1,417 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsInt64_h__
#define nsInt64_h__
#include "prlong.h"
#include "nscore.h"
/**
* This class encapsulates full 64-bit integer functionality and
* provides simple arithmetic and conversion operations.
*/
// If you ever decide that you need to add a non-inline method to this
// class, be sure to change the class declaration to "class NS_BASE
// nsInt64".
template<class T>
class nsTInt64
{
public: //XXX should be private
T mValue;
public:
/**
* Construct a new 64-bit integer.
*/
nsTInt64(void) : mValue(LL_ZERO) {
}
/**
* Construct a new 64-bit integer from a 32-bit signed integer
*/
nsTInt64(const PRInt32 aInt32) {
LL_I2L(mValue, aInt32);
}
/**
* Construct a new 64-bit integer from a 32-bit unsigned integer
*/
nsTInt64(const PRUint32 aUint32) {
LL_UI2L(mValue, aUint32);
}
/**
* Construct a new 64-bit integer from a floating point value.
*/
nsTInt64(const PRFloat64 aFloat64) {
LL_D2L(mValue, aFloat64);
}
/**
* Construct a new 64-bit integer from a native 64-bit integer
*/
nsTInt64(const T aInt64) : mValue(aInt64) {
}
/**
* Construct a new 64-bit integer from another 64-bit integer
*/
nsTInt64(const nsTInt64& aObject) : mValue(aObject.mValue) {
}
// ~nsTInt64(void) -- XXX destructor unnecessary
/**
* Assign a 64-bit integer to another 64-bit integer
*/
const nsTInt64& operator =(const nsTInt64& aObject) {
mValue = aObject.mValue;
return *this;
}
/**
* Convert a 64-bit integer to a signed 32-bit value
*/
operator PRInt32(void) const {
PRInt32 result;
LL_L2I(result, mValue);
return result;
}
/**
* Convert a 64-bit integer to an unsigned 32-bit value
*/
operator PRUint32(void) const {
PRUint32 result;
LL_L2UI(result, mValue);
return result;
}
/**
* Convert a 64-bit integer to a floating point value
*/
operator PRFloat64(void) const {
PRFloat64 result;
LL_L2D(result, mValue);
return result;
}
/**
* Convert a 64-bit integer to a native 64-bit integer.
*/
operator T() const {
return mValue;
}
/**
* Perform unary negation on a 64-bit integer.
*/
const nsTInt64 operator -(void) {
nsTInt64 result;
LL_NEG(result.mValue, mValue);
return result;
}
// Arithmetic operators
/**
* Increment a 64-bit integer by a 64-bit integer amount.
*/
nsTInt64& operator +=(const nsTInt64& aObject) {
LL_ADD(mValue, mValue, aObject.mValue);
return *this;
}
/**
* Decrement a 64-bit integer by a 64-bit integer amount.
*/
nsTInt64& operator -=(const nsTInt64& aObject) {
LL_SUB(mValue, mValue, aObject.mValue);
return *this;
}
/**
* Multiply a 64-bit integer by a 64-bit integer amount.
*/
nsTInt64& operator *=(const nsTInt64& aObject) {
LL_MUL(mValue, mValue, aObject.mValue);
return *this;
}
/**
* Divide a 64-bit integer by a 64-bit integer amount.
*/
nsTInt64& operator /=(const nsTInt64& aObject) {
LL_DIV(mValue, mValue, aObject.mValue);
return *this;
}
/**
* Compute the modulus of a 64-bit integer to a 64-bit value.
*/
nsTInt64& operator %=(const nsTInt64& aObject) {
LL_MOD(mValue, mValue, aObject.mValue);
return *this;
}
/**
* Shift a 64-bit integer left.
*/
nsTInt64& operator <<=(int aCount) {
LL_SHL(mValue, mValue, aCount);
return *this;
}
/**
* Shift a 64-bit signed integer right.
*/
nsTInt64& operator >>=(int aCount) {
LL_SHR(mValue, mValue, aCount);
return *this;
}
// Comparison operators
/**
* Add two 64-bit integers.
*/
inline const nsTInt64
operator +(const nsTInt64& aObject2) const {
return nsTInt64(*this) += aObject2;
}
/**
* Subtract one 64-bit integer from another.
*/
inline const nsTInt64
operator -(const nsTInt64& aObject2) const {
return nsTInt64(*this) -= aObject2;
}
/**
* Multiply two 64-bit integers
*/
inline const nsTInt64
operator *(const nsTInt64& aObject2) const {
return nsTInt64(*this) *= aObject2;
}
/**
* Divide one 64-bit integer by another
*/
inline const nsTInt64
operator /(const nsTInt64& aObject2) const {
return nsTInt64(*this) /= aObject2;
}
/**
* Compute the modulus of two 64-bit integers
*/
inline const nsTInt64
operator %(const nsTInt64& aObject2) const {
return nsTInt64(*this) %= aObject2;
}
/**
* Shift left a 64-bit integer
*/
inline const nsTInt64
operator <<(int aCount) const {
return nsTInt64(*this) <<= aCount;
}
/**
* Shift right a signed 64-bit integer
*/
inline const nsTInt64
operator >>(int aCount) const {
return nsTInt64(*this) >>= aCount;
}
/**
* Determine if two 64-bit integers are equal
*/
inline PRBool
operator ==(const nsTInt64& aObject2) const {
return LL_EQ(mValue, aObject2.mValue);
}
inline PRBool
operator ==(T aValue) const {
return LL_EQ(mValue, aValue);
}
/**
* Determine if two 64-bit integers are not equal
*/
inline PRBool
operator !=(const nsTInt64& aObject2) const {
return LL_NE(mValue, aObject2.mValue);
}
inline PRBool
operator !=(T aValue) const {
return LL_NE(mValue, aValue);
}
/**
* Perform a bitwise AND of two 64-bit integers
*/
inline const nsTInt64
operator &(const nsTInt64& aObject2) const {
return nsTInt64(*this) &= aObject2;
}
/**
* Perform a bitwise OR of two 64-bit integers
*/
inline const nsTInt64
operator |(const nsTInt64& aObject2) const {
return nsTInt64(*this) |= aObject2;
}
/**
* Perform a bitwise XOR of two 64-bit integers
*/
inline const nsTInt64
operator ^(const nsTInt64& aObject2) const {
return nsTInt64(*this) ^= aObject2;
}
// Bitwise operators
/**
* Compute the bitwise NOT of a 64-bit integer
*/
const nsTInt64 operator ~(void) const {
nsTInt64 result;
LL_NOT(result.mValue, mValue);
return result;
}
/**
* Compute the bitwise AND with another 64-bit integer
*/
nsTInt64& operator &=(const nsTInt64& aObject) {
LL_AND(mValue, mValue, aObject.mValue);
return *this;
}
/**
* Compute the bitwise OR with another 64-bit integer
*/
nsTInt64& operator |=(const nsTInt64& aObject) {
LL_OR(mValue, mValue, aObject.mValue);
return *this;
}
/**
* Compute the bitwise XOR with another 64-bit integer
*/
nsTInt64& operator ^=(const nsTInt64& aObject) {
LL_XOR(mValue, mValue, aObject.mValue);
return *this;
}
/**
* Allow doing if (!some_nsInt64)
*/
PRBool operator!() const {
return LL_IS_ZERO(mValue);
}
};
typedef nsTInt64<PRInt64> nsInt64;
typedef nsTInt64<PRUint64> nsUint64;
/**
* Determine if one 64-bit integer is strictly greater than another, using signed values
*/
inline PRBool
operator >(const nsInt64& aObject1, const nsInt64& aObject2) {
return LL_CMP(aObject1.mValue, >, aObject2.mValue);
}
inline PRBool
operator >(const nsUint64& aObject1, const nsUint64& aObject2) {
return LL_UCMP(aObject1.mValue, >, aObject2.mValue);
}
/**
* Determine if one 64-bit integer is greater than or equal to another, using signed values
*/
inline PRBool
operator >=(const nsInt64& aObject1, const nsInt64& aObject2) {
return ! LL_CMP(aObject1.mValue, <, aObject2.mValue);
}
inline PRBool
operator >=(const nsUint64& aObject1, const nsUint64& aObject2) {
return ! LL_UCMP(aObject1.mValue, <, aObject2.mValue);
}
/**
* Determine if one 64-bit integer is strictly less than another, using signed values
*/
inline PRBool
operator <(const nsInt64& aObject1, const nsInt64& aObject2) {
return LL_CMP(aObject1.mValue, <, aObject2.mValue);
}
inline PRBool
operator <(const nsUint64& aObject1, const nsUint64& aObject2) {
return LL_UCMP(aObject1.mValue, <, aObject2.mValue);
}
/**
* Determine if one 64-bit integers is less than or equal to another, using signed values
*/
inline PRBool
operator <=(const nsInt64& aObject1, const nsInt64& aObject2) {
return ! LL_CMP(aObject1.mValue, >, aObject2.mValue);
}
inline PRBool
operator <=(const nsUint64& aObject1, const nsUint64& aObject2) {
return ! LL_UCMP(aObject1.mValue, >, aObject2.mValue);
}
#endif // nsInt64_h__

View File

@ -39,6 +39,7 @@
#define nsTime_h__
#include "prtime.h"
#include "nsInt64.h"
#include "nscore.h"
/**
@ -50,13 +51,13 @@
// class, be sure to change the class declaration to "class NS_BASE
// nsTime".
class nsTime
class nsTime : public nsInt64
{
public:
/**
* Construct the current time.
*/
nsTime(void) : mValue(PR_Now()) {
nsTime(void) : nsInt64(PR_Now()) {
}
/**
@ -74,19 +75,37 @@ public:
/**
* Construct a time from a PRTime.
*/
nsTime(const PRTime aTime) : mValue(aTime) {
nsTime(const PRTime aTime) : nsInt64(aTime) {
}
/**
* Construct a time from a 64-bit value.
*/
nsTime(const nsInt64& aTime) : nsInt64(aTime) {
}
/**
* Construct a time from another time.
*/
nsTime(const nsTime& aTime) : nsInt64(aTime.mValue) {
}
// ~nsTime(void) -- XXX destructor unnecessary
/**
* Assign one time to another.
*/
const nsTime& operator =(const nsTime& aTime) {
mValue = aTime.mValue;
return *this;
}
/**
* Convert a nsTime object to a PRTime
*/
operator PRTime(void) const {
return mValue;
}
PRInt64 mValue;
};
/**

View File

@ -56,6 +56,7 @@
#include "nsBinaryStream.h"
#include "nsFastLoadFile.h"
#include "nsInt64.h"
#ifdef XP_UNIX
#include <sys/mman.h>
#endif

View File

@ -51,6 +51,7 @@
#include "nsISeekableStream.h"
#include "nsCOMPtr.h"
#include "nsCOMArray.h"
#include "nsInt64.h"
#include "nsIIPCSerializable.h"
#include "nsIClassInfoImpl.h"
@ -383,7 +384,7 @@ nsMultiplexInputStream::Tell(PRInt64 *_retval)
return mStatus;
nsresult rv;
PRInt64 ret64 = 0;
nsInt64 ret64 = 0;
PRUint32 i, last;
last = mStartedReadingCurrent ? mCurrentStream+1 : mCurrentStream;
for (i = 0; i < last; ++i) {

View File

@ -45,6 +45,7 @@
#include "nsCOMPtr.h"
#include "nsCRT.h"
#include "prlog.h"
#include "nsInt64.h"
#include "nsIClassInfoImpl.h"
#include "nsAtomicRefcnt.h"
@ -153,7 +154,7 @@ private:
// separate refcnt so that we know when to close the consumer
nsrefcnt mReaderRefCnt;
PRInt64 mLogicalOffset;
nsInt64 mLogicalOffset;
PRPackedBool mBlocking;
// these variables can only be accessed while inside the pipe's monitor
@ -207,7 +208,7 @@ private:
// separate refcnt so that we know when to close the producer
nsrefcnt mWriterRefCnt;
PRInt64 mLogicalOffset;
nsInt64 mLogicalOffset;
PRPackedBool mBlocking;
// these variables can only be accessed while inside the pipe's monitor

View File

@ -54,6 +54,7 @@
#include "nsIInputStream.h"
#include "nsISeekableStream.h"
#include "prlog.h"
#include "nsInt64.h"
#if defined(PR_LOGGING)
//

View File

@ -61,6 +61,7 @@
#include "nsReadableUtils.h"
#include "nsISeekableStream.h"
#include "nsISupportsPrimitives.h"
#include "nsInt64.h"
#include "nsCRT.h"
#include "prerror.h"
#include "plstr.h"

View File

@ -69,6 +69,7 @@
#include "nsMemory.h"
#include "nsCOMArray.h"
#include "nsInt64.h"
#include "nsQuickSort.h"
#include "nsXPIDLString.h"

View File

@ -40,6 +40,7 @@
#include "nscore.h"
#include "prprf.h"
#include "plstr.h"
#include "nsInt64.h"
#include "nsISupports.h"
#include "nsIServiceManager.h"