Merge services-central into mozilla-central.

This commit is contained in:
Allison Naaktgeboren 2011-08-23 14:38:16 -07:00
commit f99fc1128e
177 changed files with 1626 additions and 3381 deletions

View File

@ -976,9 +976,11 @@ refRelationSetCB(AtkObject *aAtkObj)
while ((tempAcc = rel.Next()))
targets.AppendElement(nsAccessibleWrap::GetAtkObject(tempAcc));
atkRelation = atk_relation_new(targets.Elements(), targets.Length(), atkType);
atk_relation_set_add(relation_set, atkRelation);
g_object_unref(atkRelation);
if (targets.Length()) {
atkRelation = atk_relation_new(targets.Elements(), targets.Length(), atkType);
atk_relation_set_add(relation_set, atkRelation);
g_object_unref(atkRelation);
}
}
return relation_set;

View File

@ -156,10 +156,9 @@ Sanitizer.prototype = {
}
// Clear plugin data.
let ph = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
const phInterface = Ci.nsIPluginHost;
const FLAG_CLEAR_ALL = phInterface.FLAG_CLEAR_ALL;
ph.QueryInterface(phInterface);
let ph = Cc["@mozilla.org/plugin/host;1"].getService(phInterface);
// Determine age range in seconds. (-1 means clear all.) We don't know
// that this.range[1] is actually now, so we compute age range based
@ -195,13 +194,13 @@ Sanitizer.prototype = {
} catch (e) {}
},
get canClear()
{
return true;
}
},
offlineApps: {
clear: function ()
{

View File

@ -56,8 +56,6 @@ Cc["@mozilla.org/moz/jssubscript-loader;1"].
const dm = Cc["@mozilla.org/download-manager;1"].
getService(Ci.nsIDownloadManager);
const bhist = Cc["@mozilla.org/browser/global-history;2"].
getService(Ci.nsIBrowserHistory);
const formhist = Cc["@mozilla.org/satchel/form-history;1"].
getService(Ci.nsIFormHistory2);
@ -583,7 +581,7 @@ WindowHelper.prototype = {
try {
if (wh.onunload)
wh.onunload();
doNextTest();
waitForAsyncUpdates(doNextTest);
}
catch (exc) {
win.close();
@ -698,10 +696,11 @@ function addFormEntryWithMinutesAgo(aMinutesAgo) {
*/
function addHistoryWithMinutesAgo(aMinutesAgo) {
let pURI = makeURI("http://" + aMinutesAgo + "-minutes-ago.com/");
bhist.addPageWithDetails(pURI,
aMinutesAgo + " minutes ago",
now_uSec - (aMinutesAgo * 60 * 1000 * 1000));
is(bhist.isVisited(pURI), true,
PlacesUtils.bhistory
.addPageWithDetails(pURI,
aMinutesAgo + " minutes ago",
now_uSec - (aMinutesAgo * 60 * 1000 * 1000));
is(PlacesUtils.bhistory.isVisited(pURI), true,
"Sanity check: history visit " + pURI.spec +
" should exist after creating it");
return pURI;
@ -711,11 +710,45 @@ function addHistoryWithMinutesAgo(aMinutesAgo) {
* Removes all history visits, downloads, and form entries.
*/
function blankSlate() {
bhist.removeAllPages();
PlacesUtils.bhistory.removeAllPages();
dm.cleanUp();
formhist.removeAllEntries();
}
/**
* Waits for all pending async statements on the default connection, before
* proceeding with aCallback.
*
* @param aCallback
* Function to be called when done.
* @param aScope
* Scope for the callback.
* @param aArguments
* Arguments array for the callback.
*
* @note The result is achieved by asynchronously executing a query requiring
* a write lock. Since all statements on the same connection are
* serialized, the end of this write operation means that all writes are
* complete. Note that WAL makes so that writers don't block readers, but
* this is a problem only across different connections.
*/
function waitForAsyncUpdates(aCallback, aScope, aArguments)
{
let scope = aScope || this;
let args = aArguments || [];
let db = PlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase)
.DBConnection;
db.createAsyncStatement("BEGIN EXCLUSIVE").executeAsync();
db.createAsyncStatement("COMMIT").executeAsync({
handleResult: function() {},
handleError: function() {},
handleCompletion: function(aReason)
{
aCallback.apply(scope, args);
}
});
}
/**
* Ensures that the given pref is the expected value.
*
@ -758,7 +791,7 @@ function downloadExists(aID)
function doNextTest() {
if (gAllTests.length <= gCurrTest) {
blankSlate();
finish();
waitForAsyncUpdates(finish);
}
else {
let ct = gCurrTest;
@ -810,7 +843,7 @@ function ensureFormEntriesClearedState(aFormEntries, aShouldBeCleared) {
function ensureHistoryClearedState(aURIs, aShouldBeCleared) {
let niceStr = aShouldBeCleared ? "no longer" : "still";
aURIs.forEach(function (aURI) {
is(bhist.isVisited(aURI), !aShouldBeCleared,
is(PlacesUtils.bhistory.isVisited(aURI), !aShouldBeCleared,
"history visit " + aURI.spec + " should " + niceStr + " exist");
});
}
@ -836,5 +869,5 @@ function test() {
blankSlate();
waitForExplicitFinish();
// Kick off all the tests in the gAllTests array.
doNextTest();
waitForAsyncUpdates(doNextTest);
}

View File

@ -55,8 +55,6 @@ Cc["@mozilla.org/moz/jssubscript-loader;1"].
const dm = Cc["@mozilla.org/download-manager;1"].
getService(Ci.nsIDownloadManager);
const bhist = Cc["@mozilla.org/browser/global-history;2"].
getService(Ci.nsIBrowserHistory);
const formhist = Cc["@mozilla.org/satchel/form-history;1"].
getService(Ci.nsIFormHistory2);
@ -502,10 +500,11 @@ function addFormEntryWithMinutesAgo(aMinutesAgo) {
*/
function addHistoryWithMinutesAgo(aMinutesAgo) {
let pURI = makeURI("http://" + aMinutesAgo + "-minutes-ago.com/");
bhist.addPageWithDetails(pURI,
aMinutesAgo + " minutes ago",
now_uSec - (aMinutesAgo * 60 * 1000 * 1000));
is(bhist.isVisited(pURI), true,
PlacesUtils.bhistory
.addPageWithDetails(pURI,
aMinutesAgo + " minutes ago",
now_uSec - (aMinutesAgo * 60 * 1000 * 1000));
is(PlacesUtils.bhistory.isVisited(pURI), true,
"Sanity check: history visit " + pURI.spec +
" should exist after creating it");
return pURI;
@ -515,11 +514,45 @@ function addHistoryWithMinutesAgo(aMinutesAgo) {
* Removes all history visits, downloads, and form entries.
*/
function blankSlate() {
bhist.removeAllPages();
PlacesUtils.bhistory.removeAllPages();
dm.cleanUp();
formhist.removeAllEntries();
}
/**
* Waits for all pending async statements on the default connection, before
* proceeding with aCallback.
*
* @param aCallback
* Function to be called when done.
* @param aScope
* Scope for the callback.
* @param aArguments
* Arguments array for the callback.
*
* @note The result is achieved by asynchronously executing a query requiring
* a write lock. Since all statements on the same connection are
* serialized, the end of this write operation means that all writes are
* complete. Note that WAL makes so that writers don't block readers, but
* this is a problem only across different connections.
*/
function waitForAsyncUpdates(aCallback, aScope, aArguments)
{
let scope = aScope || this;
let args = aArguments || [];
let db = PlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase)
.DBConnection;
db.createAsyncStatement("BEGIN EXCLUSIVE").executeAsync();
db.createAsyncStatement("COMMIT").executeAsync({
handleResult: function() {},
handleError: function() {},
handleCompletion: function(aReason)
{
aCallback.apply(scope, args);
}
});
}
/**
* Checks to see if the download with the specified ID exists.
*
@ -548,7 +581,7 @@ function downloadExists(aID)
function doNextTest() {
if (gAllTests.length <= gCurrTest) {
blankSlate();
finish();
waitForAsyncUpdates(finish);
}
else {
let ct = gCurrTest;
@ -600,7 +633,7 @@ function ensureFormEntriesClearedState(aFormEntries, aShouldBeCleared) {
function ensureHistoryClearedState(aURIs, aShouldBeCleared) {
let niceStr = aShouldBeCleared ? "no longer" : "still";
aURIs.forEach(function (aURI) {
is(bhist.isVisited(aURI), !aShouldBeCleared,
is(PlacesUtils.bhistory.isVisited(aURI), !aShouldBeCleared,
"history visit " + aURI.spec + " should " + niceStr + " exist");
});
}
@ -625,7 +658,7 @@ function openWindow(aOnloadCallback) {
// ok()/is() do...
try {
aOnloadCallback(win);
doNextTest();
waitForAsyncUpdates(doNextTest);
}
catch (exc) {
win.close();
@ -649,5 +682,5 @@ function test() {
blankSlate();
waitForExplicitFinish();
// Kick off all the tests in the gAllTests array.
doNextTest();
waitForAsyncUpdates(doNextTest);
}

View File

@ -536,7 +536,7 @@ function runNextTest() {
gCurrentTest.cleanup();
info("End of test: " + gCurrentTest.desc);
gCurrentTest = null;
executeSoon(runNextTest);
waitForAsyncUpdates(runNextTest);
return;
}

View File

@ -146,8 +146,7 @@ gTests.push({
menuNode.containerOpen = false;
bhist.removeAllPages();
nextTest();
waitForClearHistory(nextTest);
}
});

View File

@ -29,6 +29,13 @@ function openLibrary(callback, aLeftPaneRoot) {
return library;
}
/**
* Waits for completion of a clear history operation, before
* proceeding with aCallback.
*
* @param aCallback
* Function to be called when done.
*/
function waitForClearHistory(aCallback) {
Services.obs.addObserver(function observeCH(aSubject, aTopic, aData) {
Services.obs.removeObserver(observeCH, PlacesUtils.TOPIC_EXPIRATION_FINISHED);
@ -36,3 +43,37 @@ function waitForClearHistory(aCallback) {
}, PlacesUtils.TOPIC_EXPIRATION_FINISHED, false);
PlacesUtils.bhistory.removeAllPages();
}
/**
* Waits for all pending async statements on the default connection, before
* proceeding with aCallback.
*
* @param aCallback
* Function to be called when done.
* @param aScope
* Scope for the callback.
* @param aArguments
* Arguments array for the callback.
*
* @note The result is achieved by asynchronously executing a query requiring
* a write lock. Since all statements on the same connection are
* serialized, the end of this write operation means that all writes are
* complete. Note that WAL makes so that writers don't block readers, but
* this is a problem only across different connections.
*/
function waitForAsyncUpdates(aCallback, aScope, aArguments)
{
let scope = aScope || this;
let args = aArguments || [];
let db = PlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase)
.DBConnection;
db.createAsyncStatement("BEGIN EXCLUSIVE").executeAsync();
db.createAsyncStatement("COMMIT").executeAsync({
handleResult: function() {},
handleError: function() {},
handleCompletion: function(aReason)
{
aCallback.apply(scope, args);
}
});
}

View File

@ -619,11 +619,9 @@ PrivateBrowsingService.prototype = {
}
// Plugin data
let (ph = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost)) {
const phInterface = Ci.nsIPluginHost;
const FLAG_CLEAR_ALL = phInterface.FLAG_CLEAR_ALL;
ph.QueryInterface(phInterface);
const phInterface = Ci.nsIPluginHost;
const FLAG_CLEAR_ALL = phInterface.FLAG_CLEAR_ALL;
let (ph = Cc["@mozilla.org/plugin/host;1"].getService(phInterface)) {
let tags = ph.getPluginTags();
for (let i = 0; i < tags.length; i++) {
try {

View File

@ -42,34 +42,21 @@ function test() {
// initialization
let pb = Cc["@mozilla.org/privatebrowsing;1"].
getService(Ci.nsIPrivateBrowsingService);
let bhist = Cc["@mozilla.org/browser/global-history;2"].
getService(Ci.nsIBrowserHistory);
let histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
getService(Ci.nsINavHistoryService).
QueryInterface(Ci.nsPIPlacesDatabase);
let cm = Cc["@mozilla.org/cookiemanager;1"].
getService(Ci.nsICookieManager);
waitForExplicitFinish();
const TEST_URL = "http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/title.sjs";
function cleanup() {
// delete all history items
bhist.removeAllPages();
function waitForCleanup(aCallback) {
// delete all cookies
cm.removeAll();
// delete all history items
waitForClearHistory(aCallback);
}
cleanup();
let observer = {
pass: 1,
onBeginUpdateBatch: function() {
},
onEndUpdateBatch: function() {
},
onVisit: function(aURI, aVisitID, aTime, aSessionId, aReferringId,
aTransitionType, _added) {
},
onTitleChanged: function(aURI, aPageTitle) {
if (aURI.spec != TEST_URL)
return;
@ -80,8 +67,9 @@ function test() {
break;
case 2: // the second time that the page is loaded
is(aPageTitle, "Cookie", "The page should be loaded with a cookie for the second time");
cleanup();
gBrowser.selectedTab = gBrowser.addTab(TEST_URL);
waitForCleanup(function () {
gBrowser.selectedTab = gBrowser.addTab(TEST_URL);
});
break;
case 3: // before entering the private browsing mode
is(aPageTitle, "No Cookie", "The page should be loaded without any cookie again");
@ -89,37 +77,33 @@ function test() {
pb.privateBrowsingEnabled = true;
gBrowser.selectedTab = gBrowser.addTab(TEST_URL);
executeSoon(function() {
histsvc.removeObserver(observer);
PlacesUtils.history.removeObserver(observer);
pb.privateBrowsingEnabled = false;
while (gBrowser.browsers.length > 1)
while (gBrowser.browsers.length > 1) {
gBrowser.removeCurrentTab();
cleanup();
finish();
}
waitForCleanup(finish);
});
break;
default:
ok(false, "Unexpected pass: " + (this.pass - 1));
}
},
onBeforeDeleteURI: function(aURI) {
},
onDeleteURI: function(aURI) {
},
onClearHistory: function() {
},
onPageChanged: function(aURI, aWhat, aValue) {
},
onDeleteVisits: function() {
},
QueryInterface: function(iid) {
if (iid.equals(Ci.nsINavHistoryObserver) ||
iid.equals(Ci.nsISupports)) {
return this;
}
throw Cr.NS_ERROR_NO_INTERFACE;
}
};
histsvc.addObserver(observer, false);
gBrowser.selectedTab = gBrowser.addTab(TEST_URL);
onBeginUpdateBatch: function () {},
onEndUpdateBatch: function () {},
onVisit: function () {},
onBeforeDeleteURI: function () {},
onDeleteURI: function () {},
onClearHistory: function () {},
onPageChanged: function () {},
onDeleteVisits: function() {},
QueryInterface: XPCOMUtils.generateQI([Ci.nsINavHistoryObserver])
};
PlacesUtils.history.addObserver(observer, false);
waitForCleanup(function () {
gBrowser.selectedTab = gBrowser.addTab(TEST_URL);
});
}

View File

@ -9,3 +9,17 @@ registerCleanupFunction(function() {
} catch(e) {}
});
/**
* Waits for completion of a clear history operation, before
* proceeding with aCallback.
*
* @param aCallback
* Function to be called when done.
*/
function waitForClearHistory(aCallback) {
Services.obs.addObserver(function observeCH(aSubject, aTopic, aData) {
Services.obs.removeObserver(observeCH, PlacesUtils.TOPIC_EXPIRATION_FINISHED);
aCallback();
}, PlacesUtils.TOPIC_EXPIRATION_FINISHED, false);
PlacesUtils.bhistory.removeAllPages();
}

View File

@ -603,18 +603,37 @@ toolbar[mode="full"] .toolbarbutton-1 > .toolbarbutton-menubutton-button {
#forward-button {
list-style-image: url("moz-icon://stock/gtk-go-forward-ltr?size=toolbar");
-moz-transition: 250ms ease-out;
}
#forward-button[disabled="true"] {
list-style-image: url("moz-icon://stock/gtk-go-forward-ltr?size=toolbar&state=disabled");
}
#forward-button:-moz-locale-dir(rtl) {
list-style-image: url("moz-icon://stock/gtk-go-forward-rtl?size=toolbar");
}
#forward-button[disabled="true"]:-moz-locale-dir(rtl) {
toolbar:not([mode=icons]) #forward-button[disabled="true"] {
list-style-image: url("moz-icon://stock/gtk-go-forward-ltr?size=toolbar&state=disabled");
}
toolbar:not([mode=icons]) #forward-button[disabled="true"]:-moz-locale-dir(rtl) {
list-style-image: url("moz-icon://stock/gtk-go-forward-rtl?size=toolbar&state=disabled");
}
toolbar[mode=icons] #forward-button[disabled="true"] {
-moz-transform: scale(0);
opacity: 0;
pointer-events: none;
}
toolbar[mode=icons] #forward-button[disabled="true"]:-moz-locale-dir(ltr) {
margin-left: -36px;
}
toolbar[mode=icons] #forward-button[disabled="true"]:-moz-locale-dir(rtl) {
margin-right: -36px;
}
toolbar[mode=icons][iconsize=small] #forward-button[disabled="true"]:-moz-locale-dir(ltr) {
margin-left: -28px;
}
toolbar[mode=icons][iconsize=small] #forward-button[disabled="true"]:-moz-locale-dir(rtl) {
margin-right: -28px;
}
#reload-button {
list-style-image: url("moz-icon://stock/gtk-refresh?size=toolbar");
}
@ -786,7 +805,7 @@ toolbar[iconsize="small"] #forward-button {
.unified-nav-forward[_moz-menuactive] {
list-style-image: url("moz-icon://stock/gtk-go-forward-ltr?size=menu") !important;
}
toolbar[iconsize="small"] #forward-button[disabled="true"] {
toolbar[iconsize="small"]:not([mode=icons]) #forward-button[disabled="true"] {
list-style-image: url("moz-icon://stock/gtk-go-forward-ltr?size=menu&state=disabled");
}
@ -796,7 +815,7 @@ toolbar[iconsize="small"] #forward-button:-moz-locale-dir(rtl) {
.unified-nav-forward[_moz-menuactive]:-moz-locale-dir(rtl) {
list-style-image: url("moz-icon://stock/gtk-go-forward-rtl?size=menu") !important;
}
toolbar[iconsize="small"] #forward-button[disabled="true"]:-moz-locale-dir(rtl) {
toolbar[iconsize="small"]:not([mode=icons]) #forward-button[disabled="true"]:-moz-locale-dir(rtl) {
list-style-image: url("moz-icon://stock/gtk-go-forward-rtl?size=menu&state=disabled");
}

View File

@ -43,7 +43,6 @@ USE_AUTOCONF = 1
MOZILLA_CLIENT = 1
target = @target@
ac_configure_args = @ac_configure_args@
BUILD_MODULES = @BUILD_MODULES@
MOZILLA_VERSION = @MOZILLA_VERSION@
FIREFOX_VERSION = @FIREFOX_VERSION@

View File

@ -41,6 +41,38 @@ static BOOL sh_DoCopy(wchar_t *srcFileName, DWORD srcFileAttributes,
#define ARRAY_LEN(a) (sizeof(a) / sizeof(a[0]))
#define STR_LEN(a) (ARRAY_LEN(a) - 1)
#ifdef __MINGW32__
/* MingW currently does not implement a wide version of the
startup routines. Workaround is to implement something like
it ourselves. */
#include <shellapi.h>
int wmain(int argc, WCHAR **argv);
int main(int argc, char **argv)
{
int result;
wchar_t *commandLine = GetCommandLineW();
int argcw = 0;
wchar_t **_argvw = CommandLineToArgvW( commandLine, &argcw );
wchar_t *argvw[argcw + 1];
int i;
if (!_argvw)
return 127;
/* CommandLineToArgvW doesn't output the ending NULL so
we have to manually add it on */
for ( i = 0; i < argcw; i++ )
argvw[i] = _argvw[i];
argvw[argcw] = NULL;
result = wmain(argcw, argvw);
LocalFree(_argvw);
return result;
}
#endif /* __MINGW32__ */
/* changes all forward slashes in token to backslashes */
void changeForwardSlashesToBackSlashes ( wchar_t *arg )
{

View File

@ -1153,8 +1153,9 @@ ifdef HAVE_DTRACE
ifndef XP_MACOSX
ifdef DTRACE_PROBE_OBJ
ifndef DTRACE_LIB_DEPENDENT
$(DTRACE_PROBE_OBJ):
dtrace -G -C -s $(MOZILLA_DTRACE_SRC) -o $(DTRACE_PROBE_OBJ)
NON_DTRACE_OBJS := $(filter-out $(DTRACE_PROBE_OBJ),$(OBJS))
$(DTRACE_PROBE_OBJ): $(NON_DTRACE_OBJS)
dtrace -G -C -s $(MOZILLA_DTRACE_SRC) -o $(DTRACE_PROBE_OBJ) $(NON_DTRACE_OBJS)
endif
endif
endif
@ -1550,9 +1551,6 @@ export:: FORCE
@echo; sleep 2; false
endif
$(IDL_DIR)::
$(NSINSTALL) -D $@
# generate .h files from into $(XPIDL_GEN_DIR), then export to $(DIST)/include;
# warn against overriding existing .h file.
$(XPIDL_GEN_DIR)/.done:
@ -1623,14 +1621,8 @@ endif # XPIDLSRCS
#
# General rules for exporting idl files.
#
# WORK-AROUND ONLY, for mozilla/tools/module-deps/bootstrap.pl build.
# Bug to fix idl dependency problems w/o this extra build pass is
# http://bugzilla.mozilla.org/show_bug.cgi?id=145777
#
$(IDL_DIR)::
$(IDL_DIR):
$(NSINSTALL) -D $@
export-idl:: $(SUBMAKEFILES) $(MAKE_DIRS)
@ -2097,7 +2089,6 @@ showhost:
@echo "HOST_LIBRARY = $(HOST_LIBRARY)"
showbuildmods::
@echo "Build Modules = $(BUILD_MODULES)"
@echo "Module dirs = $(BUILD_MODULE_DIRS)"
documentation:

View File

@ -970,7 +970,6 @@ if test -n "$_WIN32_MSVC"; then
AC_DEFINE(HAVE_IO_H)
AC_DEFINE(HAVE_SETBUF)
AC_DEFINE(HAVE_ISATTY)
AC_DEFINE(HAVE_STDCALL)
fi
fi # COMPILE_ENVIRONMENT
@ -2482,6 +2481,8 @@ ia64*-hpux*)
if test -n "$GNU_CC"; then
CFLAGS="$CFLAGS -mstackrealign"
CXXFLAGS="$CXXFLAGS -mstackrealign"
else
AC_DEFINE(HAVE_STDCALL)
fi
MOZ_CHECK_HEADERS(mmintrin.h)

View File

@ -6125,7 +6125,7 @@ nsDocument::AdoptNode(nsIDOMNode *aAdoptedNode, nsIDOMNode **aResult)
} while ((doc = doc->GetParentDocument()));
// Remove from parent.
nsINode* parent = adoptedNode->GetNodeParent();
nsCOMPtr<nsINode> parent = adoptedNode->GetNodeParent();
if (parent) {
rv = parent->RemoveChildAt(parent->IndexOf(adoptedNode), PR_TRUE);
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -620,7 +620,7 @@ nsINode::Normalize()
}
// Remove node
nsINode* parent = node->GetNodeParent();
nsCOMPtr<nsINode> parent = node->GetNodeParent();
NS_ASSERTION(parent || hasRemoveListeners,
"Should always have a parent unless "
"mutation events messed us up");
@ -3945,7 +3945,7 @@ nsINode::ReplaceOrInsertBefore(PRBool aReplace, nsINode* aNewChild,
}
// Remove the new child from the old parent if one exists
nsINode* oldParent = newContent->GetNodeParent();
nsCOMPtr<nsINode> oldParent = newContent->GetNodeParent();
if (oldParent) {
PRInt32 removeIndex = oldParent->IndexOf(newContent);
if (removeIndex < 0) {

View File

@ -2510,12 +2510,12 @@ nsHTMLInputElement::SanitizeValue(nsAString& aValue)
case NS_FORM_INPUT_SEARCH:
case NS_FORM_INPUT_TEL:
case NS_FORM_INPUT_PASSWORD:
case NS_FORM_INPUT_EMAIL:
{
PRUnichar crlf[] = { PRUnichar('\r'), PRUnichar('\n'), 0 };
aValue.StripChars(crlf);
}
break;
case NS_FORM_INPUT_EMAIL:
case NS_FORM_INPUT_URL:
{
PRUnichar crlf[] = { PRUnichar('\r'), PRUnichar('\n'), 0 };

View File

@ -75,8 +75,12 @@ var email = document.forms[0].elements[0];
var values = [
[ '', true ], // The empty string shouldn't be considered as invalid.
[ 'foo@bar.com', true ],
[ ' foo@bar.com', false ],
[ 'foo@bar.com ', false ],
[ ' foo@bar.com', true ],
[ 'foo@bar.com ', true ],
[ '\r\n foo@bar.com', true ],
[ 'foo@bar.com \n\r', true ],
[ '\n\n \r\rfoo@bar.com\n\n \r\r', true ],
[ '\n\r \n\rfoo@bar.com\n\r \n\r', true ],
[ 'tulip', false ],
// Some checks on the user part of the address.
[ '@bar.com', false ],
@ -163,7 +167,7 @@ values.push(["foo@bar.com" + legalCharacters, true]);
// Add domain illegal characters.
illegalCharacters = "()<>[]:;@\\,!#$%&'*+/=?^_`{|}~ \t";
for each (c in illegalCharacters) {
values.push(['foo@foo.bar' + c, false]);
values.push(['foo@foo.ba' + c + 'r', false]);
}
values.forEach(function([value, valid]) {

View File

@ -47,9 +47,9 @@ function sanitizeValue(aType, aValue)
case "password":
case "search":
case "tel":
case "email":
return aValue.replace(/[\n\r]/g, "");
case "url":
case "email":
return aValue.replace(/[\n\r]/g, "").replace(/^\s+|\s+$/g, "");
case "date":
case "month":

View File

@ -32,7 +32,6 @@ function seekStarted(evt) {
function seekEnded(evt) {
var v = evt.target;
v._gotSeekEnded = true;
v.play();
}
function loadedData(evt) {

View File

@ -146,8 +146,14 @@ nsSMILCSSProperty::GetBaseValue() const
// (4) Populate our nsSMILValue from the computed style
if (didGetComputedVal) {
// When we parse animation values we check if they are context-sensitive or
// not so that we don't cache animation values whose meaning may change.
// For base values however this is unnecessary since on each sample the
// compositor will fetch the (computed) base value and compare it against
// the cached (computed) value and detect changes for us.
nsSMILCSSValueType::ValueFromString(mPropID, mElement,
computedStyleVal, baseValue);
computedStyleVal, baseValue,
nsnull);
}
return baseValue;
}
@ -160,22 +166,17 @@ nsSMILCSSProperty::ValueFromString(const nsAString& aStr,
{
NS_ENSURE_TRUE(IsPropertyAnimatable(mPropID), NS_ERROR_FAILURE);
nsSMILCSSValueType::ValueFromString(mPropID, mElement, aStr, aValue);
if (aValue.IsNull()) {
return NS_ERROR_FAILURE;
nsSMILCSSValueType::ValueFromString(mPropID, mElement, aStr, aValue,
&aPreventCachingOfSandwich);
// XXX Due to bug 536660 (or at least that seems to be the most likely
// culprit), when we have animation setting display:none on a <use> element,
// if we DON'T set the property every sample, chaos ensues.
if (!aPreventCachingOfSandwich && mPropID == eCSSProperty_display) {
aPreventCachingOfSandwich = PR_TRUE;
}
// XXXdholbert: For simplicity, just assume that all CSS values have to
// reparsed every sample. This prevents us from doing the "nothing's changed
// so don't recompose" optimization (bug 533291) for CSS properties & mapped
// attributes. If it ends up being expensive to always recompose those, we
// can be a little smarter here. We really only need to set
// aPreventCachingOfSandwich to true for "inherit" & "currentColor" (whose
// values could change at any time), for length-valued types (particularly
// those with em/ex/percent units, since their conversion ratios can change
// at any time), and for any value for 'font-family'.
aPreventCachingOfSandwich = PR_TRUE;
return NS_OK;
return aValue.IsNull() ? NS_ERROR_FAILURE : NS_OK;
}
nsresult

View File

@ -371,7 +371,8 @@ ValueFromStringHelper(nsCSSProperty aPropID,
Element* aTargetElement,
nsPresContext* aPresContext,
const nsAString& aString,
nsStyleAnimation::Value& aStyleAnimValue)
nsStyleAnimation::Value& aStyleAnimValue,
PRBool* aIsContextSensitive)
{
// If value is negative, we'll strip off the "-" so the CSS parser won't
// barf, and then manually make the parsed value negative.
@ -386,7 +387,8 @@ ValueFromStringHelper(nsCSSProperty aPropID,
}
nsDependentSubstring subString(aString, subStringBegin);
if (!nsStyleAnimation::ComputeValue(aPropID, aTargetElement, subString,
PR_TRUE, aStyleAnimValue)) {
PR_TRUE, aStyleAnimValue,
aIsContextSensitive)) {
return PR_FALSE;
}
if (isNegative) {
@ -409,7 +411,8 @@ void
nsSMILCSSValueType::ValueFromString(nsCSSProperty aPropID,
Element* aTargetElement,
const nsAString& aString,
nsSMILValue& aValue)
nsSMILValue& aValue,
PRBool* aIsContextSensitive)
{
NS_ABORT_IF_FALSE(aValue.IsNull(), "Outparam should be null-typed");
nsPresContext* presContext = GetPresContextForElement(aTargetElement);
@ -420,7 +423,7 @@ nsSMILCSSValueType::ValueFromString(nsCSSProperty aPropID,
nsStyleAnimation::Value parsedValue;
if (ValueFromStringHelper(aPropID, aTargetElement, presContext,
aString, parsedValue)) {
aString, parsedValue, aIsContextSensitive)) {
sSingleton.Init(aValue);
aValue.mU.mPtr = new ValueWrapper(aPropID, parsedValue, presContext);
}

View File

@ -100,13 +100,20 @@ public:
* @param aString The string to be parsed as a CSS value.
* @param [out] aValue The nsSMILValue to be populated. Should
* initially be null-typed.
* @param [out] aIsContextSensitive Set to PR_TRUE if |aString| may produce
* a different |aValue| depending on other
* CSS properties on |aTargetElement|
* or its ancestors (e.g. 'inherit).
* PR_FALSE otherwise. May be nsnull.
* Not set if the method fails.
* @pre aValue.IsNull()
* @post aValue.IsNull() || aValue.mType == nsSMILCSSValueType::sSingleton
*/
static void ValueFromString(nsCSSProperty aPropID,
Element* aTargetElement,
const nsAString& aString,
nsSMILValue& aValue);
nsSMILValue& aValue,
PRBool* aIsContextSensitive);
/**
* Creates a string representation of the given nsSMILValue.

View File

@ -67,15 +67,9 @@ nsSMILMappedAttribute::ValueFromString(const nsAString& aStr,
{
NS_ENSURE_TRUE(IsPropertyAnimatable(mPropID), NS_ERROR_FAILURE);
nsSMILCSSValueType::ValueFromString(mPropID, mElement, aStr, aValue);
if (aValue.IsNull()) {
return NS_ERROR_FAILURE;
}
// XXXdholbert: For simplicity, just assume that all CSS values have to
// reparsed every sample. See note in nsSMILCSSProperty::ValueFromString.
aPreventCachingOfSandwich = PR_TRUE;
return NS_OK;
nsSMILCSSValueType::ValueFromString(mPropID, mElement, aStr, aValue,
&aPreventCachingOfSandwich);
return aValue.IsNull() ? NS_ERROR_FAILURE : NS_OK;
}
nsSMILValue
@ -87,8 +81,12 @@ nsSMILMappedAttribute::GetBaseValue() const
baseStringValue);
nsSMILValue baseValue;
if (success) {
// For base values, we don't need to worry whether the value returned is
// context-sensitive or not since the compositor will take care of comparing
// the returned (computed) base value and its cached value and determining
// if an update is required or not.
nsSMILCSSValueType::ValueFromString(mPropID, mElement,
baseStringValue, baseValue);
baseStringValue, baseValue, nsnull);
} else {
// Attribute is unset -- use computed value.
// FIRST: Temporarily clear animated value, to make sure it doesn't pollute

View File

@ -8,7 +8,10 @@
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=533291">Mozilla Bug 533291</a>
<p id="display"></p>
<div id="content" style="display: none">
<!-- Bug 628848: The following should be display: none but we currently don't
handle percentage lengths properly when the whole fragment is display: none
-->
<div id="content" style="visibility: hidden">
<svg id="svg" xmlns="http://www.w3.org/2000/svg" width="120px" height="120px"
onload="this.pauseAnimations()">
<g id="circleParent">
@ -19,68 +22,99 @@
<pre id="test">
<script class="testbody" type="text/javascript">
<![CDATA[
/** Test for SMIL fill modes **/
/** Test for SMIL values that are context-sensitive **/
/* See bugs 533291 and 562815.
The format of each test is basically:
1) create some animated and frozen state
2) test the animated values
3) change the context
4) test that context-sensitive animation values have changed
Ideally, after changing the context (3), the animated state would instantly
update. However, this is not currently the case for many situations.
For CSS properties we have bug 545282 - In animations involving 'inherit'
/ 'currentColor', changes to inherited value / 'color' don't show up in
animated value immediately
For SVG lengths we have bug 508206 - Relative units used in
animation don't update immediately
(There are a few of todo_is's in the following tests so that if those bugs
are ever resolved we'll know to update this test case accordingly.)
So in between (3) and (4) we force a sample. This is currently done by
calling SVGSVGElement.setCurrentTime with the same current time which has the
side effect of forcing a sample.
What we *are* testing is that we're not too zealous with caching animation
values whilst in the frozen state. Normally we'd say, "Hey, we're frozen,
let's just use the same animation result as last time" but for some
context-sensitive animation values that doesn't work.
*/
/* Global Variables */
const SVGNS = "http://www.w3.org/2000/svg";
// Animation parameters -- not used for <set> animation
const ANIM_DUR = "4s";
const TIME_ANIM_END = "4";
const TIME_AFTER_ANIM_END = "5";
// SETTIMEOUT_INTERVAL: This value just needs to be at least as large as
// nsSMILAnimationController::kTimerInterval, so we can queue up a callback
// for this far in the future and be assured that an animation sample will
// have happened before the callback fires (because we presumably already
// have an animation sample in the setTimeout queue, with a lower timeout
// value than this).
// NOTE: We only need to use timeouts here because of Bug 545282.
const SETTIMEOUT_INTERVAL = 60;
const gTestArray =
[ testBaseValueChange,
testCurrentColorChange,
testCurrentColorChangeUsingStyle,
testInheritChange,
testInheritChangeUsingStyle
];
// Index of current test in gTestArray
var gNextTestIndex = 0;
const gSvg = document.getElementById("svg");
const gCircle = document.getElementById("circle");
const gCircleParent = document.getElementById("circleParent");
SimpleTest.waitForExplicitFinish();
// MAIN FUNCTION
// -------------
function main() {
function main()
{
ok(gSvg.animationsPaused(), "should be paused by <svg> load handler");
is(gSvg.getCurrentTime(), 0, "should be paused at 0 in <svg> load handler");
if (gNextTestIndex != 0) {
ok(false, "expecting to start at first test in array.");
const tests =
[ testBaseValueChange,
testCurrentColorChange,
testCurrentColorChangeUsingStyle,
testCurrentColorChangeOnFallback,
testInheritChange,
testInheritChangeUsingStyle,
testEmUnitChangeOnProp,
testEmUnitChangeOnPropBase,
testEmUnitChangeOnLength,
testPercentUnitChangeOnProp,
testPercentUnitChangeOnLength,
testRelativeFontSize,
testRelativeFontWeight,
testRelativeFont,
testCalcFontSize,
testDashArray,
testClip
];
while (tests.length) {
tests.shift()();
}
// Kick off first test. (It will kick off the one after it, and so on.)
runNextTest();
SimpleTest.finish();
}
// HELPER FUNCTIONS
// ----------------
function createAnimFromTo(attrName, fromVal, toVal) {
var anim = document.createElementNS(SVGNS,"animate");
function createAnimSetTo(attrName, toVal)
{
var anim = document.createElementNS(SVGNS,"set");
anim.setAttribute("attributeName", attrName);
anim.setAttribute("dur", ANIM_DUR);
anim.setAttribute("begin", "0s");
anim.setAttribute("from", fromVal);
anim.setAttribute("to", toVal);
anim.setAttribute("fill", "freeze");
return gCircle.appendChild(anim);
}
function createAnimBy(attrName, byVal) {
function createAnimBy(attrName, byVal)
{
var anim = document.createElementNS(SVGNS,"animate");
anim.setAttribute("attributeName", attrName);
anim.setAttribute("dur", ANIM_DUR);
@ -90,6 +124,18 @@ function createAnimBy(attrName, byVal) {
return gCircle.appendChild(anim);
}
function createAnimFromTo(attrName, fromVal, toVal)
{
var anim = document.createElementNS(SVGNS,"animate");
anim.setAttribute("attributeName", attrName);
anim.setAttribute("dur", ANIM_DUR);
anim.setAttribute("begin","0s");
anim.setAttribute("from", fromVal);
anim.setAttribute("to", toVal);
anim.setAttribute("fill", "freeze");
return gCircle.appendChild(anim);
}
// Common setup code for each test function: seek to 0, and make sure
// the previous test cleaned up its animations.
function setupTest() {
@ -99,17 +145,6 @@ function setupTest() {
}
}
function runNextTest() {
if (gNextTestIndex == gTestArray.length) {
// No tests left! we're done.
SimpleTest.finish();
return;
}
// Call next test (and increment next-test index)
gTestArray[gNextTestIndex++]();
}
// THE TESTS
// ---------
@ -130,106 +165,400 @@ function testBaseValueChange()
"Checking animated cx after anim ends & after changing base val");
anim.parentNode.removeChild(anim); // clean up
runNextTest();
}
function testCurrentColorChange()
{
gCircle.setAttribute("color", "red"); // At first: currentColor=red
var anim = createAnimFromTo("fill", "yellow", "currentColor");
var anim = createAnimSetTo("fill", "currentColor");
gSvg.setCurrentTime(TIME_AFTER_ANIM_END);
gSvg.setCurrentTime(0); // trigger synchronous sample
is(SMILUtil.getComputedStyleSimple(gCircle, "fill"), "rgb(255, 0, 0)",
"Checking animated fill=currentColor after anim ends");
"Checking animated fill=currentColor after animating");
gCircle.setAttribute("color", "lime"); // Change: currentColor=lime
setTimeout(testCurrentColorChange_final, SETTIMEOUT_INTERVAL);
}
function testCurrentColorChange_final()
{
// Bug 545282: We should really detect this change and update immediately but
// currently we don't until we get sampled again
todo_is(SMILUtil.getComputedStyleSimple(gCircle, "fill"), "rgb(0, 255, 0)",
"Checking animated fill=currentColor after updating context but before " +
"sampling");
gSvg.setCurrentTime(0);
is(SMILUtil.getComputedStyleSimple(gCircle, "fill"), "rgb(0, 255, 0)",
"Checking animated fill=currentColor after anim ends and 'color' changes");
"Checking animated fill=currentColor after updating context");
// Clean up
gCircle.removeAttribute("color");
gCircle.firstChild.parentNode.removeChild(gCircle.firstChild);
// Kick off next test
runNextTest();
gCircle.removeChild(gCircle.firstChild);
}
function testCurrentColorChangeUsingStyle()
{
setupTest();
gCircle.setAttribute("style", "color: red"); // At first: currentColor=red
var anim = createAnimFromTo("fill", "yellow", "currentColor");
var anim = createAnimSetTo("fill", "currentColor");
gSvg.setCurrentTime(TIME_AFTER_ANIM_END);
gSvg.setCurrentTime(0);
is(SMILUtil.getComputedStyleSimple(gCircle, "fill"), "rgb(255, 0, 0)",
"Checking animated fill=currentColor after anim ends (using style attr)");
"Checking animated fill=currentColor after animating (using style attr)");
gCircle.setAttribute("style", "color: lime"); // Change: currentColor=lime
setTimeout(testCurrentColorChangeUsingStyle_final, SETTIMEOUT_INTERVAL);
}
function testCurrentColorChangeUsingStyle_final()
{
gSvg.setCurrentTime(0);
is(SMILUtil.getComputedStyleSimple(gCircle, "fill"), "rgb(0, 255, 0)",
"Checking animated fill=currentColor after anim ends and 'color' changes "
"Checking animated fill=currentColor after updating context "
+ "(using style attr)");
// Clean up
gCircle.removeAttribute("style");
gCircle.firstChild.parentNode.removeChild(gCircle.firstChild);
runNextTest();
gCircle.removeChild(gCircle.firstChild);
}
function getFallbackColor(pServerStr)
{
return pServerStr.substr(pServerStr.indexOf(" ")+1);
}
function testCurrentColorChangeOnFallback()
{
setupTest();
gCircle.setAttribute("color", "red"); // At first: currentColor=red
var anim = createAnimSetTo("fill", "url(#missingGrad) currentColor");
gSvg.setCurrentTime(0);
var fallback =
getFallbackColor(SMILUtil.getComputedStyleSimple(gCircle, "fill"));
is(fallback, "rgb(255, 0, 0)",
"Checking animated fallback fill=currentColor after animating");
gCircle.setAttribute("color", "lime"); // Change: currentColor=lime
gSvg.setCurrentTime(0);
fallback = getFallbackColor(SMILUtil.getComputedStyleSimple(gCircle, "fill"));
is(fallback, "rgb(0, 255, 0)",
"Checking animated fallback fill=currentColor after updating context");
gCircle.removeAttribute("style");
gCircle.removeChild(gCircle.firstChild);
}
function testInheritChange()
{
setupTest();
gCircleParent.setAttribute("fill", "red"); // At first: inherit=red
var anim = createAnimFromTo("fill", "yellow", "inherit");
var anim = createAnimSetTo("fill", "inherit");
gSvg.setCurrentTime(TIME_AFTER_ANIM_END);
gSvg.setCurrentTime(0);
is(SMILUtil.getComputedStyleSimple(gCircle, "fill"), "rgb(255, 0, 0)",
"Checking animated fill=inherit after anim ends");
"Checking animated fill=inherit after animating");
gCircleParent.setAttribute("fill", "lime"); // Change: inherit=lime
setTimeout(testInheritChange_final, SETTIMEOUT_INTERVAL);
}
function testInheritChange_final() {
gSvg.setCurrentTime(0);
is(SMILUtil.getComputedStyleSimple(gCircle, "fill"), "rgb(0, 255, 0)",
"Checking animated fill=inherit after anim ends and parent val changes");
"Checking animated fill=inherit after updating context");
gCircleParent.removeAttribute("fill");
gCircle.firstChild.parentNode.removeChild(gCircle.firstChild);
runNextTest();
gCircle.removeChild(gCircle.firstChild);
}
function testInheritChangeUsingStyle()
{
setupTest();
gCircleParent.setAttribute("style", "fill: red"); // At first: inherit=red
var anim = createAnimFromTo("fill", "yellow", "inherit");
var anim = createAnimSetTo("fill", "inherit");
gSvg.setCurrentTime(TIME_AFTER_ANIM_END);
gSvg.setCurrentTime(0);
is(SMILUtil.getComputedStyleSimple(gCircle, "fill"), "rgb(255, 0, 0)",
"Checking animated fill=inherit after anim ends (using style attr)");
"Checking animated fill=inherit after animating (using style attr)");
gCircleParent.setAttribute("style", "fill: lime"); // Change: inherit=lime
setTimeout(testInheritChangeUsingStyle_final, SETTIMEOUT_INTERVAL);
}
function testInheritChangeUsingStyle_final() {
gSvg.setCurrentTime(0);
is(SMILUtil.getComputedStyleSimple(gCircle, "fill"), "rgb(0, 255, 0)",
"Checking animated fill=inherit after anim ends and parent val changes "
"Checking animated fill=inherit after updating context "
+ "(using style attr)");
gCircleParent.removeAttribute("style");
gCircle.firstChild.parentNode.removeChild(gCircle.firstChild);
runNextTest();
gCircle.removeChild(gCircle.firstChild);
}
function testEmUnitChangeOnProp()
{
setupTest();
gCircleParent.setAttribute("font-size", "10px"); // At first: font-size: 10px
var anim = createAnimSetTo("font-size", "2em");
gSvg.setCurrentTime(0);
is(SMILUtil.getComputedStyleSimple(gCircle, "font-size"), "20px",
"Checking animated font-size=2em after animating ends");
gCircleParent.setAttribute("font-size", "20px"); // Change: font-size: 20px
gSvg.setCurrentTime(0);
is(SMILUtil.getComputedStyleSimple(gCircle, "font-size"), "40px",
"Checking animated font-size=2em after updating context");
gCircleParent.removeAttribute("font-size");
gCircle.removeChild(gCircle.firstChild);
}
function testEmUnitChangeOnPropBase()
{
// Test the case where the base value for our animation sandwich is
// context-sensitive.
// Currently, this is taken care of by the compositor which keeps a cached
// base value and compares it with the current base value. This test then just
// serves as a regression test in case the compositor's behaviour changes.
setupTest();
gSvg.setAttribute("font-size", "10px"); // At first: font-size: 10px
gCircleParent.setAttribute("font-size", "1em"); // Base: 10px
var anim = createAnimBy("font-size", "10px");
gSvg.setCurrentTime(TIME_AFTER_ANIM_END);
is(SMILUtil.getComputedStyleSimple(gCircle, "font-size"), "20px",
"Checking animated font-size=20px after anim ends");
gSvg.setAttribute("font-size", "20px"); // Change: font-size: 20px
gSvg.setCurrentTime(TIME_AFTER_ANIM_END);
is(SMILUtil.getComputedStyleSimple(gCircle, "font-size"), "30px",
"Checking animated font-size=30px after updating context");
gCircleParent.removeAttribute("font-size");
gCircle.removeChild(gCircle.firstChild);
}
function testEmUnitChangeOnLength()
{
setupTest();
gCircleParent.setAttribute("font-size", "10px"); // At first: font-size: 10px
var anim = createAnimSetTo("cx", "2em");
gSvg.setCurrentTime(0);
is(gCircle.cx.animVal.value, 20,
"Checking animated length=2em after animating");
gCircleParent.setAttribute("font-size", "20px"); // Change: font-size: 20px
// Bug 508206: We should really detect this change and update immediately but
// currently we don't until we get sampled again
todo_is(gCircle.cx.animVal.value, 40,
"Checking animated length=2em after updating context but before sampling");
gSvg.setCurrentTime(0);
is(gCircle.cx.animVal.value, 40,
"Checking animated length=2em after updating context and after " +
"resampling");
gCircleParent.removeAttribute("font-size");
gCircle.removeChild(gCircle.firstChild);
}
function testPercentUnitChangeOnProp()
{
setupTest();
gCircleParent.setAttribute("font-size", "10px"); // At first: font-size: 10px
var anim = createAnimSetTo("font-size", "150%");
gSvg.setCurrentTime(0);
is(SMILUtil.getComputedStyleSimple(gCircle, "font-size"), "15px",
"Checking animated font-size=150% after animating");
gCircleParent.setAttribute("font-size", "20px"); // Change: font-size: 20px
gSvg.setCurrentTime(0);
is(SMILUtil.getComputedStyleSimple(gCircle, "font-size"), "30px",
"Checking animated font-size=150% after updating context");
gCircleParent.removeAttribute("font-size");
gCircle.removeChild(gCircle.firstChild);
}
function testPercentUnitChangeOnLength()
{
setupTest();
var oldHeight = gSvg.getAttribute("height");
gSvg.setAttribute("height", "100px"); // At first: viewport height: 100px
var anim = createAnimSetTo("cy", "100%");
gSvg.setCurrentTime(0); // Force synchronous sample so animation takes effect
// Due to bug 627594 (SVGLength.value for percent value lengths doesn't
// reflect updated viewport until reflow) the following will fail.
// Check that it does indeed fail so that when that bug is fixed this test
// can be updated.
todo_is(gCircle.cy.animVal.value, 100,
"Checking animated length=100% after animating but before reflow");
gSvg.forceRedraw();
// Even after doing a reflow though we'll still fail due to bug 508206
// (Relative units used in animation don't update immediately)
todo_is(gCircle.cy.animVal.value, 100,
"Checking animated length=100% after animating but before resampling");
gSvg.setCurrentTime(0);
// Now we should be up to date
is(gCircle.cy.animVal.value, 100,
"Checking animated length=100% after animating");
gSvg.setAttribute("height", "50px"); // Change: height: 50px
gSvg.forceRedraw(); // Bug 627594
gSvg.setCurrentTime(0); // Bug 508206
is(gCircle.cy.animVal.value, 50,
"Checking animated length=100% after updating context");
gSvg.setAttribute("height", oldHeight);
gCircle.removeChild(gCircle.firstChild);
}
function testRelativeFontSize()
{
setupTest();
gCircleParent.setAttribute("font-size", "10px"); // At first: font-size: 10px
var anim = createAnimSetTo("font-size", "larger");
gSvg.setCurrentTime(0);
var fsize = parseInt(SMILUtil.getComputedStyleSimple(gCircle, "font-size"));
// CSS 2 suggests a scaling factor of 1.2 so we should be looking at something
// around about 12 or so
ok(fsize > 10 && fsize < 20,
"Checking animated font-size > 10px after animating");
gCircleParent.setAttribute("font-size", "20px"); // Change: font-size: 20px
gSvg.setCurrentTime(0);
fsize = parseInt(SMILUtil.getComputedStyleSimple(gCircle, "font-size"));
ok(fsize > 20, "Checking animated font-size > 20px after updating context");
gCircleParent.removeAttribute("font-size");
gCircle.removeChild(gCircle.firstChild);
}
function testRelativeFontWeight()
{
setupTest();
gCircleParent.setAttribute("font-weight", "100"); // At first: font-weight 100
var anim = createAnimSetTo("font-weight", "bolder");
// CSS 2: 'bolder': Specifies the next weight that is assigned to a font
// that is darker than the inherited one. If there is no such weight, it
// simply results in the next darker numerical value (and the font remains
// unchanged), unless the inherited value was '900', in which case the
// resulting weight is also '900'.
gSvg.setCurrentTime(0);
var weight =
parseInt(SMILUtil.getComputedStyleSimple(gCircle, "font-weight"));
ok(weight > 100, "Checking animated font-weight > 100 after animating");
gCircleParent.setAttribute("font-weight", "800"); // Change: font-weight 800
gSvg.setCurrentTime(0);
weight = parseInt(SMILUtil.getComputedStyleSimple(gCircle, "font-weight"));
is(weight, 900,
"Checking animated font-weight = 900 after updating context");
gCircleParent.removeAttribute("font-weight");
gCircle.removeChild(gCircle.firstChild);
}
function testRelativeFont()
{
// Test a relative font-size as part of a 'font' spec since the code path
// is different in this case
// It turns out that, due to the way we store shorthand font properties, we
// don't need to worry about marking such values as context-sensitive since we
// seem to store them in their relative form. If, however, we change the way
// we store shorthand font properties in the future, this will serve as
// a useful regression test.
setupTest();
gCircleParent.setAttribute("font-size", "10px"); // At first: font-size: 10px
// We must be sure to set every part of the shorthand property to some
// non-context sensitive value because we want to test that even if only the
// font-size is relative we will update it appropriately.
var anim =
createAnimSetTo("font", "normal normal bold larger/normal sans-serif");
gSvg.setCurrentTime(0);
var fsize = parseInt(SMILUtil.getComputedStyleSimple(gCircle, "font-size"));
ok(fsize > 10 && fsize < 20,
"Checking size of shorthand 'font' > 10px after animating");
gCircleParent.setAttribute("font-size", "20px"); // Change: font-size: 20px
gSvg.setCurrentTime(0);
fsize = parseInt(SMILUtil.getComputedStyleSimple(gCircle, "font-size"));
ok(fsize > 20,
"Checking size of shorthand 'font' > 20px after updating context");
gCircleParent.removeAttribute("font-size");
gCircle.removeChild(gCircle.firstChild);
}
function testCalcFontSize()
{
setupTest();
gCircleParent.setAttribute("font-size", "10px"); // At first: font-size: 10px
var anim = createAnimSetTo("font-size", "-moz-calc(110% + 0.1em)");
gSvg.setCurrentTime(0);
var fsize = parseInt(SMILUtil.getComputedStyleSimple(gCircle, "font-size"));
// Font size should be 1.1 * 10px + 0.1 * 10px = 12
is(fsize, 12, "Checking animated calc font-size == 12px after animating");
gCircleParent.setAttribute("font-size", "20px"); // Change: font-size: 20px
gSvg.setCurrentTime(0);
fsize = parseInt(SMILUtil.getComputedStyleSimple(gCircle, "font-size"));
is(fsize, 24, "Checking animated calc font-size == 24px after updating " +
"context");
gCircleParent.removeAttribute("font-size");
gCircle.removeChild(gCircle.firstChild);
}
function testDashArray()
{
// stroke dasharrays don't currently convert units--but if someone ever fixes
// that, hopefully this test will fail and remind us not to cache percentage
// values in that case
setupTest();
var oldHeight = gSvg.getAttribute("height");
var oldWidth = gSvg.getAttribute("width");
gSvg.setAttribute("height", "100px"); // At first: viewport: 100x100px
gSvg.setAttribute("width", "100px");
var anim = createAnimFromTo("stroke-dasharray", "0 5", "0 50%");
gSvg.setCurrentTime(TIME_AFTER_ANIM_END);
// Now we should be up to date
is(SMILUtil.getComputedStyleSimple(gCircle, "stroke-dasharray"), "0, 50%",
"Checking animated stroke-dasharray after animating");
gSvg.setAttribute("height", "50px"); // Change viewport: 50x50px
gSvg.setAttribute("width", "50px");
gSvg.setCurrentTime(TIME_AFTER_ANIM_END);
is(SMILUtil.getComputedStyleSimple(gCircle, "stroke-dasharray"), "0, 50%",
"Checking animated stroke-dasharray after updating context");
gSvg.setAttribute("height", oldHeight);
gSvg.setAttribute("width", oldWidth);
gCircle.removeChild(gCircle.firstChild);
}
function testClip()
{
setupTest();
gCircleParent.setAttribute("font-size", "20px"); // At first: font-size: 20px
// The clip property only applies to elements that establish a new
// viewport so we need to create a nested svg and add animation to that
var nestedSVG = document.createElementNS(SVGNS, "svg");
nestedSVG.setAttribute("clip", "rect(0px 0px 0px 0px)");
gCircleParent.appendChild(nestedSVG);
var anim = createAnimSetTo("clip", "rect(1em 1em 1em 1em)");
// createAnimSetTo will make the animation a child of gCircle so we need to
// move it so it targets nestedSVG instead
nestedSVG.appendChild(anim);
gSvg.setCurrentTime(TIME_AFTER_ANIM_END);
is(SMILUtil.getComputedStyleSimple(nestedSVG, "clip"),
"rect(20px, 20px, 20px, 20px)",
"Checking animated clip rect after animating");
gCircleParent.setAttribute("font-size", "10px"); // Change: font-size: 10px
gSvg.setCurrentTime(TIME_AFTER_ANIM_END);
is(SMILUtil.getComputedStyleSimple(nestedSVG, "clip"),
"rect(10px, 10px, 10px, 10px)",
"Checking animated clip rect after updating context");
gCircleParent.removeAttribute("font-size");
gCircleParent.removeChild(nestedSVG);
}
window.addEventListener("load", main, false);

View File

@ -57,7 +57,6 @@ _TEST_FILES = \
a_href_helper_04.svg \
test_animLengthObjectIdentity.xhtml \
test_animLengthReadonly.xhtml \
test_animLengthRelativeUnits.xhtml \
test_animLengthUnits.xhtml \
test_bbox.xhtml \
test_bbox-with-invalid-viewBox.xhtml \

View File

@ -1,80 +0,0 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=508206
-->
<head>
<title>Test for liveness of relative units in animation</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=508206">Mozilla Bug 508206</a>
<p id="display"></p>
<!-- XXX The following should be display: none but that's broken by bug 413975
where we don't handle percentage lengths when the whole fragment is
display: none properly. -->
<div id="content" style="visibility: hidden">
<svg id="svg" xmlns="http://www.w3.org/2000/svg" width="100px" height="100px"
onload="this.pauseAnimations()">
<g font-size="10px">
<circle cx="0" cy="0" r="15" fill="blue" id="circle">
<animate attributeName="cx" from="0" to="10em" dur="10s" begin="0s"
fill="freeze" id="animate"/>
<animate attributeName="cy" from="0" to="100%" dur="10s" begin="0s"
fill="freeze"/>
</circle>
</g>
</svg>
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
<![CDATA[
/** Test liveness of relative units of animated lengths **/
/* Global Variables */
const svgns="http://www.w3.org/2000/svg";
var svg = document.getElementById("svg");
var circle = document.getElementById('circle');
SimpleTest.waitForExplicitFinish();
function main() {
ok(svg.animationsPaused(), "should be paused by <svg> load handler");
is(svg.getCurrentTime(), 0, "should be paused at 0 in <svg> load handler");
// Sample mid-way through the animation
svg.setCurrentTime(5);
// (1) Check values mid-way
is(circle.cx.animVal.value, 50,
"(1) Unexpected animVal for cx before changing base length");
is(circle.cy.animVal.value, 50,
"(1) Unexpected animVal for cy before changing base length");
// (2) Change the frame of reference and check values are updated immediately
// Change font-size
circle.parentNode.setAttribute('font-size', '5px');
todo_is(circle.cx.animVal.value, 25,
"(2) Unexpected animVal for cx after changing parent font-size");
// Change the viewport size
svg.setAttribute('height', '50px');
todo_is(circle.cy.animVal.value, 25,
"(2) Unexpected animVal for cy after changing containing viewport size");
SimpleTest.finish();
}
var animate = document.getElementById('animate');
if (animate && animate.targetElement) {
window.addEventListener("load", main, false);
} else {
ok(true); // Skip tests but don't report 'todo' either
SimpleTest.finish();
}
]]>
</script>
</pre>
</body>
</html>

View File

@ -429,7 +429,7 @@ static PRBool IsChromeURI(nsIURI* aURI)
/* Implementation file */
static PRIntn
static PRBool
TraverseProtos(nsHashKey *aKey, void *aData, void* aClosure)
{
nsCycleCollectionTraversalCallback *cb =
@ -439,7 +439,7 @@ TraverseProtos(nsHashKey *aKey, void *aData, void* aClosure)
return kHashEnumerateNext;
}
static PRIntn
static PRBool
UnlinkProtoJSObjects(nsHashKey *aKey, void *aData, void* aClosure)
{
nsXBLPrototypeBinding *proto = static_cast<nsXBLPrototypeBinding*>(aData);
@ -453,7 +453,7 @@ struct ProtoTracer
void *mClosure;
};
static PRIntn
static PRBool
TraceProtos(nsHashKey *aKey, void *aData, void* aClosure)
{
ProtoTracer* closure = static_cast<ProtoTracer*>(aClosure);

View File

@ -328,7 +328,7 @@ PRBool nsXBLPrototypeBinding::CompareBindingURI(nsIURI* aURI) const
return equal;
}
static PRIntn
static PRBool
TraverseInsertionPoint(nsHashKey* aKey, void* aData, void* aClosure)
{
nsCycleCollectionTraversalCallback &cb =
@ -1213,7 +1213,7 @@ nsXBLPrototypeBinding::ConstructInsertionTable(nsIContent* aContent)
PRInt32 i;
for (i = 0; i < count; i++) {
nsIContent* child = childrenElements[i];
nsIContent* parent = child->GetParent();
nsCOMPtr<nsIContent> parent = child->GetParent();
// Create an XBL insertion point entry.
nsXBLInsertionPointEntry* xblIns = nsXBLInsertionPointEntry::Create(parent);

View File

@ -4047,7 +4047,8 @@ nsXULDocument::OverlayForwardReference::Merge(nsIContent* aTargetNode,
if (attr == nsGkAtoms::removeelement &&
value.EqualsLiteral("true")) {
rv = RemoveElement(aTargetNode->GetParent(), aTargetNode);
nsCOMPtr<nsIContent> parent = aTargetNode->GetParent();
rv = RemoveElement(parent, aTargetNode);
if (NS_FAILED(rv)) return rv;
return NS_OK;

View File

@ -1324,7 +1324,7 @@ nsXULContentBuilder::RemoveGeneratedContent(nsIContent* aElement)
while (0 != (count = ungenerated.Length())) {
// Pull the next "ungenerated" element off the queue.
PRUint32 last = count - 1;
nsIContent* element = ungenerated[last];
nsCOMPtr<nsIContent> element = ungenerated[last];
ungenerated.RemoveElementAt(last);
PRUint32 i = element->GetChildCount();

View File

@ -8452,13 +8452,13 @@ nsDocShell::InternalLoad(nsIURI * aURI,
GetCurScrollPos(ScrollOrientation_X, &cx);
GetCurScrollPos(ScrollOrientation_Y, &cy);
// We scroll whenever we're not doing a history load. Note that
// sometimes we might scroll even if we don't fire a hashchange
// event! See bug 653741.
if (!aSHEntry) {
rv = ScrollToAnchor(curHash, newHash, aLoadType);
NS_ENSURE_SUCCESS(rv, rv);
}
// ScrollToAnchor doesn't necessarily cause us to scroll the window;
// the function decides whether a scroll is appropriate based on the
// arguments it receives. But even if we don't end up scrolling,
// ScrollToAnchor performs other important tasks, such as informing
// the presShell that we have a new hash. See bug 680257.
rv = ScrollToAnchor(curHash, newHash, aLoadType);
NS_ENSURE_SUCCESS(rv, rv);
mLoadType = aLoadType;
mURIResultedInDocument = PR_TRUE;

View File

@ -120,6 +120,8 @@ _TEST_FILES = \
file_bug669671.sjs \
test_bug675587.html \
test_bfcache_plus_hash.html \
test_bug680257.html \
file_bug680257.html \
$(NULL)
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)

View File

@ -0,0 +1,16 @@
<!DOCTYPE HTML>
<html>
<head>
<style type='text/css'>
a { color: black; }
a:target { color: red; }
</style>
</head>
<body onload='(opener || parent).popupLoaded()'>
<a id='a' href='#a'>link</a>
<a id='b' href='#b'>link2</a>
</body>
</html>

View File

@ -0,0 +1,59 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=680257
-->
<head>
<title>Test for Bug 680257</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=680257">Mozilla Bug 680257</a>
<script type="application/javascript;version=1.7">
SimpleTest.waitForExplicitFinish();
var popup = window.open('file_bug680257.html');
// The popup will call into popupLoaded() once it loads.
function popupLoaded() {
// runTests() needs to be called from outside popupLoaded's onload handler.
// Otherwise, the navigations we do in runTests won't create new SHEntries.
SimpleTest.executeSoon(runTests);
}
function runTests() {
checkPopupLinkStyle(false, 'Initial');
popup.location.hash = 'a';
checkPopupLinkStyle(true, 'After setting hash');
popup.history.back();
checkPopupLinkStyle(false, 'After going back');
popup.history.forward();
checkPopupLinkStyle(true, 'After going forward');
popup.close();
SimpleTest.finish();
}
function checkPopupLinkStyle(isTarget, desc) {
var link = popup.document.getElementById('a');
var style = popup.getComputedStyle(link);
var color = style.getPropertyValue('color');
// Color is red if isTarget, black otherwise.
if (isTarget) {
is(color, 'rgb(255, 0, 0)', desc);
}
else {
is(color, 'rgb(0, 0, 0)', desc);
}
}
</script>
</body>
</html>

View File

@ -8220,19 +8220,21 @@ NS_IMETHODIMP
nsGlobalWindow::GetMozIndexedDB(nsIIDBFactory** _retval)
{
if (!mIndexedDB) {
nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil =
do_GetService(THIRDPARTYUTIL_CONTRACTID);
NS_ENSURE_TRUE(thirdPartyUtil, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (!IsChromeWindow()) {
nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil =
do_GetService(THIRDPARTYUTIL_CONTRACTID);
NS_ENSURE_TRUE(thirdPartyUtil, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
PRBool isThirdParty;
nsresult rv = thirdPartyUtil->IsThirdPartyWindow(this, nsnull,
&isThirdParty);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
PRBool isThirdParty;
nsresult rv = thirdPartyUtil->IsThirdPartyWindow(this, nsnull,
&isThirdParty);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (isThirdParty) {
NS_WARNING("IndexedDB is not permitted in a third-party window.");
*_retval = nsnull;
return NS_OK;
if (isThirdParty) {
NS_WARNING("IndexedDB is not permitted in a third-party window.");
*_retval = nsnull;
return NS_OK;
}
}
mIndexedDB = indexedDB::IDBFactory::Create(this);

View File

@ -51,7 +51,7 @@
* http://www.w3.org/TR/DOM-Level-2-Style
*/
[builtinclass, scriptable, uuid(10f43750-b379-11e0-aff2-0800200c9a66)]
[builtinclass, scriptable, uuid(286466f1-4246-4574-afdb-2f8a03ad7cc8)]
interface nsIDOMCSS2Properties : nsISupports
{
attribute DOMString background;
@ -657,6 +657,9 @@ interface nsIDOMCSS2Properties : nsISupports
attribute DOMString MozBorderImage;
// raises(DOMException) on setting
attribute DOMString MozColumns;
// raises(DOMException) on setting
attribute DOMString MozColumnRule;
// raises(DOMException) on setting

View File

@ -45,7 +45,7 @@
* For more information on this interface, please see
* http://www.whatwg.org/specs/web-apps/current-work/#messageevent
*/
[scriptable, uuid(dc8ec5c6-ebf2-4f95-be99-cd13e3c0d0c6)]
[scriptable, uuid(9ac4fa26-4d19-4f4e-807e-b30cd0dbe56a)]
interface nsIDOMMessageEvent : nsIDOMEvent
{
/**

View File

@ -169,8 +169,30 @@ class GeckoSurfaceView
}
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
// Force exactly one frame to render
// because the surface change is only seen after we
// have swapped the back buffer.
// The buffer size only changes after the next swap buffer.
// We need to make sure the Gecko's view resize when Android's
// buffer resizes.
if (mDrawMode == DRAW_GLES_2) {
// When we get a surfaceChange event, we have 0 to n paint events
// waiting in the Gecko event queue. We will make the first
// succeed and the abort the others.
mDrawSingleFrame = true;
if (!mInDrawing) {
// Queue at least one paint event in case none are queued.
GeckoAppShell.scheduleRedraw();
}
GeckoAppShell.geckoEventSync();
mDrawSingleFrame = false;
mAbortDraw = false;
}
if (mShowingSplashScreen)
drawSplashScreen(holder, width, height);
mSurfaceLock.lock();
try {
@ -221,6 +243,12 @@ class GeckoSurfaceView
}
} finally {
mSurfaceLock.unlock();
if (mDrawMode == DRAW_GLES_2) {
// Force a frame to be drawn before the surfaceChange returns,
// otherwise we get artifacts.
GeckoAppShell.scheduleRedraw();
GeckoAppShell.geckoEventSync();
}
}
Object syncDrawObject = null;
@ -293,6 +321,10 @@ class GeckoSurfaceView
public static final int DRAW_ERROR = 0;
public static final int DRAW_GLES_2 = 1;
public static final int DRAW_2D = 2;
// Drawing is disable when the surface buffer
// has changed size but we haven't yet processed the
// resize event.
public static final int DRAW_DISABLED = 3;
public int beginDrawing() {
if (mInDrawing) {
@ -300,6 +332,12 @@ class GeckoSurfaceView
return DRAW_ERROR;
}
// Once we drawn our first frame after resize we can ignore
// the other draw events until we handle the resize events.
if (mAbortDraw) {
return DRAW_DISABLED;
}
/* Grab the lock, which we'll hold while we're drawing.
* It gets released in endDrawing(), and is also used in surfaceChanged
* to make sure that we don't change our surface details while
@ -330,6 +368,9 @@ class GeckoSurfaceView
return;
}
if (mDrawSingleFrame)
mAbortDraw = true;
try {
if (!mSurfaceValid) {
Log.e(LOG_FILE_NAME, "endDrawing with false mSurfaceValid");
@ -657,6 +698,10 @@ class GeckoSurfaceView
// Are we actively between beginDrawing/endDrawing?
boolean mInDrawing;
// Used to finish the current buffer before changing the surface size
boolean mDrawSingleFrame = false;
boolean mAbortDraw = false;
// Are we waiting for a buffer to draw in surfaceChanged?
boolean mSyncDraw;

View File

@ -285,7 +285,7 @@ NS_IMETHODIMP nsSystemPrefService::GetBoolPref(const char *aPrefName, PRBool *_r
}
/* void setBoolPref (in string aPrefName, in long aValue); */
NS_IMETHODIMP nsSystemPrefService::SetBoolPref(const char *aPrefName, PRInt32 aValue)
NS_IMETHODIMP nsSystemPrefService::SetBoolPref(const char *aPrefName, PRBool aValue)
{
return NS_ERROR_NOT_IMPLEMENTED;
}

View File

@ -41,10 +41,6 @@
#include "nsICategoryManager.h"
#include "nsISupportsPrimitives.h"
// The number 130 more or less comes out of thin air.
// See https://bugzilla.mozilla.org/show_bug.cgi?id=355178#c78 for a pseudo-rationale.
#define UNREASONABLE_WORD_LENGTH 130
#define DEFAULT_SPELL_CHECKER "@mozilla.org/spellchecker/engine;1"
NS_IMPL_CYCLE_COLLECTING_ADDREF(mozSpellChecker)
@ -149,12 +145,6 @@ mozSpellChecker::CheckWord(const nsAString &aWord, PRBool *aIsMisspelled, nsTArr
if(!mSpellCheckingEngine)
return NS_ERROR_NULL_POINTER;
// don't bother to check crazy words
if (aWord.Length() > UNREASONABLE_WORD_LENGTH) {
*aIsMisspelled = PR_TRUE;
return NS_OK;
}
*aIsMisspelled = PR_FALSE;
result = mSpellCheckingEngine->Check(PromiseFlatString(aWord).get(), &correct);
NS_ENSURE_SUCCESS(result, result);

View File

@ -488,7 +488,7 @@ bool Parse0514(ots::OpenTypeFile *file,
return OTS_FAILURE();
}
const uint32_t check_value =
ranges[j].unicode_value + ranges[i].additional_count;
ranges[j].unicode_value + ranges[j].additional_count;
if (ranges[j].unicode_value == 0 ||
ranges[j].unicode_value > kUnicodeUpperLimit ||
check_value > kUVSUpperLimit ||

View File

@ -48,7 +48,6 @@ EXTRA_DEPS += $(topsrcdir)/ipc/chromium/chromium-config.mk
DEFINES += \
-DEXCLUDE_SKIA_DEPENDENCIES \
-DCHROMIUM_MOZILLA_BUILD \
$(NULL)
LOCAL_INCLUDES += \

View File

@ -64,11 +64,9 @@ void AtExitManager::ProcessCallbacksNow() {
}
}
#ifdef CHROMIUM_MOZILLA_BUILD
// static
bool AtExitManager::AlreadyRegistered() {
return !!g_top_manager;
}
#endif
} // namespace base

View File

@ -51,9 +51,7 @@ class AtExitManager {
// is possible to register new callbacks after calling this function.
static void ProcessCallbacksNow();
#ifdef CHROMIUM_MOZILLA_BUILD
static bool AlreadyRegistered();
#endif
private:
struct CallbackAndParam {

View File

@ -196,7 +196,6 @@ inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) {
*ptr = value;
}
#if defined(CHROMIUM_MOZILLA_BUILD)
inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,
Atomic64 old_value,
Atomic64 new_value) {
@ -207,7 +206,6 @@ inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,
}
return x;
}
#endif
inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) {
*ptr = value;

View File

@ -7,7 +7,7 @@
#ifndef BASE_BASE_SWITCHES_H_
#define BASE_BASE_SWITCHES_H_
#if defined(CHROMIUM_MOZILLA_BUILD) && defined(COMPILER_MSVC)
#if defined(COMPILER_MSVC)
#include <string.h>
#endif

View File

@ -5,8 +5,6 @@
#ifndef BASE_BASICTYPES_H_
#define BASE_BASICTYPES_H_
#ifdef CHROMIUM_MOZILLA_BUILD
// Chromium includes a prtypes.h also, but it has been modified to include
// their build_config.h as well. We can therefore test for both to determine
// if someone screws up the include order.
@ -41,8 +39,6 @@
#define _WIN32
#endif
#endif // CHROMIUM_MOZILLA_BUILD
#include <limits.h> // So we can set the bounds of our types
#include <stddef.h> // For size_t
#include <string.h> // for memcpy
@ -63,7 +59,7 @@ typedef short int16;
#define _INT32
typedef int int32;
#endif
#if !(defined(CHROMIUM_MOZILLA_BUILD) && defined(PROTYPES_H))
#ifndef PROTYPES_H
typedef long long int64;
#endif
@ -81,7 +77,7 @@ typedef unsigned short uint16;
#define _UINT32
typedef unsigned int uint32;
#endif
#if !(defined(CHROMIUM_MOZILLA_BUILD) && defined(PROTYPES_H))
#ifndef PROTYPES_H
typedef unsigned long long uint64;
#endif
@ -104,7 +100,6 @@ const int32 kint32max = (( int32) 0x7FFFFFFF);
const int64 kint64min = (( int64) GG_LONGLONG(0x8000000000000000));
const int64 kint64max = (( int64) GG_LONGLONG(0x7FFFFFFFFFFFFFFF));
#if defined(CHROMIUM_MOZILLA_BUILD)
// Platform- and hardware-dependent printf specifiers
# if defined(OS_POSIX)
# define __STDC_FORMAT_MACROS 1
@ -120,7 +115,6 @@ const int64 kint64max = (( int64) GG_LONGLONG(0x7FFFFFFFFFFFFFFF));
# define PRIu64L L"I64u"
# define PRIx64L L"I64x"
# endif
#endif // defined(CHROMIUM_MOZILLA_BUILD)
// A macro to disallow the copy constructor and operator= functions
// This should be used in the private: declarations for a class

View File

@ -65,11 +65,9 @@ class CommandLine {
return current_process_commandline_;
}
#ifdef CHROMIUM_MOZILLA_BUILD
static bool IsInitialized() {
return !!current_process_commandline_;
}
#endif
// Returns true if this command line contains the given switch.
// (Switch names are case-insensitive.)

View File

@ -144,25 +144,5 @@ void StackTrace::PrintBacktrace() {
}
void StackTrace::OutputToStream(std::ostream* os) {
#ifdef CHROMIUM_MOZILLA_BUILD
return;
#else
scoped_ptr_malloc<char*> trace_symbols(
backtrace_symbols(&trace_[0], trace_.size()));
// If we can't retrieve the symbols, print an error and just dump the raw
// addresses.
if (trace_symbols.get() == NULL) {
(*os) << "Unable get symbols for backtrace (" << strerror(errno)
<< "). Dumping raw addresses in trace:\n";
for (size_t i = 0; i < trace_.size(); ++i) {
(*os) << "\t" << trace_[i] << "\n";
}
} else {
(*os) << "Backtrace:\n";
for (size_t i = 0; i < trace_.size(); ++i) {
(*os) << "\t" << trace_symbols.get()[i] << "\n";
}
}
#endif
}

View File

@ -21,13 +21,11 @@
namespace base {
#if defined(CHROMIUM_MOZILLA_BUILD)
#define DVLOG(x) LOG(ERROR)
#define CHECK_GT DCHECK_GT
#define CHECK_LT DCHECK_LT
typedef ::Lock Lock;
typedef ::AutoLock AutoLock;
#endif
// Static table of checksums for all possible 8 bit bytes.
const uint32 Histogram::kCrcTable[256] = {0x0, 0x77073096L, 0xee0e612cL,

View File

@ -45,11 +45,6 @@
#include <string>
#include <vector>
#if defined(CHROMIUM_MOZILLA_BUILD)
#define BASE_API
#else
#include "base/base_api.h"
#endif
#include "testing/gtest/include/gtest/gtest_prod.h"
#include "base/time.h"
#include "base/lock.h"
@ -264,7 +259,7 @@ class CustomHistogram;
class Histogram;
class LinearHistogram;
class BASE_API Histogram {
class Histogram {
public:
typedef int Sample; // Used for samples (and ranges of samples).
typedef int Count; // Used to count samples in a bucket.
@ -323,7 +318,7 @@ class BASE_API Histogram {
//----------------------------------------------------------------------------
// Statistic values, developed over the life of the histogram.
class BASE_API SampleSet {
class SampleSet {
public:
explicit SampleSet();
~SampleSet();
@ -582,7 +577,7 @@ class BASE_API Histogram {
// LinearHistogram is a more traditional histogram, with evenly spaced
// buckets.
class BASE_API LinearHistogram : public Histogram {
class LinearHistogram : public Histogram {
public:
virtual ~LinearHistogram();
@ -638,7 +633,7 @@ class BASE_API LinearHistogram : public Histogram {
//------------------------------------------------------------------------------
// BooleanHistogram is a histogram for booleans.
class BASE_API BooleanHistogram : public LinearHistogram {
class BooleanHistogram : public LinearHistogram {
public:
static Histogram* FactoryGet(const std::string& name, Flags flags);
@ -655,7 +650,7 @@ class BASE_API BooleanHistogram : public LinearHistogram {
//------------------------------------------------------------------------------
// CustomHistogram is a histogram for a set of custom integers.
class BASE_API CustomHistogram : public Histogram {
class CustomHistogram : public Histogram {
public:
static Histogram* FactoryGet(const std::string& name,
@ -681,7 +676,7 @@ class BASE_API CustomHistogram : public Histogram {
// general place for histograms to register, and supports a global API for
// accessing (i.e., dumping, or graphing) the data in all the histograms.
class BASE_API StatisticsRecorder {
class StatisticsRecorder {
public:
typedef std::vector<Histogram*> Histograms;

View File

@ -72,7 +72,6 @@ class IDMap {
return data_.empty();
}
#if defined(CHROMIUM_MOZILLA_BUILD)
void Clear() {
data_.clear();
}
@ -84,7 +83,6 @@ class IDMap {
return true;
return false;
}
#endif
T* Lookup(int32 id) const {
const_iterator i = data_.find(id);

View File

@ -3,9 +3,6 @@
// found in the LICENSE file.
#include "base/logging.h"
#ifdef CHROMIUM_MOZILLA_BUILD
#include "prmem.h"
#include "prprf.h"
#include "base/string_util.h"
@ -106,570 +103,3 @@ operator<<(mozilla::Logger& log, void* p)
log.printf("%p", p);
return log;
}
#else
#if defined(OS_WIN)
#include <windows.h>
typedef HANDLE FileHandle;
typedef HANDLE MutexHandle;
#elif defined(OS_MACOSX)
#include <CoreFoundation/CoreFoundation.h>
#include <mach/mach.h>
#include <mach/mach_time.h>
#include <mach-o/dyld.h>
#elif defined(OS_LINUX)
#include <sys/syscall.h>
#include <time.h>
#endif
#if defined(OS_POSIX)
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#define MAX_PATH PATH_MAX
typedef FILE* FileHandle;
typedef pthread_mutex_t* MutexHandle;
#endif
#include <ctime>
#include <iomanip>
#include <cstring>
#include <algorithm>
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/debug_util.h"
#include "base/lock_impl.h"
#include "base/string_piece.h"
#include "base/string_util.h"
#include "base/sys_string_conversions.h"
namespace logging {
bool g_enable_dcheck = false;
const char* const log_severity_names[LOG_NUM_SEVERITIES] = {
"INFO", "WARNING", "ERROR", "ERROR_REPORT", "FATAL" };
int min_log_level = 0;
LogLockingState lock_log_file = LOCK_LOG_FILE;
// The default set here for logging_destination will only be used if
// InitLogging is not called. On Windows, use a file next to the exe;
// on POSIX platforms, where it may not even be possible to locate the
// executable on disk, use stderr.
#if defined(OS_WIN)
LoggingDestination logging_destination = LOG_ONLY_TO_FILE;
#elif defined(OS_POSIX)
LoggingDestination logging_destination = LOG_ONLY_TO_SYSTEM_DEBUG_LOG;
#endif
const int kMaxFilteredLogLevel = LOG_WARNING;
std::string* log_filter_prefix;
// For LOG_ERROR and above, always print to stderr.
const int kAlwaysPrintErrorLevel = LOG_ERROR;
// Which log file to use? This is initialized by InitLogging or
// will be lazily initialized to the default value when it is
// first needed.
#if defined(OS_WIN)
typedef wchar_t PathChar;
typedef std::wstring PathString;
#else
typedef char PathChar;
typedef std::string PathString;
#endif
PathString* log_file_name = NULL;
// this file is lazily opened and the handle may be NULL
FileHandle log_file = NULL;
// what should be prepended to each message?
bool log_process_id = false;
bool log_thread_id = false;
bool log_timestamp = true;
bool log_tickcount = false;
// An assert handler override specified by the client to be called instead of
// the debug message dialog and process termination.
LogAssertHandlerFunction log_assert_handler = NULL;
// An report handler override specified by the client to be called instead of
// the debug message dialog.
LogReportHandlerFunction log_report_handler = NULL;
// The lock is used if log file locking is false. It helps us avoid problems
// with multiple threads writing to the log file at the same time. Use
// LockImpl directly instead of using Lock, because Lock makes logging calls.
static LockImpl* log_lock = NULL;
// When we don't use a lock, we are using a global mutex. We need to do this
// because LockFileEx is not thread safe.
#if defined(OS_WIN)
MutexHandle log_mutex = NULL;
#elif defined(OS_POSIX)
pthread_mutex_t log_mutex = PTHREAD_MUTEX_INITIALIZER;
#endif
// Helper functions to wrap platform differences.
int32 CurrentProcessId() {
#if defined(OS_WIN)
return GetCurrentProcessId();
#elif defined(OS_POSIX)
return getpid();
#endif
}
int32 CurrentThreadId() {
#if defined(OS_WIN)
return GetCurrentThreadId();
#elif defined(OS_MACOSX)
return mach_thread_self();
#elif defined(OS_LINUX)
return syscall(__NR_gettid);
#endif
}
uint64 TickCount() {
#if defined(OS_WIN)
return GetTickCount();
#elif defined(OS_MACOSX)
return mach_absolute_time();
#elif defined(OS_LINUX)
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
uint64 absolute_micro =
static_cast<int64>(ts.tv_sec) * 1000000 +
static_cast<int64>(ts.tv_nsec) / 1000;
return absolute_micro;
#endif
}
void CloseFile(FileHandle log) {
#if defined(OS_WIN)
CloseHandle(log);
#else
fclose(log);
#endif
}
void DeleteFilePath(const PathString& log_name) {
#if defined(OS_WIN)
DeleteFile(log_name.c_str());
#else
unlink(log_name.c_str());
#endif
}
// Called by logging functions to ensure that debug_file is initialized
// and can be used for writing. Returns false if the file could not be
// initialized. debug_file will be NULL in this case.
bool InitializeLogFileHandle() {
if (log_file)
return true;
if (!log_file_name) {
// Nobody has called InitLogging to specify a debug log file, so here we
// initialize the log file name to a default.
#if defined(OS_WIN)
// On Windows we use the same path as the exe.
wchar_t module_name[MAX_PATH];
GetModuleFileName(NULL, module_name, MAX_PATH);
log_file_name = new std::wstring(module_name);
std::wstring::size_type last_backslash =
log_file_name->rfind('\\', log_file_name->size());
if (last_backslash != std::wstring::npos)
log_file_name->erase(last_backslash + 1);
*log_file_name += L"debug.log";
#elif defined(OS_POSIX)
// On other platforms we just use the current directory.
log_file_name = new std::string("debug.log");
#endif
}
if (logging_destination == LOG_ONLY_TO_FILE ||
logging_destination == LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG) {
#if defined(OS_WIN)
log_file = CreateFile(log_file_name->c_str(), GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (log_file == INVALID_HANDLE_VALUE || log_file == NULL) {
// try the current directory
log_file = CreateFile(L".\\debug.log", GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (log_file == INVALID_HANDLE_VALUE || log_file == NULL) {
log_file = NULL;
return false;
}
}
SetFilePointer(log_file, 0, 0, FILE_END);
#elif defined(OS_POSIX)
log_file = fopen(log_file_name->c_str(), "a");
if (log_file == NULL)
return false;
#endif
}
return true;
}
void InitLogMutex() {
#if defined(OS_WIN)
if (!log_mutex) {
// \ is not a legal character in mutex names so we replace \ with /
std::wstring safe_name(*log_file_name);
std::replace(safe_name.begin(), safe_name.end(), '\\', '/');
std::wstring t(L"Global\\");
t.append(safe_name);
log_mutex = ::CreateMutex(NULL, FALSE, t.c_str());
}
#elif defined(OS_POSIX)
// statically initialized
#endif
}
void InitLogging(const PathChar* new_log_file, LoggingDestination logging_dest,
LogLockingState lock_log, OldFileDeletionState delete_old) {
g_enable_dcheck =
CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableDCHECK);
if (log_file) {
// calling InitLogging twice or after some log call has already opened the
// default log file will re-initialize to the new options
CloseFile(log_file);
log_file = NULL;
}
lock_log_file = lock_log;
logging_destination = logging_dest;
// ignore file options if logging is disabled or only to system
if (logging_destination == LOG_NONE ||
logging_destination == LOG_ONLY_TO_SYSTEM_DEBUG_LOG)
return;
if (!log_file_name)
log_file_name = new PathString();
*log_file_name = new_log_file;
if (delete_old == DELETE_OLD_LOG_FILE)
DeleteFilePath(*log_file_name);
if (lock_log_file == LOCK_LOG_FILE) {
InitLogMutex();
} else if (!log_lock) {
log_lock = new LockImpl();
}
InitializeLogFileHandle();
}
void SetMinLogLevel(int level) {
min_log_level = level;
}
int GetMinLogLevel() {
return min_log_level;
}
void SetLogFilterPrefix(const char* filter) {
if (log_filter_prefix) {
delete log_filter_prefix;
log_filter_prefix = NULL;
}
if (filter)
log_filter_prefix = new std::string(filter);
}
void SetLogItems(bool enable_process_id, bool enable_thread_id,
bool enable_timestamp, bool enable_tickcount) {
log_process_id = enable_process_id;
log_thread_id = enable_thread_id;
log_timestamp = enable_timestamp;
log_tickcount = enable_tickcount;
}
void SetLogAssertHandler(LogAssertHandlerFunction handler) {
log_assert_handler = handler;
}
void SetLogReportHandler(LogReportHandlerFunction handler) {
log_report_handler = handler;
}
// Displays a message box to the user with the error message in it. For
// Windows programs, it's possible that the message loop is messed up on
// a fatal error, and creating a MessageBox will cause that message loop
// to be run. Instead, we try to spawn another process that displays its
// command line. We look for "Debug Message.exe" in the same directory as
// the application. If it exists, we use it, otherwise, we use a regular
// message box.
void DisplayDebugMessage(const std::string& str) {
if (str.empty())
return;
#if defined(OS_WIN)
// look for the debug dialog program next to our application
wchar_t prog_name[MAX_PATH];
GetModuleFileNameW(NULL, prog_name, MAX_PATH);
wchar_t* backslash = wcsrchr(prog_name, '\\');
if (backslash)
backslash[1] = 0;
wcscat_s(prog_name, MAX_PATH, L"debug_message.exe");
std::wstring cmdline = base::SysUTF8ToWide(str);
if (cmdline.empty())
return;
STARTUPINFO startup_info;
memset(&startup_info, 0, sizeof(startup_info));
startup_info.cb = sizeof(startup_info);
PROCESS_INFORMATION process_info;
if (CreateProcessW(prog_name, &cmdline[0], NULL, NULL, false, 0, NULL,
NULL, &startup_info, &process_info)) {
WaitForSingleObject(process_info.hProcess, INFINITE);
CloseHandle(process_info.hThread);
CloseHandle(process_info.hProcess);
} else {
// debug process broken, let's just do a message box
MessageBoxW(NULL, &cmdline[0], L"Fatal error",
MB_OK | MB_ICONHAND | MB_TOPMOST);
}
#else
fprintf(stderr, "%s\n", str.c_str());
#endif
}
#if defined(OS_WIN)
LogMessage::SaveLastError::SaveLastError() : last_error_(::GetLastError()) {
}
LogMessage::SaveLastError::~SaveLastError() {
::SetLastError(last_error_);
}
#endif // defined(OS_WIN)
LogMessage::LogMessage(const char* file, int line, LogSeverity severity,
int ctr)
: severity_(severity) {
Init(file, line);
}
LogMessage::LogMessage(const char* file, int line, const CheckOpString& result)
: severity_(LOG_FATAL) {
Init(file, line);
stream_ << "Check failed: " << (*result.str_);
}
LogMessage::LogMessage(const char* file, int line, LogSeverity severity,
const CheckOpString& result)
: severity_(severity) {
Init(file, line);
stream_ << "Check failed: " << (*result.str_);
}
LogMessage::LogMessage(const char* file, int line)
: severity_(LOG_INFO) {
Init(file, line);
}
LogMessage::LogMessage(const char* file, int line, LogSeverity severity)
: severity_(severity) {
Init(file, line);
}
// writes the common header info to the stream
void LogMessage::Init(const char* file, int line) {
// log only the filename
const char* last_slash = strrchr(file, '\\');
if (last_slash)
file = last_slash + 1;
// TODO(darin): It might be nice if the columns were fixed width.
stream_ << '[';
if (log_process_id)
stream_ << CurrentProcessId() << ':';
if (log_thread_id)
stream_ << CurrentThreadId() << ':';
if (log_timestamp) {
time_t t = time(NULL);
#if _MSC_VER >= 1400
struct tm local_time = {0};
localtime_s(&local_time, &t);
struct tm* tm_time = &local_time;
#else
struct tm* tm_time = localtime(&t);
#endif
stream_ << std::setfill('0')
<< std::setw(2) << 1 + tm_time->tm_mon
<< std::setw(2) << tm_time->tm_mday
<< '/'
<< std::setw(2) << tm_time->tm_hour
<< std::setw(2) << tm_time->tm_min
<< std::setw(2) << tm_time->tm_sec
<< ':';
}
if (log_tickcount)
stream_ << TickCount() << ':';
stream_ << log_severity_names[severity_] << ":" << file <<
"(" << line << ")] ";
message_start_ = stream_.tellp();
}
LogMessage::~LogMessage() {
// TODO(brettw) modify the macros so that nothing is executed when the log
// level is too high.
if (severity_ < min_log_level)
return;
std::string str_newline(stream_.str());
#if defined(OS_WIN)
str_newline.append("\r\n");
#else
str_newline.append("\n");
#endif
if (log_filter_prefix && severity_ <= kMaxFilteredLogLevel &&
str_newline.compare(message_start_, log_filter_prefix->size(),
log_filter_prefix->data()) != 0) {
return;
}
if (logging_destination == LOG_ONLY_TO_SYSTEM_DEBUG_LOG ||
logging_destination == LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG) {
#if defined(OS_WIN)
OutputDebugStringA(str_newline.c_str());
if (severity_ >= kAlwaysPrintErrorLevel)
#endif
// TODO(erikkay): this interferes with the layout tests since it grabs
// stderr and stdout and diffs them against known data. Our info and warn
// logs add noise to that. Ideally, the layout tests would set the log
// level to ignore anything below error. When that happens, we should
// take this fprintf out of the #else so that Windows users can benefit
// from the output when running tests from the command-line. In the
// meantime, we leave this in for Mac and Linux, but until this is fixed
// they won't be able to pass any layout tests that have info or warn logs.
// See http://b/1343647
fprintf(stderr, "%s", str_newline.c_str());
} else if (severity_ >= kAlwaysPrintErrorLevel) {
// When we're only outputting to a log file, above a certain log level, we
// should still output to stderr so that we can better detect and diagnose
// problems with unit tests, especially on the buildbots.
fprintf(stderr, "%s", str_newline.c_str());
}
// write to log file
if (logging_destination != LOG_NONE &&
logging_destination != LOG_ONLY_TO_SYSTEM_DEBUG_LOG &&
InitializeLogFileHandle()) {
// We can have multiple threads and/or processes, so try to prevent them
// from clobbering each other's writes.
if (lock_log_file == LOCK_LOG_FILE) {
// Ensure that the mutex is initialized in case the client app did not
// call InitLogging. This is not thread safe. See below.
InitLogMutex();
#if defined(OS_WIN)
DWORD r = ::WaitForSingleObject(log_mutex, INFINITE);
DCHECK(r != WAIT_ABANDONED);
#elif defined(OS_POSIX)
pthread_mutex_lock(&log_mutex);
#endif
} else {
// use the lock
if (!log_lock) {
// The client app did not call InitLogging, and so the lock has not
// been created. We do this on demand, but if two threads try to do
// this at the same time, there will be a race condition to create
// the lock. This is why InitLogging should be called from the main
// thread at the beginning of execution.
log_lock = new LockImpl();
}
log_lock->Lock();
}
#if defined(OS_WIN)
SetFilePointer(log_file, 0, 0, SEEK_END);
DWORD num_written;
WriteFile(log_file,
static_cast<const void*>(str_newline.c_str()),
static_cast<DWORD>(str_newline.length()),
&num_written,
NULL);
#else
fprintf(log_file, "%s", str_newline.c_str());
#endif
if (lock_log_file == LOCK_LOG_FILE) {
#if defined(OS_WIN)
ReleaseMutex(log_mutex);
#elif defined(OS_POSIX)
pthread_mutex_unlock(&log_mutex);
#endif
} else {
log_lock->Unlock();
}
}
if (severity_ == LOG_FATAL) {
// display a message or break into the debugger on a fatal error
if (DebugUtil::BeingDebugged()) {
DebugUtil::BreakDebugger();
} else {
#ifndef NDEBUG
// Dump a stack trace on a fatal.
StackTrace trace;
stream_ << "\n"; // Newline to separate from log message.
trace.OutputToStream(&stream_);
#endif
if (log_assert_handler) {
// make a copy of the string for the handler out of paranoia
log_assert_handler(std::string(stream_.str()));
} else {
// Don't use the string with the newline, get a fresh version to send to
// the debug message process. We also don't display assertions to the
// user in release mode. The enduser can't do anything with this
// information, and displaying message boxes when the application is
// hosed can cause additional problems.
#ifndef NDEBUG
DisplayDebugMessage(stream_.str());
#endif
// Crash the process to generate a dump.
DebugUtil::BreakDebugger();
}
}
} else if (severity_ == LOG_ERROR_REPORT) {
// We are here only if the user runs with --enable-dcheck in release mode.
if (log_report_handler) {
log_report_handler(std::string(stream_.str()));
} else {
DisplayDebugMessage(stream_.str());
}
}
}
void CloseLogFile() {
if (!log_file)
return;
CloseFile(log_file);
log_file = NULL;
}
} // namespace logging
std::ostream& operator<<(std::ostream& out, const wchar_t* wstr) {
return out << base::SysWideToUTF8(std::wstring(wstr));
}
#endif // CHROMIUM_MOZILLA_BUILD

View File

@ -9,9 +9,6 @@
#include <cstring>
#include "base/basictypes.h"
#ifdef CHROMIUM_MOZILLA_BUILD
#include "prlog.h"
// Replace the Chromium logging code with NSPR-based logging code and
@ -123,640 +120,4 @@ const mozilla::EmptyLog& operator <<(const mozilla::EmptyLog& log, const T&)
#endif
#define assert DLOG_ASSERT
#else
#include <sstream>
//
// Optional message capabilities
// -----------------------------
// Assertion failed messages and fatal errors are displayed in a dialog box
// before the application exits. However, running this UI creates a message
// loop, which causes application messages to be processed and potentially
// dispatched to existing application windows. Since the application is in a
// bad state when this assertion dialog is displayed, these messages may not
// get processed and hang the dialog, or the application might go crazy.
//
// Therefore, it can be beneficial to display the error dialog in a separate
// process from the main application. When the logging system needs to display
// a fatal error dialog box, it will look for a program called
// "DebugMessage.exe" in the same directory as the application executable. It
// will run this application with the message as the command line, and will
// not include the name of the application as is traditional for easier
// parsing.
//
// The code for DebugMessage.exe is only one line. In WinMain, do:
// MessageBox(NULL, GetCommandLineW(), L"Fatal Error", 0);
//
// If DebugMessage.exe is not found, the logging code will use a normal
// MessageBox, potentially causing the problems discussed above.
// Instructions
// ------------
//
// Make a bunch of macros for logging. The way to log things is to stream
// things to LOG(<a particular severity level>). E.g.,
//
// LOG(INFO) << "Found " << num_cookies << " cookies";
//
// You can also do conditional logging:
//
// LOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
//
// The above will cause log messages to be output on the 1st, 11th, 21st, ...
// times it is executed. Note that the special COUNTER value is used to
// identify which repetition is happening.
//
// The CHECK(condition) macro is active in both debug and release builds and
// effectively performs a LOG(FATAL) which terminates the process and
// generates a crashdump unless a debugger is attached.
//
// There are also "debug mode" logging macros like the ones above:
//
// DLOG(INFO) << "Found cookies";
//
// DLOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
//
// All "debug mode" logging is compiled away to nothing for non-debug mode
// compiles. LOG_IF and development flags also work well together
// because the code can be compiled away sometimes.
//
// We also have
//
// LOG_ASSERT(assertion);
// DLOG_ASSERT(assertion);
//
// which is syntactic sugar for {,D}LOG_IF(FATAL, assert fails) << assertion;
//
// We also override the standard 'assert' to use 'DLOG_ASSERT'.
//
// The supported severity levels for macros that allow you to specify one
// are (in increasing order of severity) INFO, WARNING, ERROR, ERROR_REPORT,
// and FATAL.
//
// Very important: logging a message at the FATAL severity level causes
// the program to terminate (after the message is logged).
//
// Note the special severity of ERROR_REPORT only available/relevant in normal
// mode, which displays error dialog without terminating the program. There is
// no error dialog for severity ERROR or below in normal mode.
//
// There is also the special severity of DFATAL, which logs FATAL in
// debug mode, ERROR_REPORT in normal mode.
namespace logging {
// Where to record logging output? A flat file and/or system debug log via
// OutputDebugString. Defaults on Windows to LOG_ONLY_TO_FILE, and on
// POSIX to LOG_ONLY_TO_SYSTEM_DEBUG_LOG (aka stderr).
enum LoggingDestination { LOG_NONE,
LOG_ONLY_TO_FILE,
LOG_ONLY_TO_SYSTEM_DEBUG_LOG,
LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG };
// Indicates that the log file should be locked when being written to.
// Often, there is no locking, which is fine for a single threaded program.
// If logging is being done from multiple threads or there can be more than
// one process doing the logging, the file should be locked during writes to
// make each log outut atomic. Other writers will block.
//
// All processes writing to the log file must have their locking set for it to
// work properly. Defaults to DONT_LOCK_LOG_FILE.
enum LogLockingState { LOCK_LOG_FILE, DONT_LOCK_LOG_FILE };
// On startup, should we delete or append to an existing log file (if any)?
// Defaults to APPEND_TO_OLD_LOG_FILE.
enum OldFileDeletionState { DELETE_OLD_LOG_FILE, APPEND_TO_OLD_LOG_FILE };
// Sets the log file name and other global logging state. Calling this function
// is recommended, and is normally done at the beginning of application init.
// If you don't call it, all the flags will be initialized to their default
// values, and there is a race condition that may leak a critical section
// object if two threads try to do the first log at the same time.
// See the definition of the enums above for descriptions and default values.
//
// The default log file is initialized to "debug.log" in the application
// directory. You probably don't want this, especially since the program
// directory may not be writable on an enduser's system.
#if defined(OS_WIN)
void InitLogging(const wchar_t* log_file, LoggingDestination logging_dest,
LogLockingState lock_log, OldFileDeletionState delete_old);
#elif defined(OS_POSIX)
// TODO(avi): do we want to do a unification of character types here?
void InitLogging(const char* log_file, LoggingDestination logging_dest,
LogLockingState lock_log, OldFileDeletionState delete_old);
#endif
// Sets the log level. Anything at or above this level will be written to the
// log file/displayed to the user (if applicable). Anything below this level
// will be silently ignored. The log level defaults to 0 (everything is logged)
// if this function is not called.
void SetMinLogLevel(int level);
// Gets the current log level.
int GetMinLogLevel();
// Sets the log filter prefix. Any log message below LOG_ERROR severity that
// doesn't start with this prefix with be silently ignored. The filter defaults
// to NULL (everything is logged) if this function is not called. Messages
// with severity of LOG_ERROR or higher will not be filtered.
void SetLogFilterPrefix(const char* filter);
// Sets the common items you want to be prepended to each log message.
// process and thread IDs default to off, the timestamp defaults to on.
// If this function is not called, logging defaults to writing the timestamp
// only.
void SetLogItems(bool enable_process_id, bool enable_thread_id,
bool enable_timestamp, bool enable_tickcount);
// Sets the Log Assert Handler that will be used to notify of check failures.
// The default handler shows a dialog box and then terminate the process,
// however clients can use this function to override with their own handling
// (e.g. a silent one for Unit Tests)
typedef void (*LogAssertHandlerFunction)(const std::string& str);
void SetLogAssertHandler(LogAssertHandlerFunction handler);
// Sets the Log Report Handler that will be used to notify of check failures
// in non-debug mode. The default handler shows a dialog box and continues
// the execution, however clients can use this function to override with their
// own handling.
typedef void (*LogReportHandlerFunction)(const std::string& str);
void SetLogReportHandler(LogReportHandlerFunction handler);
typedef int LogSeverity;
const LogSeverity LOG_INFO = 0;
const LogSeverity LOG_WARNING = 1;
const LogSeverity LOG_ERROR = 2;
const LogSeverity LOG_ERROR_REPORT = 3;
const LogSeverity LOG_FATAL = 4;
const LogSeverity LOG_NUM_SEVERITIES = 5;
// LOG_DFATAL_LEVEL is LOG_FATAL in debug mode, ERROR_REPORT in normal mode
#ifdef NDEBUG
const LogSeverity LOG_DFATAL_LEVEL = LOG_ERROR_REPORT;
#else
const LogSeverity LOG_DFATAL_LEVEL = LOG_FATAL;
#endif
// A few definitions of macros that don't generate much code. These are used
// by LOG() and LOG_IF, etc. Since these are used all over our code, it's
// better to have compact code for these operations.
#define COMPACT_GOOGLE_LOG_INFO \
logging::LogMessage(__FILE__, __LINE__)
#define COMPACT_GOOGLE_LOG_WARNING \
logging::LogMessage(__FILE__, __LINE__, logging::LOG_WARNING)
#define COMPACT_GOOGLE_LOG_ERROR \
logging::LogMessage(__FILE__, __LINE__, logging::LOG_ERROR)
#define COMPACT_GOOGLE_LOG_ERROR_REPORT \
logging::LogMessage(__FILE__, __LINE__, logging::LOG_ERROR_REPORT)
#define COMPACT_GOOGLE_LOG_FATAL \
logging::LogMessage(__FILE__, __LINE__, logging::LOG_FATAL)
#define COMPACT_GOOGLE_LOG_DFATAL \
logging::LogMessage(__FILE__, __LINE__, logging::LOG_DFATAL_LEVEL)
// wingdi.h defines ERROR to be 0. When we call LOG(ERROR), it gets
// substituted with 0, and it expands to COMPACT_GOOGLE_LOG_0. To allow us
// to keep using this syntax, we define this macro to do the same thing
// as COMPACT_GOOGLE_LOG_ERROR, and also define ERROR the same way that
// the Windows SDK does for consistency.
#define ERROR 0
#define COMPACT_GOOGLE_LOG_0 \
logging::LogMessage(__FILE__, __LINE__, logging::LOG_ERROR)
// We use the preprocessor's merging operator, "##", so that, e.g.,
// LOG(INFO) becomes the token COMPACT_GOOGLE_LOG_INFO. There's some funny
// subtle difference between ostream member streaming functions (e.g.,
// ostream::operator<<(int) and ostream non-member streaming functions
// (e.g., ::operator<<(ostream&, string&): it turns out that it's
// impossible to stream something like a string directly to an unnamed
// ostream. We employ a neat hack by calling the stream() member
// function of LogMessage which seems to avoid the problem.
#define LOG(severity) COMPACT_GOOGLE_LOG_ ## severity.stream()
#define SYSLOG(severity) LOG(severity)
#define LOG_IF(severity, condition) \
!(condition) ? (void) 0 : logging::LogMessageVoidify() & LOG(severity)
#define SYSLOG_IF(severity, condition) LOG_IF(severity, condition)
#define LOG_ASSERT(condition) \
LOG_IF(FATAL, !(condition)) << "Assert failed: " #condition ". "
#define SYSLOG_ASSERT(condition) \
SYSLOG_IF(FATAL, !(condition)) << "Assert failed: " #condition ". "
// CHECK dies with a fatal error if condition is not true. It is *not*
// controlled by NDEBUG, so the check will be executed regardless of
// compilation mode.
#define CHECK(condition) \
LOG_IF(FATAL, !(condition)) << "Check failed: " #condition ". "
// A container for a string pointer which can be evaluated to a bool -
// true iff the pointer is NULL.
struct CheckOpString {
CheckOpString(std::string* str) : str_(str) { }
// No destructor: if str_ is non-NULL, we're about to LOG(FATAL),
// so there's no point in cleaning up str_.
operator bool() const { return str_ != NULL; }
std::string* str_;
};
// Build the error message string. This is separate from the "Impl"
// function template because it is not performance critical and so can
// be out of line, while the "Impl" code should be inline.
template<class t1, class t2>
std::string* MakeCheckOpString(const t1& v1, const t2& v2, const char* names) {
std::ostringstream ss;
ss << names << " (" << v1 << " vs. " << v2 << ")";
std::string* msg = new std::string(ss.str());
return msg;
}
extern std::string* MakeCheckOpStringIntInt(int v1, int v2, const char* names);
template<int, int>
std::string* MakeCheckOpString(const int& v1,
const int& v2,
const char* names) {
return MakeCheckOpStringIntInt(v1, v2, names);
}
// Plus some debug-logging macros that get compiled to nothing for production
//
// DEBUG_MODE is for uses like
// if (DEBUG_MODE) foo.CheckThatFoo();
// instead of
// #ifndef NDEBUG
// foo.CheckThatFoo();
// #endif
#ifdef OFFICIAL_BUILD
// We want to have optimized code for an official build so we remove DLOGS and
// DCHECK from the executable.
#define DLOG(severity) \
true ? (void) 0 : logging::LogMessageVoidify() & LOG(severity)
#define DLOG_IF(severity, condition) \
true ? (void) 0 : logging::LogMessageVoidify() & LOG(severity)
#define DLOG_ASSERT(condition) \
true ? (void) 0 : LOG_ASSERT(condition)
enum { DEBUG_MODE = 0 };
// This macro can be followed by a sequence of stream parameters in
// non-debug mode. The DCHECK and friends macros use this so that
// the expanded expression DCHECK(foo) << "asdf" is still syntactically
// valid, even though the expression will get optimized away.
// In order to avoid variable unused warnings for code that only uses a
// variable in a CHECK, we make sure to use the macro arguments.
#define NDEBUG_EAT_STREAM_PARAMETERS \
logging::LogMessage(__FILE__, __LINE__).stream()
#define DCHECK(condition) \
while (false && (condition)) NDEBUG_EAT_STREAM_PARAMETERS
#define DCHECK_EQ(val1, val2) \
while (false && (val1) == (val2)) NDEBUG_EAT_STREAM_PARAMETERS
#define DCHECK_NE(val1, val2) \
while (false && (val1) == (val2)) NDEBUG_EAT_STREAM_PARAMETERS
#define DCHECK_LE(val1, val2) \
while (false && (val1) == (val2)) NDEBUG_EAT_STREAM_PARAMETERS
#define DCHECK_LT(val1, val2) \
while (false && (val1) == (val2)) NDEBUG_EAT_STREAM_PARAMETERS
#define DCHECK_GE(val1, val2) \
while (false && (val1) == (val2)) NDEBUG_EAT_STREAM_PARAMETERS
#define DCHECK_GT(val1, val2) \
while (false && (val1) == (val2)) NDEBUG_EAT_STREAM_PARAMETERS
#define DCHECK_STREQ(str1, str2) \
while (false && (str1) == (str2)) NDEBUG_EAT_STREAM_PARAMETERS
#define DCHECK_STRCASEEQ(str1, str2) \
while (false && (str1) == (str2)) NDEBUG_EAT_STREAM_PARAMETERS
#define DCHECK_STRNE(str1, str2) \
while (false && (str1) == (str2)) NDEBUG_EAT_STREAM_PARAMETERS
#define DCHECK_STRCASENE(str1, str2) \
while (false && (str1) == (str2)) NDEBUG_EAT_STREAM_PARAMETERS
#else
#ifndef NDEBUG
// On a regular debug build, we want to have DCHECKS and DLOGS enabled.
#define DLOG(severity) LOG(severity)
#define DLOG_IF(severity, condition) LOG_IF(severity, condition)
#define DLOG_ASSERT(condition) LOG_ASSERT(condition)
// debug-only checking. not executed in NDEBUG mode.
enum { DEBUG_MODE = 1 };
#define DCHECK(condition) \
LOG_IF(FATAL, !(condition)) << "Check failed: " #condition ". "
// Helper macro for binary operators.
// Don't use this macro directly in your code, use DCHECK_EQ et al below.
#define DCHECK_OP(name, op, val1, val2) \
if (logging::CheckOpString _result = \
logging::Check##name##Impl((val1), (val2), #val1 " " #op " " #val2)) \
logging::LogMessage(__FILE__, __LINE__, _result).stream()
// Helper functions for string comparisons.
// To avoid bloat, the definitions are in logging.cc.
#define DECLARE_DCHECK_STROP_IMPL(func, expected) \
std::string* Check##func##expected##Impl(const char* s1, \
const char* s2, \
const char* names);
DECLARE_DCHECK_STROP_IMPL(strcmp, true)
DECLARE_DCHECK_STROP_IMPL(strcmp, false)
DECLARE_DCHECK_STROP_IMPL(_stricmp, true)
DECLARE_DCHECK_STROP_IMPL(_stricmp, false)
#undef DECLARE_DCHECK_STROP_IMPL
// Helper macro for string comparisons.
// Don't use this macro directly in your code, use CHECK_STREQ et al below.
#define DCHECK_STROP(func, op, expected, s1, s2) \
while (CheckOpString _result = \
logging::Check##func##expected##Impl((s1), (s2), \
#s1 " " #op " " #s2)) \
LOG(FATAL) << *_result.str_
// String (char*) equality/inequality checks.
// CASE versions are case-insensitive.
//
// Note that "s1" and "s2" may be temporary strings which are destroyed
// by the compiler at the end of the current "full expression"
// (e.g. DCHECK_STREQ(Foo().c_str(), Bar().c_str())).
#define DCHECK_STREQ(s1, s2) DCHECK_STROP(strcmp, ==, true, s1, s2)
#define DCHECK_STRNE(s1, s2) DCHECK_STROP(strcmp, !=, false, s1, s2)
#define DCHECK_STRCASEEQ(s1, s2) DCHECK_STROP(_stricmp, ==, true, s1, s2)
#define DCHECK_STRCASENE(s1, s2) DCHECK_STROP(_stricmp, !=, false, s1, s2)
#define DCHECK_INDEX(I,A) DCHECK(I < (sizeof(A)/sizeof(A[0])))
#define DCHECK_BOUND(B,A) DCHECK(B <= (sizeof(A)/sizeof(A[0])))
#else // NDEBUG
// On a regular release build we want to be able to enable DCHECKS through the
// command line.
#define DLOG(severity) \
true ? (void) 0 : logging::LogMessageVoidify() & LOG(severity)
#define DLOG_IF(severity, condition) \
true ? (void) 0 : logging::LogMessageVoidify() & LOG(severity)
#define DLOG_ASSERT(condition) \
true ? (void) 0 : LOG_ASSERT(condition)
enum { DEBUG_MODE = 0 };
// This macro can be followed by a sequence of stream parameters in
// non-debug mode. The DCHECK and friends macros use this so that
// the expanded expression DCHECK(foo) << "asdf" is still syntactically
// valid, even though the expression will get optimized away.
#define NDEBUG_EAT_STREAM_PARAMETERS \
logging::LogMessage(__FILE__, __LINE__).stream()
// Set to true in InitLogging when we want to enable the dchecks in release.
extern bool g_enable_dcheck;
#define DCHECK(condition) \
!logging::g_enable_dcheck ? void (0) : \
LOG_IF(ERROR_REPORT, !(condition)) << "Check failed: " #condition ". "
// Helper macro for binary operators.
// Don't use this macro directly in your code, use DCHECK_EQ et al below.
#define DCHECK_OP(name, op, val1, val2) \
if (logging::g_enable_dcheck) \
if (logging::CheckOpString _result = \
logging::Check##name##Impl((val1), (val2), #val1 " " #op " " #val2)) \
logging::LogMessage(__FILE__, __LINE__, logging::LOG_ERROR_REPORT, \
_result).stream()
#define DCHECK_STREQ(str1, str2) \
while (false) NDEBUG_EAT_STREAM_PARAMETERS
#define DCHECK_STRCASEEQ(str1, str2) \
while (false) NDEBUG_EAT_STREAM_PARAMETERS
#define DCHECK_STRNE(str1, str2) \
while (false) NDEBUG_EAT_STREAM_PARAMETERS
#define DCHECK_STRCASENE(str1, str2) \
while (false) NDEBUG_EAT_STREAM_PARAMETERS
#endif // NDEBUG
// Helper functions for DCHECK_OP macro.
// The (int, int) specialization works around the issue that the compiler
// will not instantiate the template version of the function on values of
// unnamed enum type - see comment below.
#define DEFINE_DCHECK_OP_IMPL(name, op) \
template <class t1, class t2> \
inline std::string* Check##name##Impl(const t1& v1, const t2& v2, \
const char* names) { \
if (v1 op v2) return NULL; \
else return MakeCheckOpString(v1, v2, names); \
} \
inline std::string* Check##name##Impl(int v1, int v2, const char* names) { \
if (v1 op v2) return NULL; \
else return MakeCheckOpString(v1, v2, names); \
}
DEFINE_DCHECK_OP_IMPL(EQ, ==)
DEFINE_DCHECK_OP_IMPL(NE, !=)
DEFINE_DCHECK_OP_IMPL(LE, <=)
DEFINE_DCHECK_OP_IMPL(LT, < )
DEFINE_DCHECK_OP_IMPL(GE, >=)
DEFINE_DCHECK_OP_IMPL(GT, > )
#undef DEFINE_DCHECK_OP_IMPL
// Equality/Inequality checks - compare two values, and log a LOG_FATAL message
// including the two values when the result is not as expected. The values
// must have operator<<(ostream, ...) defined.
//
// You may append to the error message like so:
// DCHECK_NE(1, 2) << ": The world must be ending!";
//
// We are very careful to ensure that each argument is evaluated exactly
// once, and that anything which is legal to pass as a function argument is
// legal here. In particular, the arguments may be temporary expressions
// which will end up being destroyed at the end of the apparent statement,
// for example:
// DCHECK_EQ(string("abc")[1], 'b');
//
// WARNING: These may not compile correctly if one of the arguments is a pointer
// and the other is NULL. To work around this, simply static_cast NULL to the
// type of the desired pointer.
#define DCHECK_EQ(val1, val2) DCHECK_OP(EQ, ==, val1, val2)
#define DCHECK_NE(val1, val2) DCHECK_OP(NE, !=, val1, val2)
#define DCHECK_LE(val1, val2) DCHECK_OP(LE, <=, val1, val2)
#define DCHECK_LT(val1, val2) DCHECK_OP(LT, < , val1, val2)
#define DCHECK_GE(val1, val2) DCHECK_OP(GE, >=, val1, val2)
#define DCHECK_GT(val1, val2) DCHECK_OP(GT, > , val1, val2)
#endif // OFFICIAL_BUILD
#define NOTREACHED() DCHECK(false)
// Redefine the standard assert to use our nice log files
#undef assert
#define assert(x) DLOG_ASSERT(x)
// This class more or less represents a particular log message. You
// create an instance of LogMessage and then stream stuff to it.
// When you finish streaming to it, ~LogMessage is called and the
// full message gets streamed to the appropriate destination.
//
// You shouldn't actually use LogMessage's constructor to log things,
// though. You should use the LOG() macro (and variants thereof)
// above.
class LogMessage {
public:
LogMessage(const char* file, int line, LogSeverity severity, int ctr);
// Two special constructors that generate reduced amounts of code at
// LOG call sites for common cases.
//
// Used for LOG(INFO): Implied are:
// severity = LOG_INFO, ctr = 0
//
// Using this constructor instead of the more complex constructor above
// saves a couple of bytes per call site.
LogMessage(const char* file, int line);
// Used for LOG(severity) where severity != INFO. Implied
// are: ctr = 0
//
// Using this constructor instead of the more complex constructor above
// saves a couple of bytes per call site.
LogMessage(const char* file, int line, LogSeverity severity);
// A special constructor used for check failures.
// Implied severity = LOG_FATAL
LogMessage(const char* file, int line, const CheckOpString& result);
// A special constructor used for check failures, with the option to
// specify severity.
LogMessage(const char* file, int line, LogSeverity severity,
const CheckOpString& result);
~LogMessage();
std::ostream& stream() { return stream_; }
private:
void Init(const char* file, int line);
LogSeverity severity_;
std::ostringstream stream_;
size_t message_start_; // Offset of the start of the message (past prefix
// info).
#if defined(OS_WIN)
// Stores the current value of GetLastError in the constructor and restores
// it in the destructor by calling SetLastError.
// This is useful since the LogMessage class uses a lot of Win32 calls
// that will lose the value of GLE and the code that called the log function
// will have lost the thread error value when the log call returns.
class SaveLastError {
public:
SaveLastError();
~SaveLastError();
unsigned long get_error() const { return last_error_; }
protected:
unsigned long last_error_;
};
SaveLastError last_error_;
#endif
DISALLOW_COPY_AND_ASSIGN(LogMessage);
};
// A non-macro interface to the log facility; (useful
// when the logging level is not a compile-time constant).
inline void LogAtLevel(int const log_level, std::string const &msg) {
LogMessage(__FILE__, __LINE__, log_level).stream() << msg;
}
// This class is used to explicitly ignore values in the conditional
// logging macros. This avoids compiler warnings like "value computed
// is not used" and "statement has no effect".
class LogMessageVoidify {
public:
LogMessageVoidify() { }
// This has to be an operator with a precedence lower than << but
// higher than ?:
void operator&(std::ostream&) { }
};
// Closes the log file explicitly if open.
// NOTE: Since the log file is opened as necessary by the action of logging
// statements, there's no guarantee that it will stay closed
// after this call.
void CloseLogFile();
} // namespace logging
// These functions are provided as a convenience for logging, which is where we
// use streams (it is against Google style to use streams in other places). It
// is designed to allow you to emit non-ASCII Unicode strings to the log file,
// which is normally ASCII. It is relatively slow, so try not to use it for
// common cases. Non-ASCII characters will be converted to UTF-8 by these
// operators.
std::ostream& operator<<(std::ostream& out, const wchar_t* wstr);
inline std::ostream& operator<<(std::ostream& out, const std::wstring& wstr) {
return out << wstr.c_str();
}
// The NOTIMPLEMENTED() macro annotates codepaths which have
// not been implemented yet.
//
// The implementation of this macro is controlled by NOTIMPLEMENTED_POLICY:
// 0 -- Do nothing (stripped by compiler)
// 1 -- Warn at compile time
// 2 -- Fail at compile time
// 3 -- Fail at runtime (DCHECK)
// 4 -- [default] LOG(ERROR) at runtime
// 5 -- LOG(ERROR) at runtime, only once per call-site
#ifndef NOTIMPLEMENTED_POLICY
// Select default policy: LOG(ERROR)
#define NOTIMPLEMENTED_POLICY 4
#endif
#if defined(COMPILER_GCC)
// On Linux, with GCC, we can use __PRETTY_FUNCTION__ to get the demangled name
// of the current function in the NOTIMPLEMENTED message.
#define NOTIMPLEMENTED_MSG "Not implemented reached in " << __PRETTY_FUNCTION__
#else
#define NOTIMPLEMENTED_MSG "NOT IMPLEMENTED"
#endif
#if NOTIMPLEMENTED_POLICY == 0
#define NOTIMPLEMENTED() ;
#elif NOTIMPLEMENTED_POLICY == 1
// TODO, figure out how to generate a warning
#define NOTIMPLEMENTED() COMPILE_ASSERT(false, NOT_IMPLEMENTED)
#elif NOTIMPLEMENTED_POLICY == 2
#define NOTIMPLEMENTED() COMPILE_ASSERT(false, NOT_IMPLEMENTED)
#elif NOTIMPLEMENTED_POLICY == 3
#define NOTIMPLEMENTED() NOTREACHED()
#elif NOTIMPLEMENTED_POLICY == 4
#define NOTIMPLEMENTED() LOG(ERROR) << NOTIMPLEMENTED_MSG
#elif NOTIMPLEMENTED_POLICY == 5
#define NOTIMPLEMENTED() do {\
static int count = 0;\
LOG_IF(ERROR, 0 == count++) << NOTIMPLEMENTED_MSG;\
} while(0)
#endif
#endif // CHROMIUM_MOZILLA_BUILD
#endif // BASE_LOGGING_H_

View File

@ -31,9 +31,7 @@
#include "base/message_pump_android.h"
#endif
#ifdef CHROMIUM_MOZILLA_BUILD
#include "MessagePump.h"
#endif
using base::Time;
using base::TimeDelta;
@ -98,8 +96,6 @@ MessageLoop::MessageLoop(Type type)
next_sequence_num_(0) {
DCHECK(!current()) << "should only have one message loop per thread";
lazy_tls_ptr.Pointer()->Set(this);
#ifdef CHROMIUM_MOZILLA_BUILD
if (type_ == TYPE_MOZILLA_UI) {
pump_ = new mozilla::ipc::MessagePump();
return;
@ -108,7 +104,7 @@ MessageLoop::MessageLoop(Type type)
pump_ = new mozilla::ipc::MessagePumpForChildProcess();
return;
}
#endif
#if defined(OS_WIN)
// TODO(rvargas): Get rid of the OS guards.
if (type_ == TYPE_DEFAULT) {
@ -209,15 +205,6 @@ void MessageLoop::RunHandler() {
void MessageLoop::RunInternal() {
DCHECK(this == current());
#if !defined(CHROMIUM_MOZILLA_BUILD)
StartHistogrammer();
#if defined(OS_WIN)
if (state_->dispatcher) {
pump_win()->RunWithDispatcher(this, state_->dispatcher);
return;
}
#endif
#endif
pump_->Run(this);
}
@ -291,16 +278,7 @@ void MessageLoop::PostTask_Helper(
scoped_refptr<base::MessagePump> pump;
{
AutoLock locked(incoming_queue_lock_);
#ifdef CHROMIUM_MOZILLA_BUILD
incoming_queue_.push(pending_task);
#else
bool was_empty = incoming_queue_.empty();
incoming_queue_.push(pending_task);
if (!was_empty)
return; // Someone else should have started the sub-pump.
#endif
pump = pump_;
}
// Since the incoming_queue_ may contain a task that destroys this message
@ -317,11 +295,7 @@ void MessageLoop::SetNestableTasksAllowed(bool allowed) {
if (!nestable_tasks_allowed_)
return;
// Start the native pump if we are not already pumping.
#ifndef CHROMIUM_MOZILLA_BUILD
pump_->ScheduleWork();
#else
pump_->ScheduleWorkForNestedLoop();
#endif
}
}
@ -341,7 +315,6 @@ void MessageLoop::RunTask(Task* task) {
// Execute the task and assume the worst: It is probably not reentrant.
nestable_tasks_allowed_ = false;
HistogramEvent(kTaskRunEvent);
task->Run();
delete task;
@ -533,76 +506,6 @@ bool MessageLoop::PendingTask::operator<(const PendingTask& other) const {
return (sequence_num - other.sequence_num) > 0;
}
//------------------------------------------------------------------------------
// Method and data for histogramming events and actions taken by each instance
// on each thread.
#if !defined(CHROMIUM_MOZILLA_BUILD)
// static
bool MessageLoop::enable_histogrammer_ = false;
#endif
// static
void MessageLoop::EnableHistogrammer(bool enable) {
#if !defined(CHROMIUM_MOZILLA_BUILD)
enable_histogrammer_ = enable;
#endif
}
void MessageLoop::StartHistogrammer() {
#if !defined(CHROMIUM_MOZILLA_BUILD)
if (enable_histogrammer_ && !message_histogram_.get()
&& base::StatisticsRecorder::IsActive()) {
DCHECK(!thread_name_.empty());
message_histogram_.reset(static_cast<base::LinearHistogram*>(
base::LinearHistogram::FactoryGet(("MsgLoop:" + thread_name_).c_str(),
kLeastNonZeroMessageId,
kMaxMessageId,
kNumberOfDistinctMessagesDisplayed,
base::Histogram::kNoFlags)));
message_histogram_->SetFlags(message_histogram_->kHexRangePrintingFlag);
message_histogram_->SetRangeDescriptions(event_descriptions_);
}
#endif
}
void MessageLoop::HistogramEvent(int event) {
#if !defined(CHROMIUM_MOZILLA_BUILD)
if (message_histogram_.get())
message_histogram_->Add(event);
#endif
}
// Provide a macro that takes an expression (such as a constant, or macro
// constant) and creates a pair to initalize an array of pairs. In this case,
// our pair consists of the expressions value, and the "stringized" version
// of the expression (i.e., the exrpression put in quotes). For example, if
// we have:
// #define FOO 2
// #define BAR 5
// then the following:
// VALUE_TO_NUMBER_AND_NAME(FOO + BAR)
// will expand to:
// {7, "FOO + BAR"}
// We use the resulting array as an argument to our histogram, which reads the
// number as a bucket identifier, and proceeds to use the corresponding name
// in the pair (i.e., the quoted string) when printing out a histogram.
#define VALUE_TO_NUMBER_AND_NAME(name) {name, #name},
#if !defined(CHROMIUM_MOZILLA_BUILD)
// static
const base::LinearHistogram::DescriptionPair MessageLoop::event_descriptions_[] = {
// Provide some pretty print capability in our histogram for our internal
// messages.
// A few events we handle (kindred to messages), and used to profile actions.
VALUE_TO_NUMBER_AND_NAME(kTaskRunEvent)
VALUE_TO_NUMBER_AND_NAME(kTimerEvent)
{-1, NULL} // The list must be null terminated, per API to histogram.
};
#endif
//------------------------------------------------------------------------------
// MessageLoopForUI
@ -662,7 +565,6 @@ bool MessageLoopForIO::WatchFileDescriptor(int fd,
delegate);
}
#if defined(CHROMIUM_MOZILLA_BUILD)
bool
MessageLoopForIO::CatchSignal(int sig,
SignalEvent* sigevent,
@ -670,6 +572,5 @@ MessageLoopForIO::CatchSignal(int sig,
{
return pump_libevent()->CatchSignal(sig, sigevent, delegate);
}
#endif // defined(CHROMIUM_MOZILLA_BUILD)
#endif

View File

@ -10,12 +10,8 @@
#include <string>
#include <vector>
#if defined(CHROMIUM_MOZILLA_BUILD)
#include <map>
#include "base/lock.h"
#else
#include "base/histogram.h"
#endif
#include "base/message_pump.h"
#include "base/observer_list.h"
#include "base/ref_counted.h"
@ -31,7 +27,6 @@
#include "base/message_pump_libevent.h"
#endif
#ifdef CHROMIUM_MOZILLA_BUILD
namespace mozilla {
namespace ipc {
@ -39,7 +34,6 @@ class DoWorkRunnable;
} /* namespace ipc */
} /* namespace mozilla */
#endif
// A MessageLoop is used to process events for a particular thread. There is
// at most one MessageLoop instance per thread.
@ -73,13 +67,9 @@ class DoWorkRunnable;
//
class MessageLoop : public base::MessagePump::Delegate {
#ifdef CHROMIUM_MOZILLA_BUILD
friend class mozilla::ipc::DoWorkRunnable;
#endif
public:
static void EnableHistogrammer(bool enable_histogrammer);
// A DestructionObserver is notified when the current MessageLoop is being
// destroyed. These obsevers are notified prior to MessageLoop::current()
// being changed to return NULL. This gives interested parties the chance to
@ -212,11 +202,9 @@ public:
enum Type {
TYPE_DEFAULT,
TYPE_UI,
TYPE_IO
#ifdef CHROMIUM_MOZILLA_BUILD
, TYPE_MOZILLA_CHILD
, TYPE_MOZILLA_UI
#endif
TYPE_IO,
TYPE_MOZILLA_CHILD,
TYPE_MOZILLA_UI
};
// Normally, it is not necessary to instantiate a MessageLoop. Instead, it
@ -381,20 +369,6 @@ public:
virtual bool DoDelayedWork(base::Time* next_delayed_work_time);
virtual bool DoIdleWork();
// Start recording histogram info about events and action IF it was enabled
// and IF the statistics recorder can accept a registration of our histogram.
void StartHistogrammer();
// Add occurence of event to our histogram, so that we can see what is being
// done in a specific MessageLoop instance (i.e., specific thread).
// If message_histogram_ is NULL, this is a no-op.
void HistogramEvent(int event);
#if !defined(CHROMIUM_MOZILLA_BUILD)
static const base::LinearHistogram::DescriptionPair event_descriptions_[];
static bool enable_histogrammer_;
#endif
Type type_;
// A list of tasks that need to be processed by this instance. Note that
@ -420,10 +394,7 @@ public:
bool exception_restoration_;
std::string thread_name_;
#if !defined(CHROMIUM_MOZILLA_BUILD)
// A profiling histogram showing the counts of various messages and events.
scoped_ptr<base::LinearHistogram> message_histogram_;
#endif
// A null terminated list which creates an incoming_queue of tasks that are
// aquired under a mutex for processing on this instance's thread. These tasks
// have not yet been sorted out into items for our work_queue_ vs items that
@ -463,14 +434,10 @@ class MessageLoopForUI : public MessageLoop {
MessageLoop* loop = MessageLoop::current();
if (!loop)
return NULL;
#ifdef CHROMIUM_MOZILLA_BUILD
Type type = loop->type();
DCHECK(type == MessageLoop::TYPE_UI ||
type == MessageLoop::TYPE_MOZILLA_UI ||
type == MessageLoop::TYPE_MOZILLA_CHILD);
#else
DCHECK_EQ(MessageLoop::TYPE_UI, loop->type());
#endif
return static_cast<MessageLoopForUI*>(loop);
}
@ -551,13 +518,11 @@ class MessageLoopForIO : public MessageLoop {
FileDescriptorWatcher *controller,
Watcher *delegate);
#if defined(CHROMIUM_MOZILLA_BUILD)
typedef base::MessagePumpLibevent::SignalEvent SignalEvent;
typedef base::MessagePumpLibevent::SignalWatcher SignalWatcher;
bool CatchSignal(int sig,
SignalEvent* sigevent,
SignalWatcher* delegate);
#endif // defined(CHROMIUM_MOZILLA_BUILD)
#endif // defined(OS_POSIX)
};

View File

@ -111,7 +111,6 @@ class MessagePump : public RefCountedThreadSafe<MessagePump> {
// until it returns a value of false.
virtual void ScheduleWork() = 0;
#if defined(CHROMIUM_MOZILLA_BUILD)
// This method may only called from the thread that called Run.
//
// Ensure that DoWork will be called if a nested loop is entered.
@ -119,7 +118,6 @@ class MessagePump : public RefCountedThreadSafe<MessagePump> {
// "reasonably soon", this method can be a no-op to avoid expensive
// atomic tests and/or syscalls required for ScheduleWork().
virtual void ScheduleWorkForNestedLoop() { ScheduleWork(); };
#endif // defined(CHROMIUM_MOZILLA_BUILD)
// Schedule a DoDelayedWork callback to happen at the specified time,
// cancelling any pending DoDelayedWork callback. This method may only be

View File

@ -22,11 +22,7 @@ class MessagePumpDefault : public MessagePump {
virtual void ScheduleWork();
virtual void ScheduleDelayedWork(const Time& delayed_work_time);
#ifdef CHROMIUM_MOZILLA_BUILD
protected:
#else
private:
#endif
// This flag is set to false when Run should return.
bool keep_running_;
@ -36,9 +32,7 @@ class MessagePumpDefault : public MessagePump {
// The time at which we should call DoDelayedWork.
Time delayed_work_time_;
#ifdef CHROMIUM_MOZILLA_BUILD
private:
#endif
DISALLOW_COPY_AND_ASSIGN(MessagePumpDefault);
};

View File

@ -212,7 +212,6 @@ void MessagePumpLibevent::OnLibeventNotification(int fd, short flags,
}
#if defined(CHROMIUM_MOZILLA_BUILD)
MessagePumpLibevent::SignalEvent::SignalEvent() :
event_(NULL)
{
@ -293,7 +292,6 @@ MessagePumpLibevent::OnLibeventSignalNotification(int sig, short flags,
DCHECK(context);
reinterpret_cast<SignalWatcher*>(context)->OnSignal(sig);
}
#endif // defined(CHROMIUM_MOZILLA_BUILD)
// Reentrant!

View File

@ -85,7 +85,6 @@ class MessagePumpLibevent : public MessagePump {
Watcher *delegate);
#if defined(CHROMIUM_MOZILLA_BUILD)
// This is analagous to FileDescriptorWatcher above, which really is
// just a wrapper around libevent's |struct event|. This class acts
// as a sort of "scoped event watcher" in that it guarantees that
@ -129,7 +128,6 @@ class MessagePumpLibevent : public MessagePump {
bool CatchSignal(int sig,
SignalEvent* sigevent,
SignalWatcher* delegate);
#endif // defined(CHROMIUM_MOZILLA_BUILD)
// MessagePump methods:
@ -160,11 +158,9 @@ class MessagePumpLibevent : public MessagePump {
static void OnLibeventNotification(int fd, short flags,
void* context);
#if defined(CHROMIUM_MOZILLA_BUILD)
// Called by libevent upon receiving a signal
static void OnLibeventSignalNotification(int sig, short flags,
void* context);
#endif
// Unix pipe used to implement ScheduleWork()
// ... callback; called by libevent inside Run() when pipe is ready to read

View File

@ -15,11 +15,7 @@
const int Pickle::kPayloadUnit = 64;
// We mark a read only pickle with a special capacity_.
#ifdef CHROMIUM_MOZILLA_BUILD
static const uint32 kCapacityReadOnly = (uint32) -1;
#else
static const size_t kCapacityReadOnly = (size_t) -1;
#endif
// Payload is uint32 aligned.
@ -37,11 +33,7 @@ Pickle::Pickle(int header_size)
header_size_(AlignInt(header_size, sizeof(uint32))),
capacity_(0),
variable_buffer_offset_(0) {
#ifdef CHROMIUM_MOZILLA_BUILD
DCHECK(static_cast<uint32>(header_size) >= sizeof(Header));
#else
DCHECK(static_cast<size_t>(header_size) >= sizeof(Header));
#endif
DCHECK(header_size <= kPayloadUnit);
Resize(kPayloadUnit);
header_->payload_size = 0;
@ -61,11 +53,7 @@ Pickle::Pickle(const Pickle& other)
header_size_(other.header_size_),
capacity_(0),
variable_buffer_offset_(other.variable_buffer_offset_) {
#ifdef CHROMIUM_MOZILLA_BUILD
uint32 payload_size = header_size_ + other.header_->payload_size;
#else
size_t payload_size = header_size_ + other.header_->payload_size;
#endif
bool resized = Resize(payload_size);
CHECK(resized); // Realloc failed.
memcpy(header_, other.header_, payload_size);
@ -399,21 +387,12 @@ bool Pickle::ReadData(void** iter, const char** data, int* length) const {
return ReadBytes(iter, data, *length);
}
#ifdef CHROMIUM_MOZILLA_BUILD
char* Pickle::BeginWrite(uint32 length) {
#else
char* Pickle::BeginWrite(size_t length) {
#endif
// write at a uint32-aligned offset from the beginning of the header
uint32 offset = AlignInt(header_->payload_size, sizeof(uint32));
#ifdef CHROMIUM_MOZILLA_BUILD
uint32 new_size = offset + AlignInt(length, sizeof(uint32));
uint32 needed_size = header_size_ + new_size;
#else
size_t new_size = offset + length;
size_t needed_size = header_size_ + new_size;
#endif
if (needed_size > capacity_ && !Resize(std::max(capacity_ * 2, needed_size)))
return NULL;
@ -509,11 +488,7 @@ void Pickle::TrimWriteData(int new_length) {
*cur_length = new_length;
}
#ifdef CHROMIUM_MOZILLA_BUILD
bool Pickle::Resize(uint32 new_capacity) {
#else
bool Pickle::Resize(size_t new_capacity) {
#endif
new_capacity = AlignInt(new_capacity, kPayloadUnit);
void* p = realloc(header_, new_capacity);
@ -526,19 +501,11 @@ bool Pickle::Resize(size_t new_capacity) {
}
// static
#ifdef CHROMIUM_MOZILLA_BUILD
const char* Pickle::FindNext(uint32 header_size,
#else
const char* Pickle::FindNext(size_t header_size,
#endif
const char* start,
const char* end) {
DCHECK(header_size == AlignInt(header_size, sizeof(uint32)));
#ifdef CHROMIUM_MOZILLA_BUILD
DCHECK(header_size <= static_cast<uint32>(kPayloadUnit));
#else
DCHECK(header_size <= static_cast<size_t>(kPayloadUnit));
#endif
const Header* hdr = reinterpret_cast<const Header*>(start);
const char* payload_base = start + header_size;

View File

@ -170,11 +170,9 @@ class Pickle {
// not been changed.
void TrimWriteData(int length);
#if defined(CHROMIUM_MOZILLA_BUILD)
void EndRead(void* iter) const {
DCHECK(iter == end_of_payload());
}
#endif
// Payload follows after allocation of Header (header size is customizable).
struct Header {
@ -207,11 +205,7 @@ class Pickle {
}
protected:
#ifdef CHROMIUM_MOZILLA_BUILD
uint32 payload_size() const { return header_->payload_size; }
#else
size_t payload_size() const { return header_->payload_size; }
#endif
char* payload() {
return reinterpret_cast<char*>(header_) + header_size_;
@ -229,11 +223,7 @@ class Pickle {
return payload() + payload_size();
}
#ifdef CHROMIUM_MOZILLA_BUILD
uint32 capacity() const {
#else
size_t capacity() const {
#endif
return capacity_;
}
@ -241,11 +231,7 @@ class Pickle {
// location that the data should be written at is returned, or NULL if there
// was an error. Call EndWrite with the returned offset and the given length
// to pad out for the next write.
#ifdef CHROMIUM_MOZILLA_BUILD
char* BeginWrite(uint32 length);
#else
char* BeginWrite(size_t length);
#endif
// Completes the write operation by padding the data with NULL bytes until it
// is padded. Should be paired with BeginWrite, but it does not necessarily
@ -256,18 +242,10 @@ class Pickle {
// the header: new_capacity = sizeof(Header) + desired_payload_capacity.
// A realloc() failure will cause a Resize failure... and caller should check
// the return result for true (i.e., successful resizing).
#ifdef CHROMIUM_MOZILLA_BUILD
bool Resize(uint32 new_capacity);
#else
bool Resize(size_t new_capacity);
#endif
// Aligns 'i' by rounding it up to the next multiple of 'alignment'
#ifdef CHROMIUM_MOZILLA_BUILD
static uint32 AlignInt(uint32 i, int alignment) {
#else
static size_t AlignInt(size_t i, int alignment) {
#endif
return i + (alignment - (i % alignment)) % alignment;
}
@ -280,11 +258,7 @@ class Pickle {
// Find the end of the pickled data that starts at range_start. Returns NULL
// if the entire Pickle is not found in the given data range.
#ifdef CHROMIUM_MOZILLA_BUILD
static const char* FindNext(uint32 header_size,
#else
static const char* FindNext(size_t header_size,
#endif
const char* range_start,
const char* range_end);
@ -293,17 +267,9 @@ class Pickle {
private:
Header* header_;
#ifdef CHROMIUM_MOZILLA_BUILD
uint32 header_size_;
uint32 capacity_;
uint32 variable_buffer_offset_;
#else
size_t header_size_; // Supports extra data between header and payload.
// Allocation size of payload (or -1 if allocation is const).
size_t capacity_;
size_t variable_buffer_offset_; // IF non-zero, then offset to a buffer.
#endif
FRIEND_TEST(PickleTest, Resize);
FRIEND_TEST(PickleTest, FindNext);
FRIEND_TEST(PickleTest, IteratorHasRoom);

View File

@ -40,16 +40,7 @@ namespace base {
// for this purpose. MSVC does not provide va_copy, so define an
// implementation here. It is not guaranteed that assignment is a copy, so the
// StringUtil.VariableArgsFunc unit test tests this capability.
#if !defined(CHROMIUM_MOZILLA_BUILD)
inline void va_copy(va_list& a, va_list& b) {
#if defined(COMPILER_GCC)
::va_copy(a, b);
#elif defined(COMPILER_MSVC)
a = b;
#endif
}
#else
// The C standard says that va_copy is a "macro", not a function. Trying to
// use va_list as ref args to a function, as above, breaks some machines.
# if defined(COMPILER_GCC)
@ -60,8 +51,6 @@ inline void va_copy(va_list& a, va_list& b) {
# error No va_copy for your compiler
# endif
#endif
} // namespace base
// Define an OS-neutral wrapper for shared library entry points

View File

@ -32,20 +32,16 @@ static mozilla::EnvironmentLog gProcessLog("MOZ_PROCESS_LOG");
namespace base {
#if defined(CHROMIUM_MOZILLA_BUILD)
bool LaunchApp(const std::vector<std::string>& argv,
const file_handle_mapping_vector& fds_to_remap,
bool wait, ProcessHandle* process_handle) {
return LaunchApp(argv, fds_to_remap, environment_map(),
wait, process_handle);
}
#endif
bool LaunchApp(const std::vector<std::string>& argv,
const file_handle_mapping_vector& fds_to_remap,
#if defined(CHROMIUM_MOZILLA_BUILD)
const environment_map& env_vars_to_set,
#endif
bool wait, ProcessHandle* process_handle,
ProcessArchitecture arch) {
pid_t pid = fork();
@ -64,23 +60,19 @@ bool LaunchApp(const std::vector<std::string>& argv,
CloseSuperfluousFds(fd_shuffle);
#if defined(CHROMIUM_MOZILLA_BUILD)
for (environment_map::const_iterator it = env_vars_to_set.begin();
it != env_vars_to_set.end(); ++it) {
if (setenv(it->first.c_str(), it->second.c_str(), 1/*overwrite*/))
exit(127);
}
#endif
scoped_array<char*> argv_cstr(new char*[argv.size() + 1]);
for (size_t i = 0; i < argv.size(); i++)
argv_cstr[i] = const_cast<char*>(argv[i].c_str());
argv_cstr[argv.size()] = NULL;
execvp(argv_cstr[0], argv_cstr.get());
#if defined(CHROMIUM_MOZILLA_BUILD)
// if we get here, we're in serious trouble and should complain loudly
DLOG(ERROR) << "FAILED TO exec() CHILD PROCESS, path: " << argv_cstr[0];
#endif
exit(127);
} else {
gProcessLog.print("==> process %d launched child process %d\n",

View File

@ -321,36 +321,6 @@ bool DidProcessCrash(bool* child_exited, ProcessHandle handle) {
return false;
}
#ifndef CHROMIUM_MOZILLA_BUILD
// All other exit codes indicate crashes.
// TODO(jar): Remove histogramming code when UMA stats are consistent with
// other crash metrics.
// Histogram the low order 3 nibbles for UMA
const int kLeastValue = 0;
const int kMaxValue = 0xFFF;
const int kBucketCount = kMaxValue - kLeastValue + 1;
static LinearHistogram least_significant_histogram("ExitCodes.LSNibbles",
kLeastValue + 1, kMaxValue, kBucketCount);
least_significant_histogram.SetFlags(kUmaTargetedHistogramFlag |
LinearHistogram::kHexRangePrintingFlag);
least_significant_histogram.Add(exitcode & 0xFFF);
// Histogram the high order 3 nibbles
static LinearHistogram most_significant_histogram("ExitCodes.MSNibbles",
kLeastValue + 1, kMaxValue, kBucketCount);
most_significant_histogram.SetFlags(kUmaTargetedHistogramFlag |
LinearHistogram::kHexRangePrintingFlag);
// Avoid passing in negative numbers by shifting data into low end of dword.
most_significant_histogram.Add((exitcode >> 20) & 0xFFF);
// Histogram the middle order 2 nibbles
static LinearHistogram mid_significant_histogram("ExitCodes.MidNibbles",
1, 0xFF, 0x100);
mid_significant_histogram.SetFlags(kUmaTargetedHistogramFlag |
LinearHistogram::kHexRangePrintingFlag);
mid_significant_histogram.Add((exitcode >> 12) & 0xFF);
#endif
return true;
}

View File

@ -67,11 +67,7 @@ class SharedMemory {
// opens the existing shared memory and ignores the size parameter.
// If name is the empty string, use a unique name.
// Returns true on success, false on failure.
#ifdef CHROMIUM_MOZILLA_BUILD
bool Create(const std::string& name, bool read_only, bool open_existing,
#else
bool Create(const std::wstring& name, bool read_only, bool open_existing,
#endif
size_t size);
// Deletes resources associated with a shared memory segment based on name.

View File

@ -70,17 +70,11 @@ SharedMemoryHandle SharedMemory::NULLHandle() {
return SharedMemoryHandle();
}
#ifdef CHROMIUM_MOZILLA_BUILD
bool SharedMemory::Create(const std::string &cname, bool read_only,
#else
bool SharedMemory::Create(const std::wstring &name, bool read_only,
#endif
bool open_existing, size_t size) {
read_only_ = read_only;
#ifdef CHROMIUM_MOZILLA_BUILD
std::wstring name = UTF8ToWide(cname);
#endif
int posix_flags = 0;
posix_flags |= read_only ? O_RDONLY : O_RDWR;

View File

@ -6,9 +6,7 @@
#include "base/logging.h"
#include "base/win_util.h"
#ifdef CHROMIUM_MOZILLA_BUILD
# include "base/string_util.h"
#endif
#include "base/string_util.h"
namespace base {
@ -58,18 +56,10 @@ SharedMemoryHandle SharedMemory::NULLHandle() {
return NULL;
}
#ifdef CHROMIUM_MOZILLA_BUILD
bool SharedMemory::Create(const std::string &cname, bool read_only,
#else
bool SharedMemory::Create(const std::wstring &name, bool read_only,
#endif
bool open_existing, size_t size) {
DCHECK(mapped_file_ == NULL);
#ifdef CHROMIUM_MOZILLA_BUILD
std::wstring name = UTF8ToWide(cname);
#endif
name_ = name;
read_only_ = read_only;
mapped_file_ = CreateFileMapping(INVALID_HANDLE_VALUE, NULL,

View File

@ -170,12 +170,7 @@ StatsTablePrivate* StatsTablePrivate::New(const std::string& name,
int max_threads,
int max_counters) {
scoped_ptr<StatsTablePrivate> priv(new StatsTablePrivate());
#ifdef CHROMIUM_MOZILLA_BUILD
if (!priv->shared_memory_.Create(name, false, true,
#else
if (!priv->shared_memory_.Create(base::SysUTF8ToWide(name), false, true,
#endif
size))
if (!priv->shared_memory_.Create(name, false, true, size))
return NULL;
if (!priv->shared_memory_.Map(size))
return NULL;

View File

@ -69,10 +69,4 @@ char16* c16memset(char16* s, char16 c, size_t n) {
template class std::basic_string<char16, base::string16_char_traits>;
#ifndef CHROMIUM_MOZILLA_BUILD
std::ostream& operator<<(std::ostream& out, const string16& str) {
return out << UTF16ToUTF8(str);
}
#endif
#endif // WCHAR_T_IS_UTF32

View File

@ -23,9 +23,6 @@
#include "base/basictypes.h"
#include "base/logging.h"
#include "base/singleton.h"
#ifndef CHROMIUM_MOZILLA_BUILD
#include "base/third_party/dmg_fp/dmg_fp.h"
#endif
namespace {
@ -249,47 +246,6 @@ class HexString16ToLongTraits {
}
};
#ifndef CHROMIUM_MOZILLA_BUILD
class StringToDoubleTraits {
public:
typedef std::string string_type;
typedef double value_type;
static inline value_type convert_func(const string_type::value_type* str,
string_type::value_type** endptr) {
return dmg_fp::strtod(str, endptr);
}
static inline bool valid_func(const string_type& str) {
return !str.empty() && !isspace(str[0]);
}
};
class String16ToDoubleTraits {
public:
typedef string16 string_type;
typedef double value_type;
static inline value_type convert_func(const string_type::value_type* str,
string_type::value_type** endptr) {
// Because dmg_fp::strtod does not like char16, we convert it to ASCII.
// In theory, this should be safe, but it's possible that 16-bit chars
// might get ignored by accident causing something to be parsed when it
// shouldn't.
std::string ascii_string = UTF16ToASCII(string16(str));
char* ascii_end = NULL;
value_type ret = dmg_fp::strtod(ascii_string.c_str(), &ascii_end);
if (ascii_string.c_str() + ascii_string.length() == ascii_end) {
// Put endptr at end of input string, so it's not recognized as an error.
*endptr =
const_cast<string_type::value_type*>(str) + ascii_string.length();
}
return ret;
}
static inline bool valid_func(const string_type& str) {
return !str.empty() && !iswspace(str[0]);
}
};
#endif
} // namespace
@ -335,9 +291,7 @@ bool IsWprintfFormatPortable(const wchar_t* format) {
} // namespace base
#ifdef CHROMIUM_MOZILLA_BUILD
namespace base {
#endif
const std::string& EmptyString() {
return Singleton<EmptyStrings>::get()->s;
@ -351,9 +305,7 @@ const string16& EmptyString16() {
return Singleton<EmptyStrings>::get()->s16;
}
#ifdef CHROMIUM_MOZILLA_BUILD
}
#endif
const wchar_t kWhitespaceWide[] = {
0x0009, // <control-0009> to <control-000D>
@ -765,11 +717,7 @@ bool StartsWith(const std::wstring& str,
if (search.size() > str.size())
return false;
return std::equal(search.begin(), search.end(), str.begin(),
#if defined(CHROMIUM_MOZILLA_BUILD)
chromium_CaseInsensitiveCompare<wchar_t>());
#else
CaseInsensitiveCompare<wchar_t>());
#endif
}
}
@ -944,11 +892,7 @@ static void StringAppendVT(StringType* dst,
typename StringType::value_type stack_buf[1024];
va_list backup_ap;
#if !defined(CHROMIUM_MOZILLA_BUILD)
base::va_copy(backup_ap, ap);
#else
base_va_copy(backup_ap, ap);
#endif // !defined(CHROMIUM_MOZILLA_BUILD)
#if !defined(OS_WIN)
errno = 0;
@ -995,11 +939,7 @@ static void StringAppendVT(StringType* dst,
std::vector<typename StringType::value_type> mem_buf(mem_length);
// Restore the va_list before we use it again.
#if !defined(CHROMIUM_MOZILLA_BUILD)
base::va_copy(backup_ap, ap);
#else
base_va_copy(backup_ap, ap);
#endif // !defined(CHROMIUM_MOZILLA_BUILD)
result = vsnprintfT(&mem_buf[0], mem_length, format, ap);
va_end(backup_ap);
@ -1111,19 +1051,6 @@ std::wstring Uint64ToWString(uint64 value) {
IntToString(value);
}
#ifndef CHROMIUM_MOZILLA_BUILD
std::string DoubleToString(double value) {
// According to g_fmt.cc, it is sufficient to declare a buffer of size 32.
char buffer[32];
dmg_fp::g_fmt(buffer, value);
return std::string(buffer);
}
std::wstring DoubleToWString(double value) {
return ASCIIToWide(DoubleToString(value));
}
#endif
void StringAppendV(std::string* dst, const char* format, va_list ap) {
StringAppendVT(dst, format, ap);
}
@ -1495,7 +1422,7 @@ bool MatchPattern(const std::string& eval, const std::string& pattern) {
// XXX Sigh.
#if !defined(ARCH_CPU_64_BITS) || !defined(CHROMIUM_MOZILLA_BUILD)
#if !defined(ARCH_CPU_64_BITS)
bool StringToInt(const std::string& input, int* output) {
COMPILE_ASSERT(sizeof(int) == sizeof(long), cannot_strtol_to_int);
return StringToNumber<StringToLongTraits>(input,
@ -1528,7 +1455,7 @@ bool StringToInt(const string16& input, int* output) {
*output = static_cast<int>(tmp);
return true;
}
#endif // !defined(ARCH_CPU_64_BITS) || !defined(CHROMIUM_MOZILLA_BUILD)
#endif // !defined(ARCH_CPU_64_BITS)
bool StringToInt64(const std::string& input, int64* output) {
return StringToNumber<StringToInt64Traits>(input, output);
@ -1538,7 +1465,7 @@ bool StringToInt64(const string16& input, int64* output) {
return StringToNumber<String16ToInt64Traits>(input, output);
}
#if !defined(ARCH_CPU_64_BITS) || !defined(CHROMIUM_MOZILLA_BUILD)
#if !defined(ARCH_CPU_64_BITS)
bool HexStringToInt(const std::string& input, int* output) {
COMPILE_ASSERT(sizeof(int) == sizeof(long), cannot_strtol_to_int);
return StringToNumber<HexStringToLongTraits>(input,
@ -1572,7 +1499,7 @@ bool HexStringToInt(const string16& input, int* output) {
return true;
}
#endif // !defined(ARCH_CPU_64_BITS) || !defined(CHROMIUM_MOZILLA_BUILD)
#endif // !defined(ARCH_CPU_64_BITS)
namespace {
@ -1652,28 +1579,6 @@ int HexStringToInt(const string16& value) {
return result;
}
#ifndef CHROMIUM_MOZILLA_BUILD
bool StringToDouble(const std::string& input, double* output) {
return StringToNumber<StringToDoubleTraits>(input, output);
}
bool StringToDouble(const string16& input, double* output) {
return StringToNumber<String16ToDoubleTraits>(input, output);
}
double StringToDouble(const std::string& value) {
double result;
StringToDouble(value, &result);
return result;
}
double StringToDouble(const string16& value) {
double result;
StringToDouble(value, &result);
return result;
}
#endif
// The following code is compatible with the OpenBSD lcpy interface. See:
// http://www.gratisoft.us/todd/papers/strlcpy.html
// ftp://ftp.openbsd.org/pub/OpenBSD/src/lib/libc/string/{wcs,str}lcpy.c

View File

@ -108,9 +108,7 @@ bool IsWprintfFormatPortable(const wchar_t* format);
#error Define string operations appropriately for your platform
#endif
#ifdef CHROMIUM_MOZILLA_BUILD
namespace base {
#endif
// Returns a reference to a globally unique empty string that functions can
// return. Use this to avoid static construction of strings, not to replace
// any and all uses of "std::string()" as nicer-looking sugar.
@ -118,9 +116,7 @@ namespace base {
const std::string& EmptyString();
const std::wstring& EmptyWString();
const string16& EmptyString16();
#ifdef CHROMIUM_MOZILLA_BUILD
}
#endif
extern const wchar_t kWhitespaceWide[];
extern const char kWhitespaceASCII[];
@ -509,11 +505,7 @@ inline typename string_type::value_type* WriteInto(string_type* str,
// Function objects to aid in comparing/searching strings.
#if defined(CHROMIUM_MOZILLA_BUILD)
template<typename Char> struct chromium_CaseInsensitiveCompare {
#else
template<typename Char> struct CaseInsensitiveCompare {
#endif
public:
bool operator()(Char x, Char y) const {
return tolower(x) == tolower(y);

View File

@ -55,13 +55,7 @@
#include "base/logging.h"
#include "base/third_party/nspr/prtypes.h"
#ifdef CHROMIUM_MOZILLA_BUILD
PR_BEGIN_EXTERN_C
#endif
#ifndef CHROMIUM_MOZILLA_BUILD
#define PR_ASSERT DCHECK
#endif
#define LL_I2L(l, i) ((l) = (PRInt64)(i))
#define LL_MUL(r, a, b) ((r) = (a) * (b))
@ -171,9 +165,7 @@ typedef struct PRExplodedTime {
typedef PRTimeParameters (PR_CALLBACK *PRTimeParamFn)(const PRExplodedTime *gmt);
#ifdef CHROMIUM_MOZILLA_BUILD
PR_END_EXTERN_C
#endif
namespace nspr {

View File

@ -65,26 +65,10 @@
#endif
// Type detection for wchar_t.
#ifndef CHROMIUM_MOZILLA_BUILD
#if defined(OS_WIN)
#define WCHAR_T_IS_UTF16
#elif defined(OS_POSIX) && defined(COMPILER_GCC) && \
defined(__WCHAR_MAX__) && \
(__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff)
#define WCHAR_T_IS_UTF32
#else
#error Please add support for your compiler in build/build_config.h
#endif
#else // CHROMIUM_MOZILLA_BUILD
#if defined(OS_WIN)
#define WCHAR_T_IS_UTF16
#else
#define WCHAR_T_IS_UTF32
#endif
#endif // CHROMIUM_MOZILLA_BUILD
#endif // BUILD_BUILD_CONFIG_H_

View File

@ -10,19 +10,12 @@
#include "base/process_util.h"
#include "base/singleton.h"
#include "base/waitable_event.h"
#ifdef CHROMIUM_MOZILLA_BUILD
#include "mozilla/ipc/ProcessChild.h"
#include "mozilla/ipc/BrowserProcessSubThread.h"
typedef mozilla::ipc::BrowserProcessSubThread ChromeThread;
#else
#include "chrome/browser/chrome_thread.h"
#endif
#include "chrome/common/ipc_logging.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/notification_type.h"
#ifndef CHROMIUM_MOZILLA_BUILD
#include "chrome/common/plugin_messages.h"
#endif
#include "chrome/common/process_watcher.h"
#include "chrome/common/result_codes.h"
@ -57,11 +50,7 @@ class ChildNotificationTask : public Task {
ChildProcessHost::ChildProcessHost(
ProcessType type, ResourceDispatcherHost* resource_dispatcher_host)
:
#ifdef CHROMIUM_MOZILLA_BUILD
ChildProcessInfo(type),
#else
Receiver(type),
#endif
ALLOW_THIS_IN_INITIALIZER_LIST(listener_(this)),
resource_dispatcher_host_(resource_dispatcher_host),
opening_channel_(false),
@ -120,16 +109,12 @@ bool ChildProcessHost::Send(IPC::Message* msg) {
}
void ChildProcessHost::Notify(NotificationType type) {
#ifdef CHROMIUM_MOZILLA_BUILD
MessageLoop* loop = ChromeThread::GetMessageLoop(ChromeThread::IO);
if (!loop)
loop = mozilla::ipc::ProcessChild::message_loop();
if (!loop)
loop = MessageLoop::current();
loop->PostTask(
#else
resource_dispatcher_host_->ui_loop()->PostTask(
#endif
FROM_HERE, new ChildNotificationTask(type, this));
}
@ -147,10 +132,6 @@ void ChildProcessHost::OnWaitableEventSignaled(base::WaitableEvent *event) {
// Notify in the main loop of the disconnection.
Notify(NotificationType::CHILD_PROCESS_HOST_DISCONNECTED);
#endif
#ifndef CHROMIUM_MOZILLA_BUILD
delete this;
#endif
}
ChildProcessHost::ListenerHook::ListenerHook(ChildProcessHost* host)
@ -171,27 +152,10 @@ void ChildProcessHost::ListenerHook::OnMessageReceived(
#endif
bool msg_is_ok = true;
#ifdef CHROMIUM_MOZILLA_BUILD
bool handled = false;
#else
bool handled = host_->resource_dispatcher_host_->OnMessageReceived(
msg, host_, &msg_is_ok);
#endif
if (!handled) {
#ifdef CHROMIUM_MOZILLA_BUILD
if (0) {
#else
if (msg.type() == PluginProcessHostMsg_ShutdownRequest::ID) {
// Must remove the process from the list now, in case it gets used for a
// new instance before our watcher tells us that the process terminated.
Singleton<ChildProcessList>::get()->remove(host_);
if (host_->CanShutdown())
host_->Send(new PluginProcessMsg_Shutdown());
#endif
} else {
host_->OnMessageReceived(msg);
}
}
if (!msg_is_ok)
@ -206,9 +170,6 @@ void ChildProcessHost::ListenerHook::OnMessageReceived(
void ChildProcessHost::ListenerHook::OnChannelConnected(int32 peer_pid) {
host_->opening_channel_ = false;
host_->OnChannelConnected(peer_pid);
#ifndef CHROMIUM_MOZILLA_BUILD
host_->Send(new PluginProcessMsg_AskBeforeShutdown());
#endif
// Notify in the main loop of the connection.
host_->Notify(NotificationType::CHILD_PROCESS_HOST_CONNECTED);
@ -221,21 +182,11 @@ void ChildProcessHost::ListenerHook::OnChannelError() {
ChildProcessHost::Iterator::Iterator() : all_(true) {
#ifndef CHROMIUM_MOZILLA_BUILD
DCHECK(MessageLoop::current() ==
ChromeThread::GetMessageLoop(ChromeThread::IO)) <<
"ChildProcessInfo::Iterator must be used on the IO thread.";
#endif
iterator_ = Singleton<ChildProcessList>::get()->begin();
}
ChildProcessHost::Iterator::Iterator(ProcessType type)
: all_(false), type_(type) {
#ifndef CHROMIUM_MOZILLA_BUILD
DCHECK(MessageLoop::current() ==
ChromeThread::GetMessageLoop(ChromeThread::IO)) <<
"ChildProcessInfo::Iterator must be used on the IO thread.";
#endif
iterator_ = Singleton<ChildProcessList>::get()->begin();
if (!Done() && (*iterator_)->type() != type_)
++(*this);

View File

@ -12,11 +12,7 @@
#include "base/basictypes.h"
#include "base/scoped_ptr.h"
#include "base/waitable_event_watcher.h"
#ifdef CHROMIUM_MOZILLA_BUILD
class ResourceDispatcherHost;
#else
#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
#endif
#include "chrome/common/child_process_info.h"
#include "chrome/common/ipc_channel.h"
@ -25,12 +21,8 @@ class NotificationType;
// Plugins/workers and other child processes that live on the IO thread should
// derive from this class.
class ChildProcessHost :
#ifdef CHROMIUM_MOZILLA_BUILD
public IPC::Message::Sender,
public ChildProcessInfo,
#else
public ResourceDispatcherHost::Receiver,
#endif
public base::WaitableEventWatcher::Delegate,
public IPC::Channel::Listener {
public:
@ -84,28 +76,20 @@ class ChildProcessHost :
bool opening_channel() { return opening_channel_; }
const std::wstring& channel_id() { return channel_id_; }
#ifdef CHROMIUM_MOZILLA_BUILD
base::WaitableEvent* GetProcessEvent() { return process_event_.get(); }
#endif
const IPC::Channel& channel() const { return *channel_; }
#ifdef CHROMIUM_MOZILLA_BUILD
IPC::Channel* channelp() const { return channel_.get(); }
#endif
private:
// Sends the given notification to the notification service on the UI thread.
void Notify(NotificationType type);
#ifdef CHROMIUM_MOZILLA_BUILD
protected:
#endif
// WaitableEventWatcher::Delegate implementation:
virtual void OnWaitableEventSignaled(base::WaitableEvent *event);
#ifdef CHROMIUM_MOZILLA_BUILD
private:
#endif
private:
// By using an internal class as the IPC::Channel::Listener, we can intercept
// OnMessageReceived/OnChannelConnected and do our own processing before
// calling the subclass' implementation.

View File

@ -6,16 +6,10 @@
#include <limits>
#ifndef CHROMIUM_MOZILLA_BUILD
#include "app/l10n_util.h"
#endif
#include "base/logging.h"
#include "base/process_util.h"
#include "base/rand_util.h"
#include "base/string_util.h"
#ifndef CHROMIUM_MOZILLA_BUILD
#include "grit/generated_resources.h"
#endif
std::wstring ChildProcessInfo::GetTypeNameInEnglish(
ChildProcessInfo::ProcessType type) {
@ -36,30 +30,7 @@ std::wstring ChildProcessInfo::GetTypeNameInEnglish(
}
std::wstring ChildProcessInfo::GetLocalizedTitle() const {
#ifdef CHROMIUM_MOZILLA_BUILD
return name_;
#else
std::wstring title = name_;
if (type_ == ChildProcessInfo::PLUGIN_PROCESS && title.empty())
title = l10n_util::GetString(IDS_TASK_MANAGER_UNKNOWN_PLUGIN_NAME);
int message_id;
if (type_ == ChildProcessInfo::PLUGIN_PROCESS) {
message_id = IDS_TASK_MANAGER_PLUGIN_PREFIX;
} else if (type_ == ChildProcessInfo::WORKER_PROCESS) {
message_id = IDS_TASK_MANAGER_WORKER_PREFIX;
} else {
DCHECK(false) << "Need localized name for child process type.";
return title;
}
// Explicitly mark name as LTR if there is no strong RTL character,
// to avoid the wrong concatenation result similar to "!Yahoo! Mail: the
// best web-based Email: NIGULP", in which "NIGULP" stands for the Hebrew
// or Arabic word for "plugin".
l10n_util::AdjustStringForLocaleDirection(title, &title);
return l10n_util::GetStringF(message_id, title);
#endif
}
ChildProcessInfo::ChildProcessInfo(ProcessType type) {

View File

@ -9,10 +9,6 @@
#include "chrome/common/child_process.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/ipc_logging.h"
#ifndef CHROMIUM_MOZILLA_BUILD
#include "chrome/common/plugin_messages.h"
#include "webkit/glue/webkit_glue.h"
#endif
// V8 needs a 1MB stack size.
const size_t ChildThread::kV8StackSize = 1024 * 1024;
@ -25,14 +21,6 @@ ChildThread::ChildThread(Thread::Options options)
DCHECK(owner_loop_);
channel_name_ = CommandLine::ForCurrentProcess()->GetSwitchValue(
switches::kProcessChannelID);
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUserAgent)) {
#ifndef CHROMIUM_MOZILLA_BUILD
webkit_glue::SetUserAgent(WideToUTF8(
CommandLine::ForCurrentProcess()->GetSwitchValue(
switches::kUserAgent)));
#endif
}
}
ChildThread::~ChildThread() {
@ -68,22 +56,6 @@ void ChildThread::RemoveRoute(int32 routing_id) {
}
void ChildThread::OnMessageReceived(const IPC::Message& msg) {
#ifndef CHROMIUM_MOZILLA_BUILD
// Resource responses are sent to the resource dispatcher.
if (resource_dispatcher_->OnMessageReceived(msg))
return;
if (msg.type() == PluginProcessMsg_AskBeforeShutdown::ID) {
check_with_browser_before_shutdown_ = true;
return;
}
if (msg.type() == PluginProcessMsg_Shutdown::ID) {
owner_loop_->PostTask(FROM_HERE, new MessageLoop::QuitTask());
return;
}
#endif
if (msg.routing_id() == MSG_ROUTING_CONTROL) {
OnControlMessageReceived(msg);
} else {
@ -96,23 +68,13 @@ ChildThread* ChildThread::current() {
}
void ChildThread::Init() {
#ifndef CHROMIUM_MOZILLA_BUILD
channel_.reset(new IPC::SyncChannel(channel_name_,
IPC::Channel::MODE_CLIENT, this, NULL, owner_loop_, true,
ChildProcess::current()->GetShutDownEvent()));
#else
channel_.reset(new IPC::Channel(channel_name_,
IPC::Channel::MODE_CLIENT,
this));
#endif
#ifdef IPC_MESSAGE_LOG_ENABLED
IPC::Logging::current()->SetIPCSender(this);
#endif
#ifndef CHROMIUM_MOZILLA_BUILD
resource_dispatcher_.reset(new ResourceDispatcher(this));
#endif
}
void ChildThread::CleanUp() {
@ -122,9 +84,6 @@ void ChildThread::CleanUp() {
// Need to destruct the SyncChannel to the browser before we go away because
// it caches a pointer to this thread.
channel_.reset();
#ifndef CHROMIUM_MOZILLA_BUILD
resource_dispatcher_.reset();
#endif
}
void ChildThread::OnProcessFinalRelease() {
@ -132,12 +91,4 @@ void ChildThread::OnProcessFinalRelease() {
owner_loop_->PostTask(FROM_HERE, new MessageLoop::QuitTask());
return;
}
#ifndef CHROMIUM_MOZILLA_BUILD
// The child process shutdown sequence is a request response based mechanism,
// where we send out an initial feeler request to the child process host
// instance in the browser to verify if it's ok to shutdown the child process.
// The browser then sends back a response if it's ok to shutdown.
Send(new PluginProcessHostMsg_ShutdownRequest);
#endif
}

View File

@ -9,11 +9,7 @@
#include "chrome/common/ipc_sync_channel.h"
#include "chrome/common/message_router.h"
#ifdef CHROMIUM_MOZILLA_BUILD
class ResourceDispatcher;
#else
#include "chrome/common/resource_dispatcher.h"
#endif
// Child processes's background thread should derive from this class.
class ChildThread : public IPC::Channel::Listener,
@ -33,12 +29,6 @@ class ChildThread : public IPC::Channel::Listener,
MessageLoop* owner_loop() { return owner_loop_; }
#ifndef CHROMIUM_MOZILLA_BUILD
ResourceDispatcher* resource_dispatcher() {
return resource_dispatcher_.get();
}
#endif
protected:
friend class ChildProcess;
@ -60,11 +50,7 @@ class ChildThread : public IPC::Channel::Listener,
// Returns the one child thread.
static ChildThread* current();
#ifndef CHROMIUM_MOZILLA_BUILD
IPC::SyncChannel* channel() { return channel_.get(); }
#else
IPC::Channel* channel() { return channel_.get(); }
#endif
// Thread implementation.
virtual void Init();
@ -79,11 +65,7 @@ class ChildThread : public IPC::Channel::Listener,
MessageLoop* owner_loop_;
std::wstring channel_name_;
#ifndef CHROMIUM_MOZILLA_BUILD
scoped_ptr<IPC::SyncChannel> channel_;
#else
scoped_ptr<IPC::Channel> channel_;
#endif
// Used only on the background render thread to implement message routing
// functionality to the consumers of the ChildThread.
@ -91,12 +73,6 @@ class ChildThread : public IPC::Channel::Listener,
Thread::Options options_;
#ifndef CHROMIUM_MOZILLA_BUILD
// Handles resource loads for this process.
// NOTE: this object lives on the owner thread.
scoped_ptr<ResourceDispatcher> resource_dispatcher_;
#endif
// If true, checks with the browser process before shutdown. This avoids race
// conditions if the process refcount is 0 but there's an IPC message inflight
// that would addref it.

View File

@ -32,187 +32,6 @@ bool GetGearsPluginPathFromCommandLine(FilePath* path) {
}
bool PathProvider(int key, FilePath* result) {
#ifndef CHROMIUM_MOZILLA_BUILD
// Some keys are just aliases...
switch (key) {
case chrome::DIR_APP:
return PathService::Get(base::DIR_MODULE, result);
case chrome::DIR_LOGS:
#ifndef NDEBUG
return PathService::Get(chrome::DIR_USER_DATA, result);
#else
return PathService::Get(base::DIR_EXE, result);
#endif
case chrome::FILE_RESOURCE_MODULE:
return PathService::Get(base::FILE_MODULE, result);
}
// Assume that we will not need to create the directory if it does not exist.
// This flag can be set to true for the cases where we want to create it.
bool create_dir = false;
FilePath cur;
switch (key) {
case chrome::DIR_USER_DATA:
if (!GetDefaultUserDataDirectory(&cur))
return false;
create_dir = true;
break;
case chrome::DIR_USER_DOCUMENTS:
if (!GetUserDocumentsDirectory(&cur))
return false;
create_dir = true;
break;
case chrome::DIR_DEFAULT_DOWNLOADS:
if (!GetUserDownloadsDirectory(&cur))
return false;
break;
case chrome::DIR_CRASH_DUMPS:
// The crash reports are always stored relative to the default user data
// directory. This avoids the problem of having to re-initialize the
// exception handler after parsing command line options, which may
// override the location of the app's profile directory.
if (!GetDefaultUserDataDirectory(&cur))
return false;
cur = cur.Append(FILE_PATH_LITERAL("Crash Reports"));
create_dir = true;
break;
case chrome::DIR_USER_DESKTOP:
if (!GetUserDesktop(&cur))
return false;
break;
case chrome::DIR_RESOURCES:
if (!PathService::Get(chrome::DIR_APP, &cur))
return false;
cur = cur.Append(FILE_PATH_LITERAL("resources"));
create_dir = true;
break;
case chrome::DIR_INSPECTOR:
if (!PathService::Get(chrome::DIR_APP, &cur))
return false;
cur = cur.Append(FILE_PATH_LITERAL("resources"));
cur = cur.Append(FILE_PATH_LITERAL("inspector"));
break;
case chrome::DIR_THEMES:
if (!PathService::Get(chrome::DIR_APP, &cur))
return false;
cur = cur.Append(FILE_PATH_LITERAL("themes"));
create_dir = true;
break;
case chrome::DIR_LOCALES:
if (!PathService::Get(chrome::DIR_APP, &cur))
return false;
#if defined(OS_MACOSX)
// On Mac, locale files are in Contents/Resources, a sibling of the
// App dir.
cur = cur.DirName();
cur = cur.Append(FILE_PATH_LITERAL("Resources"));
#else
cur = cur.Append(FILE_PATH_LITERAL("locales"));
#endif
create_dir = true;
break;
case chrome::DIR_APP_DICTIONARIES:
#if defined(OS_LINUX)
// We can't write into the EXE dir on Linux, so keep dictionaries
// alongside the safe browsing database in the user data dir.
if (!PathService::Get(chrome::DIR_USER_DATA, &cur))
return false;
#else
if (!PathService::Get(base::DIR_EXE, &cur))
return false;
#endif
cur = cur.Append(FILE_PATH_LITERAL("Dictionaries"));
create_dir = true;
break;
case chrome::FILE_LOCAL_STATE:
if (!PathService::Get(chrome::DIR_USER_DATA, &cur))
return false;
#ifdef CHROMIUM_MOZILLA_BUILD
cur = cur.Append(FILE_PATH_LITERAL("Local State"));
#else
cur = cur.Append(chrome::kLocalStateFilename);
#endif
break;
case chrome::FILE_RECORDED_SCRIPT:
if (!PathService::Get(chrome::DIR_USER_DATA, &cur))
return false;
cur = cur.Append(FILE_PATH_LITERAL("script.log"));
break;
case chrome::FILE_GEARS_PLUGIN:
if (!GetGearsPluginPathFromCommandLine(&cur)) {
#if defined(OS_WIN)
// Search for gears.dll alongside chrome.dll first. This new model
// allows us to package gears.dll with the Chrome installer and update
// it while Chrome is running.
if (!PathService::Get(base::DIR_MODULE, &cur))
return false;
cur = cur.Append(FILE_PATH_LITERAL("gears.dll"));
if (!file_util::PathExists(cur)) {
if (!PathService::Get(base::DIR_EXE, &cur))
return false;
cur = cur.Append(FILE_PATH_LITERAL("plugins"));
cur = cur.Append(FILE_PATH_LITERAL("gears"));
cur = cur.Append(FILE_PATH_LITERAL("gears.dll"));
}
#else
// No gears.dll on non-Windows systems.
return false;
#endif
}
break;
// The following are only valid in the development environment, and
// will fail if executed from an installed executable (because the
// generated path won't exist).
case chrome::DIR_TEST_DATA:
if (!PathService::Get(base::DIR_SOURCE_ROOT, &cur))
return false;
cur = cur.Append(FILE_PATH_LITERAL("chrome"));
cur = cur.Append(FILE_PATH_LITERAL("test"));
cur = cur.Append(FILE_PATH_LITERAL("data"));
if (!file_util::PathExists(cur)) // we don't want to create this
return false;
break;
case chrome::DIR_TEST_TOOLS:
if (!PathService::Get(base::DIR_SOURCE_ROOT, &cur))
return false;
cur = cur.Append(FILE_PATH_LITERAL("chrome"));
cur = cur.Append(FILE_PATH_LITERAL("tools"));
cur = cur.Append(FILE_PATH_LITERAL("test"));
if (!file_util::PathExists(cur)) // we don't want to create this
return false;
break;
case chrome::FILE_PYTHON_RUNTIME:
if (!PathService::Get(base::DIR_SOURCE_ROOT, &cur))
return false;
cur = cur.Append(FILE_PATH_LITERAL("third_party"));
cur = cur.Append(FILE_PATH_LITERAL("python_24"));
cur = cur.Append(FILE_PATH_LITERAL("python.exe"));
if (!file_util::PathExists(cur)) // we don't want to create this
return false;
break;
case chrome::FILE_TEST_SERVER:
if (!PathService::Get(base::DIR_SOURCE_ROOT, &cur))
return false;
cur = cur.Append(FILE_PATH_LITERAL("net"));
cur = cur.Append(FILE_PATH_LITERAL("tools"));
cur = cur.Append(FILE_PATH_LITERAL("test"));
cur = cur.Append(FILE_PATH_LITERAL("testserver"));
cur = cur.Append(FILE_PATH_LITERAL("testserver.py"));
if (!file_util::PathExists(cur)) // we don't want to create this
return false;
break;
default:
return false;
}
if (create_dir && !file_util::PathExists(cur) &&
!file_util::CreateDirectory(cur))
return false;
*result = cur;
#endif
return true;
}

View File

@ -9,9 +9,6 @@
#include "base/file_path.h"
#include "base/path_service.h"
#ifndef CHROMIUM_MOZILLA_BUILD
#include "chrome/third_party/xdg_user_dirs/xdg_user_dir_lookup.h"
#endif // ifndef CHROMIUM_MOZILLA_BUILD
namespace {
@ -36,14 +33,6 @@ FilePath GetHomeDir() {
// Wrapper around xdg_user_dir_lookup() from
// src/chrome/third_party/xdg-user-dirs
FilePath GetXDGUserDirectory(const char* env_name, const char* fallback_dir) {
#ifndef CHROMIUM_MOZILLA_BUILD
char* xdg_dir = xdg_user_dir_lookup(env_name);
if (xdg_dir) {
FilePath rv(xdg_dir);
free(xdg_dir);
return rv;
}
#endif // ifndef CHROMIUM_MOZILLA_BUILD
return GetHomeDir().Append(fallback_dir);
}

View File

@ -7,7 +7,7 @@
#ifndef CHROME_COMMON_ENV_VARS_H__
#define CHROME_COMMON_ENV_VARS_H__
#if defined(CHROMIUM_MOZILLA_BUILD) && defined(COMPILER_MSVC)
#if defined(COMPILER_MSVC)
#include <string.h>
#endif

View File

@ -59,7 +59,6 @@ class Channel : public Message::Sender {
//
Channel(const std::wstring& channel_id, Mode mode, Listener* listener);
#if defined(CHROMIUM_MOZILLA_BUILD)
// XXX it would nice not to have yet more platform-specific code in
// here but it's just not worth the trouble.
# if defined(OS_POSIX)
@ -71,7 +70,6 @@ class Channel : public Message::Sender {
Channel(const std::wstring& channel_id, void* server_pipe,
Mode mode, Listener* listener);
# endif
#endif
~Channel();
@ -86,11 +84,7 @@ class Channel : public Message::Sender {
void Close();
// Modify the Channel's listener.
#ifdef CHROMIUM_MOZILLA_BUILD
Listener* set_listener(Listener* listener);
#else
void set_listener(Listener* listener);
#endif
// Send a message over the Channel to the listener on the other end.
//
@ -114,15 +108,11 @@ class Channel : public Message::Sender {
// socketpair() in which case this method returns -1 for both parameters.
void GetClientFileDescriptorMapping(int *src_fd, int *dest_fd) const;
# if defined(CHROMIUM_MOZILLA_BUILD)
// Return the server side of the socketpair.
int GetServerFileDescriptor() const;
# endif
#elif defined(OS_WIN)
# if defined(CHROMIUM_MOZILLA_BUILD)
// Return the server pipe handle.
void* GetServerPipeHandle() const;
# endif
#endif // defined(OS_POSIX)
private:

View File

@ -238,7 +238,6 @@ bool ClientConnectToFifo(const std::string &pipe_name, int* client_socket) {
return true;
}
#if defined(CHROMIUM_MOZILLA_BUILD)
bool SetCloseOnExec(int fd) {
int flags = fcntl(fd, F_GETFD);
if (flags == -1)
@ -250,7 +249,6 @@ bool SetCloseOnExec(int fd) {
return true;
}
#endif
} // namespace
//------------------------------------------------------------------------------
@ -327,14 +325,12 @@ bool Channel::ChannelImpl::CreatePipe(const std::wstring& channel_id,
return false;
}
#if defined(CHROMIUM_MOZILLA_BUILD)
if (!SetCloseOnExec(pipe_fds[0]) ||
!SetCloseOnExec(pipe_fds[1])) {
HANDLE_EINTR(close(pipe_fds[0]));
HANDLE_EINTR(close(pipe_fds[1]));
return false;
}
#endif
pipe_ = pipe_fds[0];
client_pipe_ = pipe_fds[1];
@ -688,9 +684,6 @@ bool Channel::ChannelImpl::ProcessOutgoingMessages() {
}
bool Channel::ChannelImpl::Send(Message* message) {
#ifndef CHROMIUM_MOZILLA_BUILD
chrome::Counters::ipc_send_counter().Increment();
#endif
#ifdef IPC_MESSAGE_DEBUG_EXTRA
DLOG(INFO) << "sending message @" << message << " on channel @" << this
<< " with type " << message->type()
@ -824,11 +817,9 @@ Channel::Channel(const std::wstring& channel_id, Mode mode,
: channel_impl_(new ChannelImpl(channel_id, mode, listener)) {
}
#if defined(CHROMIUM_MOZILLA_BUILD)
Channel::Channel(int fd, Mode mode, Listener* listener)
: channel_impl_(new ChannelImpl(fd, mode, listener)) {
}
#endif
Channel::~Channel() {
delete channel_impl_;
@ -842,15 +833,9 @@ void Channel::Close() {
channel_impl_->Close();
}
#ifdef CHROMIUM_MOZILLA_BUILD
Channel::Listener* Channel::set_listener(Listener* listener) {
return channel_impl_->set_listener(listener);
}
#else
void Channel::set_listener(Listener* listener) {
channel_impl_->set_listener(listener);
}
#endif
bool Channel::Send(Message* message) {
return channel_impl_->Send(message);
@ -860,10 +845,8 @@ void Channel::GetClientFileDescriptorMapping(int *src_fd, int *dest_fd) const {
return channel_impl_->GetClientFileDescriptorMapping(src_fd, dest_fd);
}
#ifdef CHROMIUM_MOZILLA_BUILD
int Channel::GetServerFileDescriptor() const {
return channel_impl_->GetServerFileDescriptor();
}
#endif
} // namespace IPC

View File

@ -28,23 +28,17 @@ class Channel::ChannelImpl : public MessageLoopForIO::Watcher {
~ChannelImpl() { Close(); }
bool Connect();
void Close();
#ifdef CHROMIUM_MOZILLA_BUILD
Listener* set_listener(Listener* listener) {
Listener* old = listener_;
listener_ = listener;
return old;
}
#else
void set_listener(Listener* listener) { listener_ = listener; }
#endif
bool Send(Message* message);
void GetClientFileDescriptorMapping(int *src_fd, int *dest_fd) const;
#ifdef CHROMIUM_MOZILLA_BUILD
int GetServerFileDescriptor() const {
DCHECK(mode_ == MODE_SERVER);
return pipe_;
}
#endif
private:
void Init(Mode mode, Listener* listener);

View File

@ -45,7 +45,6 @@ Channel::ChannelImpl::ChannelImpl(const std::wstring& channel_id, Mode mode,
}
}
#if defined(CHROMIUM_MOZILLA_BUILD)
Channel::ChannelImpl::ChannelImpl(const std::wstring& channel_id,
HANDLE server_pipe,
Mode mode, Listener* listener)
@ -74,7 +73,6 @@ void Channel::ChannelImpl::Init(Mode mode, Listener* listener) {
HANDLE Channel::ChannelImpl::GetServerPipeHandle() const {
return pipe_;
}
#endif
void Channel::ChannelImpl::Close() {
if (thread_check_.get()) {
@ -94,19 +92,10 @@ void Channel::ChannelImpl::Close() {
pipe_ = INVALID_HANDLE_VALUE;
}
#ifndef CHROMIUM_MOZILLA_BUILD
// Make sure all IO has completed.
base::Time start = base::Time::Now();
#endif
while (input_state_.is_pending || output_state_.is_pending) {
MessageLoopForIO::current()->WaitForIOCompletion(INFINITE, this);
}
#ifndef CHROMIUM_MOZILLA_BUILD
if (waited) {
// We want to see if we block the message loop for too long.
UMA_HISTOGRAM_TIMES("AsyncIO.IPCChannelClose", base::Time::Now() - start);
}
#endif
while (!output_queue_.empty()) {
Message* m = output_queue_.front();
output_queue_.pop();
@ -211,10 +200,6 @@ bool Channel::ChannelImpl::EnqueueHelloMessage() {
}
bool Channel::ChannelImpl::Connect() {
#ifndef CHROMIUM_MOZILLA_BUILD
DLOG(WARNING) << "Connect called twice";
#endif
if (!thread_check_.get())
thread_check_.reset(new NonThreadSafe());
@ -459,12 +444,10 @@ Channel::Channel(const std::wstring& channel_id, Mode mode,
: channel_impl_(new ChannelImpl(channel_id, mode, listener)) {
}
#ifdef CHROMIUM_MOZILLA_BUILD
Channel::Channel(const std::wstring& channel_id, void* server_pipe,
Mode mode, Listener* listener)
: channel_impl_(new ChannelImpl(channel_id, server_pipe, mode, listener)) {
}
#endif
Channel::~Channel() {
delete channel_impl_;
@ -478,7 +461,6 @@ void Channel::Close() {
channel_impl_->Close();
}
#ifdef CHROMIUM_MOZILLA_BUILD
void* Channel::GetServerPipeHandle() const {
return channel_impl_->GetServerPipeHandle();
}
@ -486,11 +468,6 @@ void* Channel::GetServerPipeHandle() const {
Channel::Listener* Channel::set_listener(Listener* listener) {
return channel_impl_->set_listener(listener);
}
#else
void Channel::set_listener(Listener* listener) {
channel_impl_->set_listener(listener);
}
#endif
bool Channel::Send(Message* message) {
return channel_impl_->Send(message);

View File

@ -29,17 +29,12 @@ class Channel::ChannelImpl : public MessageLoopForIO::IOHandler {
}
bool Connect();
void Close();
#ifdef CHROMIUM_MOZILLA_BUILD
HANDLE GetServerPipeHandle() const;
Listener* set_listener(Listener* listener) {
Listener* old = listener_;
listener_ = listener;
return old;
}
#else
void set_listener(Listener* listener) { listener_ = listener; }
#endif
bool Send(Message* message);
private:
void Init(Mode mode, Listener* listener);

View File

@ -23,21 +23,6 @@
#include "chrome/common/ipc_sync_message.h"
#include "chrome/common/ipc_message_utils.h"
#ifndef CHROMIUM_MOZILLA_BUILD
// This include list should contain all _messages.h header files so that they
// can get *MsgLog function etc. This makes ipc logs much more informative.
#include "chrome/common/render_messages.h"
#include "chrome/test/automation/automation_messages.h"
#if defined(OS_WIN)
// Pulling this file in Mac/Linux causes a lot of binaries to need to bring in
// WebKit and all the dependencies, which results in a very large number of
// linker errors.
#include "chrome/common/plugin_messages.h"
#endif
#endif
#if defined(OS_POSIX)
#include "base/string_util.h"
#include <unistd.h>
@ -101,10 +86,6 @@ Logging::Logging()
CreateEvent(NULL, TRUE, FALSE, event_name.c_str())));
RegisterWaitForEvent(true);
#elif (!defined(CHROMIUM_MOZILLA_BUILD) && defined(OS_POSIX))
if (getenv("CHROME_IPC_LOGGING"))
enabled_ = true;
SetLoggerFunctions(g_log_function_mapping);
#endif
MessageLoop::current()->AddDestructionObserver(this);

View File

@ -27,12 +27,8 @@ Message::Message()
InitLoggingVariables();
}
#if !defined(CHROMIUM_MOZILLA_BUILD)
Message::Message(int32 routing_id, msgid_t type, PriorityValue priority)
#else
Message::Message(int32 routing_id, msgid_t type, PriorityValue priority,
const char* const name)
#endif
: Pickle(sizeof(Header)) {
header()->routing = routing_id;
header()->type = type;
@ -40,14 +36,10 @@ Message::Message(int32 routing_id, msgid_t type, PriorityValue priority,
#if defined(OS_POSIX)
header()->num_fds = 0;
#endif
#if defined(CHROMIUM_MOZILLA_BUILD)
header()->rpc_remote_stack_depth_guess = static_cast<uint32>(-1);
header()->rpc_local_stack_depth = static_cast<uint32>(-1);
header()->seqno = 0;
InitLoggingVariables(name);
#else
InitLoggingVariables();
#endif
}
Message::Message(const char* data, int data_len) : Pickle(data, data_len) {
@ -55,22 +47,14 @@ Message::Message(const char* data, int data_len) : Pickle(data, data_len) {
}
Message::Message(const Message& other) : Pickle(other) {
#if !defined(CHROMIUM_MOZILLA_BUILD)
InitLoggingVariables();
#else
InitLoggingVariables(other.name_);
#endif
#if defined(OS_POSIX)
file_descriptor_set_ = other.file_descriptor_set_;
#endif
}
#if !defined(CHROMIUM_MOZILLA_BUILD)
void Message::InitLoggingVariables() {
#else
void Message::InitLoggingVariables(const char* const name) {
name_ = name;
#endif
#ifdef IPC_MESSAGE_LOG_ENABLED
received_time_ = 0;
dont_log_ = false;
@ -80,9 +64,7 @@ void Message::InitLoggingVariables(const char* const name) {
Message& Message::operator=(const Message& other) {
*static_cast<Pickle*>(this) = other;
#if defined(CHROMIUM_MOZILLA_BUILD)
InitLoggingVariables(other.name_);
#endif
#if defined(OS_POSIX)
file_descriptor_set_ = other.file_descriptor_set_;
#endif

View File

@ -18,10 +18,6 @@
#include "base/ref_counted.h"
#endif
#if defined(CHROMIUM_MOZILLA_BUILD)
#define IPC_MESSAGE_ENABLE_RPC
#endif
namespace base {
class FileDescriptor;
}
@ -38,11 +34,7 @@ struct LogData;
class Message : public Pickle {
public:
#if defined(CHROMIUM_MOZILLA_BUILD)
typedef uint32 msgid_t;
#else
typedef uint16 msgid_t;
#endif
// Implemented by objects that can send IPC messages across a channel.
class Sender {
@ -68,12 +60,8 @@ class Message : public Pickle {
// Initialize a message with a user-defined type, priority value, and
// destination WebView ID.
#if !defined(CHROMIUM_MOZILLA_BUILD)
Message(int32 routing_id, msgid_t type, PriorityValue priority);
#else
Message(int32 routing_id, msgid_t type, PriorityValue priority,
const char* const name="???");
#endif
// Initializes a message from a const block of data. The data is not copied;
// instead the data is merely referenced by this message. Only const methods
@ -92,12 +80,10 @@ class Message : public Pickle {
return (header()->flags & SYNC_BIT) != 0;
}
#if defined(IPC_MESSAGE_ENABLE_RPC)
// True if this is a synchronous message.
bool is_rpc() const {
return (header()->flags & RPC_BIT) != 0;
}
#endif
// Set this on a reply to a synchronous message.
void set_reply() {
@ -151,7 +137,6 @@ class Message : public Pickle {
header()->routing = new_id;
}
#if defined(CHROMIUM_MOZILLA_BUILD)
uint32 rpc_remote_stack_depth_guess() const {
return header()->rpc_remote_stack_depth_guess;
}
@ -185,7 +170,6 @@ class Message : public Pickle {
void set_name(const char* const name) {
name_ = name;
}
#endif
template<class T>
static bool Dispatch(const Message* msg, T* obj, void (T::*func)()) {
@ -254,9 +238,6 @@ class Message : public Pickle {
bool dont_log() const { return dont_log_; }
#endif
#if !defined(CHROMIUM_MOZILLA_BUILD)
protected:
#endif
friend class Channel;
friend class MessageReplyDeserializer;
friend class SyncMessage;
@ -265,13 +246,11 @@ class Message : public Pickle {
header()->flags |= SYNC_BIT;
}
#if defined(IPC_MESSAGE_ENABLE_RPC)
void set_rpc() {
header()->flags |= RPC_BIT;
}
#endif
#if defined(CHROMIUM_MOZILLA_BUILD) && !defined(OS_MACOSX)
#if !defined(OS_MACOSX)
protected:
#endif
@ -284,31 +263,23 @@ class Message : public Pickle {
UNBLOCK_BIT = 0x0020,
PUMPING_MSGS_BIT= 0x0040,
HAS_SENT_TIME_BIT = 0x0080,
#if defined(IPC_MESSAGE_ENABLE_RPC)
RPC_BIT = 0x0100,
#endif
};
#pragma pack(push, 2)
struct Header : Pickle::Header {
int32 routing; // ID of the view that this message is destined for
msgid_t type; // specifies the user-defined message type
#if defined(CHROMIUM_MOZILLA_BUILD)
uint32 flags; // specifies control flags for the message
#else
uint16 flags; // specifies control flags for the message
#endif
#if defined(OS_POSIX)
uint32 num_fds; // the number of descriptors included with this message
#endif
#if defined(CHROMIUM_MOZILLA_BUILD)
// For RPC messages, a guess at what the *other* side's stack depth is.
uint32 rpc_remote_stack_depth_guess;
// The actual local stack depth.
uint32 rpc_local_stack_depth;
// Sequence number
int32 seqno;
#endif
};
#pragma pack(pop)
@ -319,11 +290,7 @@ class Message : public Pickle {
return headerT<Header>();
}
#if !defined(CHROMIUM_MOZILLA_BUILD)
void InitLoggingVariables();
#else
void InitLoggingVariables(const char* const name="???");
#endif
#if defined(OS_POSIX)
// The set of file descriptors associated with this message.
@ -341,9 +308,7 @@ class Message : public Pickle {
}
#endif
#if defined(CHROMIUM_MOZILLA_BUILD)
const char* name_;
#endif
#ifdef IPC_MESSAGE_LOG_ENABLED
// Used for logging.

View File

@ -40,12 +40,7 @@
// ViewHostMsg_SyncMessageName::WriteReplyParams(reply_msg, out1, out2);
// Send(reply_msg);
#ifndef CHROMIUM_MOZILLA_BUILD
#include "IPC/IPCMessageUtils.h"
#else
#include "chrome/common/ipc_message_utils.h"
#endif
#ifndef MESSAGES_INTERNAL_FILE
#error This file should only be included by X_messages.h, which needs to define MESSAGES_INTERNAL_FILE first.

View File

@ -5,15 +5,9 @@
#include "chrome/common/ipc_message_utils.h"
#include "base/gfx/rect.h"
#ifndef CHROMIUM_MOZILLA_BUILD
#include "googleurl/src/gurl.h"
#endif
#ifndef EXCLUDE_SKIA_DEPENDENCIES
#include "SkBitmap.h"
#endif
#ifndef CHROMIUM_MOZILLA_BUILD
#include "webkit/glue/dom_operations.h"
#endif
namespace IPC {
@ -100,132 +94,4 @@ void ParamTraits<SkBitmap>::Log(const SkBitmap& p, std::wstring* l) {
#endif // EXCLUDE_SKIA_DEPENDENCIES
#ifndef CHROMIUM_MOZILLA_BUILD
void ParamTraits<GURL>::Write(Message* m, const GURL& p) {
m->WriteString(p.possibly_invalid_spec());
// TODO(brettw) bug 684583: Add encoding for query params.
}
bool ParamTraits<GURL>::Read(const Message* m, void** iter, GURL* p) {
std::string s;
if (!m->ReadString(iter, &s)) {
*p = GURL();
return false;
}
*p = GURL(s);
return true;
}
void ParamTraits<GURL>::Log(const GURL& p, std::wstring* l) {
l->append(UTF8ToWide(p.spec()));
}
void ParamTraits<gfx::Point>::Write(Message* m, const gfx::Point& p) {
m->WriteInt(p.x());
m->WriteInt(p.y());
}
bool ParamTraits<gfx::Point>::Read(const Message* m, void** iter,
gfx::Point* r) {
int x, y;
if (!m->ReadInt(iter, &x) ||
!m->ReadInt(iter, &y))
return false;
r->set_x(x);
r->set_y(y);
return true;
}
void ParamTraits<gfx::Point>::Log(const gfx::Point& p, std::wstring* l) {
l->append(StringPrintf(L"(%d, %d)", p.x(), p.y()));
}
void ParamTraits<gfx::Rect>::Write(Message* m, const gfx::Rect& p) {
m->WriteInt(p.x());
m->WriteInt(p.y());
m->WriteInt(p.width());
m->WriteInt(p.height());
}
bool ParamTraits<gfx::Rect>::Read(const Message* m, void** iter, gfx::Rect* r) {
int x, y, w, h;
if (!m->ReadInt(iter, &x) ||
!m->ReadInt(iter, &y) ||
!m->ReadInt(iter, &w) ||
!m->ReadInt(iter, &h))
return false;
r->set_x(x);
r->set_y(y);
r->set_width(w);
r->set_height(h);
return true;
}
void ParamTraits<gfx::Rect>::Log(const gfx::Rect& p, std::wstring* l) {
l->append(StringPrintf(L"(%d, %d, %d, %d)", p.x(), p.y(),
p.width(), p.height()));
}
void ParamTraits<gfx::Size>::Write(Message* m, const gfx::Size& p) {
m->WriteInt(p.width());
m->WriteInt(p.height());
}
bool ParamTraits<gfx::Size>::Read(const Message* m, void** iter, gfx::Size* r) {
int w, h;
if (!m->ReadInt(iter, &w) ||
!m->ReadInt(iter, &h))
return false;
r->set_width(w);
r->set_height(h);
return true;
}
void ParamTraits<gfx::Size>::Log(const gfx::Size& p, std::wstring* l) {
l->append(StringPrintf(L"(%d, %d)", p.width(), p.height()));
}
void ParamTraits<webkit_glue::WebApplicationInfo>::Write(
Message* m, const webkit_glue::WebApplicationInfo& p) {
WriteParam(m, p.title);
WriteParam(m, p.description);
WriteParam(m, p.app_url);
WriteParam(m, p.icons.size());
for (size_t i = 0; i < p.icons.size(); ++i) {
WriteParam(m, p.icons[i].url);
WriteParam(m, p.icons[i].width);
WriteParam(m, p.icons[i].height);
}
}
bool ParamTraits<webkit_glue::WebApplicationInfo>::Read(
const Message* m, void** iter, webkit_glue::WebApplicationInfo* r) {
size_t icon_count;
bool result =
ReadParam(m, iter, &r->title) &&
ReadParam(m, iter, &r->description) &&
ReadParam(m, iter, &r->app_url) &&
ReadParam(m, iter, &icon_count);
if (!result)
return false;
for (size_t i = 0; i < icon_count && result; ++i) {
param_type::IconInfo icon_info;
result =
ReadParam(m, iter, &icon_info.url) &&
ReadParam(m, iter, &icon_info.width) &&
ReadParam(m, iter, &icon_info.height);
r->icons.push_back(icon_info);
}
return result;
}
void ParamTraits<webkit_glue::WebApplicationInfo>::Log(
const webkit_glue::WebApplicationInfo& p, std::wstring* l) {
l->append(L"<WebApplicationInfo>");
}
#endif // CHROMIUM_MOZILLA_BUILD
} // namespace IPC

View File

@ -20,56 +20,6 @@
#include "chrome/common/ipc_sync_message.h"
#include "chrome/common/thumbnail_score.h"
#include "chrome/common/transport_dib.h"
#ifndef CHROMIUM_MOZILLA_BUILD
#include "webkit/glue/webcursor.h"
#include "webkit/glue/window_open_disposition.h"
// Forward declarations.
class GURL;
class SkBitmap;
namespace gfx {
class Point;
class Rect;
class Size;
} // namespace gfx
namespace webkit_glue {
struct WebApplicationInfo;
} // namespace webkit_glue
// Used by IPC_BEGIN_MESSAGES so that each message class starts from a unique
// base. Messages have unique IDs across channels in order for the IPC logging
// code to figure out the message class from its ID.
enum IPCMessageStart {
// By using a start value of 0 for automation messages, we keep backward
// compatibility with old builds.
AutomationMsgStart = 0,
ViewMsgStart,
ViewHostMsgStart,
PluginProcessMsgStart,
PluginProcessHostMsgStart,
PluginMsgStart,
PluginHostMsgStart,
NPObjectMsgStart,
TestMsgStart,
DevToolsAgentMsgStart,
DevToolsClientMsgStart,
WorkerProcessMsgStart,
WorkerProcessHostMsgStart,
WorkerMsgStart,
WorkerHostMsgStart,
// NOTE: When you add a new message class, also update
// IPCStatusView::IPCStatusView to ensure logging works.
// NOTE: this enum is used by IPC_MESSAGE_MACRO to generate a unique message
// id. Only 4 bits are used for the message type, so if this enum needs more
// than 16 entries, that code needs to be updated.
LastMsgIndex
};
COMPILE_ASSERT(LastMsgIndex <= 16, need_to_update_IPC_MESSAGE_MACRO);
#endif /* CHROMIUM_MOZILLA_BUILD */
namespace IPC {
@ -219,7 +169,7 @@ struct ParamTraits<unsigned long> {
}
};
#if !(defined(OS_MACOSX) || defined(OS_WIN) || (defined(CHROMIUM_MOZILLA_BUILD) && defined(OS_LINUX) && defined(ARCH_CPU_64_BITS)))
#if !(defined(OS_MACOSX) || defined(OS_WIN) || (defined(OS_LINUX) && defined(ARCH_CPU_64_BITS)))
// There size_t is a synonym for |unsigned long| ...
template <>
struct ParamTraits<size_t> {
@ -272,7 +222,7 @@ struct ParamTraits<uint32> {
};
#endif // defined(OS_MACOSX)
#if !(defined(CHROMIUM_MOZILLA_BUILD) && defined(OS_LINUX) && defined(ARCH_CPU_64_BITS))
#if !(defined(OS_LINUX) && defined(ARCH_CPU_64_BITS))
// int64 is |long int| on 64-bit systems, uint64 is |unsigned long|
template <>
struct ParamTraits<int64> {
@ -284,11 +234,7 @@ struct ParamTraits<int64> {
return m->ReadInt64(iter, r);
}
static void Log(const param_type& p, std::wstring* l) {
#ifndef CHROMIUM_MOZILLA_BUILD
l->append(StringPrintf(L"%I64d", p));
#else
l->append(StringPrintf(L"%" PRId64L, p));
#endif // ifndef CHROMIUM_MOZILLA_BUILD
}
};
@ -302,14 +248,10 @@ struct ParamTraits<uint64> {
return m->ReadInt64(iter, reinterpret_cast<int64*>(r));
}
static void Log(const param_type& p, std::wstring* l) {
#ifndef CHROMIUM_MOZILLA_BUILD
l->append(StringPrintf(L"%I64u", p));
#else
l->append(StringPrintf(L"%" PRIu64L, p));
#endif // ifndef CHROMIUM_MOZILLA_BUILD
}
};
#endif // if !(defined(CHROMIUM_MOZILLA_BUILD) && defined(OS_LINUX) && defined(ARCH_CPU_64_BITS))
#endif // if !(defined(OS_LINUX) && defined(ARCH_CPU_64_BITS))
template <>
struct ParamTraits<double> {
@ -335,32 +277,6 @@ struct ParamTraits<double> {
}
};
#ifndef CHROMIUM_MOZILLA_BUILD
template <>
struct ParamTraits<wchar_t> {
typedef wchar_t param_type;
static void Write(Message* m, const param_type& p) {
m->WriteData(reinterpret_cast<const char*>(&p), sizeof(param_type));
}
static bool Read(const Message* m, void** iter, param_type* r) {
const char *data;
int data_size = 0;
bool result = m->ReadData(iter, &data, &data_size);
if (result && data_size == sizeof(param_type)) {
memcpy(r, data, sizeof(param_type));
} else {
result = false;
NOTREACHED();
}
return result;
}
static void Log(const param_type& p, std::wstring* l) {
l->append(StringPrintf(L"%lc", p));
}
};
#endif /* CHROMIUM_MOZILLA_BUILD */
template <>
struct ParamTraits<base::Time> {
typedef base::Time param_type;
@ -426,20 +342,6 @@ struct ParamTraits<MSG> {
};
#endif // defined(OS_WIN)
#ifndef CHROMIUM_MOZILLA_BUILD
template <>
struct ParamTraits<SkBitmap> {
typedef SkBitmap param_type;
static void Write(Message* m, const param_type& p);
// Note: This function expects parameter |r| to be of type &SkBitmap since
// r->SetConfig() and r->SetPixels() are called.
static bool Read(const Message* m, void** iter, param_type* r);
static void Log(const param_type& p, std::wstring* l);
};
#endif /* CHROMIUM_MOZILLA_BUILD */
template <>
struct ParamTraits<std::string> {
typedef std::string param_type;
@ -609,16 +511,6 @@ struct ParamTraits<string16> {
};
#endif
#ifndef CHROMIUM_MOZILLA_BUILD
template <>
struct ParamTraits<GURL> {
typedef GURL param_type;
static void Write(Message* m, const param_type& p);
static bool Read(const Message* m, void** iter, param_type* p);
static void Log(const param_type& p, std::wstring* l);
};
#endif /* CHROMIUM_MOZILLA_BUILD */
// and, a few more useful types...
#if defined(OS_WIN)
template <>
@ -717,32 +609,6 @@ struct ParamTraits<FilePath> {
}
};
#ifndef CHROMIUM_MOZILLA_BUILD
template <>
struct ParamTraits<gfx::Point> {
typedef gfx::Point param_type;
static void Write(Message* m, const param_type& p);
static bool Read(const Message* m, void** iter, param_type* r);
static void Log(const param_type& p, std::wstring* l);
};
template <>
struct ParamTraits<gfx::Rect> {
typedef gfx::Rect param_type;
static void Write(Message* m, const param_type& p);
static bool Read(const Message* m, void** iter, param_type* r);
static void Log(const param_type& p, std::wstring* l);
};
template <>
struct ParamTraits<gfx::Size> {
typedef gfx::Size param_type;
static void Write(Message* m, const param_type& p);
static bool Read(const Message* m, void** iter, param_type* r);
static void Log(const param_type& p, std::wstring* l);
};
#endif /* CHROMIUM_MOZILLA_BUILD */
#if defined(OS_POSIX)
// FileDescriptors may be serialised over IPC channels on POSIX. On the
// receiving side, the FileDescriptor is a valid duplicate of the file
@ -825,25 +691,6 @@ struct ParamTraits<ThumbnailScore> {
}
};
#ifndef CHROMIUM_MOZILLA_BUILD
template <>
struct ParamTraits<WindowOpenDisposition> {
typedef WindowOpenDisposition param_type;
static void Write(Message* m, const param_type& p) {
m->WriteInt(p);
}
static bool Read(const Message* m, void** iter, param_type* r) {
int temp;
bool res = m->ReadInt(iter, &temp);
*r = static_cast<WindowOpenDisposition>(temp);
return res;
}
static void Log(const param_type& p, std::wstring* l) {
l->append(StringPrintf(L"%d", p));
}
};
#endif
#if defined(OS_WIN)
template <>
struct ParamTraits<XFORM> {
@ -870,22 +717,6 @@ struct ParamTraits<XFORM> {
};
#endif // defined(OS_WIN)
#ifndef CHROMIUM_MOZILLA_BUILD
template <>
struct ParamTraits<WebCursor> {
typedef WebCursor param_type;
static void Write(Message* m, const param_type& p) {
p.Serialize(m);
}
static bool Read(const Message* m, void** iter, param_type* r) {
return r->Deserialize(m, iter);
}
static void Log(const param_type& p, std::wstring* l) {
l->append(L"<WebCursor>");
}
};
#endif
struct LogData {
std::wstring channel;
int32 routing_id;
@ -932,16 +763,6 @@ struct ParamTraits<LogData> {
}
};
#ifndef CHROMIUM_MOZILLA_BUILD
template <>
struct ParamTraits<webkit_glue::WebApplicationInfo> {
typedef webkit_glue::WebApplicationInfo param_type;
static void Write(Message* m, const param_type& p);
static bool Read(const Message* m, void** iter, param_type* r);
static void Log(const param_type& p, std::wstring* l);
};
#endif /* CHROMIUM_MOZILLA_BUILD */
#if defined(OS_WIN)
template<>
struct ParamTraits<TransportDIB::Id> {

View File

@ -3,9 +3,6 @@
// found in the LICENSE file.
#include "chrome/common/message_router.h"
#ifndef CHROMIUM_MOZILLA_BUILD
#include "chrome/common/render_messages.h"
#endif
void MessageRouter::OnControlMessageReceived(const IPC::Message& msg) {
NOTREACHED() <<

View File

@ -6,16 +6,9 @@
#import <Cocoa/Cocoa.h>
#ifndef CHROMIUM_MOZILLA_BUILD
#include "app/l10n_util.h"
#endif
#include "base/file_path.h"
#include "base/logging.h"
#include "base/sys_string_conversions.h"
#ifndef CHROMIUM_MOZILLA_BUILD
#include "chrome/browser/cocoa/tab_window_controller.h"
#include "grit/generated_resources.h"
#endif
namespace platform_util {
@ -30,22 +23,8 @@ gfx::NativeWindow GetTopLevel(gfx::NativeView view) {
}
string16 GetWindowTitle(gfx::NativeWindow window) {
#ifdef CHROMIUM_MOZILLA_BUILD
std::string str("Untitled");
return string16(str.begin(), str.end());
#else
NSString* title = nil;
if ([[window delegate] isKindOfClass:[TabWindowController class]])
title = [[window delegate] selectedTabTitle];
else
title = [window title];
// If we don't yet have a title, use "Untitled".
if (![title length])
return WideToUTF16(l10n_util::GetString(
IDS_BROWSER_WINDOW_MAC_TAB_UNTITLED));
return base::SysNSStringToUTF16(title);
#endif
}
bool IsWindowActive(gfx::NativeWindow window) {

View File

@ -24,9 +24,7 @@ class ProcessWatcher {
// and SYNCHRONIZE permissions.
//
static void EnsureProcessTerminated(base::ProcessHandle process_handle
#if defined(CHROMIUM_MOZILLA_BUILD)
, bool force=true
#endif
);
private:

View File

@ -79,19 +79,15 @@ class TimerExpiredTask : public Task, public base::ObjectWatcher::Delegate {
// static
void ProcessWatcher::EnsureProcessTerminated(base::ProcessHandle process
#ifdef CHROMIUM_MOZILLA_BUILD
, bool force
#endif
) {
DCHECK(process != GetCurrentProcess());
#ifdef CHROMIUM_MOZILLA_BUILD
if (!force) {
WaitForSingleObject(process, INFINITE);
CloseHandle(process);
return;
}
#endif
// If already signaled, then we are done!
if (WaitForSingleObject(process, 0) == WAIT_OBJECT_0) {

View File

@ -25,11 +25,7 @@ TransportDIB::~TransportDIB() {
// static
TransportDIB* TransportDIB::Create(size_t size, uint32 sequence_num) {
TransportDIB* dib = new TransportDIB;
#ifdef CHROMIUM_MOZILLA_BUILD
if (!dib->shared_memory_.Create("", false /* read write */,
#else
if (!dib->shared_memory_.Create(L"", false /* read write */,
#endif
false /* do not open existing */, size)) {
delete dib;
return NULL;

Some files were not shown because too many files have changed in this diff Show More