From 0b85b6d782e69abd40cee76405153254d0d30937 Mon Sep 17 00:00:00 2001 From: Andrew Halberstadt Date: Wed, 3 Sep 2014 14:17:40 -0400 Subject: [PATCH 01/68] Bug 857966 - manifestparser should error on non-existent test when strict enabled, r=davehunt --- .../manifestparser/manifestparser.py | 31 ++++++++++++++----- .../manifestparser/tests/missing-path.ini | 2 ++ .../manifestparser/tests/test_testmanifest.py | 19 +++++++++++- 3 files changed, 43 insertions(+), 9 deletions(-) create mode 100644 testing/mozbase/manifestparser/tests/missing-path.ini diff --git a/testing/mozbase/manifestparser/manifestparser/manifestparser.py b/testing/mozbase/manifestparser/manifestparser/manifestparser.py index 4378162e0cc..5987b6d7817 100755 --- a/testing/mozbase/manifestparser/manifestparser/manifestparser.py +++ b/testing/mozbase/manifestparser/manifestparser/manifestparser.py @@ -12,6 +12,7 @@ __all__ = ['read_ini', # .ini reader 'ManifestParser', 'TestManifest', 'convert', # manifest handling 'parse', 'ParseError', 'ExpressionParser'] # conditional expression parser +import json import fnmatch import os import re @@ -384,7 +385,7 @@ def read_ini(fp, variables=None, default='DEFAULT', if 'skip-if' in local_dict and 'skip-if' in variables: local_dict['skip-if'] = "(%s) || (%s)" % (variables['skip-if'].split('#')[0], local_dict['skip-if'].split('#')[0]) variables.update(local_dict) - + return variables sections = [(i, interpret_variables(variables, j)) for i, j in sections] @@ -623,6 +624,18 @@ class ManifestParser(object): return [test for test in tests if not os.path.exists(test['path'])] + def check_missing(self, tests=None): + missing = self.missing(tests=tests) + if missing: + missing_paths = [test['path'] for test in missing] + if self.strict: + raise IOError("Strict mode enabled, test paths must exist. " + "The following test(s) are missing: %s" % + json.dumps(missing_paths, indent=2)) + print >> sys.stderr, "Warning: The following test(s) are missing: %s" % \ + json.dumps(missing_paths, indent=2) + return missing + def verifyDirectory(self, directories, pattern=None, extensions=None): """ checks what is on the filesystem vs what is in a manifest @@ -776,14 +789,13 @@ class ManifestParser(object): # sanity check assert os.path.isdir(dirname) shutil.copy(os.path.join(rootdir, manifest), destination) + + missing = self.check_missing(tests) + tests = [test for test in tests if test not in missing] for test in tests: if os.path.isabs(test['name']): continue source = test['path'] - if not os.path.exists(source): - print >> sys.stderr, "Missing test: '%s' does not exist!" % source - continue - # TODO: should err on strict destination = os.path.join(directory, relpath(test['path'], rootdir)) shutil.copy(source, destination) # TODO: ensure that all of the tests are below the from_dir @@ -810,8 +822,10 @@ class ManifestParser(object): _relpath = relpath(test['path'], rootdir) source = os.path.join(from_dir, _relpath) if not os.path.exists(source): - # TODO err on strict - print >> sys.stderr, "Missing test: '%s'; skipping" % test['name'] + message = "Missing test: '%s' does not exist!" + if self.strict: + raise IOError(message) + print >> sys.stderr, message + " Skipping." continue destination = os.path.join(rootdir, _relpath) shutil.copy(source, destination) @@ -1108,7 +1122,8 @@ class TestManifest(ManifestParser): # ignore tests that do not exist if exists: - tests = [test for test in tests if os.path.exists(test['path'])] + missing = self.check_missing(tests) + tests = [test for test in tests if test not in missing] # filter by tags self.filter(values, tests) diff --git a/testing/mozbase/manifestparser/tests/missing-path.ini b/testing/mozbase/manifestparser/tests/missing-path.ini new file mode 100644 index 00000000000..919d8e04da7 --- /dev/null +++ b/testing/mozbase/manifestparser/tests/missing-path.ini @@ -0,0 +1,2 @@ +[foo] +[bar] diff --git a/testing/mozbase/manifestparser/tests/test_testmanifest.py b/testing/mozbase/manifestparser/tests/test_testmanifest.py index 898706f4d04..ad8521a3d5e 100644 --- a/testing/mozbase/manifestparser/tests/test_testmanifest.py +++ b/testing/mozbase/manifestparser/tests/test_testmanifest.py @@ -1,6 +1,8 @@ #!/usr/bin/env python import os +import shutil +import tempfile import unittest from manifestparser import TestManifest @@ -12,7 +14,7 @@ class TestTestManifest(unittest.TestCase): def test_testmanifest(self): # Test filtering based on platform: filter_example = os.path.join(here, 'filter-example.ini') - manifest = TestManifest(manifests=(filter_example,)) + manifest = TestManifest(manifests=(filter_example,), strict=False) self.assertEqual([i['name'] for i in manifest.active_tests(os='win', disabled=False, exists=False)], ['windowstest', 'fleem']) self.assertEqual([i['name'] for i in manifest.active_tests(os='linux', disabled=False, exists=False)], @@ -29,6 +31,21 @@ class TestTestManifest(unittest.TestCase): last_test = manifest.active_tests(exists=False, toolkit='cocoa')[-1] self.assertEqual(last_test['expected'], 'fail') + def test_missing_paths(self): + """ + Test paths that don't exist raise an exception in strict mode. + """ + tempdir = tempfile.mkdtemp() + + missing_path = os.path.join(here, 'missing-path.ini') + manifest = TestManifest(manifests=(missing_path,), strict=True) + self.assertRaises(IOError, manifest.active_tests) + self.assertRaises(IOError, manifest.copy, tempdir) + self.assertRaises(IOError, manifest.update, tempdir) + + shutil.rmtree(tempdir) + + def test_comments(self): """ ensure comments work, see From a549c1a3b3d605a3d722f8e61e8becc94ca1175c Mon Sep 17 00:00:00 2001 From: David Keeler Date: Wed, 3 Sep 2014 11:44:08 -0700 Subject: [PATCH 02/68] bug 1050546 - telemetry for baseline requirements sections 9.2.1 and 9.2.2 (subject alt names/common name) r=rbarnes --- security/certverifier/CertVerifier.h | 2 + .../ssl/src/SSLServerCertVerification.cpp | 217 +++++++++++++++++- toolkit/components/telemetry/Histograms.json | 12 + 3 files changed, 230 insertions(+), 1 deletion(-) diff --git a/security/certverifier/CertVerifier.h b/security/certverifier/CertVerifier.h index 0816990dc15..93ab1b5231e 100644 --- a/security/certverifier/CertVerifier.h +++ b/security/certverifier/CertVerifier.h @@ -79,6 +79,8 @@ private: }; void InitCertVerifierLog(); +SECStatus IsCertBuiltInRoot(CERTCertificate* cert, bool& result); + } } // namespace mozilla::psm #endif // mozilla_psm__CertVerifier_h diff --git a/security/manager/ssl/src/SSLServerCertVerification.cpp b/security/manager/ssl/src/SSLServerCertVerification.cpp index 8c9837b37cd..41ee6b9fd83 100644 --- a/security/manager/ssl/src/SSLServerCertVerification.cpp +++ b/security/manager/ssl/src/SSLServerCertVerification.cpp @@ -98,6 +98,7 @@ #include "pkix/pkixtypes.h" #include "pkix/pkixnss.h" +#include "pkix/ScopedPtr.h" #include "CertVerifier.h" #include "CryptoTask.h" #include "ExtendedValidation.h" @@ -112,6 +113,7 @@ #include "mozilla/Assertions.h" #include "mozilla/Mutex.h" #include "mozilla/Telemetry.h" +#include "mozilla/net/DNS.h" #include "mozilla/unused.h" #include "nsIThreadPool.h" #include "nsNetUtil.h" @@ -121,6 +123,7 @@ #include "PSMRunnable.h" #include "SharedSSLState.h" #include "nsContentUtils.h" +#include "nsURLHelper.h" #include "ssl.h" #include "secerr.h" @@ -739,6 +742,216 @@ BlockServerCertChangeForSpdy(nsNSSSocketInfo* infoObject, return SECFailure; } +void +AccumulateSubjectCommonNameTelemetry(const char* commonName, + bool commonNameInSubjectAltNames) +{ + if (!commonName) { + // 1 means no common name present + Telemetry::Accumulate(Telemetry::BR_9_2_2_SUBJECT_COMMON_NAME, 1); + } else if (!commonNameInSubjectAltNames) { + PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, + ("BR telemetry: common name '%s' not in subject alt. names " + "(or the subject alt. names extension is not present)\n", + commonName)); + // 2 means the common name is not present in subject alt names + Telemetry::Accumulate(Telemetry::BR_9_2_2_SUBJECT_COMMON_NAME, 2); + } else { + // 0 means the common name is present in subject alt names + Telemetry::Accumulate(Telemetry::BR_9_2_2_SUBJECT_COMMON_NAME, 0); + } +} + +// Returns true if and only if commonName ends with altName (minus its leading +// "*"). altName has already been checked to be of the form "*.". +// commonName may be NULL. +static bool +TryMatchingWildcardSubjectAltName(const char* commonName, + nsDependentCString altName) +{ + if (!commonName) { + return false; + } + // altNameSubstr is now "." + nsDependentCString altNameSubstr(altName.get() + 1, altName.Length() - 1); + nsDependentCString commonNameStr(commonName, strlen(commonName)); + int32_t altNameIndex = commonNameStr.Find(altNameSubstr); + // This only matches if the end of commonNameStr is the altName without + // the '*'. + // Consider this.example.com and *.example.com: + // "this.example.com".Find(".example.com") is 4 + // 4 + ".example.com".Length() == 4 + 12 == 16 == "this.example.com".Length() + // Now this.example.com and *.example: + // "this.example.com".Find(".example") is 4 + // 4 + ".example".Length() == 4 + 8 == 12 != "this.example.com".Length() + return altNameIndex >= 0 && + altNameIndex + altNameSubstr.Length() == commonNameStr.Length(); +} + +// Gathers telemetry on Baseline Requirements 9.2.1 (Subject Alternative +// Names Extension) and 9.2.2 (Subject Common Name Field). +// Specifically: +// - whether or not the subject common name field is present +// - whether or not the subject alternative names extension is present +// - if there is a malformed entry in the subject alt. names extension +// - if there is an entry in the subject alt. names extension corresponding +// to the subject common name +// Telemetry is only gathered for certificates that chain to a trusted root +// in Mozilla's Root CA program. +// certList consists of a validated certificate chain. The end-entity +// certificate is first and the root (trust anchor) is last. +void +GatherBaselineRequirementsTelemetry(const ScopedCERTCertList& certList) +{ + CERTCertListNode* endEntityNode = CERT_LIST_HEAD(certList); + CERTCertListNode* rootNode = CERT_LIST_TAIL(certList); + PR_ASSERT(endEntityNode && rootNode); + if (!endEntityNode || !rootNode) { + return; + } + CERTCertificate* cert = endEntityNode->cert; + mozilla::pkix::ScopedPtr commonName( + CERT_GetCommonName(&cert->subject)); + // This only applies to certificates issued by authorities in our root + // program. + bool isBuiltIn = false; + SECStatus rv = IsCertBuiltInRoot(rootNode->cert, isBuiltIn); + if (rv != SECSuccess || !isBuiltIn) { + PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, + ("BR telemetry: '%s' not a built-in root (or IsCertBuiltInRoot " + "failed)\n", commonName.get())); + return; + } + SECItem altNameExtension; + rv = CERT_FindCertExtension(cert, SEC_OID_X509_SUBJECT_ALT_NAME, + &altNameExtension); + if (rv != SECSuccess) { + PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, + ("BR telemetry: no subject alt names extension for '%s'\n", + commonName.get())); + // 1 means there is no subject alt names extension + Telemetry::Accumulate(Telemetry::BR_9_2_1_SUBJECT_ALT_NAMES, 1); + AccumulateSubjectCommonNameTelemetry(commonName.get(), false); + return; + } + + ScopedPLArenaPool arena(PORT_NewArena(DER_DEFAULT_CHUNKSIZE)); + CERTGeneralName* subjectAltNames = + CERT_DecodeAltNameExtension(arena, &altNameExtension); + // CERT_FindCertExtension takes a pointer to a SECItem and allocates memory + // in its data field. This is a bad way to do this because we can't use a + // ScopedSECItem and neither is that memory tracked by an arena. We have to + // manually reach in and free the memory. + PORT_Free(altNameExtension.data); + if (!subjectAltNames) { + PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, + ("BR telemetry: could not decode subject alt names for '%s'\n", + commonName.get())); + // 2 means the subject alt names extension could not be decoded + Telemetry::Accumulate(Telemetry::BR_9_2_1_SUBJECT_ALT_NAMES, 2); + AccumulateSubjectCommonNameTelemetry(commonName.get(), false); + return; + } + + CERTGeneralName* currentName = subjectAltNames; + bool commonNameInSubjectAltNames = false; + bool nonDNSNameOrIPAddressPresent = false; + bool malformedDNSNameOrIPAddressPresent = false; + bool nonFQDNPresent = false; + do { + nsDependentCString altName; + if (currentName->type == certDNSName) { + altName.Assign(reinterpret_cast(currentName->name.other.data), + currentName->name.other.len); + nsDependentCString altNameWithoutWildcard(altName); + if (altNameWithoutWildcard.Find("*.") == 0) { + altNameWithoutWildcard.Assign(altName.get() + 2, altName.Length() - 2); + commonNameInSubjectAltNames |= + TryMatchingWildcardSubjectAltName(commonName.get(), altName); + } + // net_IsValidHostName appears to return true for valid IP addresses, + // which would be invalid for a DNS name. + // Note that the net_IsValidHostName check will catch things like + // "a.*.example.com". + if (!net_IsValidHostName(altNameWithoutWildcard) || + net_IsValidIPv4Addr(altName.get(), altName.Length()) || + net_IsValidIPv6Addr(altName.get(), altName.Length())) { + PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, + ("BR telemetry: DNSName '%s' not valid (for '%s')\n", + altName.get(), commonName.get())); + malformedDNSNameOrIPAddressPresent = true; + } + if (altName.FindChar('.') == kNotFound) { + nonFQDNPresent = true; + } + } else if (currentName->type == certIPAddress) { + // According to DNS.h, this includes space for the null-terminator + char buf[net::kNetAddrMaxCStrBufSize] = { 0 }; + PRNetAddr addr; + if (currentName->name.other.len == 4) { + addr.inet.family = PR_AF_INET; + memcpy(&addr.inet.ip, currentName->name.other.data, + currentName->name.other.len); + if (PR_NetAddrToString(&addr, buf, sizeof(buf) - 1) != PR_SUCCESS) { + PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, + ("BR telemetry: IPAddress (v4) not valid (for '%s')\n", + commonName.get())); + malformedDNSNameOrIPAddressPresent = true; + } else { + altName.Assign(buf, strlen(buf)); + } + } else if (currentName->name.other.len == 16) { + addr.inet.family = PR_AF_INET6; + memcpy(&addr.ipv6.ip, currentName->name.other.data, + currentName->name.other.len); + if (PR_NetAddrToString(&addr, buf, sizeof(buf) - 1) != PR_SUCCESS) { + PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, + ("BR telemetry: IPAddress (v6) not valid (for '%s')\n", + commonName.get())); + malformedDNSNameOrIPAddressPresent = true; + } else { + altName.Assign(buf, strlen(buf)); + } + } else { + PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, + ("BR telemetry: IPAddress not valid (for '%s')\n", + commonName.get())); + malformedDNSNameOrIPAddressPresent = true; + } + } else { + PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, + ("BR telemetry: non-DNSName, non-IPAddress present for '%s'\n", + commonName.get())); + nonDNSNameOrIPAddressPresent = true; + } + if (commonName && altName.Equals(commonName.get())) { + commonNameInSubjectAltNames = true; + } + currentName = CERT_GetNextGeneralName(currentName); + } while (currentName && currentName != subjectAltNames); + + if (nonDNSNameOrIPAddressPresent) { + // 3 means there's an entry that isn't an ip address or dns name + Telemetry::Accumulate(Telemetry::BR_9_2_1_SUBJECT_ALT_NAMES, 3); + } + if (malformedDNSNameOrIPAddressPresent) { + // 4 means there's a malformed ip address or dns name entry + Telemetry::Accumulate(Telemetry::BR_9_2_1_SUBJECT_ALT_NAMES, 4); + } + if (nonFQDNPresent) { + // 5 means there's a DNS name entry with a non-fully-qualified domain name + Telemetry::Accumulate(Telemetry::BR_9_2_1_SUBJECT_ALT_NAMES, 5); + } + if (!nonDNSNameOrIPAddressPresent && !malformedDNSNameOrIPAddressPresent && + !nonFQDNPresent) { + // 0 means the extension is acceptable + Telemetry::Accumulate(Telemetry::BR_9_2_1_SUBJECT_ALT_NAMES, 0); + } + + AccumulateSubjectCommonNameTelemetry(commonName.get(), + commonNameInSubjectAltNames); +} + SECStatus AuthCertificate(CertVerifier& certVerifier, TransportSecurityInfo* infoObject, @@ -759,10 +972,11 @@ AuthCertificate(CertVerifier& certVerifier, !(providerFlags & nsISocketProvider::NO_PERMANENT_STORAGE); SECOidTag evOidPolicy; + ScopedCERTCertList certList; rv = certVerifier.VerifySSLServerCert(cert, stapledOCSPResponse, time, infoObject, infoObject->GetHostNameRaw(), - saveIntermediates, 0, nullptr, + saveIntermediates, 0, &certList, &evOidPolicy); // We want to remember the CA certs in the temp db, so that the application can find the @@ -782,6 +996,7 @@ AuthCertificate(CertVerifier& certVerifier, } if (rv == SECSuccess) { + GatherBaselineRequirementsTelemetry(certList); // The connection may get terminated, for example, if the server requires // a client cert. Let's provide a minimal SSLStatus // to the caller that contains at least the cert and its status. diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index b1abd651407..708dd3711d6 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -6507,6 +6507,18 @@ "n_buckets": 10, "description": "Sidebar showing: seconds that the sidebar has been opened" }, + "BR_9_2_1_SUBJECT_ALT_NAMES": { + "expires_in_version": "never", + "kind": "enumerated", + "n_values": 8, + "description": "Baseline Requirements section 9.2.1: subject alternative names extension (0: ok, 1 or more: error)" + }, + "BR_9_2_2_SUBJECT_COMMON_NAME": { + "expires_in_version": "never", + "kind": "enumerated", + "n_values": 8, + "description": "Baseline Requirements section 9.2.2: subject common name field (0: present, in subject alt. names; 1: not present; 2: not present in subject alt. names)" + }, "TRACKING_PROTECTION_ENABLED": { "expires_in_version": "never", "kind": "boolean", From 6e755c76a43b4150f8d127bfd0812051b54d3d4d Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Wed, 3 Sep 2014 18:13:35 +1000 Subject: [PATCH 03/68] Bug 1062098: Do not attempt to output dropped frames. r=rillian --- content/media/fmp4/apple/AppleVTDecoder.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/content/media/fmp4/apple/AppleVTDecoder.cpp b/content/media/fmp4/apple/AppleVTDecoder.cpp index 57f20e9ccf8..5f44d9266d2 100644 --- a/content/media/fmp4/apple/AppleVTDecoder.cpp +++ b/content/media/fmp4/apple/AppleVTDecoder.cpp @@ -197,6 +197,7 @@ PlatformCallback(void* decompressionOutputRefCon, } if (flags & kVTDecodeInfo_FrameDropped) { NS_WARNING(" ...frame dropped..."); + return; } MOZ_ASSERT(CFGetTypeID(image) == CVPixelBufferGetTypeID(), "VideoToolbox returned an unexpected image type"); From 966fc103422ce94da02a5501ee2a2df6516928ab Mon Sep 17 00:00:00 2001 From: John Schoenick Date: Wed, 3 Sep 2014 11:25:56 -0700 Subject: [PATCH 04/68] Bug 1062469 - Trailing whitespace plague in nsNPAPIPlugin. r=bsmedberg --- dom/plugins/base/nsNPAPIPlugin.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/dom/plugins/base/nsNPAPIPlugin.cpp b/dom/plugins/base/nsNPAPIPlugin.cpp index 0455b86d619..ad8eb6a814b 100644 --- a/dom/plugins/base/nsNPAPIPlugin.cpp +++ b/dom/plugins/base/nsNPAPIPlugin.cpp @@ -866,7 +866,7 @@ _geturl(NPP npp, const char* relativeURL, const char* target) (strncmp(relativeURL, "ftp:", 4) != 0)) { nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *) npp->ndata; - + const char *name = nullptr; nsRefPtr host = nsPluginHost::GetInst(); host->GetPluginName(inst, &name); @@ -2096,14 +2096,14 @@ _getvalue(NPP npp, NPNVariable variable, void *result) #ifndef NP_NO_QUICKDRAW case NPNVsupportsQuickDrawBool: { *(NPBool*)result = false; - + return NPERR_NO_ERROR; } #endif case NPNVsupportsCoreGraphicsBool: { *(NPBool*)result = true; - + return NPERR_NO_ERROR; } @@ -2173,14 +2173,14 @@ _getvalue(NPP npp, NPNVariable variable, void *result) InitMatrixInterface(i); return NPERR_NO_ERROR; } - + case kPathInterfaceV0_ANPGetValue: { LOG("get path interface"); ANPPathInterfaceV0 *i = (ANPPathInterfaceV0 *) result; InitPathInterface(i); return NPERR_NO_ERROR; } - + case kTypefaceInterfaceV0_ANPGetValue: { LOG("get typeface interface"); ANPTypefaceInterfaceV0 *i = (ANPTypefaceInterfaceV0 *) result; @@ -2236,7 +2236,7 @@ _getvalue(NPP npp, NPNVariable variable, void *result) InitSurfaceInterface(i); return NPERR_NO_ERROR; } - + case kSupportedDrawingModel_ANPGetValue: { LOG("get supported drawing model"); uint32_t* bits = reinterpret_cast(result); From f4bd17973561861e109f978c5593dd642f4effdf Mon Sep 17 00:00:00 2001 From: John Schoenick Date: Tue, 25 Feb 2014 15:54:57 -0800 Subject: [PATCH 05/68] Bug 1062469 - Remove obsolete OOM check in nsNPAPIPlugin. r=bsmedberg --- dom/plugins/base/nsNPAPIPlugin.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/dom/plugins/base/nsNPAPIPlugin.cpp b/dom/plugins/base/nsNPAPIPlugin.cpp index ad8eb6a814b..9420b62ac65 100644 --- a/dom/plugins/base/nsNPAPIPlugin.cpp +++ b/dom/plugins/base/nsNPAPIPlugin.cpp @@ -410,8 +410,6 @@ nsNPAPIPlugin::CreatePlugin(nsPluginTag *aPluginTag, nsNPAPIPlugin** aResult) CheckClassInitialized(); nsRefPtr plugin = new nsNPAPIPlugin(); - if (!plugin) - return NS_ERROR_OUT_OF_MEMORY; PluginLibrary* pluginLib = GetNewPluginLibrary(aPluginTag); if (!pluginLib) { From db885444502410e11b9fcb69858a160e617b8974 Mon Sep 17 00:00:00 2001 From: John Schoenick Date: Tue, 25 Feb 2014 15:55:07 -0800 Subject: [PATCH 06/68] Bug 1062469 - Don't leak pluginLib in nsNPAPIPlugin error path. r=bsmedberg --- dom/plugins/base/nsNPAPIPlugin.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/dom/plugins/base/nsNPAPIPlugin.cpp b/dom/plugins/base/nsNPAPIPlugin.cpp index 9420b62ac65..c3e722db257 100644 --- a/dom/plugins/base/nsNPAPIPlugin.cpp +++ b/dom/plugins/base/nsNPAPIPlugin.cpp @@ -419,6 +419,7 @@ nsNPAPIPlugin::CreatePlugin(nsPluginTag *aPluginTag, nsNPAPIPlugin** aResult) #if defined(XP_MACOSX) || defined(MOZ_WIDGET_ANDROID) if (!pluginLib->HasRequiredFunctions()) { NS_WARNING("Not all necessary functions exposed by plugin, it will not load."); + delete pluginLib; return NS_ERROR_FAILURE; } #endif From ccebd554ec66439efe3e6597e227763294d59c1d Mon Sep 17 00:00:00 2001 From: Milan Sreckovic Date: Wed, 3 Sep 2014 15:11:55 -0400 Subject: [PATCH 07/68] Bug 1033098: Wallpaper over the intermittent crash. r=nsilva --- gfx/gl/GLBlitTextureImageHelper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/gl/GLBlitTextureImageHelper.cpp b/gfx/gl/GLBlitTextureImageHelper.cpp index 58494eb5c78..4fb50d3cfc8 100644 --- a/gfx/gl/GLBlitTextureImageHelper.cpp +++ b/gfx/gl/GLBlitTextureImageHelper.cpp @@ -38,7 +38,7 @@ GLBlitTextureImageHelper::BlitTextureImage(TextureImage *aSrc, const nsIntRect& NS_ASSERTION(!aSrc->InUpdate(), "Source texture is in update!"); NS_ASSERTION(!aDst->InUpdate(), "Destination texture is in update!"); - if (aSrcRect.IsEmpty() || aDstRect.IsEmpty()) + if (!aSrc || !aDst || aSrcRect.IsEmpty() || aDstRect.IsEmpty()) return; int savedFb = 0; From e1449f689d70d7ad1b0811ff852396c4100b127d Mon Sep 17 00:00:00 2001 From: Botond Ballo Date: Tue, 2 Sep 2014 19:15:52 -0400 Subject: [PATCH 08/68] Bug 1061976 - Remove background-drawing for overscrolled layers. r=BenWa --- .../composite/ContainerLayerComposite.cpp | 36 ------------------- 1 file changed, 36 deletions(-) diff --git a/gfx/layers/composite/ContainerLayerComposite.cpp b/gfx/layers/composite/ContainerLayerComposite.cpp index 4396c1d88c2..d2bbbd6c4d9 100644 --- a/gfx/layers/composite/ContainerLayerComposite.cpp +++ b/gfx/layers/composite/ContainerLayerComposite.cpp @@ -257,42 +257,6 @@ RenderLayers(ContainerT* aContainer, { Compositor* compositor = aManager->GetCompositor(); - float opacity = aContainer->GetEffectiveOpacity(); - - // If this is a scrollable container layer, and it's overscrolled, the layer's - // contents are transformed in a way that would leave blank regions in the - // composited area. If the layer has a background color, fill these areas - // with the background color by drawing a rectangle of the background color - // over the entire composited area before drawing the container contents. - // Make sure not to do this on a "scrollinfo" layer because it's just a - // placeholder for APZ purposes. - if (aContainer->HasScrollableFrameMetrics() && !aContainer->IsScrollInfoLayer()) { - bool overscrolled = false; - gfxRGBA color; - for (uint32_t i = 0; i < aContainer->GetFrameMetricsCount(); i++) { - AsyncPanZoomController* apzc = aContainer->GetAsyncPanZoomController(i); - if (apzc && apzc->IsOverscrolled()) { - overscrolled = true; - color = aContainer->GetFrameMetrics(i).GetBackgroundColor(); - break; - } - } - if (overscrolled) { - // If the background is completely transparent, there's no point in - // drawing anything for it. Hopefully the layers behind, if any, will - // provide suitable content for the overscroll effect. - if (color.a != 0.0) { - EffectChain effectChain(aContainer); - effectChain.mPrimaryEffect = new EffectSolidColor(ToColor(color)); - gfx::Rect clipRect(aClipRect.x, aClipRect.y, aClipRect.width, aClipRect.height); - compositor->DrawQuad( - RenderTargetPixel::ToUnknown( - compositor->ClipRectInLayersCoordinates(aContainer, aClipRect)), - clipRect, effectChain, opacity, Matrix4x4()); - } - } - } - for (size_t i = 0u; i < aContainer->mPrepared->mLayers.Length(); i++) { PreparedLayer& preparedData = aContainer->mPrepared->mLayers[i]; LayerComposite* layerToRender = preparedData.mLayer; From 81fd150c8dd479adf37915a82147db88a592329f Mon Sep 17 00:00:00 2001 From: Botond Ballo Date: Tue, 2 Sep 2014 20:39:40 -0400 Subject: [PATCH 09/68] Bug 1061976 - Reinstate APZ gtests for overscrolling during panning. r=BenWa --- .../gtest/TestAsyncPanZoomController.cpp | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/gfx/tests/gtest/TestAsyncPanZoomController.cpp b/gfx/tests/gtest/TestAsyncPanZoomController.cpp index fb2af5af330..4336ca9da49 100644 --- a/gfx/tests/gtest/TestAsyncPanZoomController.cpp +++ b/gfx/tests/gtest/TestAsyncPanZoomController.cpp @@ -934,6 +934,93 @@ TEST_F(APZCBasicTester, FlingIntoOverscroll) { EXPECT_TRUE(recoveredFromOverscroll); } +TEST_F(APZCBasicTester, OverScrollPanning) { + SCOPED_GFX_PREF(APZOverscrollEnabled, bool, true); + + // Pan sufficiently to hit overscroll behavior + int time = 0; + int touchStart = 500; + int touchEnd = 10; + ApzcPan(apzc, time, touchStart, touchEnd); + EXPECT_TRUE(apzc->IsOverscrolled()); + + // Note that in the calls to SampleContentTransformForFrame below, the time + // increment used is sufficiently large for the animation to have completed. However, + // any single call to SampleContentTransformForFrame will not finish an animation + // *and* also proceed through the following animation, if there is one. + // Therefore the minimum number of calls to go from an overscroll-inducing pan + // to a reset state is 3; these are documented further below. + + ScreenPoint pointOut; + ViewTransform viewTransformOut; + + // This sample will run to the end of the non-overscrolling fling animation + // and will schedule the overscrolling fling animation. + apzc->SampleContentTransformForFrame(testStartTime + TimeDuration::FromMilliseconds(10000), &viewTransformOut, pointOut); + EXPECT_EQ(ScreenPoint(0, 90), pointOut); + EXPECT_TRUE(apzc->IsOverscrolled()); + + // This sample will run to the end of the overscrolling fling animation and + // will schedule the snapback animation. + apzc->SampleContentTransformForFrame(testStartTime + TimeDuration::FromMilliseconds(20000), &viewTransformOut, pointOut); + EXPECT_EQ(ScreenPoint(0, 90), pointOut); + EXPECT_TRUE(apzc->IsOverscrolled()); + + // This sample will run to the end of the snapback animation and reset the state. + apzc->SampleContentTransformForFrame(testStartTime + TimeDuration::FromMilliseconds(30000), &viewTransformOut, pointOut); + EXPECT_EQ(ScreenPoint(0, 90), pointOut); + EXPECT_FALSE(apzc->IsOverscrolled()); + + apzc->AssertStateIsReset(); +} + +TEST_F(APZCBasicTester, OverScrollAbort) { + SCOPED_GFX_PREF(APZOverscrollEnabled, bool, true); + + // Pan sufficiently to hit overscroll behavior + int time = 0; + int touchStart = 500; + int touchEnd = 10; + ApzcPan(apzc, time, touchStart, touchEnd); + EXPECT_TRUE(apzc->IsOverscrolled()); + + ScreenPoint pointOut; + ViewTransform viewTransformOut; + + // This sample call will run to the end of the non-overscrolling fling animation + // and will schedule the overscrolling fling animation (see comment in OverScrollPanning + // above for more explanation). + apzc->SampleContentTransformForFrame(testStartTime + TimeDuration::FromMilliseconds(10000), &viewTransformOut, pointOut); + EXPECT_TRUE(apzc->IsOverscrolled()); + + // At this point, we have an active overscrolling fling animation. + // Check that cancelling the animation clears the overscroll. + apzc->CancelAnimation(); + EXPECT_FALSE(apzc->IsOverscrolled()); + apzc->AssertStateIsReset(); +} + +TEST_F(APZCBasicTester, OverScrollPanningAbort) { + SCOPED_GFX_PREF(APZOverscrollEnabled, bool, true); + + // Pan sufficiently to hit overscroll behaviour. Keep the finger down so + // the pan does not end. + int time = 0; + int touchStart = 500; + int touchEnd = 10; + ApzcPan(apzc, time, touchStart, touchEnd, + true); // keep finger down + EXPECT_TRUE(apzc->IsOverscrolled()); + + // Check that calling CancelAnimation() while the user is still panning + // (and thus no fling or snap-back animation has had a chance to start) + // clears the overscroll. + apzc->CancelAnimation(); + EXPECT_FALSE(apzc->IsOverscrolled()); + apzc->AssertStateIsReset(); +} + + class APZCFlingStopTester : public APZCGestureDetectorTester { protected: // Start a fling, and then tap while the fling is ongoing. When From c5fd4830208a43d826615a10693219d283a770c6 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Wed, 3 Sep 2014 13:02:36 -0700 Subject: [PATCH 10/68] Bug 1051224 - Add an opt-out for cross-origin argument checking. r=gabor --- js/xpconnect/src/ExportHelpers.cpp | 41 +++++++++++++++---- js/xpconnect/src/XPCComponents.cpp | 3 +- js/xpconnect/src/xpcprivate.h | 38 ++++++++++++++++- .../tests/unit/test_exportFunction.js | 10 +++++ 4 files changed, 82 insertions(+), 10 deletions(-) diff --git a/js/xpconnect/src/ExportHelpers.cpp b/js/xpconnect/src/ExportHelpers.cpp index 2ea1675929b..37a2dca7094 100644 --- a/js/xpconnect/src/ExportHelpers.cpp +++ b/js/xpconnect/src/ExportHelpers.cpp @@ -83,8 +83,12 @@ StackScopedCloneRead(JSContext *cx, JSStructuredCloneReader *reader, uint32_t ta if (!JS_WrapObject(cx, &obj)) return nullptr; - if (!xpc::NewFunctionForwarder(cx, JSID_VOIDHANDLE, obj, &functionValue)) + FunctionForwarderOptions forwarderOptions; + if (!xpc::NewFunctionForwarder(cx, JSID_VOIDHANDLE, obj, forwarderOptions, + &functionValue)) + { return nullptr; + } return &functionValue.toObject(); } @@ -200,8 +204,13 @@ StackScopedClone(JSContext *cx, StackScopedCloneOptions &options, // Note - This function mirrors the logic of CheckPassToChrome in // ChromeObjectWrapper.cpp. static bool -CheckSameOriginArg(JSContext *cx, HandleValue v) +CheckSameOriginArg(JSContext *cx, FunctionForwarderOptions &options, HandleValue v) { + // Consumers can explicitly opt out of this security check. This is used in + // the web console to allow the utility functions to accept cross-origin Windows. + if (options.allowCrossOriginArguments) + return true; + // Primitives are fine. if (!v.isObject()) return true; @@ -232,6 +241,13 @@ FunctionForwarder(JSContext *cx, unsigned argc, Value *vp) { CallArgs args = CallArgsFromVp(argc, vp); + // Grab the options from the reserved slot. + RootedObject optionsObj(cx, &js::GetFunctionNativeReserved(&args.callee(), 1).toObject()); + FunctionForwarderOptions options(cx, optionsObj); + if (!options.Parse()) + return false; + + // Grab and unwrap the underlying callable. RootedValue v(cx, js::GetFunctionNativeReserved(&args.callee(), 0)); RootedObject unwrappedFun(cx, js::UncheckedUnwrap(&v.toObject())); @@ -247,11 +263,11 @@ FunctionForwarder(JSContext *cx, unsigned argc, Value *vp) JSAutoCompartment ac(cx, unwrappedFun); RootedValue thisVal(cx, ObjectValue(*thisObj)); - if (!CheckSameOriginArg(cx, thisVal) || !JS_WrapObject(cx, &thisObj)) + if (!CheckSameOriginArg(cx, options, thisVal) || !JS_WrapObject(cx, &thisObj)) return false; for (size_t n = 0; n < args.length(); ++n) { - if (!CheckSameOriginArg(cx, args[n]) || !JS_WrapValue(cx, args[n])) + if (!CheckSameOriginArg(cx, options, args[n]) || !JS_WrapValue(cx, args[n])) return false; } @@ -266,7 +282,7 @@ FunctionForwarder(JSContext *cx, unsigned argc, Value *vp) bool NewFunctionForwarder(JSContext *cx, HandleId idArg, HandleObject callable, - MutableHandleValue vp) + FunctionForwarderOptions &options, MutableHandleValue vp) { RootedId id(cx, idArg); if (id == JSID_VOIDHANDLE) @@ -277,8 +293,17 @@ NewFunctionForwarder(JSContext *cx, HandleId idArg, HandleObject callable, if (!fun) return false; - JSObject *funobj = JS_GetFunctionObject(fun); + // Stash the callable in slot 0. + AssertSameCompartment(cx, callable); + RootedObject funobj(cx, JS_GetFunctionObject(fun)); js::SetFunctionNativeReserved(funobj, 0, ObjectValue(*callable)); + + // Stash the options in slot 1. + RootedObject optionsObj(cx, options.ToJSObject(cx)); + if (!optionsObj) + return false; + js::SetFunctionNativeReserved(funobj, 1, ObjectValue(*optionsObj)); + vp.setObject(*funobj); return true; } @@ -349,7 +374,9 @@ ExportFunction(JSContext *cx, HandleValue vfunction, HandleValue vscope, HandleV // And now, let's create the forwarder function in the target compartment // for the function the be exported. - if (!NewFunctionForwarder(cx, id, funObj, rval)) { + FunctionForwarderOptions forwarderOptions; + forwarderOptions.allowCrossOriginArguments = options.allowCrossOriginArguments; + if (!NewFunctionForwarder(cx, id, funObj, forwarderOptions, rval)) { JS_ReportError(cx, "Exporting function failed"); return false; } diff --git a/js/xpconnect/src/XPCComponents.cpp b/js/xpconnect/src/XPCComponents.cpp index f3092450534..44389237acf 100644 --- a/js/xpconnect/src/XPCComponents.cpp +++ b/js/xpconnect/src/XPCComponents.cpp @@ -3071,7 +3071,8 @@ nsXPCComponents_Utils::MakeObjectPropsNormal(HandleValue vobj, JSContext *cx) if (!js::IsWrapper(propobj) || !JS_ObjectIsCallable(cx, propobj)) continue; - if (!NewFunctionForwarder(cx, id, propobj, &v) || + FunctionForwarderOptions forwarderOptions; + if (!NewFunctionForwarder(cx, id, propobj, forwarderOptions, &v) || !JS_SetPropertyById(cx, obj, id, v)) return NS_ERROR_FAILURE; } diff --git a/js/xpconnect/src/xpcprivate.h b/js/xpconnect/src/xpcprivate.h index 1546122479c..53e2c4ac11c 100644 --- a/js/xpconnect/src/xpcprivate.h +++ b/js/xpconnect/src/xpcprivate.h @@ -3363,9 +3363,10 @@ Btoa(JSContext *cx, unsigned argc, jsval *vp); // Helper function that creates a JSFunction that wraps a native function that // forwards the call to the original 'callable'. +class FunctionForwarderOptions; bool NewFunctionForwarder(JSContext *cx, JS::HandleId id, JS::HandleObject callable, - JS::MutableHandleValue vp); + FunctionForwarderOptions &options, JS::MutableHandleValue vp); // Old fashioned xpc error reporter. Try to use JS_ReportError instead. nsresult @@ -3479,13 +3480,46 @@ public: JSObject* options = nullptr) : OptionsBase(cx, options) , defineAs(cx, JSID_VOID) + , allowCrossOriginArguments(false) { } virtual bool Parse() { - return ParseId("defineAs", &defineAs); + return ParseId("defineAs", &defineAs) && + ParseBoolean("allowCrossOriginArguments", &allowCrossOriginArguments); } JS::RootedId defineAs; + bool allowCrossOriginArguments; +}; + +class MOZ_STACK_CLASS FunctionForwarderOptions : public OptionsBase { +public: + explicit FunctionForwarderOptions(JSContext *cx = xpc_GetSafeJSContext(), + JSObject* options = nullptr) + : OptionsBase(cx, options) + , allowCrossOriginArguments(false) + { } + + JSObject *ToJSObject(JSContext *cx) { + JS::RootedObject global(cx, JS::CurrentGlobalOrNull(cx)); + JS::RootedObject obj(cx, JS_NewObjectWithGivenProto(cx, nullptr, JS::NullPtr(), global)); + if (!obj) + return nullptr; + + JS::RootedValue val(cx); + unsigned attrs = JSPROP_READONLY | JSPROP_PERMANENT; + val = JS::BooleanValue(allowCrossOriginArguments); + if (!JS_DefineProperty(cx, obj, "allowCrossOriginArguments", val, attrs)) + return nullptr; + + return obj; + } + + virtual bool Parse() { + return ParseBoolean("allowCrossOriginArguments", &allowCrossOriginArguments); + } + + bool allowCrossOriginArguments; }; class MOZ_STACK_CLASS StackScopedCloneOptions : public OptionsBase { diff --git a/js/xpconnect/tests/unit/test_exportFunction.js b/js/xpconnect/tests/unit/test_exportFunction.js index 218ffdcbc13..830816342b2 100644 --- a/js/xpconnect/tests/unit/test_exportFunction.js +++ b/js/xpconnect/tests/unit/test_exportFunction.js @@ -35,6 +35,7 @@ function run_test() { wasCalled = false; } exportFunction(funToExport, subsb, { defineAs: "imported", allowCallbacks: true }); + exportFunction((x) => x, subsb, { defineAs: "echoAllowXO", allowCallbacks: true, allowCrossOriginArguments: true }); }.toSource() + ")()", epsb); subsb.xrayed = Cu.evalInSandbox("(" + function () { @@ -64,6 +65,15 @@ function run_test() { do_check_true(/denied|insecure/.test(e)); } + // Callers can opt-out of the above. + subsb.xoNative = Cu.evalInSandbox('new XMLHttpRequest()', xorigsb); + try { + do_check_eq(Cu.evalInSandbox('echoAllowXO(xoNative)', subsb), subsb.xoNative); + do_check_true(true); + } catch (e) { + do_check_true(false); + } + // Apply should work and |this| should carry over appropriately. Cu.evalInSandbox("(" + function() { var someThis = {}; From ec4a87485a76a9e5a99f6d74e3eec97a1c2f784b Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Wed, 3 Sep 2014 13:02:36 -0700 Subject: [PATCH 11/68] Bug 1051224 - Use the opt-out for the webconsole helpers. r=ochameau --- toolkit/devtools/server/actors/webconsole.js | 26 +++++++++++++++++--- toolkit/devtools/webconsole/utils.js | 2 +- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/toolkit/devtools/server/actors/webconsole.js b/toolkit/devtools/server/actors/webconsole.js index a42d502a785..eac1b1b8c6f 100644 --- a/toolkit/devtools/server/actors/webconsole.js +++ b/toolkit/devtools/server/actors/webconsole.js @@ -933,13 +933,31 @@ WebConsoleActor.prototype = }; JSTermHelpers(helpers); - // Make sure the helpers can be used during eval. + let evalWindow = this.evalWindow; + function maybeExport(obj, name) { + if (typeof obj[name] != "function") { + return; + } + + // By default, chrome-implemented functions that are exposed to content + // refuse to accept arguments that are cross-origin for the caller. This + // is generally the safe thing, but causes problems for certain console + // helpers like cd(), where we users sometimes want to pass a cross-origin + // window. To circumvent this restriction, we use exportFunction along + // with a special option designed for this purpose. See bug 1051224. + obj[name] = + Cu.exportFunction(obj[name], evalWindow, { allowCrossOriginArguments: true }); + } for (let name in helpers.sandbox) { let desc = Object.getOwnPropertyDescriptor(helpers.sandbox, name); - if (desc.get || desc.set) { - continue; + maybeExport(desc, 'get'); + maybeExport(desc, 'set'); + maybeExport(desc, 'value'); + if (desc.value) { + // Make sure the helpers can be used during eval. + desc.value = aDebuggerGlobal.makeDebuggeeValue(desc.value); } - helpers.sandbox[name] = aDebuggerGlobal.makeDebuggeeValue(desc.value); + Object.defineProperty(helpers.sandbox, name, desc); } return helpers; }, diff --git a/toolkit/devtools/webconsole/utils.js b/toolkit/devtools/webconsole/utils.js index 335b2c49d71..c3e1f70ed6e 100644 --- a/toolkit/devtools/webconsole/utils.js +++ b/toolkit/devtools/webconsole/utils.js @@ -1583,7 +1583,7 @@ function JSTermHelpers(aOwner) return aOwner.makeDebuggeeValue(aOwner.selectedNode) }, enumerable: true, - configurable: false + configurable: true }); /** From 94c0c31d3c4491ef41cd000a6904d89aad36369d Mon Sep 17 00:00:00 2001 From: Alexandre Poirot Date: Wed, 3 Sep 2014 13:02:37 -0700 Subject: [PATCH 12/68] Bug 1051224 - Test console's cd() against sandboxed iframes. r=msucan --- toolkit/devtools/webconsole/test/chrome.ini | 1 + toolkit/devtools/webconsole/test/common.js | 3 + .../webconsole/test/sandboxed_iframe.html | 8 +++ .../test/test_jsterm_cd_iframe.html | 71 ++++++++++++++++++- 4 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 toolkit/devtools/webconsole/test/sandboxed_iframe.html diff --git a/toolkit/devtools/webconsole/test/chrome.ini b/toolkit/devtools/webconsole/test/chrome.ini index 07a654d1926..67f69c032b8 100644 --- a/toolkit/devtools/webconsole/test/chrome.ini +++ b/toolkit/devtools/webconsole/test/chrome.ini @@ -4,6 +4,7 @@ support-files = data.json data.json^headers^ network_requests_iframe.html + sandboxed_iframe.html [test_basics.html] [test_bug819670_getter_throws.html] diff --git a/toolkit/devtools/webconsole/test/common.js b/toolkit/devtools/webconsole/test/common.js index 17854dd1a28..051876240fd 100644 --- a/toolkit/devtools/webconsole/test/common.js +++ b/toolkit/devtools/webconsole/test/common.js @@ -120,6 +120,9 @@ function checkValue(aName, aValue, aExpected) else if (aValue === undefined) { ok(false, "'" + aName + "' is undefined"); } + else if (aValue === null) { + ok(false, "'" + aName + "' is null"); + } else if (typeof aExpected == "string" || typeof aExpected == "number" || typeof aExpected == "boolean") { is(aValue, aExpected, "property '" + aName + "'"); diff --git a/toolkit/devtools/webconsole/test/sandboxed_iframe.html b/toolkit/devtools/webconsole/test/sandboxed_iframe.html new file mode 100644 index 00000000000..55a6224b508 --- /dev/null +++ b/toolkit/devtools/webconsole/test/sandboxed_iframe.html @@ -0,0 +1,8 @@ + +Sandboxed iframe + + + + diff --git a/toolkit/devtools/webconsole/test/test_jsterm_cd_iframe.html b/toolkit/devtools/webconsole/test/test_jsterm_cd_iframe.html index 3091612babd..034e99ff485 100644 --- a/toolkit/devtools/webconsole/test/test_jsterm_cd_iframe.html +++ b/toolkit/devtools/webconsole/test/test_jsterm_cd_iframe.html @@ -11,6 +11,8 @@

Test for the cd() function

+ + + + + + + + + Mozilla Bug 1056459 + + +

+ +
+      
+ + + +
+ From ff935cce160023231983cee115f2493c32b09257 Mon Sep 17 00:00:00 2001 From: Daniel Holbert Date: Wed, 3 Sep 2014 15:15:38 -0700 Subject: [PATCH 21/68] Bug 1061970 followup: roll back "for...of" change, to fix test failures / crashes. CLOSED TREE --- toolkit/components/contentprefs/ContentPrefService2.jsm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toolkit/components/contentprefs/ContentPrefService2.jsm b/toolkit/components/contentprefs/ContentPrefService2.jsm index f6c3866fdcb..1b4343edb72 100644 --- a/toolkit/components/contentprefs/ContentPrefService2.jsm +++ b/toolkit/components/contentprefs/ContentPrefService2.jsm @@ -655,7 +655,7 @@ ContentPrefService2.prototype = { destroy: function CPS2_destroy() { if (this._statements) { - for (let stmt of this._statements) { + for each (let stmt in this._statements) { stmt.finalize(); } } From fc99c53ae510693c2caae7d26c9b4fe1a7f1f974 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Wed, 3 Sep 2014 14:10:54 +0900 Subject: [PATCH 22/68] Bug 1041941 - Use templates for programs, simple programs, libraries and C++ unit tests. r=gps --- accessible/interfaces/ia2/moz.build | 2 +- accessible/interfaces/msaa/moz.build | 2 +- b2g/app/moz.build | 4 +- b2g/gaia/moz.build | 2 +- browser/app/moz.build | 2 +- .../shell/commandexecutehandler/moz.build | 2 +- browser/metro/shell/linktool/moz.build | 2 +- browser/metro/shell/testing/moz.build | 2 +- build/docs/defining-binaries.rst | 63 ++++++----- build/stlport/moz.build | 2 +- build/templates.mozbuild | 51 +++++++++ build/unix/elfhack/moz.build | 2 +- build/unix/stdc++compat/moz.build | 4 +- build/win32/crashinjectdll/moz.build | 2 +- build/win32/moz.build | 2 +- build/win32/vmwarerecordinghelper/moz.build | 2 +- config/external/ffi/moz.build | 2 +- config/external/freetype2/moz.build | 2 +- config/external/icu/moz.build | 2 +- config/external/nspr/moz.build | 2 +- config/external/nss/crmf/moz.build | 2 +- config/external/nss/moz.build | 2 +- config/external/sqlite/moz.build | 2 +- config/external/zlib/moz.build | 2 +- config/moz.build | 2 +- content/base/test/moz.build | 4 +- content/media/compiledtest/moz.build | 4 +- content/media/webaudio/compiledtest/moz.build | 4 +- dom/audiochannel/tests/moz.build | 4 +- dom/bindings/test/moz.build | 2 +- dom/canvas/compiledtest/moz.build | 4 +- dom/media/gmp-plugin/moz.build | 2 +- dom/plugins/ipc/hangui/moz.build | 2 +- dom/plugins/ipc/interpose/moz.build | 2 +- .../test/testplugin/javaplugin/moz.build | 2 +- dom/plugins/test/testplugin/moz.build | 2 +- .../test/testplugin/secondplugin/moz.build | 2 +- editor/txmgr/tests/moz.build | 4 +- embedding/tests/winEmbed/moz.build | 2 +- gfx/angle/src/libEGL/moz.build | 2 +- gfx/angle/src/libGLESv2/moz.build | 2 +- intl/lwbrk/tests/moz.build | 4 +- intl/uconv/tools/moz.build | 4 +- intl/unicharutil/tests/moz.build | 4 +- intl/unicharutil/tools/moz.build | 2 +- intl/unicharutil/util/moz.build | 2 +- ipc/app/moz.build | 2 +- ipc/contentproc/moz.build | 2 +- ipc/ipdl/test/cxx/app/moz.build | 2 +- js/src/editline/moz.build | 2 +- js/src/gdb/moz.build | 2 +- js/src/jsapi-tests/moz.build | 2 +- js/src/moz.build | 6 +- js/src/shell/moz.build | 2 +- js/xpconnect/shell/moz.build | 2 +- layout/media/moz.build | 2 +- layout/media/webrtc/moz.build | 2 +- layout/style/test/moz.build | 4 +- media/libcubeb/src/moz.build | 2 +- media/libcubeb/tests/moz.build | 8 +- media/libpng/moz.build | 2 +- media/libspeex_resampler/src/moz.build | 2 +- media/libvpx/moz.build | 2 +- media/mtransport/standalone/moz.build | 2 +- media/mtransport/test/moz.build | 8 +- media/omx-plugin/froyo/moz.build | 2 +- media/omx-plugin/gb/moz.build | 2 +- media/omx-plugin/gb235/moz.build | 2 +- media/omx-plugin/hc/moz.build | 2 +- media/omx-plugin/kk/moz.build | 2 +- .../lib/froyo/libstagefright/moz.build | 2 +- .../lib/gb/libstagefright/moz.build | 2 +- .../libstagefright_color_conversion/moz.build | 2 +- media/omx-plugin/lib/gb/libutils/moz.build | 2 +- .../lib/gb235/libstagefright/moz.build | 2 +- .../lib/hc/libstagefright/moz.build | 2 +- .../lib/ics/libstagefright/moz.build | 2 +- media/omx-plugin/lib/ics/libutils/moz.build | 2 +- .../lib/ics/libvideoeditorplayer/moz.build | 2 +- media/omx-plugin/moz.build | 2 +- media/webrtc/signaling/test/moz.build | 4 +- memory/build/moz.build | 2 +- memory/jemalloc/moz.build | 2 +- memory/mozalloc/moz.build | 2 +- memory/mozalloc/tests/moz.build | 4 +- memory/mozjemalloc/moz.build | 2 +- memory/replace/dmd/moz.build | 2 +- memory/replace/dummy/moz.build | 2 +- memory/replace/jemalloc/moz.build | 2 +- mfbt/moz.build | 2 +- mfbt/tests/moz.build | 8 +- modules/libbz2/src/moz.build | 4 +- modules/libmar/sign/moz.build | 2 +- modules/libmar/src/moz.build | 4 +- modules/libmar/tool/moz.build | 4 +- modules/libmar/verify/moz.build | 2 +- mozglue/build/moz.build | 2 +- mozglue/linker/moz.build | 4 +- mozglue/linker/tests/moz.build | 4 +- mozglue/tests/moz.build | 4 +- netwerk/sctp/src/moz.build | 2 +- netwerk/srtp/src/moz.build | 2 +- netwerk/streamconv/test/moz.build | 2 +- netwerk/test/moz.build | 8 +- other-licenses/bsdiff/moz.build | 2 +- profile/dirserviceprovider/moz.build | 2 +- python/mozbuild/mozbuild/frontend/context.py | 107 +++++++++++++++++- .../mozbuild/mozbuild/frontend/gyp_reader.py | 7 +- python/mozbuild/mozbuild/frontend/reader.py | 12 +- .../test/backend/data/visual-studio/moz.build | 2 +- .../test/frontend/data/program/moz.build | 13 ++- rdf/tests/rdfcat/moz.build | 2 +- rdf/tests/rdfpoll/moz.build | 2 +- rdf/tests/triplescat/moz.build | 2 +- rdf/util/moz.build | 2 +- security/manager/ssl/tests/compiled/moz.build | 4 +- .../ssl/tests/unit/pkcs11testmodule/moz.build | 2 +- .../ssl/tests/unit/tlsserver/cmd/moz.build | 4 +- .../ssl/tests/unit/tlsserver/lib/moz.build | 2 +- security/pkix/moz.build | 2 +- security/pkix/test/lib/moz.build | 2 +- security/sandbox/linux/moz.build | 2 +- security/sandbox/moz.build | 2 +- security/sandbox/staticruntime/moz.build | 2 +- .../sandbox/win/src/sandboxbroker/moz.build | 2 +- startupcache/test/moz.build | 4 +- storage/test/moz.build | 8 +- testing/gtest/moz.build | 2 +- testing/mochitest/ssltunnel/moz.build | 2 +- testing/tools/screenshot/moz.build | 4 +- toolkit/components/ctypes/tests/moz.build | 2 +- .../components/maintenanceservice/moz.build | 2 +- toolkit/components/places/tests/cpp/moz.build | 4 +- .../breakpad-windows-libxul/moz.build | 2 +- .../staticruntime/moz.build | 2 +- toolkit/crashreporter/client/moz.build | 2 +- .../src/common/dwarf/moz.build | 2 +- .../src/common/linux/moz.build | 4 +- .../google-breakpad/src/common/mac/moz.build | 4 +- .../google-breakpad/src/common/moz.build | 4 +- .../src/common/solaris/moz.build | 4 +- .../src/tools/linux/dump_syms/moz.build | 2 +- .../src/tools/mac/dump_syms/moz.build | 2 +- .../src/tools/solaris/dump_syms/moz.build | 2 +- toolkit/crashreporter/injector/moz.build | 2 +- toolkit/crashreporter/test/moz.build | 2 +- .../library/StaticXULComponentsEnd/moz.build | 2 +- toolkit/library/gtest/moz.build | 2 +- toolkit/library/moz.build | 2 +- toolkit/mozapps/plugins/tests/moz.build | 4 +- .../update/common-standalone/moz.build | 2 +- toolkit/mozapps/update/common/moz.build | 2 +- toolkit/mozapps/update/tests/moz.build | 4 +- toolkit/mozapps/update/updater/moz.build | 2 +- toolkit/webapps/tests/moz.build | 2 +- toolkit/xre/test/win/moz.build | 8 +- tools/jprof/moz.build | 2 +- tools/jprof/stub/moz.build | 2 +- tools/trace-malloc/moz.build | 6 +- uriloader/exthandler/tests/moz.build | 4 +- webapprt/gtk/moz.build | 2 +- webapprt/mac/moz.build | 2 +- webapprt/win/moz.build | 2 +- widget/gonk/libdisplay/moz.build | 2 +- widget/gtk/mozgtk/gtk2/moz.build | 2 +- widget/gtk/mozgtk/gtk3/moz.build | 2 +- widget/gtk/mozgtk/stub/moz.build | 2 +- widget/tests/moz.build | 4 +- widget/xremoteclient/moz.build | 2 +- xpcom/glue/moz.build | 2 +- xpcom/glue/nomozalloc/moz.build | 2 +- xpcom/glue/standalone/moz.build | 2 +- xpcom/glue/standalone/staticruntime/moz.build | 2 +- xpcom/glue/staticruntime/moz.build | 2 +- xpcom/reflect/xptcall/md/test/moz.build | 4 +- xpcom/reflect/xptcall/tests/moz.build | 4 +- xpcom/reflect/xptinfo/tests/moz.build | 4 +- xpcom/sample/program/moz.build | 4 +- xpcom/tests/external/moz.build | 4 +- xpcom/tests/moz.build | 24 ++-- xpcom/tests/windows/moz.build | 4 +- xpcom/typelib/xpt/moz.build | 2 +- xpcom/typelib/xpt/tests/moz.build | 4 +- xpcom/windbgdlg/moz.build | 4 +- xulrunner/app/moz.build | 2 +- xulrunner/stub/moz.build | 2 +- xulrunner/tools/redit/moz.build | 2 +- 187 files changed, 468 insertions(+), 295 deletions(-) diff --git a/accessible/interfaces/ia2/moz.build b/accessible/interfaces/ia2/moz.build index 6c73a1a2bf5..3aae77cd38b 100644 --- a/accessible/interfaces/ia2/moz.build +++ b/accessible/interfaces/ia2/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -LIBRARY_NAME = 'IA2Marshal' +Library('IA2Marshal') FORCE_SHARED_LIB = True diff --git a/accessible/interfaces/msaa/moz.build b/accessible/interfaces/msaa/moz.build index 94ed2889cc4..e6d5f2f0937 100644 --- a/accessible/interfaces/msaa/moz.build +++ b/accessible/interfaces/msaa/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -LIBRARY_NAME = 'AccessibleMarshal' +Library('AccessibleMarshal') GENERATED_SOURCES += [ 'dlldata.c', diff --git a/b2g/app/moz.build b/b2g/app/moz.build index abc17ee4512..948e70a00e8 100644 --- a/b2g/app/moz.build +++ b/b2g/app/moz.build @@ -6,9 +6,9 @@ if not CONFIG['LIBXUL_SDK']: if CONFIG['GAIADIR']: - PROGRAM = CONFIG['MOZ_APP_NAME'] + "-bin" + Program(CONFIG['MOZ_APP_NAME'] + "-bin") else: - PROGRAM = CONFIG['MOZ_APP_NAME'] + Program(CONFIG['MOZ_APP_NAME']) if CONFIG['MOZ_B2G_LOADER']: SOURCES += [ 'B2GLoader.cpp', diff --git a/b2g/gaia/moz.build b/b2g/gaia/moz.build index 282c716c25f..c0c06424909 100644 --- a/b2g/gaia/moz.build +++ b/b2g/gaia/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -PROGRAM = CONFIG['MOZ_APP_NAME'] +Program(CONFIG['MOZ_APP_NAME']) if CONFIG['OS_ARCH'] == 'WINNT': SOURCES += [ diff --git a/browser/app/moz.build b/browser/app/moz.build index 0e78b951500..3d22eab10b0 100644 --- a/browser/app/moz.build +++ b/browser/app/moz.build @@ -6,7 +6,7 @@ DIRS += ['profile/extensions'] -PROGRAM = CONFIG['MOZ_APP_NAME'] +Program(CONFIG['MOZ_APP_NAME']) SOURCES += [ 'nsBrowserApp.cpp', diff --git a/browser/metro/shell/commandexecutehandler/moz.build b/browser/metro/shell/commandexecutehandler/moz.build index 9e671d8ff17..fb47441be41 100644 --- a/browser/metro/shell/commandexecutehandler/moz.build +++ b/browser/metro/shell/commandexecutehandler/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -PROGRAM = 'CommandExecuteHandler' +Program('CommandExecuteHandler') SOURCES += [ 'CEHHelper.cpp', diff --git a/browser/metro/shell/linktool/moz.build b/browser/metro/shell/linktool/moz.build index 20b154e1e9b..223928bf18c 100644 --- a/browser/metro/shell/linktool/moz.build +++ b/browser/metro/shell/linktool/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -PROGRAM = 'linktool' +Program('linktool') SOURCES += [ 'linktool.cpp', diff --git a/browser/metro/shell/testing/moz.build b/browser/metro/shell/testing/moz.build index 8ff0f896bf6..151d98bf1ff 100644 --- a/browser/metro/shell/testing/moz.build +++ b/browser/metro/shell/testing/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -PROGRAM = 'metrotestharness' +Program('metrotestharness') SOURCES += [ 'metrotestharness.cpp', diff --git a/build/docs/defining-binaries.rst b/build/docs/defining-binaries.rst index 1cfd855e8c5..fd155917a18 100644 --- a/build/docs/defining-binaries.rst +++ b/build/docs/defining-binaries.rst @@ -39,20 +39,20 @@ Static Libraries ================ To build a static library, other than defining the source files (see above), one -just needs to define a library name with the ``LIBRARY_NAME`` variable. +just needs to define a library name with the ``Library`` template. - LIBRARY_NAME = 'foo' + Library('foo') The library file name will be ``libfoo.a`` on UNIX systems and ``foo.lib`` on Windows. If the static library needs to aggregate other static libraries, a list of -``LIBRARY_NAME`` can be added to the ``USE_LIBS`` variable. Like ``SOURCES``, it +``Library`` names can be added to the ``USE_LIBS`` variable. Like ``SOURCES``, it requires the appended list to be alphanumerically ordered. USE_LIBS += ['bar', 'baz'] -If there are multiple directories containing the same ``LIBRARY_NAME``, it is +If there are multiple directories containing the same ``Library`` name, it is possible to disambiguate by prefixing with the path to the wanted one (relative or absolute): @@ -61,7 +61,7 @@ or absolute): '../relative/baz', ] -Note that the leaf name in those paths is the ``LIBRARY_NAME``, not an actual +Note that the leaf name in those paths is the ``Library`` name, not an actual file name. Note that currently, the build system may not create an actual library for @@ -84,10 +84,10 @@ be linked to that bigger library, with the ``FINAL_LIBRARY`` variable. FINAL_LIBRARY = 'xul' -The ``FINAL_LIBRARY`` value must match a unique ``LIBRARY_NAME`` somewhere +The ``FINAL_LIBRARY`` value must match a unique ``Library`` name somewhere in the tree. -As a special rule, those intermediate libraries don't need a ``LIBRARY_NAME`` +As a special rule, those intermediate libraries don't need a ``Library`` name for themselves. @@ -103,7 +103,7 @@ the ``FORCE_SHARED_LIB`` boolean variable: When this variable is set, no static library is built. See further below to build both types of libraries. -With a ``LIBRARY_NAME`` of ``foo``, the library file name will be +With a ``Library`` name of ``foo``, the library file name will be ``libfoo.dylib`` on OSX, ``libfoo.so`` on ELF systems (Linux, etc.), and ``foo.dll`` on Windows. On Windows, there is also an import library named ``foo.lib``, used on the linker command line. ``libfoo.dylib`` and @@ -115,7 +115,7 @@ This is done with the ``IS_FRAMEWORK`` boolean variable. IS_FRAMEWORK = True -With a ``LIBRARY_NAME`` of ``foo``, the framework file name will be ``foo``. +With a ``Library`` name of ``foo``, the framework file name will be ``foo``. This variable however affects the behavior on all platforms, so it needs to be set only on OSX. @@ -129,23 +129,24 @@ Executables =========== Executables, a.k.a. programs, are, in the simplest form, defined with the -``PROGRAM`` variable. +``Program`` template. - PROGRAM = 'foobar' + Program('foobar') On UNIX systems, the executable file name will be ``foobar``, while on Windows, it will be ``foobar.exe``. Like static and shared libraries, the build system can be instructed to link -libraries to the executable with ``USE_LIBS``, listing various ``LIBRARY_NAME``. +libraries to the executable with ``USE_LIBS``, listing various ``Library`` +names. In some cases, we want to create an executable per source file in the current -directory, in which case we can use the ``SIMPLE_PROGRAMS`` list: +directory, in which case we can use the ``SimplePrograms`` template - SIMPLE_PROGRAMS = [ + SimplePrograms([ 'FirstProgram', 'SecondProgram', - ] + ]) The corresponding ``SOURCES`` must match: @@ -154,8 +155,8 @@ The corresponding ``SOURCES`` must match: 'SecondProgram.c', ] -Similar to ``SIMPLE_PROGRAMS``, is ``CPP_UNIT_TESTS``, which defines, with the -same rules, C++ unit tests programs. +Similar to ``SimplePrograms``, is the ``CppUnitTests`` template, which defines, +with the same rules, C++ unit tests programs. Linking with system libraries @@ -189,10 +190,10 @@ Libraries from third party build system ======================================= Some libraries in the tree are not built by the moz.build-governed build -system, and there is no ``LIBRARY_NAME`` corresponding to them. +system, and there is no ``Library`` corresponding to them. However, ``USE_LIBS`` allows to reference such libraries by giving a full -path (like when disambiguating identical ``LIBRARY_NAME``). The same naming +path (like when disambiguating identical ``Library`` names). The same naming rules apply as other uses of ``USE_LIBS``, so only the library name without prefix and suffix shall be given. @@ -217,12 +218,12 @@ When both types of libraries are required, one needs to set both But because static libraries and Windows import libraries have the same file names, either the static or the shared library name needs to be different -than ``LIBRARY_NAME``. +than the name given to the ``Library`` template. The ``STATIC_LIBRARY_NAME`` and ``SHARED_LIBRARY_NAME`` variables can be used to change either the static or the shared library name. - LIBRARY_NAME = 'foo' + Library('foo') STATIC_LIBRARY_NAME = 'foo_s' With the above, on Windows, ``foo_s.lib`` will be the static library, @@ -231,25 +232,25 @@ With the above, on Windows, ``foo_s.lib`` will be the static library, In some cases, for convenience, it is possible to set both ``STATIC_LIBRARY_NAME`` and ``SHARED_LIBRARY_NAME``. For example: - LIBRARY_NAME = 'mylib' + Library('mylib') STATIC_LIBRARY_NAME = 'mylib_s' SHARED_LIBRARY_NAME = CONFIG['SHARED_NAME'] This allows to use ``mylib`` in the ``USE_LIBS`` of another library or executable. -When refering to a ``LIBRARY_NAME`` building both types of libraries in +When refering to a ``Library`` name building both types of libraries in ``USE_LIBS``, the shared library is chosen to be linked. But sometimes, -it is wanted to link the static version, in which case the ``LIBRARY_NAME`` +it is wanted to link the static version, in which case the ``Library`` name needs to be prefixed with ``static:`` in ``USE_LIBS`` a/moz.build: - LIBRARY_NAME = 'mylib' + Library('mylib') FORCE_SHARED_LIB = True FORCE_STATIC_LIB = True STATIC_LIBRARY_NAME = 'mylib_s' b/moz.build: - PROGRAM = 'myprog' + Program('myprog') USE_LIBS += [ 'static:mylib', ] @@ -262,18 +263,18 @@ The ``SDK_LIBRARY`` boolean variable defines whether the library in the current directory is going to be installed in the SDK. The ``SONAME`` variable declares a "shared object name" for the library. It -defaults to the ``LIBRARY_NAME`` or the ``SHARED_LIBRARY_NAME`` if set. When +defaults to the ``Library`` name or the ``SHARED_LIBRARY_NAME`` if set. When linking to a library with a ``SONAME``, the resulting library or program will have a dependency on the library with the name corresponding to the ``SONAME`` -instead of ``LIBRARY_NAME``. This only impacts ELF systems. +instead of the ``Library`` name. This only impacts ELF systems. a/moz.build: - LIBRARY_NAME = 'mylib' + Library('mylib') b/moz.build: - LIBRARY_NAME = 'otherlib' + Library('otherlib') SONAME = 'foo' c/moz.build: - PROGRAM = 'myprog' + Program('myprog') USE_LIBS += [ 'mylib', 'otherlib', diff --git a/build/stlport/moz.build b/build/stlport/moz.build index af9be36a0fa..649ce0b27f7 100644 --- a/build/stlport/moz.build +++ b/build/stlport/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -LIBRARY_NAME = 'stlport_static' +Library('stlport_static') FORCE_STATIC_LIB = True diff --git a/build/templates.mozbuild b/build/templates.mozbuild index 0dff49d667e..6df5f1411e3 100644 --- a/build/templates.mozbuild +++ b/build/templates.mozbuild @@ -4,6 +4,57 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +@template +def Program(name): + '''Template for program executables.''' + PROGRAM = name + + +@template +def SimplePrograms(names): + '''Template for simple program executables. + + Those have a single source with the same base name as the executable. + ''' + SIMPLE_PROGRAMS += names + + +@template +def CppUnitTests(names): + '''Template for C++ unit tests. + + Those have a single source with the same base name as the executable. + ''' + CPP_UNIT_TESTS += names + + +@template +def Library(name): + '''Template for libraries.''' + LIBRARY_NAME = name + + +@template +def HostProgram(name): + '''Template for build tools executables.''' + HOST_PROGRAM = name + + +@template +def HostSimplePrograms(names): + '''Template for simple build tools executables. + + Those have a single source with the same base name as the executable. + ''' + HOST_SIMPLE_PROGRAMS += names + + +@template +def HostLibrary(name): + '''Template for build tools libraries.''' + HOST_LIBRARY_NAME = name + + @template def GeckoBinary(): '''Template for binaries using Gecko. diff --git a/build/unix/elfhack/moz.build b/build/unix/elfhack/moz.build index 65a968bf394..a3cb69c9b18 100644 --- a/build/unix/elfhack/moz.build +++ b/build/unix/elfhack/moz.build @@ -19,7 +19,7 @@ HOST_SOURCES += [ 'elfhack.cpp', ] -HOST_PROGRAM = 'elfhack' +HostProgram('elfhack') DEFINES['ELFHACK_BUILD'] = True diff --git a/build/unix/stdc++compat/moz.build b/build/unix/stdc++compat/moz.build index d9247607920..73f4e22e1d9 100644 --- a/build/unix/stdc++compat/moz.build +++ b/build/unix/stdc++compat/moz.build @@ -5,11 +5,11 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. if CONFIG['MOZ_LIBSTDCXX_TARGET_VERSION']: - LIBRARY_NAME = 'stdc++compat' + Library('stdc++compat') SOURCES += ['stdc++compat.cpp'] if CONFIG['MOZ_LIBSTDCXX_HOST_VERSION']: - HOST_LIBRARY_NAME = 'host_stdc++compat' + HostLibrary('host_stdc++compat') HOST_SOURCES += [ 'stdc++compat.cpp', ] diff --git a/build/win32/crashinjectdll/moz.build b/build/win32/crashinjectdll/moz.build index 24655529ab6..6f1fc4cab12 100644 --- a/build/win32/crashinjectdll/moz.build +++ b/build/win32/crashinjectdll/moz.build @@ -8,7 +8,7 @@ SOURCES += [ 'crashinjectdll.cpp', ] -LIBRARY_NAME = 'crashinjectdll' +Library('crashinjectdll') FORCE_SHARED_LIB = True diff --git a/build/win32/moz.build b/build/win32/moz.build index ece8f8067db..0d14f247d28 100644 --- a/build/win32/moz.build +++ b/build/win32/moz.build @@ -10,7 +10,7 @@ if CONFIG['_MSC_VER'] and CONFIG['OS_TEST'] != 'x86_64': TEST_DIRS += ['crashinjectdll'] if CONFIG['ENABLE_TESTS']: - PROGRAM = 'crashinject' + Program('crashinject') SOURCES += [ 'crashinject.cpp', ] diff --git a/build/win32/vmwarerecordinghelper/moz.build b/build/win32/vmwarerecordinghelper/moz.build index 4cfdc4f64f6..55e842e2b98 100644 --- a/build/win32/vmwarerecordinghelper/moz.build +++ b/build/win32/vmwarerecordinghelper/moz.build @@ -8,7 +8,7 @@ SOURCES += [ 'vmwarerecordinghelper.cpp', ] -LIBRARY_NAME = 'vmwarerecordinghelper' +Library('vmwarerecordinghelper') FORCE_SHARED_LIB = True diff --git a/config/external/ffi/moz.build b/config/external/ffi/moz.build index 130e35b39e5..725b483153f 100644 --- a/config/external/ffi/moz.build +++ b/config/external/ffi/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -LIBRARY_NAME = 'ffi' +Library('ffi') if CONFIG['MOZ_NATIVE_FFI']: OS_LIBS += CONFIG['MOZ_FFI_LIBS'] diff --git a/config/external/freetype2/moz.build b/config/external/freetype2/moz.build index 1c9b09e8762..fc52d25bda7 100644 --- a/config/external/freetype2/moz.build +++ b/config/external/freetype2/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -LIBRARY_NAME = 'freetype' +Library('freetype') if CONFIG['MOZ_TREE_FREETYPE']: USE_LIBS += [ diff --git a/config/external/icu/moz.build b/config/external/icu/moz.build index 32422d4bb20..eda9c4c561c 100644 --- a/config/external/icu/moz.build +++ b/config/external/icu/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -LIBRARY_NAME = 'icu' +Library('icu') if CONFIG['MOZ_NATIVE_ICU']: OS_LIBS += CONFIG['MOZ_ICU_LIBS'] diff --git a/config/external/nspr/moz.build b/config/external/nspr/moz.build index 34e0369bafa..424119e8a63 100644 --- a/config/external/nspr/moz.build +++ b/config/external/nspr/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -LIBRARY_NAME = 'nspr' +Library('nspr') if CONFIG['MOZ_FOLD_LIBS']: # When folding libraries, nspr is actually in the nss library. diff --git a/config/external/nss/crmf/moz.build b/config/external/nss/crmf/moz.build index d0ceb4bd9cf..9b8005f96e2 100644 --- a/config/external/nss/crmf/moz.build +++ b/config/external/nss/crmf/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -LIBRARY_NAME = 'crmf' +Library('crmf') if CONFIG['MOZ_NATIVE_NSS']: OS_LIBS += [l for l in CONFIG['NSS_LIBS'] if l.startswith('-L')] diff --git a/config/external/nss/moz.build b/config/external/nss/moz.build index 2ebfa800657..b7b69e7017b 100644 --- a/config/external/nss/moz.build +++ b/config/external/nss/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -LIBRARY_NAME = 'nss' +Library('nss') DIRS += ['crmf'] diff --git a/config/external/sqlite/moz.build b/config/external/sqlite/moz.build index b765049d06c..9826ced3f77 100644 --- a/config/external/sqlite/moz.build +++ b/config/external/sqlite/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -LIBRARY_NAME = 'sqlite' +Library('sqlite') if CONFIG['MOZ_NATIVE_SQLITE']: OS_LIBS += CONFIG['SQLITE_LIBS'] diff --git a/config/external/zlib/moz.build b/config/external/zlib/moz.build index e6c14a73f4a..f1efe437af3 100644 --- a/config/external/zlib/moz.build +++ b/config/external/zlib/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -LIBRARY_NAME = 'zlib' +Library('zlib') if CONFIG['MOZ_NATIVE_ZLIB']: OS_LIBS += CONFIG['MOZ_ZLIB_LIBS'] diff --git a/config/moz.build b/config/moz.build index d355cb5e79e..9e6ab581bc6 100644 --- a/config/moz.build +++ b/config/moz.build @@ -21,7 +21,7 @@ if CONFIG['HOST_OS_ARCH'] != 'WINNT': 'nsinstall.c', 'pathsub.c', ] - HOST_PROGRAM = 'nsinstall_real' + HostProgram('nsinstall_real') if CONFIG['GKMEDIAS_SHARED_LIBRARY']: DEFINES['GKMEDIAS_SHARED_LIBRARY'] = True diff --git a/content/base/test/moz.build b/content/base/test/moz.build index f4fd51a587f..ec05b17e996 100644 --- a/content/base/test/moz.build +++ b/content/base/test/moz.build @@ -10,12 +10,12 @@ XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini'] if CONFIG['OS_ARCH'] != 'Darwin': XPCSHELL_TESTS_MANIFESTS += ['unit_ipc/xpcshell.ini'] -CPP_UNIT_TESTS += [ +CppUnitTests([ 'TestCSPParser', 'TestGetURL', 'TestNativeXMLHttpRequest', 'TestPlainTextSerializer', -] +]) SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) diff --git a/content/media/compiledtest/moz.build b/content/media/compiledtest/moz.build index a8ea07907d9..0da44099221 100644 --- a/content/media/compiledtest/moz.build +++ b/content/media/compiledtest/moz.build @@ -4,10 +4,10 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -CPP_UNIT_TESTS += [ +CppUnitTests([ 'TestAudioBuffers', 'TestAudioMixer' -] +]) SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) diff --git a/content/media/webaudio/compiledtest/moz.build b/content/media/webaudio/compiledtest/moz.build index 55c96401da1..e584c2016a5 100644 --- a/content/media/webaudio/compiledtest/moz.build +++ b/content/media/webaudio/compiledtest/moz.build @@ -4,9 +4,9 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -CPP_UNIT_TESTS += [ +CppUnitTests([ 'TestAudioEventTimeline', -] +]) SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) diff --git a/dom/audiochannel/tests/moz.build b/dom/audiochannel/tests/moz.build index ffa7abe72a0..64304545b10 100644 --- a/dom/audiochannel/tests/moz.build +++ b/dom/audiochannel/tests/moz.build @@ -4,9 +4,9 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -CPP_UNIT_TESTS += [ +CppUnitTests([ 'TestAudioChannelService', -] +]) SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) diff --git a/dom/bindings/test/moz.build b/dom/bindings/test/moz.build index f5fe25f3a99..afa87cc7e4e 100644 --- a/dom/bindings/test/moz.build +++ b/dom/bindings/test/moz.build @@ -12,7 +12,7 @@ DEFINES.update({ # Do NOT export this library. We don't actually want our test code # being added to libxul or anything. -LIBRARY_NAME = 'dombindings_test_s' +Library('dombindings_test_s') EXTRA_COMPONENTS += [ 'TestInterfaceJS.js', diff --git a/dom/canvas/compiledtest/moz.build b/dom/canvas/compiledtest/moz.build index 376b321970b..6e3a66ea13c 100644 --- a/dom/canvas/compiledtest/moz.build +++ b/dom/canvas/compiledtest/moz.build @@ -4,9 +4,9 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -CPP_UNIT_TESTS += [ +CppUnitTests([ 'TestWebGLElementArrayCache', -] +]) SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) diff --git a/dom/media/gmp-plugin/moz.build b/dom/media/gmp-plugin/moz.build index 2b066082bd9..27774758ff2 100644 --- a/dom/media/gmp-plugin/moz.build +++ b/dom/media/gmp-plugin/moz.build @@ -9,7 +9,7 @@ SOURCES += [ 'gmp-fake.cpp' ] -LIBRARY_NAME = "fake" +Library("fake") USE_STATIC_LIBS = True FORCE_SHARED_LIB = True diff --git a/dom/plugins/ipc/hangui/moz.build b/dom/plugins/ipc/hangui/moz.build index 15e41686853..8b803c961dd 100644 --- a/dom/plugins/ipc/hangui/moz.build +++ b/dom/plugins/ipc/hangui/moz.build @@ -6,7 +6,7 @@ FAIL_ON_WARNINGS = True -PROGRAM = 'plugin-hang-ui' +Program('plugin-hang-ui') UNIFIED_SOURCES += [ 'MiniShmChild.cpp', diff --git a/dom/plugins/ipc/interpose/moz.build b/dom/plugins/ipc/interpose/moz.build index 3818e1ece36..e80b868b419 100644 --- a/dom/plugins/ipc/interpose/moz.build +++ b/dom/plugins/ipc/interpose/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -LIBRARY_NAME = 'plugin_child_interpose' +Library('plugin_child_interpose') UNIFIED_SOURCES += [ "%s.mm" % (LIBRARY_NAME) ] diff --git a/dom/plugins/test/testplugin/javaplugin/moz.build b/dom/plugins/test/testplugin/javaplugin/moz.build index 4dd056fcd0e..2c7f6a0f73c 100644 --- a/dom/plugins/test/testplugin/javaplugin/moz.build +++ b/dom/plugins/test/testplugin/javaplugin/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -LIBRARY_NAME = 'nptestjava' +Library('nptestjava') relative_path = '..' include('../testplugin.mozbuild') diff --git a/dom/plugins/test/testplugin/moz.build b/dom/plugins/test/testplugin/moz.build index 678c75f2b66..705995b20cd 100644 --- a/dom/plugins/test/testplugin/moz.build +++ b/dom/plugins/test/testplugin/moz.build @@ -6,7 +6,7 @@ DIRS += ['secondplugin', 'javaplugin'] -LIBRARY_NAME = 'nptest' +Library('nptest') FAIL_ON_WARNINGS = not CONFIG['_MSC_VER'] diff --git a/dom/plugins/test/testplugin/secondplugin/moz.build b/dom/plugins/test/testplugin/secondplugin/moz.build index a9e6cca1e70..c9c6215ee2e 100644 --- a/dom/plugins/test/testplugin/secondplugin/moz.build +++ b/dom/plugins/test/testplugin/secondplugin/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -LIBRARY_NAME = 'npsecondtest' +Library('npsecondtest') relative_path = '..' include('../testplugin.mozbuild') diff --git a/editor/txmgr/tests/moz.build b/editor/txmgr/tests/moz.build index e113d7309d7..316d7a80b5b 100644 --- a/editor/txmgr/tests/moz.build +++ b/editor/txmgr/tests/moz.build @@ -4,9 +4,9 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -CPP_UNIT_TESTS += [ +CppUnitTests([ 'TestTXMgr', -] +]) SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) diff --git a/embedding/tests/winEmbed/moz.build b/embedding/tests/winEmbed/moz.build index 74a8adc7d43..e7ff37a2374 100644 --- a/embedding/tests/winEmbed/moz.build +++ b/embedding/tests/winEmbed/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -PROGRAM = 'winEmbed' +Program('winEmbed') SOURCES += [ 'WebBrowserChrome.cpp', diff --git a/gfx/angle/src/libEGL/moz.build b/gfx/angle/src/libEGL/moz.build index 4dc7ba8ee2a..96f105e7652 100644 --- a/gfx/angle/src/libEGL/moz.build +++ b/gfx/angle/src/libEGL/moz.build @@ -54,7 +54,7 @@ DISABLE_STL_WRAPPING = True LOCAL_INCLUDES += [ '../../include', '../../src' ] USE_LIBS += [ 'libGLESv2' ] -LIBRARY_NAME = 'libEGL' +Library('libEGL') FORCE_SHARED_LIB = True RCFILE = SRCDIR + '/libEGL.rc' diff --git a/gfx/angle/src/libGLESv2/moz.build b/gfx/angle/src/libGLESv2/moz.build index 3704ba8c94a..131868dd09f 100644 --- a/gfx/angle/src/libGLESv2/moz.build +++ b/gfx/angle/src/libGLESv2/moz.build @@ -204,7 +204,7 @@ else: '\'%s/lib/%s/dxguid.lib\'' % (CONFIG['MOZ_DIRECTX_SDK_PATH'], CONFIG['MOZ_D3D_CPU_SUFFIX']), ] -LIBRARY_NAME = 'libGLESv2' +Library('libGLESv2') FORCE_SHARED_LIB = True RCFILE = SRCDIR + '/libGLESv2.rc' diff --git a/intl/lwbrk/tests/moz.build b/intl/lwbrk/tests/moz.build index 795aacb3fa2..8beb091cf2c 100644 --- a/intl/lwbrk/tests/moz.build +++ b/intl/lwbrk/tests/moz.build @@ -4,9 +4,9 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -CPP_UNIT_TESTS += [ +CppUnitTests([ 'TestLineBreak', -] +]) SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) diff --git a/intl/uconv/tools/moz.build b/intl/uconv/tools/moz.build index c8086e62032..fa7756ae9a9 100644 --- a/intl/uconv/tools/moz.build +++ b/intl/uconv/tools/moz.build @@ -4,9 +4,9 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -SIMPLE_PROGRAMS += [ +SimplePrograms([ 'umaptable', -] +]) SOURCES += [ '%s.c' % s for s in SIMPLE_PROGRAMS diff --git a/intl/unicharutil/tests/moz.build b/intl/unicharutil/tests/moz.build index 8a5ff8f0680..9820a2de05e 100644 --- a/intl/unicharutil/tests/moz.build +++ b/intl/unicharutil/tests/moz.build @@ -11,9 +11,9 @@ SOURCES += [ 'UnicharSelfTest.cpp', ] -SIMPLE_PROGRAMS += [ +SimplePrograms([ "%s" % (fyl[0:-4]) for fyl in SOURCES -] +]) USE_STATIC_LIBS = True diff --git a/intl/unicharutil/tools/moz.build b/intl/unicharutil/tools/moz.build index cbd55a1f230..a46688a2532 100644 --- a/intl/unicharutil/tools/moz.build +++ b/intl/unicharutil/tools/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -PROGRAM = 'ucgendat' +Program('ucgendat') SOURCES += [ 'ucgendat.c', diff --git a/intl/unicharutil/util/moz.build b/intl/unicharutil/util/moz.build index 8e87514378c..e9bf0ed4b04 100644 --- a/intl/unicharutil/util/moz.build +++ b/intl/unicharutil/util/moz.build @@ -21,7 +21,7 @@ include('objs.mozbuild') UNIFIED_SOURCES += intl_unicharutil_util_cppsrcs -LIBRARY_NAME = 'unicharutil_external_s' +Library('unicharutil_external_s') FORCE_STATIC_LIB = True diff --git a/ipc/app/moz.build b/ipc/app/moz.build index fc4a3f846c4..e72c3f26258 100644 --- a/ipc/app/moz.build +++ b/ipc/app/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -PROGRAM = CONFIG['MOZ_CHILD_PROCESS_NAME'] +Program(CONFIG['MOZ_CHILD_PROCESS_NAME']) if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android': SOURCES += [ diff --git a/ipc/contentproc/moz.build b/ipc/contentproc/moz.build index 39b5d327379..2a6756346e7 100644 --- a/ipc/contentproc/moz.build +++ b/ipc/contentproc/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -LIBRARY_NAME = 'plugin-container' +Library('plugin-container') if CONFIG['MOZ_B2G_LOADER']: FINAL_LIBRARY = 'xul' diff --git a/ipc/ipdl/test/cxx/app/moz.build b/ipc/ipdl/test/cxx/app/moz.build index 848ad2ada5b..4f6a7b48ca9 100644 --- a/ipc/ipdl/test/cxx/app/moz.build +++ b/ipc/ipdl/test/cxx/app/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -PROGRAM = 'ipdlunittest' +Program('ipdlunittest') SOURCES += [ 'TestIPDL.cpp', diff --git a/js/src/editline/moz.build b/js/src/editline/moz.build index 63afd7f4042..ab3841f7ccb 100644 --- a/js/src/editline/moz.build +++ b/js/src/editline/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -LIBRARY_NAME = 'editline' +Library('editline') UNIFIED_SOURCES += [ 'editline.c', diff --git a/js/src/gdb/moz.build b/js/src/gdb/moz.build index 27b15ea7b2d..119e9eb7373 100644 --- a/js/src/gdb/moz.build +++ b/js/src/gdb/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -PROGRAM = 'gdb-tests' +Program('gdb-tests') UNIFIED_SOURCES += [ 'gdb-tests.cpp', diff --git a/js/src/jsapi-tests/moz.build b/js/src/jsapi-tests/moz.build index 3e485bf5c6e..099da704b2b 100644 --- a/js/src/jsapi-tests/moz.build +++ b/js/src/jsapi-tests/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -PROGRAM = 'jsapi-tests' +Program('jsapi-tests') UNIFIED_SOURCES += [ 'selfTest.cpp', diff --git a/js/src/moz.build b/js/src/moz.build index 31a0d4cfe6f..6eb7736b19d 100644 --- a/js/src/moz.build +++ b/js/src/moz.build @@ -427,9 +427,9 @@ HOST_SOURCES += [ 'jskwgen.cpp', ] -HOST_SIMPLE_PROGRAMS += [ +HostSimplePrograms([ 'host_%s' % f.replace('.cpp', '') for f in HOST_SOURCES -] +]) # JavaScript must be built shared, even for static builds, as it is used by # other modules which are always built shared. Failure to do so results in @@ -439,7 +439,7 @@ HOST_SIMPLE_PROGRAMS += [ # In fact, we now build both a static and a shared library, as the # JS shell would like to link to the static library. -LIBRARY_NAME = 'js' +Library('js') if CONFIG['JS_SHARED_LIBRARY']: FORCE_SHARED_LIB = True diff --git a/js/src/shell/moz.build b/js/src/shell/moz.build index 10a930cba58..b88334f1548 100644 --- a/js/src/shell/moz.build +++ b/js/src/shell/moz.build @@ -5,7 +5,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. if CONFIG['JS_SHELL_NAME']: - PROGRAM = CONFIG['JS_SHELL_NAME'] + Program(CONFIG['JS_SHELL_NAME']) if CONFIG['JS_BUNDLED_EDITLINE']: USE_LIBS += ['editline'] USE_LIBS += ['static:js'] diff --git a/js/xpconnect/shell/moz.build b/js/xpconnect/shell/moz.build index 36b19bb16dc..289b5d17d81 100644 --- a/js/xpconnect/shell/moz.build +++ b/js/xpconnect/shell/moz.build @@ -6,7 +6,7 @@ FAIL_ON_WARNINGS = True -PROGRAM = 'xpcshell' +Program('xpcshell') SOURCES += [ 'xpcshell.cpp', diff --git a/layout/media/moz.build b/layout/media/moz.build index a10875dd15c..fd2101cf99f 100644 --- a/layout/media/moz.build +++ b/layout/media/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -LIBRARY_NAME = 'gkmedias' +Library('gkmedias') if CONFIG['GKMEDIAS_SHARED_LIBRARY']: FORCE_SHARED_LIB = True diff --git a/layout/media/webrtc/moz.build b/layout/media/webrtc/moz.build index 8a0701f6382..32f5e78d335 100644 --- a/layout/media/webrtc/moz.build +++ b/layout/media/webrtc/moz.build @@ -4,5 +4,5 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -LIBRARY_NAME = 'webrtc' +Library('webrtc') FINAL_LIBRARY = 'xul' diff --git a/layout/style/test/moz.build b/layout/style/test/moz.build index bc62ec5cb0f..96f7636f3c4 100644 --- a/layout/style/test/moz.build +++ b/layout/style/test/moz.build @@ -8,9 +8,9 @@ HOST_SOURCES += [ 'ListCSSProperties.cpp', ] -HOST_SIMPLE_PROGRAMS += [ +HostSimplePrograms([ 'host_%s' % f.replace('.cpp', '') for f in HOST_SOURCES -] +]) MOCHITEST_MANIFESTS += [ 'chrome/mochitest.ini', diff --git a/media/libcubeb/src/moz.build b/media/libcubeb/src/moz.build index 944744d07eb..8b7a0dd1b03 100644 --- a/media/libcubeb/src/moz.build +++ b/media/libcubeb/src/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -LIBRARY_NAME = 'cubeb' +Library('cubeb') SOURCES += [ 'cubeb.c', diff --git a/media/libcubeb/tests/moz.build b/media/libcubeb/tests/moz.build index 08e6b94d15c..e7869a529ca 100644 --- a/media/libcubeb/tests/moz.build +++ b/media/libcubeb/tests/moz.build @@ -4,16 +4,16 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -CPP_UNIT_TESTS += [ +CppUnitTests([ 'test_tone' -] +]) if CONFIG['OS_TARGET'] != 'Android': - CPP_UNIT_TESTS += [ + CppUnitTests([ 'test_audio', 'test_latency', 'test_sanity' - ] + ]) SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) diff --git a/media/libpng/moz.build b/media/libpng/moz.build index 330f5ff7515..b95c00779a9 100644 --- a/media/libpng/moz.build +++ b/media/libpng/moz.build @@ -38,7 +38,7 @@ if CONFIG['MOZ_PNG_ARM_NEON']: 'arm/filter_neon.S' ] -LIBRARY_NAME = 'mozpng' +Library('mozpng') MSVC_ENABLE_PGO = True diff --git a/media/libspeex_resampler/src/moz.build b/media/libspeex_resampler/src/moz.build index 850cd926023..5ab9d06825b 100644 --- a/media/libspeex_resampler/src/moz.build +++ b/media/libspeex_resampler/src/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -LIBRARY_NAME = 'speex' +Library('speex') EXPORTS.speex += [ 'speex_resampler.h', diff --git a/media/libvpx/moz.build b/media/libvpx/moz.build index 4e97a486568..03aa3edd5aa 100644 --- a/media/libvpx/moz.build +++ b/media/libvpx/moz.build @@ -13,7 +13,7 @@ if CONFIG['VPX_NEED_OBJ_INT_EXTRACT']: 'build/make/obj_int_extract.c', ] - HOST_PROGRAM = 'host_obj_int_extract' + HostProgram('host_obj_int_extract') # Unify fewer files together to reduce the chance of name collision FILES_PER_UNIFIED_FILE = 8 diff --git a/media/mtransport/standalone/moz.build b/media/mtransport/standalone/moz.build index e15cc713638..e9f28d5507e 100644 --- a/media/mtransport/standalone/moz.build +++ b/media/mtransport/standalone/moz.build @@ -9,7 +9,7 @@ include('../objs.mozbuild') # These files cannot be built in unified mode because they force NSPR logging. SOURCES += mtransport_cppsrcs -LIBRARY_NAME = 'mtransport_s' +Library('mtransport_s') LOCAL_INCLUDES += [ '/media/mtransport/', diff --git a/media/mtransport/test/moz.build b/media/mtransport/test/moz.build index cd08fbfc869..fd2c8fb29e8 100644 --- a/media/mtransport/test/moz.build +++ b/media/mtransport/test/moz.build @@ -5,7 +5,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. if CONFIG['OS_TARGET'] != 'WINNT' and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk': - CPP_UNIT_TESTS += [ + CppUnitTests([ 'buffered_stun_socket_unittest', 'ice_unittest', 'nrappkit_unittest', @@ -16,12 +16,12 @@ if CONFIG['OS_TARGET'] != 'WINNT' and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk': 'TestSyncRunnable', 'transport_unittests', 'turn_unittest', - ] + ]) if CONFIG['MOZ_SCTP']: - CPP_UNIT_TESTS += [ + CppUnitTests([ 'sctp_unittest', - ] + ]) SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) diff --git a/media/omx-plugin/froyo/moz.build b/media/omx-plugin/froyo/moz.build index 6faa233c2d2..dc530b2134c 100644 --- a/media/omx-plugin/froyo/moz.build +++ b/media/omx-plugin/froyo/moz.build @@ -8,7 +8,7 @@ SOURCES += [ 'OmxPluginFroyo.cpp', ] -LIBRARY_NAME = 'omxpluginfroyo' +Library('omxpluginfroyo') FORCE_SHARED_LIB = True diff --git a/media/omx-plugin/gb/moz.build b/media/omx-plugin/gb/moz.build index 755b92870e9..c7616aaa8dd 100644 --- a/media/omx-plugin/gb/moz.build +++ b/media/omx-plugin/gb/moz.build @@ -8,7 +8,7 @@ SOURCES += [ 'OmxPlugin236.cpp', ] -LIBRARY_NAME = 'omxplugingb' +Library('omxplugingb') FORCE_SHARED_LIB = True diff --git a/media/omx-plugin/gb235/moz.build b/media/omx-plugin/gb235/moz.build index 8cae2d6dcfe..c25bed8b144 100644 --- a/media/omx-plugin/gb235/moz.build +++ b/media/omx-plugin/gb235/moz.build @@ -8,7 +8,7 @@ SOURCES += [ 'OmxPlugin235.cpp', ] -LIBRARY_NAME = 'omxplugingb235' +Library('omxplugingb235') FORCE_SHARED_LIB = True diff --git a/media/omx-plugin/hc/moz.build b/media/omx-plugin/hc/moz.build index 4de7ee83fff..9ad3794f7e2 100644 --- a/media/omx-plugin/hc/moz.build +++ b/media/omx-plugin/hc/moz.build @@ -8,7 +8,7 @@ SOURCES += [ 'OmxPluginHoneycomb.cpp', ] -LIBRARY_NAME = 'omxpluginhc' +Library('omxpluginhc') FORCE_SHARED_LIB = True diff --git a/media/omx-plugin/kk/moz.build b/media/omx-plugin/kk/moz.build index 974b057a7a6..4667493d803 100644 --- a/media/omx-plugin/kk/moz.build +++ b/media/omx-plugin/kk/moz.build @@ -8,7 +8,7 @@ SOURCES += [ 'OmxPluginKitKat.cpp', ] -LIBRARY_NAME = 'omxpluginkk' +Library('omxpluginkk') FORCE_SHARED_LIB = True diff --git a/media/omx-plugin/lib/froyo/libstagefright/moz.build b/media/omx-plugin/lib/froyo/libstagefright/moz.build index 2061ad10a8d..0632ae65f5b 100644 --- a/media/omx-plugin/lib/froyo/libstagefright/moz.build +++ b/media/omx-plugin/lib/froyo/libstagefright/moz.build @@ -10,7 +10,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk': 'libstagefright.cpp', ] -LIBRARY_NAME = 'stagefright' +Library('stagefright') FORCE_SHARED_LIB = True diff --git a/media/omx-plugin/lib/gb/libstagefright/moz.build b/media/omx-plugin/lib/gb/libstagefright/moz.build index 3d9a3da02e0..209ceb46d1b 100644 --- a/media/omx-plugin/lib/gb/libstagefright/moz.build +++ b/media/omx-plugin/lib/gb/libstagefright/moz.build @@ -10,7 +10,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk': 'libstagefright.cpp', ] -LIBRARY_NAME = 'stagefright' +Library('stagefright') FORCE_SHARED_LIB = True diff --git a/media/omx-plugin/lib/gb/libstagefright_color_conversion/moz.build b/media/omx-plugin/lib/gb/libstagefright_color_conversion/moz.build index f2deef9aa55..efbd44f49e8 100644 --- a/media/omx-plugin/lib/gb/libstagefright_color_conversion/moz.build +++ b/media/omx-plugin/lib/gb/libstagefright_color_conversion/moz.build @@ -10,7 +10,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk': 'libstagefright_color_conversion.cpp', ] -LIBRARY_NAME = 'stagefright_color_conversion' +Library('stagefright_color_conversion') FORCE_SHARED_LIB = True diff --git a/media/omx-plugin/lib/gb/libutils/moz.build b/media/omx-plugin/lib/gb/libutils/moz.build index f1d6f969eac..a131edf0ad6 100644 --- a/media/omx-plugin/lib/gb/libutils/moz.build +++ b/media/omx-plugin/lib/gb/libutils/moz.build @@ -10,7 +10,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk': 'libutils.cpp', ] -LIBRARY_NAME = 'utils' +Library('utils') FORCE_SHARED_LIB = True diff --git a/media/omx-plugin/lib/gb235/libstagefright/moz.build b/media/omx-plugin/lib/gb235/libstagefright/moz.build index 3d9a3da02e0..209ceb46d1b 100644 --- a/media/omx-plugin/lib/gb235/libstagefright/moz.build +++ b/media/omx-plugin/lib/gb235/libstagefright/moz.build @@ -10,7 +10,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk': 'libstagefright.cpp', ] -LIBRARY_NAME = 'stagefright' +Library('stagefright') FORCE_SHARED_LIB = True diff --git a/media/omx-plugin/lib/hc/libstagefright/moz.build b/media/omx-plugin/lib/hc/libstagefright/moz.build index 3d9a3da02e0..209ceb46d1b 100644 --- a/media/omx-plugin/lib/hc/libstagefright/moz.build +++ b/media/omx-plugin/lib/hc/libstagefright/moz.build @@ -10,7 +10,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk': 'libstagefright.cpp', ] -LIBRARY_NAME = 'stagefright' +Library('stagefright') FORCE_SHARED_LIB = True diff --git a/media/omx-plugin/lib/ics/libstagefright/moz.build b/media/omx-plugin/lib/ics/libstagefright/moz.build index 3f95e12fc84..c22b723f5cc 100644 --- a/media/omx-plugin/lib/ics/libstagefright/moz.build +++ b/media/omx-plugin/lib/ics/libstagefright/moz.build @@ -10,7 +10,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk': 'libstagefright.cpp', ] -LIBRARY_NAME = 'stagefright' +Library('stagefright') FORCE_SHARED_LIB = True diff --git a/media/omx-plugin/lib/ics/libutils/moz.build b/media/omx-plugin/lib/ics/libutils/moz.build index b5c914d5162..409b4e712ba 100644 --- a/media/omx-plugin/lib/ics/libutils/moz.build +++ b/media/omx-plugin/lib/ics/libutils/moz.build @@ -10,7 +10,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk': 'libutils.cpp', ] -LIBRARY_NAME = 'utils' +Library('utils') FORCE_SHARED_LIB = True diff --git a/media/omx-plugin/lib/ics/libvideoeditorplayer/moz.build b/media/omx-plugin/lib/ics/libvideoeditorplayer/moz.build index 99859c8fe80..b250510128d 100644 --- a/media/omx-plugin/lib/ics/libvideoeditorplayer/moz.build +++ b/media/omx-plugin/lib/ics/libvideoeditorplayer/moz.build @@ -10,7 +10,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk': 'libvideoeditorplayer.cpp', ] -LIBRARY_NAME = 'videoeditorplayer' +Library('videoeditorplayer') FORCE_SHARED_LIB = True diff --git a/media/omx-plugin/moz.build b/media/omx-plugin/moz.build index 05bc4c20f4f..1507a4094c0 100644 --- a/media/omx-plugin/moz.build +++ b/media/omx-plugin/moz.build @@ -18,7 +18,7 @@ SOURCES += [ 'OmxPlugin.cpp', ] -LIBRARY_NAME = 'omxplugin' +Library('omxplugin') FORCE_SHARED_LIB = True diff --git a/media/webrtc/signaling/test/moz.build b/media/webrtc/signaling/test/moz.build index 5e32f53f872..5ce5002546b 100644 --- a/media/webrtc/signaling/test/moz.build +++ b/media/webrtc/signaling/test/moz.build @@ -5,12 +5,12 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. if CONFIG['OS_TARGET'] != 'WINNT' and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk': - CPP_UNIT_TESTS += [ + CppUnitTests([ 'mediaconduit_unittests', 'mediapipeline_unittest', 'sdp_unittests', 'signaling_unittests', - ] + ]) SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) diff --git a/memory/build/moz.build b/memory/build/moz.build index 447d02f85a4..73ce1ac955a 100644 --- a/memory/build/moz.build +++ b/memory/build/moz.build @@ -36,7 +36,7 @@ if CONFIG['MOZ_REPLACE_MALLOC']: 'replace_malloc.c', ] -LIBRARY_NAME = 'memory' +Library('memory') if CONFIG['MOZ_JEMALLOC3']: if not CONFIG['MOZ_NATIVE_JEMALLOC']: diff --git a/memory/jemalloc/moz.build b/memory/jemalloc/moz.build index 310a55a4988..0ab76125157 100644 --- a/memory/jemalloc/moz.build +++ b/memory/jemalloc/moz.build @@ -36,7 +36,7 @@ if CONFIG['OS_TARGET'] == 'Darwin' and not CONFIG['MOZ_REPLACE_MALLOC']: 'src/src/zone.c', ] -LIBRARY_NAME = 'jemalloc' +Library('jemalloc') FORCE_STATIC_LIB = True diff --git a/memory/mozalloc/moz.build b/memory/mozalloc/moz.build index 704ce673d98..d279faaedf0 100644 --- a/memory/mozalloc/moz.build +++ b/memory/mozalloc/moz.build @@ -57,7 +57,7 @@ else: 'VolatileBufferFallback.cpp', ] -LIBRARY_NAME = 'mozalloc' +Library('mozalloc') if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk': FORCE_STATIC_LIB = True diff --git a/memory/mozalloc/tests/moz.build b/memory/mozalloc/tests/moz.build index b7a99656703..6b265f5beb9 100644 --- a/memory/mozalloc/tests/moz.build +++ b/memory/mozalloc/tests/moz.build @@ -4,9 +4,9 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -CPP_UNIT_TESTS += [ +CppUnitTests([ 'TestVolatileBuffer', -] +]) SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) diff --git a/memory/mozjemalloc/moz.build b/memory/mozjemalloc/moz.build index d5b58e5ea5d..f887ae1903a 100644 --- a/memory/mozjemalloc/moz.build +++ b/memory/mozjemalloc/moz.build @@ -12,7 +12,7 @@ if not CONFIG['MOZ_JEMALLOC3']: SOURCES += [ 'jemalloc.c', ] - LIBRARY_NAME = 'mozjemalloc' + Library('mozjemalloc') STATIC_LIBRARY_NAME = 'jemalloc' FORCE_STATIC_LIB = True diff --git a/memory/replace/dmd/moz.build b/memory/replace/dmd/moz.build index acf4c2ebe06..c8f15f2dae3 100644 --- a/memory/replace/dmd/moz.build +++ b/memory/replace/dmd/moz.build @@ -18,7 +18,7 @@ SOURCES += [ '../../../nsprpub/lib/libc/src/strcpy.c', ] -LIBRARY_NAME = 'dmd' +Library('dmd') FORCE_SHARED_LIB = True diff --git a/memory/replace/dummy/moz.build b/memory/replace/dummy/moz.build index 7d2c185c85e..2aeda4fb26c 100644 --- a/memory/replace/dummy/moz.build +++ b/memory/replace/dummy/moz.build @@ -9,7 +9,7 @@ SOURCES += [ 'dummy_replace_malloc.c', ] -LIBRARY_NAME = 'replace_malloc' +Library('replace_malloc') FORCE_SHARED_LIB = True diff --git a/memory/replace/jemalloc/moz.build b/memory/replace/jemalloc/moz.build index 1759d60cab0..65c5999f6c8 100644 --- a/memory/replace/jemalloc/moz.build +++ b/memory/replace/jemalloc/moz.build @@ -17,7 +17,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android': 'pthread_atfork.c', ] -LIBRARY_NAME = 'replace_jemalloc' +Library('replace_jemalloc') USE_LIBS += [ 'jemalloc', diff --git a/mfbt/moz.build b/mfbt/moz.build index 90ef1aae540..b51eac53c0f 100644 --- a/mfbt/moz.build +++ b/mfbt/moz.build @@ -6,7 +6,7 @@ TEST_DIRS += ['tests'] -LIBRARY_NAME = 'mfbt' +Library('mfbt') EXPORTS.mozilla = [ 'Alignment.h', diff --git a/mfbt/tests/moz.build b/mfbt/tests/moz.build index 9520369fe90..48c2fde8e71 100644 --- a/mfbt/tests/moz.build +++ b/mfbt/tests/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -CPP_UNIT_TESTS += [ +CppUnitTests([ 'TestArrayUtils', 'TestAtomics', 'TestBinarySearch', @@ -30,12 +30,12 @@ CPP_UNIT_TESTS += [ 'TestTypeTraits', 'TestUniquePtr', 'TestWeakPtr', -] +]) if not CONFIG['MOZ_ASAN']: - CPP_UNIT_TESTS += [ + CppUnitTests([ 'TestPoisonArea', - ] + ]) SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) diff --git a/modules/libbz2/src/moz.build b/modules/libbz2/src/moz.build index fade621e6b9..68f46a9998b 100644 --- a/modules/libbz2/src/moz.build +++ b/modules/libbz2/src/moz.build @@ -20,9 +20,9 @@ csrcs = [ ] HOST_SOURCES += csrcs -HOST_LIBRARY_NAME = 'hostbz2' +HostLibrary('hostbz2') -LIBRARY_NAME = 'bz2' +Library('bz2') UNIFIED_SOURCES += [ 'blocksort.c', diff --git a/modules/libmar/sign/moz.build b/modules/libmar/sign/moz.build index a6d0308e0f0..d7b8d1f8b30 100644 --- a/modules/libmar/sign/moz.build +++ b/modules/libmar/sign/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -LIBRARY_NAME = 'signmar' +Library('signmar') UNIFIED_SOURCES += [ 'mar_sign.c', diff --git a/modules/libmar/src/moz.build b/modules/libmar/src/moz.build index e40ed05673e..2d25e0849af 100644 --- a/modules/libmar/src/moz.build +++ b/modules/libmar/src/moz.build @@ -14,9 +14,9 @@ HOST_SOURCES += [ 'mar_extract.c', 'mar_read.c', ] -HOST_LIBRARY_NAME = 'hostmar' +HostLibrary('hostmar') -LIBRARY_NAME = 'mar' +Library('mar') UNIFIED_SOURCES += [ 'mar_create.c', diff --git a/modules/libmar/tool/moz.build b/modules/libmar/tool/moz.build index 638c8ea744d..7cb27da298d 100644 --- a/modules/libmar/tool/moz.build +++ b/modules/libmar/tool/moz.build @@ -8,14 +8,14 @@ HOST_SOURCES += [ 'mar.c', ] -HOST_PROGRAM = 'mar' +HostProgram('mar') HOST_USE_LIBS += [ 'hostmar', ] if CONFIG['MOZ_ENABLE_SIGNMAR']: - PROGRAM = 'signmar' + Program('signmar') SOURCES += HOST_SOURCES diff --git a/modules/libmar/verify/moz.build b/modules/libmar/verify/moz.build index eea09b9cc47..7a6a1422730 100644 --- a/modules/libmar/verify/moz.build +++ b/modules/libmar/verify/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -LIBRARY_NAME = 'verifymar' +Library('verifymar') UNIFIED_SOURCES += [ 'cryptox.c', diff --git a/mozglue/build/moz.build b/mozglue/build/moz.build index d0e90f0b71d..e97a8f258d2 100644 --- a/mozglue/build/moz.build +++ b/mozglue/build/moz.build @@ -69,7 +69,7 @@ if CONFIG['MOZ_ASAN']: ] -LIBRARY_NAME = 'mozglue' +Library('mozglue') USE_LIBS += [ 'mfbt', diff --git a/mozglue/linker/moz.build b/mozglue/linker/moz.build index 4b7ccdcf3ad..c44bd429fd2 100644 --- a/mozglue/linker/moz.build +++ b/mozglue/linker/moz.build @@ -12,14 +12,14 @@ SOURCES += [ 'Zip.cpp', ] -LIBRARY_NAME = 'linker' +Library('linker') HOST_SOURCES += [ 'SeekableZStream.cpp', 'szip.cpp', ] -HOST_PROGRAM = 'szip' +HostProgram('szip') FINAL_LIBRARY = 'mozglue' diff --git a/mozglue/linker/tests/moz.build b/mozglue/linker/tests/moz.build index 73c4585ebe8..4d1468bcfa0 100644 --- a/mozglue/linker/tests/moz.build +++ b/mozglue/linker/tests/moz.build @@ -9,9 +9,9 @@ NO_DIST_INSTALL = True SOURCES += [ 'TestZip.cpp', ] -SIMPLE_PROGRAMS += [ +SimplePrograms([ 'TestZip', -] +]) LOCAL_INCLUDES += ['..'] USE_LIBS += [ 'linker', diff --git a/mozglue/tests/moz.build b/mozglue/tests/moz.build index 01fb5234f39..7b8d5ef7376 100644 --- a/mozglue/tests/moz.build +++ b/mozglue/tests/moz.build @@ -10,6 +10,6 @@ SOURCES += [ 'ShowSSEConfig.cpp', ] -CPP_UNIT_TESTS += [ +CppUnitTests([ 'ShowSSEConfig', -] +]) diff --git a/netwerk/sctp/src/moz.build b/netwerk/sctp/src/moz.build index 39fc3176f4a..95c058250b5 100644 --- a/netwerk/sctp/src/moz.build +++ b/netwerk/sctp/src/moz.build @@ -40,7 +40,7 @@ if CONFIG['OS_TARGET'] == 'Android': 'ifaddrs_android.cpp', ] -LIBRARY_NAME = 'nksctp_s' +Library('nksctp_s') include('/ipc/chromium/chromium-config.mozbuild') diff --git a/netwerk/srtp/src/moz.build b/netwerk/srtp/src/moz.build index 3fe725ab3c8..ff564203140 100644 --- a/netwerk/srtp/src/moz.build +++ b/netwerk/srtp/src/moz.build @@ -31,7 +31,7 @@ UNIFIED_SOURCES += [ 'srtp/srtp.c', ] -LIBRARY_NAME = 'nksrtp_s' +Library('nksrtp_s') include('/ipc/chromium/chromium-config.mozbuild') diff --git a/netwerk/streamconv/test/moz.build b/netwerk/streamconv/test/moz.build index b5a9f98b2f4..d62d4669197 100644 --- a/netwerk/streamconv/test/moz.build +++ b/netwerk/streamconv/test/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -PROGRAM = 'TestStreamConv' +Program('TestStreamConv') UNIFIED_SOURCES += [ 'Converters.cpp', diff --git a/netwerk/test/moz.build b/netwerk/test/moz.build index 5a6e7d370ac..c86196ed4ae 100644 --- a/netwerk/test/moz.build +++ b/netwerk/test/moz.build @@ -16,7 +16,7 @@ XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini'] if CONFIG['OS_ARCH'] != 'Darwin': XPCSHELL_TESTS_MANIFESTS += ['unit_ipc/xpcshell.ini'] -SIMPLE_PROGRAMS = [ +SimplePrograms([ 'PropertiesTest', 'ReadNTLM', 'TestBlockingSocket', @@ -32,7 +32,7 @@ SIMPLE_PROGRAMS = [ 'TestUpload', 'TestURLParser', 'urltest', -] +]) # XXX Make this work in libxul builds. #SIMPLE_PROGRAMS += [ @@ -50,11 +50,11 @@ SOURCES += [ '%s.cpp' % s for s in SIMPLE_PROGRAMS ] -CPP_UNIT_TESTS += [ +CppUnitTests([ 'TestCookie', 'TestSTSParser', 'TestUDPSocket', -] +]) SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) diff --git a/other-licenses/bsdiff/moz.build b/other-licenses/bsdiff/moz.build index a341e449613..e12a40f8853 100644 --- a/other-licenses/bsdiff/moz.build +++ b/other-licenses/bsdiff/moz.build @@ -8,7 +8,7 @@ HOST_SOURCES += [ 'bsdiff.c', ] -HOST_PROGRAM = 'mbsdiff' +HostProgram('mbsdiff') if CONFIG['MOZ_NATIVE_BZ2']: HOST_OS_LIBS += CONFIG['MOZ_BZ2_LIBS'] diff --git a/profile/dirserviceprovider/moz.build b/profile/dirserviceprovider/moz.build index b576c8da6c6..a55af7f5086 100644 --- a/profile/dirserviceprovider/moz.build +++ b/profile/dirserviceprovider/moz.build @@ -15,7 +15,7 @@ if CONFIG['MOZ_PROFILELOCKING']: UNIFIED_SOURCES += ['ProfileUnlockerWin.cpp'] EXPORTS.mozilla += ['ProfileUnlockerWin.h'] -LIBRARY_NAME = 'profdirserviceprovidersa_s' +Library('profdirserviceprovidersa_s') FORCE_STATIC_LIB = True diff --git a/python/mozbuild/mozbuild/frontend/context.py b/python/mozbuild/mozbuild/frontend/context.py index 339ab7610dd..346cae03ccd 100644 --- a/python/mozbuild/mozbuild/frontend/context.py +++ b/python/mozbuild/mozbuild/frontend/context.py @@ -122,14 +122,14 @@ class Context(KeyedDefaultDict): else: return default() - def _validate(self, key, value): + def _validate(self, key, value, is_template=False): """Validates whether the key is allowed and if the value's type matches. """ stored_type, input_type, docs, tier = \ self._allowed_variables.get(key, (None, None, None, None)) - if stored_type is None: + if stored_type is None or not is_template and key in TEMPLATE_VARIABLES: raise KeyError('global_ns', 'set_unknown', key, value) # If the incoming value is not the type we store, we try to convert @@ -182,6 +182,11 @@ class Context(KeyedDefaultDict): return set(tier for tier in tiers if tier) +class TemplateContext(Context): + def _validate(self, key, value): + return Context._validate(self, key, value, True) + + class FinalTargetValue(ContextDerivedValue, unicode): def __new__(cls, context, value=""): if not value: @@ -946,6 +951,27 @@ for name, (storage_type, input_types, docs, tier) in VARIABLES.items(): raise RuntimeError('%s has a "list" storage type. Use "List" instead.' % name) +# Set of variables that are only allowed in templates: +TEMPLATE_VARIABLES = { + 'CPP_UNIT_TESTS', + 'HOST_PROGRAM', + 'HOST_LIBRARY_NAME', + 'HOST_SIMPLE_PROGRAMS', + 'LIBRARY_NAME', + 'PROGRAM', + 'SIMPLE_PROGRAMS', +} + +# Add a note to template variable documentation. +for name in TEMPLATE_VARIABLES: + if name not in VARIABLES: + raise RuntimeError('%s is in TEMPLATE_VARIABLES but not in VARIABLES.' + % name) + storage_type, input_types, docs, tier = VARIABLES[name] + docs += 'This variable is only available in templates.\n' + VARIABLES[name] = (storage_type, input_types, docs, tier) + + # The set of functions exposed to the sandbox. # # Each entry is a tuple of: @@ -1211,7 +1237,84 @@ SPECIAL_VARIABLES = { # Deprecation hints. DEPRECATION_HINTS = { + 'CPP_UNIT_TESTS': ''' + Please use' + + CppUnitTests(['foo', 'bar']) + + instead of + + CPP_UNIT_TESTS += ['foo', 'bar'] + ''', + + 'HOST_PROGRAM': ''' + Please use + + HostProgram('foo') + + instead of + + HOST_PROGRAM = 'foo' + ''', + + 'HOST_LIBRARY_NAME': ''' + Please use + + HostLibrary('foo') + + instead of + + HOST_LIBRARY_NAME = 'foo' + ''', + + 'HOST_SIMPLE_PROGRAMS': ''' + Please use + + HostSimplePrograms(['foo', 'bar']) + + instead of + + HOST_SIMPLE_PROGRAMS += ['foo', 'bar']" + ''', + + 'LIBRARY_NAME': ''' + Please use + + Library('foo') + + instead of + + LIBRARY_NAME = 'foo' + ''', + + 'PROGRAM': ''' + Please use + + Program('foo') + + instead of + + PROGRAM = 'foo'" + ''', + + 'SIMPLE_PROGRAMS': ''' + Please use + + SimplePrograms(['foo', 'bar']) + + instead of + + SIMPLE_PROGRAMS += ['foo', 'bar']" + ''', + 'TOOL_DIRS': 'Please use the DIRS variable instead.', + 'TEST_TOOL_DIRS': 'Please use the TEST_DIRS variable instead.', + 'PARALLEL_DIRS': 'Please use the DIRS variable instead.', } + +# Make sure that all template variables have a deprecation hint. +for name in TEMPLATE_VARIABLES: + if name not in DEPRECATION_HINTS: + raise RuntimeError('Missing deprecation hint for %s' % name) diff --git a/python/mozbuild/mozbuild/frontend/gyp_reader.py b/python/mozbuild/mozbuild/frontend/gyp_reader.py index 63a335d175a..4e9b6a16bc7 100644 --- a/python/mozbuild/mozbuild/frontend/gyp_reader.py +++ b/python/mozbuild/mozbuild/frontend/gyp_reader.py @@ -11,7 +11,7 @@ import mozpack.path as mozpath from mozpack.files import FileFinder from .sandbox import alphabetical_sorted from .context import ( - Context, + TemplateContext, VARIABLES, ) from mozbuild.util import ( @@ -52,7 +52,7 @@ for unused in ['RULE_INPUT_PATH', 'RULE_INPUT_ROOT', 'RULE_INPUT_NAME', generator_default_variables[unused] = b'' -class GypContext(Context): +class GypContext(TemplateContext): """Specialized Context for use with data extracted from Gyp. config is the ConfigEnvironment for this context. @@ -61,7 +61,8 @@ class GypContext(Context): """ def __init__(self, config, relobjdir): self._relobjdir = relobjdir - Context.__init__(self, allowed_variables=self.VARIABLES(), config=config) + TemplateContext.__init__(self, allowed_variables=self.VARIABLES(), + config=config) @classmethod @memoize diff --git a/python/mozbuild/mozbuild/frontend/reader.py b/python/mozbuild/mozbuild/frontend/reader.py index 17f187e3b17..d6a731ffa9e 100644 --- a/python/mozbuild/mozbuild/frontend/reader.py +++ b/python/mozbuild/mozbuild/frontend/reader.py @@ -22,6 +22,7 @@ import inspect import logging import os import sys +import textwrap import time import tokenize import traceback @@ -59,6 +60,7 @@ from .context import ( VARIABLES, DEPRECATION_HINTS, SPECIAL_VARIABLES, + TemplateContext, ) if sys.version_info.major == 2: @@ -379,7 +381,7 @@ class MozbuildSandbox(Sandbox): func, code, path = template def template_function(*args, **kwargs): - context = Context(VARIABLES, self._context.config) + context = TemplateContext(VARIABLES, self._context.config) context.add_source(self._execution_stack[-1]) for p in self._context.all_paths: context.add_source(p) @@ -390,6 +392,10 @@ class MozbuildSandbox(Sandbox): sandbox.exec_source(code, path) + # This is gross, but allows the merge to happen. Eventually, the + # merging will go away and template contexts emitted independently. + klass = self._context.__class__ + self._context.__class__ = TemplateContext # The sandbox will do all the necessary checks for these merges. for key, value in context.items(): if isinstance(value, dict): @@ -398,6 +404,7 @@ class MozbuildSandbox(Sandbox): self[key] += value else: self[key] = value + self._context.__class__ = klass for p in context.all_paths: self._context.add_source(p) @@ -668,7 +675,8 @@ class BuildReaderError(Exception): s.write('\n') if inner.args[2] in DEPRECATION_HINTS: - s.write('%s\n' % DEPRECATION_HINTS[inner.args[2]]) + s.write('%s\n' % + textwrap.dedent(DEPRECATION_HINTS[inner.args[2]]).strip()) return s.write('Please change the file to not use this variable.\n') diff --git a/python/mozbuild/mozbuild/test/backend/data/visual-studio/moz.build b/python/mozbuild/mozbuild/test/backend/data/visual-studio/moz.build index e52acb3794f..ae3153f2aa0 100644 --- a/python/mozbuild/mozbuild/test/backend/data/visual-studio/moz.build +++ b/python/mozbuild/mozbuild/test/backend/data/visual-studio/moz.build @@ -4,4 +4,4 @@ add_tier_dir('libs', ['dir1']) -LIBRARY_NAME = 'test' +Library('test') diff --git a/python/mozbuild/mozbuild/test/frontend/data/program/moz.build b/python/mozbuild/mozbuild/test/frontend/data/program/moz.build index 4f315a4619a..4c19b90cd54 100644 --- a/python/mozbuild/mozbuild/test/frontend/data/program/moz.build +++ b/python/mozbuild/mozbuild/test/frontend/data/program/moz.build @@ -1,6 +1,15 @@ # Any copyright is dedicated to the Public Domain. # http://creativecommons.org/publicdomain/zero/1.0/ -PROGRAM = 'test_program' +@template +def Program(name): + PROGRAM = name -SIMPLE_PROGRAMS = [ 'test_program1', 'test_program2' ] + +@template +def SimplePrograms(names): + SIMPLE_PROGRAMS += names + +Program('test_program') + +SimplePrograms([ 'test_program1', 'test_program2' ]) diff --git a/rdf/tests/rdfcat/moz.build b/rdf/tests/rdfcat/moz.build index f4b730ad887..56b2f877539 100644 --- a/rdf/tests/rdfcat/moz.build +++ b/rdf/tests/rdfcat/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -PROGRAM = 'rdfcat' +Program('rdfcat') SOURCES += [ 'rdfcat.cpp', diff --git a/rdf/tests/rdfpoll/moz.build b/rdf/tests/rdfpoll/moz.build index 7367378dbcc..41ef0fd2579 100644 --- a/rdf/tests/rdfpoll/moz.build +++ b/rdf/tests/rdfpoll/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -PROGRAM = 'rdfpoll' +Program('rdfpoll') SOURCES += [ 'rdfpoll.cpp', diff --git a/rdf/tests/triplescat/moz.build b/rdf/tests/triplescat/moz.build index 13953e1714e..f1d0cfb0a7d 100644 --- a/rdf/tests/triplescat/moz.build +++ b/rdf/tests/triplescat/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -PROGRAM = 'triplescat' +Program('triplescat') SOURCES += [ 'triplescat.cpp', diff --git a/rdf/util/moz.build b/rdf/util/moz.build index 917916bd220..b99bea462c0 100644 --- a/rdf/util/moz.build +++ b/rdf/util/moz.build @@ -14,7 +14,7 @@ include('objs.mozbuild') SOURCES += rdf_util_src_cppsrcs -LIBRARY_NAME = 'rdfutil_external_s' +Library('rdfutil_external_s') # we don't want the shared lib, but we want to force the creation of a static lib. FORCE_STATIC_LIB = True diff --git a/security/manager/ssl/tests/compiled/moz.build b/security/manager/ssl/tests/compiled/moz.build index 4c201f0b035..6ed376dd9da 100644 --- a/security/manager/ssl/tests/compiled/moz.build +++ b/security/manager/ssl/tests/compiled/moz.build @@ -4,9 +4,9 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -CPP_UNIT_TESTS += [ +CppUnitTests([ 'TestCertDB', -] +]) SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) diff --git a/security/manager/ssl/tests/unit/pkcs11testmodule/moz.build b/security/manager/ssl/tests/unit/pkcs11testmodule/moz.build index 5f9716aee57..9543ee60073 100644 --- a/security/manager/ssl/tests/unit/pkcs11testmodule/moz.build +++ b/security/manager/ssl/tests/unit/pkcs11testmodule/moz.build @@ -8,7 +8,7 @@ UNIFIED_SOURCES += [ 'pkcs11testmodule.cpp', ] -LIBRARY_NAME = 'pkcs11testmodule' +Library('pkcs11testmodule') FORCE_SHARED_LIB = True # C_GetFunctionList needs to be exported. As it turns out, it's much easier to diff --git a/security/manager/ssl/tests/unit/tlsserver/cmd/moz.build b/security/manager/ssl/tests/unit/tlsserver/cmd/moz.build index a679f8a0b90..416fb35a1c4 100644 --- a/security/manager/ssl/tests/unit/tlsserver/cmd/moz.build +++ b/security/manager/ssl/tests/unit/tlsserver/cmd/moz.build @@ -6,12 +6,12 @@ FAIL_ON_WARNINGS = True -SIMPLE_PROGRAMS = [ +SimplePrograms([ 'BadCertServer', 'ClientAuthServer', 'GenerateOCSPResponse', 'OCSPStaplingServer', -] +]) SOURCES += [ '%s.cpp' % s for s in SIMPLE_PROGRAMS diff --git a/security/manager/ssl/tests/unit/tlsserver/lib/moz.build b/security/manager/ssl/tests/unit/tlsserver/lib/moz.build index d2ce36eca6e..28df99a529c 100644 --- a/security/manager/ssl/tests/unit/tlsserver/lib/moz.build +++ b/security/manager/ssl/tests/unit/tlsserver/lib/moz.build @@ -14,4 +14,4 @@ LOCAL_INCLUDES += [ '../../../../../../pkix/test/lib', ] -LIBRARY_NAME = 'tlsserver' +Library('tlsserver') diff --git a/security/pkix/moz.build b/security/pkix/moz.build index 5e8570429c3..3c3a4dbf541 100644 --- a/security/pkix/moz.build +++ b/security/pkix/moz.build @@ -37,6 +37,6 @@ if CONFIG['_MSC_VER']: FAIL_ON_WARNINGS = True -LIBRARY_NAME = 'mozillapkix' +Library('mozillapkix') FINAL_LIBRARY = 'xul' diff --git a/security/pkix/test/lib/moz.build b/security/pkix/test/lib/moz.build index cfaa1f3fff2..9374ea43302 100644 --- a/security/pkix/test/lib/moz.build +++ b/security/pkix/test/lib/moz.build @@ -24,7 +24,7 @@ SOURCES += [ 'pkixtestutil.cpp', ] -LIBRARY_NAME = 'pkixtestutil' +Library('pkixtestutil') LOCAL_INCLUDES += [ '../../include', diff --git a/security/sandbox/linux/moz.build b/security/sandbox/linux/moz.build index 9aa1e0b1b8b..74c1736a4b4 100644 --- a/security/sandbox/linux/moz.build +++ b/security/sandbox/linux/moz.build @@ -6,7 +6,7 @@ FAIL_ON_WARNINGS = True -LIBRARY_NAME = 'mozsandbox' +Library('mozsandbox') FORCE_SHARED_LIB = True EXPORTS.mozilla += [ diff --git a/security/sandbox/moz.build b/security/sandbox/moz.build index 716fc22630b..113a143724a 100644 --- a/security/sandbox/moz.build +++ b/security/sandbox/moz.build @@ -9,7 +9,7 @@ if CONFIG['OS_ARCH'] == 'Linux': elif CONFIG['OS_ARCH'] == 'Darwin': DIRS += ['mac'] elif CONFIG['OS_ARCH'] == 'WINNT': - LIBRARY_NAME = 'sandbox_s' + Library('sandbox_s') FORCE_STATIC_LIB = True DIRS += [ diff --git a/security/sandbox/staticruntime/moz.build b/security/sandbox/staticruntime/moz.build index 33775efd1c8..ad6ddfe976f 100644 --- a/security/sandbox/staticruntime/moz.build +++ b/security/sandbox/staticruntime/moz.build @@ -5,7 +5,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. if CONFIG['OS_ARCH'] == 'WINNT': - LIBRARY_NAME = 'sandbox_staticruntime_s' + Library('sandbox_staticruntime_s') FORCE_STATIC_LIB = True USE_STATIC_LIBS = True diff --git a/security/sandbox/win/src/sandboxbroker/moz.build b/security/sandbox/win/src/sandboxbroker/moz.build index f95623820e5..eed82492d5a 100644 --- a/security/sandbox/win/src/sandboxbroker/moz.build +++ b/security/sandbox/win/src/sandboxbroker/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -LIBRARY_NAME = 'sandboxbroker' +Library('sandboxbroker') USE_LIBS += [ 'nspr', diff --git a/startupcache/test/moz.build b/startupcache/test/moz.build index 2347e19ec73..7d6a4e7f7cc 100644 --- a/startupcache/test/moz.build +++ b/startupcache/test/moz.build @@ -4,9 +4,9 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -CPP_UNIT_TESTS += [ +CppUnitTests([ 'TestStartupCache', -] +]) SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) diff --git a/storage/test/moz.build b/storage/test/moz.build index f8ea008dad0..02d25832bab 100644 --- a/storage/test/moz.build +++ b/storage/test/moz.build @@ -6,7 +6,7 @@ XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini'] -CPP_UNIT_TESTS += [ +CppUnitTests([ 'test_AsXXX_helpers', 'test_async_callbacks_with_spun_event_loops', 'test_asyncStatementExecution_transaction', @@ -19,14 +19,14 @@ CPP_UNIT_TESTS += [ 'test_transaction_helper', 'test_true_async', 'test_unlock_notify', -] +]) if CONFIG['MOZ_DEBUG'] and CONFIG['OS_ARCH'] not in ('WINNT', 'Darwin'): # FIXME bug 523392: test_deadlock_detector doesn't like Windows # FIXME bug 523378: also fails on OS X - CPP_UNIT_TESTS += [ + CppUnitTests([ 'test_deadlock_detector', - ] + ]) SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) diff --git a/testing/gtest/moz.build b/testing/gtest/moz.build index ac4de39e011..fb19ada2451 100644 --- a/testing/gtest/moz.build +++ b/testing/gtest/moz.build @@ -62,7 +62,7 @@ if CONFIG['ENABLE_TESTS']: 'mozilla/GTestRunner.cpp', ] - LIBRARY_NAME = 'gtest' + Library('gtest') SOURCES += [ 'mozilla/SanityTest.cpp', diff --git a/testing/mochitest/ssltunnel/moz.build b/testing/mochitest/ssltunnel/moz.build index 863d26128f2..dae73aff7c9 100644 --- a/testing/mochitest/ssltunnel/moz.build +++ b/testing/mochitest/ssltunnel/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -PROGRAM = 'ssltunnel' +Program('ssltunnel') SOURCES += [ 'ssltunnel.cpp', diff --git a/testing/tools/screenshot/moz.build b/testing/tools/screenshot/moz.build index 67970cda79d..50732236ee4 100644 --- a/testing/tools/screenshot/moz.build +++ b/testing/tools/screenshot/moz.build @@ -5,7 +5,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. if CONFIG['MOZ_WIDGET_GTK'] and CONFIG['MOZ_X11']: - PROGRAM = 'screentopng' + Program('screentopng') SOURCES += [ 'gdk-screenshot.cpp', ] @@ -13,7 +13,7 @@ if CONFIG['MOZ_WIDGET_GTK'] and CONFIG['MOZ_X11']: OS_LIBS += CONFIG['TK_LIBS'] OS_LIBS += CONFIG['XSS_LIBS'] elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': - PROGRAM = 'screenshot' + Program('screenshot') SOURCES += [ 'win32-screenshot.cpp', ] diff --git a/toolkit/components/ctypes/tests/moz.build b/toolkit/components/ctypes/tests/moz.build index 2db986b2572..749ccd4622c 100644 --- a/toolkit/components/ctypes/tests/moz.build +++ b/toolkit/components/ctypes/tests/moz.build @@ -14,7 +14,7 @@ UNIFIED_SOURCES += [ 'jsctypes-test.cpp', ] -LIBRARY_NAME = 'jsctypes-test' +Library('jsctypes-test') FORCE_SHARED_LIB = True diff --git a/toolkit/components/maintenanceservice/moz.build b/toolkit/components/maintenanceservice/moz.build index 05045542b05..c2e5921b1f2 100644 --- a/toolkit/components/maintenanceservice/moz.build +++ b/toolkit/components/maintenanceservice/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -PROGRAM = 'maintenanceservice' +Program('maintenanceservice') SOURCES += [ 'certificatecheck.cpp', diff --git a/toolkit/components/places/tests/cpp/moz.build b/toolkit/components/places/tests/cpp/moz.build index 9aa5a2a93cb..c5488e751fe 100644 --- a/toolkit/components/places/tests/cpp/moz.build +++ b/toolkit/components/places/tests/cpp/moz.build @@ -4,9 +4,9 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -CPP_UNIT_TESTS += [ +CppUnitTests([ 'test_IHistory', -] +]) SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) diff --git a/toolkit/crashreporter/breakpad-windows-libxul/moz.build b/toolkit/crashreporter/breakpad-windows-libxul/moz.build index 8e8f4ae0529..d638b4ef0f1 100644 --- a/toolkit/crashreporter/breakpad-windows-libxul/moz.build +++ b/toolkit/crashreporter/breakpad-windows-libxul/moz.build @@ -12,7 +12,7 @@ SOURCES += [ '../google-breakpad/src/common/windows/http_upload.cc', ] -LIBRARY_NAME = 'google_breakpad_libxul_s' +Library('google_breakpad_libxul_s') FINAL_LIBRARY = 'xul' diff --git a/toolkit/crashreporter/breakpad-windows-libxul/staticruntime/moz.build b/toolkit/crashreporter/breakpad-windows-libxul/staticruntime/moz.build index 4ab4f8ac6f0..f7b45f2ecb2 100644 --- a/toolkit/crashreporter/breakpad-windows-libxul/staticruntime/moz.build +++ b/toolkit/crashreporter/breakpad-windows-libxul/staticruntime/moz.build @@ -8,7 +8,7 @@ SOURCES += [ '../../google-breakpad/src/common/windows/http_upload.cc', ] -LIBRARY_NAME = 'google_breakpad_libxul_staticruntime_s' +Library('google_breakpad_libxul_staticruntime_s') for var in ('UNICODE', 'UNICODE_', 'BREAKPAD_NO_TERMINATE_THREAD', 'NOMINMAX'): DEFINES[var] = True diff --git a/toolkit/crashreporter/client/moz.build b/toolkit/crashreporter/client/moz.build index 3762ebf93cb..865d3d73f88 100644 --- a/toolkit/crashreporter/client/moz.build +++ b/toolkit/crashreporter/client/moz.build @@ -5,7 +5,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. if CONFIG['OS_TARGET'] != 'Android': - PROGRAM = 'crashreporter' + Program('crashreporter') UNIFIED_SOURCES += [ 'crashreporter.cpp', diff --git a/toolkit/crashreporter/google-breakpad/src/common/dwarf/moz.build b/toolkit/crashreporter/google-breakpad/src/common/dwarf/moz.build index 496c2e0183c..58f958beb28 100644 --- a/toolkit/crashreporter/google-breakpad/src/common/dwarf/moz.build +++ b/toolkit/crashreporter/google-breakpad/src/common/dwarf/moz.build @@ -5,7 +5,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. if CONFIG['MOZ_CRASHREPORTER']: - HOST_LIBRARY_NAME = 'host_breakpad_dwarf_s' + HostLibrary('host_breakpad_dwarf_s') HOST_SOURCES += [ 'bytereader.cc', 'dwarf2diehandler.cc', diff --git a/toolkit/crashreporter/google-breakpad/src/common/linux/moz.build b/toolkit/crashreporter/google-breakpad/src/common/linux/moz.build index 396a22f3ae4..13446dd3387 100644 --- a/toolkit/crashreporter/google-breakpad/src/common/linux/moz.build +++ b/toolkit/crashreporter/google-breakpad/src/common/linux/moz.build @@ -23,7 +23,7 @@ if CONFIG['OS_TARGET'] != 'Android': ] if CONFIG['MOZ_CRASHREPORTER']: - HOST_LIBRARY_NAME = 'host_breakpad_linux_common_s' + HostLibrary('host_breakpad_linux_common_s') HOST_SOURCES += [ 'dump_symbols.cc', 'elf_symbols_to_module.cc', @@ -34,7 +34,7 @@ if CONFIG['MOZ_CRASHREPORTER']: 'memory_mapped_file.cc', ] -LIBRARY_NAME = 'breakpad_linux_common_s' +Library('breakpad_linux_common_s') FINAL_LIBRARY = 'xul' diff --git a/toolkit/crashreporter/google-breakpad/src/common/mac/moz.build b/toolkit/crashreporter/google-breakpad/src/common/mac/moz.build index e896b44694d..7d2860b82d5 100644 --- a/toolkit/crashreporter/google-breakpad/src/common/mac/moz.build +++ b/toolkit/crashreporter/google-breakpad/src/common/mac/moz.build @@ -23,14 +23,14 @@ if CONFIG['MOZ_CRASHREPORTER']: HOST_SOURCES += [ 'dump_syms.mm', ] - HOST_LIBRARY_NAME = 'host_breakpad_mac_common_s' + HostLibrary('host_breakpad_mac_common_s') SOURCES += [ 'HTTPMultipartUpload.m', 'MachIPC.mm', ] -LIBRARY_NAME = 'breakpad_mac_common_s' +Library('breakpad_mac_common_s') FINAL_LIBRARY = 'xul' diff --git a/toolkit/crashreporter/google-breakpad/src/common/moz.build b/toolkit/crashreporter/google-breakpad/src/common/moz.build index a0ce6d1cbfc..be0a02cc572 100644 --- a/toolkit/crashreporter/google-breakpad/src/common/moz.build +++ b/toolkit/crashreporter/google-breakpad/src/common/moz.build @@ -47,7 +47,7 @@ else: if CONFIG['OS_TARGET'] != 'WINNT' and CONFIG['MOZ_CRASHREPORTER']: HOST_SOURCES += [ 'convert_UTF.c' ] - HOST_LIBRARY_NAME = 'host_breakpad_common_s' + HostLibrary('host_breakpad_common_s') HOST_SOURCES += [ 'arm_ex_reader.cc', 'arm_ex_to_module.cc', @@ -76,7 +76,7 @@ if CONFIG['OS_TARGET'] == 'Android': 'android/breakpad_getcontext.S', ] -LIBRARY_NAME = 'breakpad_common_s' +Library('breakpad_common_s') MSVC_ENABLE_PGO = True diff --git a/toolkit/crashreporter/google-breakpad/src/common/solaris/moz.build b/toolkit/crashreporter/google-breakpad/src/common/solaris/moz.build index cb3e39956d8..d3286166eda 100644 --- a/toolkit/crashreporter/google-breakpad/src/common/solaris/moz.build +++ b/toolkit/crashreporter/google-breakpad/src/common/solaris/moz.build @@ -10,9 +10,9 @@ UNIFIED_SOURCES += [ 'guid_creator.cc', ] -HOST_LIBRARY_NAME = 'host_breakpad_solaris_common_s' +HostLibrary('host_breakpad_solaris_common_s') -LIBRARY_NAME = 'breakpad_solaris_common_s' +Library('breakpad_solaris_common_s') # not compiling http_upload.cc currently # since it depends on libcurl diff --git a/toolkit/crashreporter/google-breakpad/src/tools/linux/dump_syms/moz.build b/toolkit/crashreporter/google-breakpad/src/tools/linux/dump_syms/moz.build index 2689c37a940..4a1d11fbd34 100644 --- a/toolkit/crashreporter/google-breakpad/src/tools/linux/dump_syms/moz.build +++ b/toolkit/crashreporter/google-breakpad/src/tools/linux/dump_syms/moz.build @@ -8,7 +8,7 @@ HOST_SOURCES += [ 'dump_syms.cc', ] -HOST_PROGRAM = 'dump_syms' +HostProgram('dump_syms') # host_breakpad_linux_common_s needs to come first HOST_USE_LIBS += [ diff --git a/toolkit/crashreporter/google-breakpad/src/tools/mac/dump_syms/moz.build b/toolkit/crashreporter/google-breakpad/src/tools/mac/dump_syms/moz.build index 0d766f9c0e8..385f8980da2 100644 --- a/toolkit/crashreporter/google-breakpad/src/tools/mac/dump_syms/moz.build +++ b/toolkit/crashreporter/google-breakpad/src/tools/mac/dump_syms/moz.build @@ -8,7 +8,7 @@ HOST_SOURCES += [ 'dump_syms_tool.mm', ] -HOST_PROGRAM = 'dump_syms' +HostProgram('dump_syms') HOST_USE_LIBS += [ 'host_breakpad_common_s', diff --git a/toolkit/crashreporter/google-breakpad/src/tools/solaris/dump_syms/moz.build b/toolkit/crashreporter/google-breakpad/src/tools/solaris/dump_syms/moz.build index 5ce6cd5b1e4..203c8d762cd 100644 --- a/toolkit/crashreporter/google-breakpad/src/tools/solaris/dump_syms/moz.build +++ b/toolkit/crashreporter/google-breakpad/src/tools/solaris/dump_syms/moz.build @@ -8,7 +8,7 @@ HOST_SOURCES += [ 'dump_syms.cc', ] -HOST_PROGRAM = 'dump_syms' +HostProgram('dump_syms') HOST_USE_LIBS += [ 'host_breakpad_common_s', diff --git a/toolkit/crashreporter/injector/moz.build b/toolkit/crashreporter/injector/moz.build index 1f706d20ec1..83d02b14c30 100644 --- a/toolkit/crashreporter/injector/moz.build +++ b/toolkit/crashreporter/injector/moz.build @@ -8,7 +8,7 @@ SOURCES += [ 'injector.cpp', ] -LIBRARY_NAME = 'breakpadinjector' +Library('breakpadinjector') include('/ipc/chromium/chromium-config.mozbuild') diff --git a/toolkit/crashreporter/test/moz.build b/toolkit/crashreporter/test/moz.build index 0fc93e03ceb..9d93cbf94d4 100644 --- a/toolkit/crashreporter/test/moz.build +++ b/toolkit/crashreporter/test/moz.build @@ -17,7 +17,7 @@ UNIFIED_SOURCES += [ 'nsTestCrasher.cpp', ] -LIBRARY_NAME = 'testcrasher' +Library('testcrasher') EXTRA_JS_MODULES += [ 'CrashTestUtils.jsm', diff --git a/toolkit/library/StaticXULComponentsEnd/moz.build b/toolkit/library/StaticXULComponentsEnd/moz.build index 752d50000e5..67989edd490 100644 --- a/toolkit/library/StaticXULComponentsEnd/moz.build +++ b/toolkit/library/StaticXULComponentsEnd/moz.build @@ -10,6 +10,6 @@ SOURCES += [ if '-flto' in CONFIG['OS_CXXFLAGS']: SOURCES['StaticXULComponentsEnd.cpp'].flags += ['-fno-lto'] -LIBRARY_NAME = 'StaticXULComponentsEnd' +Library('StaticXULComponentsEnd') DEFINES['MOZILLA_INTERNAL_API'] = True diff --git a/toolkit/library/gtest/moz.build b/toolkit/library/gtest/moz.build index f8538df8ce0..04dc296bcb4 100644 --- a/toolkit/library/gtest/moz.build +++ b/toolkit/library/gtest/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -LIBRARY_NAME = 'xul-gtest' +Library('xul-gtest') FINAL_TARGET = 'dist/bin/gtest' diff --git a/toolkit/library/moz.build b/toolkit/library/moz.build index b1b0472afb6..f3784c5eb1a 100644 --- a/toolkit/library/moz.build +++ b/toolkit/library/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -LIBRARY_NAME = 'xul' +Library('xul') SDK_LIBRARY = True diff --git a/toolkit/mozapps/plugins/tests/moz.build b/toolkit/mozapps/plugins/tests/moz.build index 5f32668cc03..ab0d7f17dd7 100644 --- a/toolkit/mozapps/plugins/tests/moz.build +++ b/toolkit/mozapps/plugins/tests/moz.build @@ -4,10 +4,10 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -SIMPLE_PROGRAMS = [ +SimplePrograms([ 'BadPlugin', 'GoodPlugin', -] +]) SOURCES += [ '%s.cpp' % s for s in SIMPLE_PROGRAMS diff --git a/toolkit/mozapps/update/common-standalone/moz.build b/toolkit/mozapps/update/common-standalone/moz.build index 34d543df730..dbc787b437b 100644 --- a/toolkit/mozapps/update/common-standalone/moz.build +++ b/toolkit/mozapps/update/common-standalone/moz.build @@ -2,7 +2,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -LIBRARY_NAME = 'updatecommon-standalone' +Library('updatecommon-standalone') srcdir = '../common' diff --git a/toolkit/mozapps/update/common/moz.build b/toolkit/mozapps/update/common/moz.build index 46ad07746e4..2e9b89d747b 100644 --- a/toolkit/mozapps/update/common/moz.build +++ b/toolkit/mozapps/update/common/moz.build @@ -18,7 +18,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': 'updatehelper.h', ] -LIBRARY_NAME = 'updatecommon' +Library('updatecommon') srcdir = '.' diff --git a/toolkit/mozapps/update/tests/moz.build b/toolkit/mozapps/update/tests/moz.build index f3764fc7fbe..49688d73e71 100644 --- a/toolkit/mozapps/update/tests/moz.build +++ b/toolkit/mozapps/update/tests/moz.build @@ -13,10 +13,10 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'android': if CONFIG['MOZ_MAINTENANCE_SERVICE'] and not CONFIG['HAVE_64BIT_BUILD']: XPCSHELL_TESTS_MANIFESTS += ['unit_service_updater/xpcshell.ini'] - SIMPLE_PROGRAMS = [ + SimplePrograms([ 'TestAUSHelper', 'TestAUSReadStrings', - ] + ]) SOURCES += [ '%s.cpp' % s for s in SIMPLE_PROGRAMS diff --git a/toolkit/mozapps/update/updater/moz.build b/toolkit/mozapps/update/updater/moz.build index fb69758993d..153217539d6 100644 --- a/toolkit/mozapps/update/updater/moz.build +++ b/toolkit/mozapps/update/updater/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -PROGRAM = 'updater' +Program('updater') SOURCES += [ 'archivereader.cpp', diff --git a/toolkit/webapps/tests/moz.build b/toolkit/webapps/tests/moz.build index b39ce28c6f8..943219eb9da 100644 --- a/toolkit/webapps/tests/moz.build +++ b/toolkit/webapps/tests/moz.build @@ -6,4 +6,4 @@ MOCHITEST_CHROME_MANIFESTS += ['chrome.ini'] SOURCES += ['TestWebappRT.cpp' ] -SIMPLE_PROGRAMS += ['TestWebappRT'] +SimplePrograms(['TestWebappRT']) diff --git a/toolkit/xre/test/win/moz.build b/toolkit/xre/test/win/moz.build index d69dbf6d7aa..e99c6d2cf97 100644 --- a/toolkit/xre/test/win/moz.build +++ b/toolkit/xre/test/win/moz.build @@ -4,17 +4,17 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -SIMPLE_PROGRAMS = [ +SimplePrograms([ 'TestXREMakeCommandLineWin', -] +]) SOURCES += [ '%s.cpp' % s for s in SIMPLE_PROGRAMS ] -CPP_UNIT_TESTS += [ +CppUnitTests([ 'TestDllInterceptor', -] +]) SOURCES += [ '%s.cpp' % s for s in CPP_UNIT_TESTS diff --git a/tools/jprof/moz.build b/tools/jprof/moz.build index 5074e7a81c4..4410e2de61c 100644 --- a/tools/jprof/moz.build +++ b/tools/jprof/moz.build @@ -6,7 +6,7 @@ DIRS += ['stub'] -PROGRAM = 'jprof' +Program('jprof') SOURCES += [ 'bfd.cpp', diff --git a/tools/jprof/stub/moz.build b/tools/jprof/stub/moz.build index 169b08076aa..1ed19f49227 100644 --- a/tools/jprof/stub/moz.build +++ b/tools/jprof/stub/moz.build @@ -12,7 +12,7 @@ SOURCES += [ 'libmalloc.cpp', ] -LIBRARY_NAME = 'jprof' +Library('jprof') FORCE_SHARED_LIB = True diff --git a/tools/trace-malloc/moz.build b/tools/trace-malloc/moz.build index 2d662c4a543..9c754913242 100644 --- a/tools/trace-malloc/moz.build +++ b/tools/trace-malloc/moz.build @@ -5,7 +5,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. if not CONFIG['MOZ_PROFILE_GENERATE']: - PROGRAM = 'spacetrace' + Program('spacetrace') SOURCES += [ 'formdata.c', 'spacecategory.c', @@ -27,7 +27,7 @@ SOURCES += [ 'tmreader.c', ] -SIMPLE_PROGRAMS += simple_c_sources +SimplePrograms(simple_c_sources) simple_cpp_sources = [ 'bloatblame', @@ -38,7 +38,7 @@ SOURCES += [ '%s.cpp' % s for s in simple_cpp_sources ] -SIMPLE_PROGRAMS += simple_cpp_sources +SimplePrograms(simple_cpp_sources) RESOURCE_FILES += [ 'spacetrace.css' diff --git a/uriloader/exthandler/tests/moz.build b/uriloader/exthandler/tests/moz.build index e0a7c7ad3b8..057d93da396 100644 --- a/uriloader/exthandler/tests/moz.build +++ b/uriloader/exthandler/tests/moz.build @@ -16,9 +16,9 @@ if CONFIG['OS_ARCH'] != 'Darwin': if not CONFIG['MOZ_JSDOWNLOADS']: XPCSHELL_TESTS_MANIFESTS += ['unit_ipc/xpcshell.ini'] -SIMPLE_PROGRAMS = [ +SimplePrograms([ 'WriteArgument', -] +]) SOURCES += [ '%s.cpp' % s for s in SIMPLE_PROGRAMS diff --git a/webapprt/gtk/moz.build b/webapprt/gtk/moz.build index 4aff81f7934..da4cc6fec4c 100644 --- a/webapprt/gtk/moz.build +++ b/webapprt/gtk/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -PROGRAM = 'webapprt-stub' +Program('webapprt-stub') SOURCES += [ 'webapprt.cpp', diff --git a/webapprt/mac/moz.build b/webapprt/mac/moz.build index f91b9db48d2..774971dcca2 100644 --- a/webapprt/mac/moz.build +++ b/webapprt/mac/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -PROGRAM = 'webapprt-stub' +Program('webapprt-stub') SOURCES += [ 'webapprt.mm', diff --git a/webapprt/win/moz.build b/webapprt/win/moz.build index beda2248b7a..7695e2ef291 100644 --- a/webapprt/win/moz.build +++ b/webapprt/win/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -PROGRAM = 'webapprt-stub' +Program('webapprt-stub') SOURCES += [ 'webapprt.cpp', diff --git a/widget/gonk/libdisplay/moz.build b/widget/gonk/libdisplay/moz.build index 94f825a57bc..1fd69b1a106 100644 --- a/widget/gonk/libdisplay/moz.build +++ b/widget/gonk/libdisplay/moz.build @@ -36,7 +36,7 @@ elif CONFIG['ANDROID_VERSION'] == '15': elif CONFIG['ANDROID_VERSION'] and CONFIG['COMPILE_ENVIRONMENT']: error('Unsupported platform version: %s' % (CONFIG['ANDROID_VERSION'])) -LIBRARY_NAME = 'display' +Library('display') include('/ipc/chromium/chromium-config.mozbuild') diff --git a/widget/gtk/mozgtk/gtk2/moz.build b/widget/gtk/mozgtk/gtk2/moz.build index b21d9062f5f..b9f7d2f6237 100644 --- a/widget/gtk/mozgtk/gtk2/moz.build +++ b/widget/gtk/mozgtk/gtk2/moz.build @@ -10,7 +10,7 @@ SOURCES += [ DEFINES['GTK3_SYMBOLS'] = True -LIBRARY_NAME = 'mozgtk2' +Library('mozgtk2') SONAME = 'mozgtk' diff --git a/widget/gtk/mozgtk/gtk3/moz.build b/widget/gtk/mozgtk/gtk3/moz.build index 3355e3a3bdc..c8b5c3b7c91 100644 --- a/widget/gtk/mozgtk/gtk3/moz.build +++ b/widget/gtk/mozgtk/gtk3/moz.build @@ -10,7 +10,7 @@ SOURCES += [ DEFINES['GTK2_SYMBOLS'] = True -LIBRARY_NAME = 'mozgtk' +Library('mozgtk') SONAME = 'mozgtk' diff --git a/widget/gtk/mozgtk/stub/moz.build b/widget/gtk/mozgtk/stub/moz.build index 02675c98ff1..c1611acbbf9 100644 --- a/widget/gtk/mozgtk/stub/moz.build +++ b/widget/gtk/mozgtk/stub/moz.build @@ -11,7 +11,7 @@ SOURCES += [ for var in ('COMMON_SYMBOLS', 'GTK2_SYMBOLS', 'GTK3_SYMBOLS'): DEFINES[var] = True -LIBRARY_NAME = 'mozgtk_stub' +Library('mozgtk_stub') SONAME = 'mozgtk' diff --git a/widget/tests/moz.build b/widget/tests/moz.build index 576a2817ba5..31e6c40c177 100644 --- a/widget/tests/moz.build +++ b/widget/tests/moz.build @@ -8,9 +8,9 @@ XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini'] MOCHITEST_MANIFESTS += ['mochitest.ini'] MOCHITEST_CHROME_MANIFESTS += ['chrome.ini'] -CPP_UNIT_TESTS += [ +CppUnitTests([ 'TestAppShellSteadyState', -] +]) FAIL_ON_WARNINGS = True diff --git a/widget/xremoteclient/moz.build b/widget/xremoteclient/moz.build index 0888a6bc294..a5813d7cc85 100644 --- a/widget/xremoteclient/moz.build +++ b/widget/xremoteclient/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -PROGRAM = 'mozilla-xremote-client' +Program('mozilla-xremote-client') FINAL_LIBRARY = 'xul' diff --git a/xpcom/glue/moz.build b/xpcom/glue/moz.build index 4d68d8242dc..9a43c7436d1 100644 --- a/xpcom/glue/moz.build +++ b/xpcom/glue/moz.build @@ -95,7 +95,7 @@ UNIFIED_SOURCES += [ 'nsStringAPI.cpp', ] -LIBRARY_NAME = 'xpcomglue_s' +Library('xpcomglue_s') SDK_LIBRARY = True diff --git a/xpcom/glue/nomozalloc/moz.build b/xpcom/glue/nomozalloc/moz.build index 7a8c7abff54..179ccfa0ed9 100644 --- a/xpcom/glue/nomozalloc/moz.build +++ b/xpcom/glue/nomozalloc/moz.build @@ -14,7 +14,7 @@ UNIFIED_SOURCES += [ '../nsStringAPI.cpp', ] -LIBRARY_NAME = 'xpcomglue_s_nomozalloc' +Library('xpcomglue_s_nomozalloc') SDK_LIBRARY = True diff --git a/xpcom/glue/standalone/moz.build b/xpcom/glue/standalone/moz.build index fe526307f7a..84c9da2fa8d 100644 --- a/xpcom/glue/standalone/moz.build +++ b/xpcom/glue/standalone/moz.build @@ -18,7 +18,7 @@ SOURCES += [ 'nsXPCOMGlue.cpp', ] -LIBRARY_NAME = 'xpcomglue' +Library('xpcomglue') EXPORTS += [ 'nsXPCOMGlue.h', diff --git a/xpcom/glue/standalone/staticruntime/moz.build b/xpcom/glue/standalone/staticruntime/moz.build index 3aac7b504b2..caf31001553 100644 --- a/xpcom/glue/standalone/staticruntime/moz.build +++ b/xpcom/glue/standalone/staticruntime/moz.build @@ -13,7 +13,7 @@ SOURCES += [ '../nsXPCOMGlue.cpp', ] -LIBRARY_NAME = 'xpcomglue_staticruntime' +Library('xpcomglue_staticruntime') SDK_LIBRARY = True diff --git a/xpcom/glue/staticruntime/moz.build b/xpcom/glue/staticruntime/moz.build index f2bb031a4ec..33cba07ec67 100644 --- a/xpcom/glue/staticruntime/moz.build +++ b/xpcom/glue/staticruntime/moz.build @@ -14,7 +14,7 @@ UNIFIED_SOURCES += [ '../nsStringAPI.cpp', ] -LIBRARY_NAME = 'xpcomglue_staticruntime_s' +Library('xpcomglue_staticruntime_s') SDK_LIBRARY = True diff --git a/xpcom/reflect/xptcall/md/test/moz.build b/xpcom/reflect/xptcall/md/test/moz.build index 363100af847..65da3214d49 100644 --- a/xpcom/reflect/xptcall/md/test/moz.build +++ b/xpcom/reflect/xptcall/md/test/moz.build @@ -8,6 +8,6 @@ SOURCES += [ 'stub_test.cpp', ] -SIMPLE_PROGRAMS += [ +SimplePrograms([ 'stub_test', -] +]) diff --git a/xpcom/reflect/xptcall/tests/moz.build b/xpcom/reflect/xptcall/tests/moz.build index 13962035047..5297e3e6dd2 100644 --- a/xpcom/reflect/xptcall/tests/moz.build +++ b/xpcom/reflect/xptcall/tests/moz.build @@ -4,9 +4,9 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -SIMPLE_PROGRAMS = [ +SimplePrograms([ 'TestXPTCInvoke', -] +]) SOURCES += [ '%s.cpp' % s for s in SIMPLE_PROGRAMS diff --git a/xpcom/reflect/xptinfo/tests/moz.build b/xpcom/reflect/xptinfo/tests/moz.build index 56d651d04b5..d3d3428bdcb 100644 --- a/xpcom/reflect/xptinfo/tests/moz.build +++ b/xpcom/reflect/xptinfo/tests/moz.build @@ -8,9 +8,9 @@ SOURCES += [ 'TestInterfaceInfo.cpp', ] -SIMPLE_PROGRAMS += [ +SimplePrograms([ 'TestInterfaceInfo' -] +]) USE_LIBS += [ 'mozalloc', diff --git a/xpcom/sample/program/moz.build b/xpcom/sample/program/moz.build index 065967ecdd9..0ada27f5d2e 100644 --- a/xpcom/sample/program/moz.build +++ b/xpcom/sample/program/moz.build @@ -11,9 +11,9 @@ SOURCES += [ ] # SIMPLE_PROGRAMS compiles a single .cpp file into an executable -SIMPLE_PROGRAMS += [ +SimplePrograms([ 'nsTestSample' -] +]) # Whatever code is going to be linked with the *standalone* glue must be # built with the XPCOM_GLUE define set. diff --git a/xpcom/tests/external/moz.build b/xpcom/tests/external/moz.build index b6cd6b94559..5de235bb470 100644 --- a/xpcom/tests/external/moz.build +++ b/xpcom/tests/external/moz.build @@ -4,9 +4,9 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -SIMPLE_PROGRAMS = [ +SimplePrograms([ 'TestMinStringAPI', -] +]) SOURCES += [ '%s.cpp' % s for s in SIMPLE_PROGRAMS diff --git a/xpcom/tests/moz.build b/xpcom/tests/moz.build index 011891f38ff..d677d8fd99c 100644 --- a/xpcom/tests/moz.build +++ b/xpcom/tests/moz.build @@ -23,7 +23,7 @@ EXPORTS.testing += [ 'TestHarness.h', ] -SIMPLE_PROGRAMS = [ +SimplePrograms([ 'nsIFileEnumerator', 'TestArguments', 'TestBlockingProcess', @@ -36,17 +36,17 @@ SIMPLE_PROGRAMS = [ 'TestThreadPoolListener', 'TestTimers', 'TestUnicodeArguments', -] +]) if CONFIG['OS_TARGET'] == 'WINNT': - SIMPLE_PROGRAMS += [ + SimplePrograms([ 'TestBase64', - ] + ]) if CONFIG['WRAP_STL_INCLUDES'] and not CONFIG['CLANG_CL']: - SIMPLE_PROGRAMS += [ + SimplePrograms([ 'TestSTLWrappers', - ] + ]) SOURCES += [ '%s.cpp' % s for s in sorted(SIMPLE_PROGRAMS) @@ -54,7 +54,7 @@ SOURCES += [ XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini'] -CPP_UNIT_TESTS += [ +CppUnitTests([ 'ShowAlignments', 'TestAutoPtr', 'TestAutoRef', @@ -74,12 +74,12 @@ CPP_UNIT_TESTS += [ 'TestTArray', 'TestTextFormatter', 'TestThreadUtils' -] +]) if CONFIG['MOZ_MEMORY']: - CPP_UNIT_TESTS += [ + CppUnitTests([ 'TestJemalloc', - ] + ]) # XXX Make these tests work in libxul builds. #CPP_UNIT_TESTS += [ @@ -109,10 +109,10 @@ if CONFIG['MOZ_MEMORY']: if CONFIG['MOZ_DEBUG'] and CONFIG['OS_ARCH'] not in ('WINNT'): # FIXME bug 523392: TestDeadlockDetector doesn't like Windows # FIXME bug 523378: also fails on OS X - CPP_UNIT_TESTS += [ + CppUnitTests([ 'TestDeadlockDetector', 'TestDeadlockDetectorScalability', - ] + ]) SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) diff --git a/xpcom/tests/windows/moz.build b/xpcom/tests/windows/moz.build index d8ff402c102..5214490f2d1 100644 --- a/xpcom/tests/windows/moz.build +++ b/xpcom/tests/windows/moz.build @@ -4,10 +4,10 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -CPP_UNIT_TESTS += [ +CppUnitTests([ 'TestCOM', 'TestNtPathToDosPath', -] +]) SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) diff --git a/xpcom/typelib/xpt/moz.build b/xpcom/typelib/xpt/moz.build index 16a4495ff54..34624102607 100644 --- a/xpcom/typelib/xpt/moz.build +++ b/xpcom/typelib/xpt/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -LIBRARY_NAME = 'xpt' +Library('xpt') DIRS += ['tools'] diff --git a/xpcom/typelib/xpt/tests/moz.build b/xpcom/typelib/xpt/tests/moz.build index 4acd0a3d858..e00c19f7b72 100644 --- a/xpcom/typelib/xpt/tests/moz.build +++ b/xpcom/typelib/xpt/tests/moz.build @@ -4,10 +4,10 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -SIMPLE_PROGRAMS = [ +SimplePrograms([ 'PrimitiveTest', 'SimpleTypeLib', -] +]) SOURCES += [ '%s.cpp' % s for s in SIMPLE_PROGRAMS diff --git a/xpcom/windbgdlg/moz.build b/xpcom/windbgdlg/moz.build index e62523f8095..744ecca5d9a 100644 --- a/xpcom/windbgdlg/moz.build +++ b/xpcom/windbgdlg/moz.build @@ -8,6 +8,6 @@ SOURCES += [ 'windbgdlg.cpp', ] -SIMPLE_PROGRAMS += [ +SimplePrograms([ 'windbgdlg' -] +]) diff --git a/xulrunner/app/moz.build b/xulrunner/app/moz.build index d3a8ea64367..798be4d8216 100644 --- a/xulrunner/app/moz.build +++ b/xulrunner/app/moz.build @@ -6,7 +6,7 @@ DIRS += ['profile'] -PROGRAM = 'xulrunner' +Program('xulrunner') SOURCES += [ 'nsXULRunnerApp.cpp', diff --git a/xulrunner/stub/moz.build b/xulrunner/stub/moz.build index 907c7d10ece..1110c6d0b5f 100644 --- a/xulrunner/stub/moz.build +++ b/xulrunner/stub/moz.build @@ -8,7 +8,7 @@ # apps to override it using the --with-xulrunner-stub-name= argument. # If this configure argument is not present then the default name is # 'xulrunner-stub'. -PROGRAM = CONFIG['XULRUNNER_STUB_NAME'] +Program(CONFIG['XULRUNNER_STUB_NAME']) SOURCES += [ 'nsXULStub.cpp', diff --git a/xulrunner/tools/redit/moz.build b/xulrunner/tools/redit/moz.build index 00fe698fa69..2d83032f1a9 100644 --- a/xulrunner/tools/redit/moz.build +++ b/xulrunner/tools/redit/moz.build @@ -5,7 +5,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. if CONFIG['OS_ARCH'] == 'WINNT': - PROGRAM = 'redit' + Program('redit') SOURCES += [ 'redit.cpp', ] From 6258dd8523ebee39dc560d2c4ec03215bd15fd31 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Wed, 3 Sep 2014 14:16:37 +0900 Subject: [PATCH 23/68] Bug 1059090 - Don't require SOURCES to be set for CPP_UNIT_TESTS and SIMPLE_PROGRAMS. r=mshal --- build/docs/defining-binaries.rst | 21 ++++++++++++----- build/templates.mozbuild | 10 +++++--- content/base/test/moz.build | 2 -- content/media/compiledtest/moz.build | 2 -- content/media/webaudio/compiledtest/moz.build | 2 -- dom/audiochannel/tests/moz.build | 2 -- dom/canvas/compiledtest/moz.build | 2 -- editor/txmgr/tests/moz.build | 2 -- intl/lwbrk/tests/moz.build | 2 -- intl/uconv/tools/moz.build | 6 +---- intl/unicharutil/tests/moz.build | 8 ++----- js/src/moz.build | 6 +---- layout/style/test/moz.build | 6 +---- media/libcubeb/tests/moz.build | 2 -- media/mtransport/test/moz.build | 2 -- media/webrtc/signaling/test/moz.build | 2 -- memory/mozalloc/tests/moz.build | 2 -- mfbt/tests/moz.build | 2 -- mozglue/linker/tests/moz.build | 3 --- mozglue/tests/moz.build | 4 ---- netwerk/test/moz.build | 6 ----- security/manager/ssl/tests/compiled/moz.build | 2 -- .../ssl/tests/unit/tlsserver/cmd/moz.build | 4 ---- startupcache/test/moz.build | 2 -- storage/test/moz.build | 2 -- toolkit/components/places/tests/cpp/moz.build | 2 -- toolkit/mozapps/plugins/tests/moz.build | 4 ---- toolkit/mozapps/update/tests/moz.build | 4 ---- toolkit/webapps/tests/moz.build | 1 - toolkit/xre/test/win/moz.build | 8 ------- tools/trace-malloc/moz.build | 23 +++++-------------- uriloader/exthandler/tests/moz.build | 4 ---- widget/tests/moz.build | 2 -- xpcom/reflect/xptcall/md/test/moz.build | 4 ---- xpcom/reflect/xptcall/tests/moz.build | 4 ---- xpcom/reflect/xptinfo/tests/moz.build | 4 ---- xpcom/sample/program/moz.build | 6 ----- xpcom/tests/external/moz.build | 4 ---- xpcom/tests/moz.build | 6 ----- xpcom/tests/windows/moz.build | 2 -- xpcom/typelib/xpt/tests/moz.build | 4 ---- xpcom/windbgdlg/moz.build | 4 ---- 42 files changed, 33 insertions(+), 157 deletions(-) diff --git a/build/docs/defining-binaries.rst b/build/docs/defining-binaries.rst index fd155917a18..cb52870cbc7 100644 --- a/build/docs/defining-binaries.rst +++ b/build/docs/defining-binaries.rst @@ -148,15 +148,24 @@ directory, in which case we can use the ``SimplePrograms`` template 'SecondProgram', ]) -The corresponding ``SOURCES`` must match: +Contrary to ``Program``, which requires corresponding ``SOURCES``, when using +``SimplePrograms``, the corresponding ``SOURCES`` are implied. If the +corresponding ``sources`` have an extension different from ``.cpp``, it is +possible to specify the proper extension: - SOURCES += [ - 'FirstProgram.cpp', - 'SecondProgram.c', - ] + SimplePrograms([ + 'ThirdProgram', + 'FourthProgram', + ], ext='.c') + +Please note this construct was added for compatibility with what already lives +in the mozilla tree ; it is recommended not to add new simple programs with +sources with a different extension than ``.cpp``. Similar to ``SimplePrograms``, is the ``CppUnitTests`` template, which defines, -with the same rules, C++ unit tests programs. +with the same rules, C++ unit tests programs. Like ``SimplePrograms``, it takes +an ``ext`` argument to specify the extension for the corresponding ``SOURCES``, +if it's different from ``.cpp``. Linking with system libraries diff --git a/build/templates.mozbuild b/build/templates.mozbuild index 6df5f1411e3..0a347091ce9 100644 --- a/build/templates.mozbuild +++ b/build/templates.mozbuild @@ -11,21 +11,23 @@ def Program(name): @template -def SimplePrograms(names): +def SimplePrograms(names, ext='.cpp'): '''Template for simple program executables. Those have a single source with the same base name as the executable. ''' SIMPLE_PROGRAMS += names + SOURCES += ['%s%s' % (name, ext) for name in names] @template -def CppUnitTests(names): +def CppUnitTests(names, ext='.cpp'): '''Template for C++ unit tests. Those have a single source with the same base name as the executable. ''' CPP_UNIT_TESTS += names + SOURCES += ['%s%s' % (name, ext) for name in names] @template @@ -41,12 +43,14 @@ def HostProgram(name): @template -def HostSimplePrograms(names): +def HostSimplePrograms(names, ext='.cpp'): '''Template for simple build tools executables. Those have a single source with the same base name as the executable. ''' HOST_SIMPLE_PROGRAMS += names + HOST_SOURCES += ['%s%s' % (name.replace('host_', ''), ext) + for name in names] @template diff --git a/content/base/test/moz.build b/content/base/test/moz.build index ec05b17e996..881e0fab9b0 100644 --- a/content/base/test/moz.build +++ b/content/base/test/moz.build @@ -17,8 +17,6 @@ CppUnitTests([ 'TestPlainTextSerializer', ]) -SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) - MOCHITEST_MANIFESTS += [ 'chrome/mochitest.ini', 'csp/mochitest.ini', diff --git a/content/media/compiledtest/moz.build b/content/media/compiledtest/moz.build index 0da44099221..cd818e4de6d 100644 --- a/content/media/compiledtest/moz.build +++ b/content/media/compiledtest/moz.build @@ -9,8 +9,6 @@ CppUnitTests([ 'TestAudioMixer' ]) -SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) - FAIL_ON_WARNINGS = True LOCAL_INCLUDES += [ diff --git a/content/media/webaudio/compiledtest/moz.build b/content/media/webaudio/compiledtest/moz.build index e584c2016a5..1cb059d6f48 100644 --- a/content/media/webaudio/compiledtest/moz.build +++ b/content/media/webaudio/compiledtest/moz.build @@ -8,8 +8,6 @@ CppUnitTests([ 'TestAudioEventTimeline', ]) -SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) - FAIL_ON_WARNINGS = True LOCAL_INCLUDES += [ diff --git a/dom/audiochannel/tests/moz.build b/dom/audiochannel/tests/moz.build index 64304545b10..51ad846ebb8 100644 --- a/dom/audiochannel/tests/moz.build +++ b/dom/audiochannel/tests/moz.build @@ -8,8 +8,6 @@ CppUnitTests([ 'TestAudioChannelService', ]) -SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) - if CONFIG['OS_ARCH'] == 'WINNT': DEFINES['NOMINMAX'] = True diff --git a/dom/canvas/compiledtest/moz.build b/dom/canvas/compiledtest/moz.build index 6e3a66ea13c..062adb39637 100644 --- a/dom/canvas/compiledtest/moz.build +++ b/dom/canvas/compiledtest/moz.build @@ -8,8 +8,6 @@ CppUnitTests([ 'TestWebGLElementArrayCache', ]) -SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) - FAIL_ON_WARNINGS = True LOCAL_INCLUDES += [ diff --git a/editor/txmgr/tests/moz.build b/editor/txmgr/tests/moz.build index 316d7a80b5b..e2c223466c5 100644 --- a/editor/txmgr/tests/moz.build +++ b/editor/txmgr/tests/moz.build @@ -8,8 +8,6 @@ CppUnitTests([ 'TestTXMgr', ]) -SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) - FAIL_ON_WARNINGS = True USE_LIBS += [ diff --git a/intl/lwbrk/tests/moz.build b/intl/lwbrk/tests/moz.build index 8beb091cf2c..1770e50da27 100644 --- a/intl/lwbrk/tests/moz.build +++ b/intl/lwbrk/tests/moz.build @@ -8,8 +8,6 @@ CppUnitTests([ 'TestLineBreak', ]) -SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) - USE_LIBS += [ 'mozalloc', 'nspr', diff --git a/intl/uconv/tools/moz.build b/intl/uconv/tools/moz.build index fa7756ae9a9..a10820eb333 100644 --- a/intl/uconv/tools/moz.build +++ b/intl/uconv/tools/moz.build @@ -6,8 +6,4 @@ SimplePrograms([ 'umaptable', -]) - -SOURCES += [ - '%s.c' % s for s in SIMPLE_PROGRAMS -] +], ext='.c') diff --git a/intl/unicharutil/tests/moz.build b/intl/unicharutil/tests/moz.build index 9820a2de05e..80fc3b2bc41 100644 --- a/intl/unicharutil/tests/moz.build +++ b/intl/unicharutil/tests/moz.build @@ -6,13 +6,9 @@ XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini'] -SOURCES += [ - 'NormalizationTest.cpp', - 'UnicharSelfTest.cpp', -] - SimplePrograms([ - "%s" % (fyl[0:-4]) for fyl in SOURCES + 'NormalizationTest', + 'UnicharSelfTest', ]) USE_STATIC_LIBS = True diff --git a/js/src/moz.build b/js/src/moz.build index 6eb7736b19d..82ff6ff3669 100644 --- a/js/src/moz.build +++ b/js/src/moz.build @@ -423,12 +423,8 @@ else: if CONFIG['_MSC_VER'] != '1600': MSVC_ENABLE_PGO = True -HOST_SOURCES += [ - 'jskwgen.cpp', -] - HostSimplePrograms([ - 'host_%s' % f.replace('.cpp', '') for f in HOST_SOURCES + 'host_jskwgen', ]) # JavaScript must be built shared, even for static builds, as it is used by diff --git a/layout/style/test/moz.build b/layout/style/test/moz.build index 96f7636f3c4..9f9b80fc883 100644 --- a/layout/style/test/moz.build +++ b/layout/style/test/moz.build @@ -4,12 +4,8 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -HOST_SOURCES += [ - 'ListCSSProperties.cpp', -] - HostSimplePrograms([ - 'host_%s' % f.replace('.cpp', '') for f in HOST_SOURCES + 'host_ListCSSProperties', ]) MOCHITEST_MANIFESTS += [ diff --git a/media/libcubeb/tests/moz.build b/media/libcubeb/tests/moz.build index e7869a529ca..7bf057a1b1b 100644 --- a/media/libcubeb/tests/moz.build +++ b/media/libcubeb/tests/moz.build @@ -15,8 +15,6 @@ if CONFIG['OS_TARGET'] != 'Android': 'test_sanity' ]) -SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) - LOCAL_INCLUDES += [ '../include' ] diff --git a/media/mtransport/test/moz.build b/media/mtransport/test/moz.build index fd2c8fb29e8..e30a3da583c 100644 --- a/media/mtransport/test/moz.build +++ b/media/mtransport/test/moz.build @@ -23,8 +23,6 @@ if CONFIG['OS_TARGET'] != 'WINNT' and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk': 'sctp_unittest', ]) - SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) - FAIL_ON_WARNINGS = True for var in ('HAVE_STRDUP', 'NR_SOCKET_IS_VOID_PTR', 'SCTP_DEBUG', 'INET'): diff --git a/media/webrtc/signaling/test/moz.build b/media/webrtc/signaling/test/moz.build index 5ce5002546b..e2af3824e4b 100644 --- a/media/webrtc/signaling/test/moz.build +++ b/media/webrtc/signaling/test/moz.build @@ -12,8 +12,6 @@ if CONFIG['OS_TARGET'] != 'WINNT' and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk': 'signaling_unittests', ]) -SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) - include('/ipc/chromium/chromium-config.mozbuild') if CONFIG['OS_TARGET'] in ('Darwin', 'Android'): diff --git a/memory/mozalloc/tests/moz.build b/memory/mozalloc/tests/moz.build index 6b265f5beb9..fc540a1d587 100644 --- a/memory/mozalloc/tests/moz.build +++ b/memory/mozalloc/tests/moz.build @@ -8,8 +8,6 @@ CppUnitTests([ 'TestVolatileBuffer', ]) -SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) - USE_LIBS += [ 'mozalloc', 'nspr', diff --git a/mfbt/tests/moz.build b/mfbt/tests/moz.build index 48c2fde8e71..f7eb7db4b5f 100644 --- a/mfbt/tests/moz.build +++ b/mfbt/tests/moz.build @@ -37,8 +37,6 @@ if not CONFIG['MOZ_ASAN']: 'TestPoisonArea', ]) -SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) - # Since we link directly with MFBT object files, define IMPL_MFBT DEFINES['IMPL_MFBT'] = True diff --git a/mozglue/linker/tests/moz.build b/mozglue/linker/tests/moz.build index 4d1468bcfa0..a42f3c9505c 100644 --- a/mozglue/linker/tests/moz.build +++ b/mozglue/linker/tests/moz.build @@ -6,9 +6,6 @@ NO_DIST_INSTALL = True -SOURCES += [ - 'TestZip.cpp', -] SimplePrograms([ 'TestZip', ]) diff --git a/mozglue/tests/moz.build b/mozglue/tests/moz.build index 7b8d5ef7376..47c4c333aff 100644 --- a/mozglue/tests/moz.build +++ b/mozglue/tests/moz.build @@ -6,10 +6,6 @@ DISABLE_STL_WRAPPING = True -SOURCES += [ - 'ShowSSEConfig.cpp', -] - CppUnitTests([ 'ShowSSEConfig', ]) diff --git a/netwerk/test/moz.build b/netwerk/test/moz.build index c86196ed4ae..75e4ced440d 100644 --- a/netwerk/test/moz.build +++ b/netwerk/test/moz.build @@ -46,18 +46,12 @@ SimplePrograms([ # TestUDPSocketProvider', #] -SOURCES += [ - '%s.cpp' % s for s in SIMPLE_PROGRAMS -] - CppUnitTests([ 'TestCookie', 'TestSTSParser', 'TestUDPSocket', ]) -SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) - RESOURCE_FILES += [ 'urlparse.dat', 'urlparse_unx.dat', diff --git a/security/manager/ssl/tests/compiled/moz.build b/security/manager/ssl/tests/compiled/moz.build index 6ed376dd9da..7aaae8b3df5 100644 --- a/security/manager/ssl/tests/compiled/moz.build +++ b/security/manager/ssl/tests/compiled/moz.build @@ -8,8 +8,6 @@ CppUnitTests([ 'TestCertDB', ]) -SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) - USE_LIBS += [ 'mozalloc', 'nspr', diff --git a/security/manager/ssl/tests/unit/tlsserver/cmd/moz.build b/security/manager/ssl/tests/unit/tlsserver/cmd/moz.build index 416fb35a1c4..dd91bbbd0b0 100644 --- a/security/manager/ssl/tests/unit/tlsserver/cmd/moz.build +++ b/security/manager/ssl/tests/unit/tlsserver/cmd/moz.build @@ -13,10 +13,6 @@ SimplePrograms([ 'OCSPStaplingServer', ]) -SOURCES += [ - '%s.cpp' % s for s in SIMPLE_PROGRAMS -] - LOCAL_INCLUDES += [ '../lib', ] diff --git a/startupcache/test/moz.build b/startupcache/test/moz.build index 7d6a4e7f7cc..6531d0dc022 100644 --- a/startupcache/test/moz.build +++ b/startupcache/test/moz.build @@ -8,8 +8,6 @@ CppUnitTests([ 'TestStartupCache', ]) -SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) - EXTRA_COMPONENTS += [ 'TestStartupCacheTelemetry.js', 'TestStartupCacheTelemetry.manifest', diff --git a/storage/test/moz.build b/storage/test/moz.build index 02d25832bab..8bcd80a1951 100644 --- a/storage/test/moz.build +++ b/storage/test/moz.build @@ -28,8 +28,6 @@ if CONFIG['MOZ_DEBUG'] and CONFIG['OS_ARCH'] not in ('WINNT', 'Darwin'): 'test_deadlock_detector', ]) -SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) - LOCAL_INCLUDES += [ '../src', ] diff --git a/toolkit/components/places/tests/cpp/moz.build b/toolkit/components/places/tests/cpp/moz.build index c5488e751fe..b7935de0d26 100644 --- a/toolkit/components/places/tests/cpp/moz.build +++ b/toolkit/components/places/tests/cpp/moz.build @@ -8,8 +8,6 @@ CppUnitTests([ 'test_IHistory', ]) -SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) - FAIL_ON_WARNINGS = True USE_LIBS += [ diff --git a/toolkit/mozapps/plugins/tests/moz.build b/toolkit/mozapps/plugins/tests/moz.build index ab0d7f17dd7..f54b170f1fb 100644 --- a/toolkit/mozapps/plugins/tests/moz.build +++ b/toolkit/mozapps/plugins/tests/moz.build @@ -9,9 +9,5 @@ SimplePrograms([ 'GoodPlugin', ]) -SOURCES += [ - '%s.cpp' % s for s in SIMPLE_PROGRAMS -] - BROWSER_CHROME_MANIFESTS += ['browser.ini'] USE_STATIC_LIBS = True diff --git a/toolkit/mozapps/update/tests/moz.build b/toolkit/mozapps/update/tests/moz.build index 49688d73e71..4d7ba65816e 100644 --- a/toolkit/mozapps/update/tests/moz.build +++ b/toolkit/mozapps/update/tests/moz.build @@ -18,10 +18,6 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'android': 'TestAUSReadStrings', ]) - SOURCES += [ - '%s.cpp' % s for s in SIMPLE_PROGRAMS - ] - LOCAL_INCLUDES += [ '/toolkit/mozapps/update', '/toolkit/mozapps/update/common', diff --git a/toolkit/webapps/tests/moz.build b/toolkit/webapps/tests/moz.build index 943219eb9da..fff331de0c9 100644 --- a/toolkit/webapps/tests/moz.build +++ b/toolkit/webapps/tests/moz.build @@ -5,5 +5,4 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. MOCHITEST_CHROME_MANIFESTS += ['chrome.ini'] -SOURCES += ['TestWebappRT.cpp' ] SimplePrograms(['TestWebappRT']) diff --git a/toolkit/xre/test/win/moz.build b/toolkit/xre/test/win/moz.build index e99c6d2cf97..8771a63e672 100644 --- a/toolkit/xre/test/win/moz.build +++ b/toolkit/xre/test/win/moz.build @@ -8,18 +8,10 @@ SimplePrograms([ 'TestXREMakeCommandLineWin', ]) -SOURCES += [ - '%s.cpp' % s for s in SIMPLE_PROGRAMS -] - CppUnitTests([ 'TestDllInterceptor', ]) -SOURCES += [ - '%s.cpp' % s for s in CPP_UNIT_TESTS -] - DEFINES['NS_NO_XPCOM'] = True LOCAL_INCLUDES += [ diff --git a/tools/trace-malloc/moz.build b/tools/trace-malloc/moz.build index 9c754913242..f602d44d516 100644 --- a/tools/trace-malloc/moz.build +++ b/tools/trace-malloc/moz.build @@ -15,30 +15,19 @@ if not CONFIG['MOZ_PROFILE_GENERATE']: bin_suffix = CONFIG['BIN_SUFFIX'] -simple_c_sources = [ - 'leakstats', - 'tmstats', -] - -SOURCES += [ - '%s.c' % s for s in simple_c_sources -] SOURCES += [ 'tmreader.c', ] -SimplePrograms(simple_c_sources) +SimplePrograms([ + 'leakstats', + 'tmstats', +], ext='.c') -simple_cpp_sources = [ +SimplePrograms([ 'bloatblame', 'leaksoup', -] - -SOURCES += [ - '%s.cpp' % s for s in simple_cpp_sources -] - -SimplePrograms(simple_cpp_sources) +]) RESOURCE_FILES += [ 'spacetrace.css' diff --git a/uriloader/exthandler/tests/moz.build b/uriloader/exthandler/tests/moz.build index 057d93da396..0f940e82341 100644 --- a/uriloader/exthandler/tests/moz.build +++ b/uriloader/exthandler/tests/moz.build @@ -20,10 +20,6 @@ SimplePrograms([ 'WriteArgument', ]) -SOURCES += [ - '%s.cpp' % s for s in SIMPLE_PROGRAMS -] - USE_LIBS += [ 'nspr', ] diff --git a/widget/tests/moz.build b/widget/tests/moz.build index 31e6c40c177..ab93b2f7778 100644 --- a/widget/tests/moz.build +++ b/widget/tests/moz.build @@ -24,8 +24,6 @@ FAIL_ON_WARNINGS = True # is bug 652123. # CPP_UNIT_TESTS += ['TestChromeMargin'] -SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) - USE_LIBS += [ 'mozalloc', 'nspr', diff --git a/xpcom/reflect/xptcall/md/test/moz.build b/xpcom/reflect/xptcall/md/test/moz.build index 65da3214d49..ebb47903c81 100644 --- a/xpcom/reflect/xptcall/md/test/moz.build +++ b/xpcom/reflect/xptcall/md/test/moz.build @@ -4,10 +4,6 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -SOURCES += [ - 'stub_test.cpp', -] - SimplePrograms([ 'stub_test', ]) diff --git a/xpcom/reflect/xptcall/tests/moz.build b/xpcom/reflect/xptcall/tests/moz.build index 5297e3e6dd2..7bc7e8d8b9e 100644 --- a/xpcom/reflect/xptcall/tests/moz.build +++ b/xpcom/reflect/xptcall/tests/moz.build @@ -8,10 +8,6 @@ SimplePrograms([ 'TestXPTCInvoke', ]) -SOURCES += [ - '%s.cpp' % s for s in SIMPLE_PROGRAMS -] - USE_LIBS += [ 'mozalloc', 'nspr', diff --git a/xpcom/reflect/xptinfo/tests/moz.build b/xpcom/reflect/xptinfo/tests/moz.build index d3d3428bdcb..6022da61589 100644 --- a/xpcom/reflect/xptinfo/tests/moz.build +++ b/xpcom/reflect/xptinfo/tests/moz.build @@ -4,10 +4,6 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -SOURCES += [ - 'TestInterfaceInfo.cpp', -] - SimplePrograms([ 'TestInterfaceInfo' ]) diff --git a/xpcom/sample/program/moz.build b/xpcom/sample/program/moz.build index 0ada27f5d2e..d00630c0475 100644 --- a/xpcom/sample/program/moz.build +++ b/xpcom/sample/program/moz.build @@ -4,12 +4,6 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -# We must specify CPP_SOURCES in order to link using the proper c++ linker -# on certain platforms. -SOURCES += [ - 'nsTestSample.cpp', -] - # SIMPLE_PROGRAMS compiles a single .cpp file into an executable SimplePrograms([ 'nsTestSample' diff --git a/xpcom/tests/external/moz.build b/xpcom/tests/external/moz.build index 5de235bb470..9999fd2c29f 100644 --- a/xpcom/tests/external/moz.build +++ b/xpcom/tests/external/moz.build @@ -8,10 +8,6 @@ SimplePrograms([ 'TestMinStringAPI', ]) -SOURCES += [ - '%s.cpp' % s for s in SIMPLE_PROGRAMS -] - USE_LIBS += [ 'mozalloc', 'nspr', diff --git a/xpcom/tests/moz.build b/xpcom/tests/moz.build index d677d8fd99c..320ba050987 100644 --- a/xpcom/tests/moz.build +++ b/xpcom/tests/moz.build @@ -48,10 +48,6 @@ if CONFIG['WRAP_STL_INCLUDES'] and not CONFIG['CLANG_CL']: 'TestSTLWrappers', ]) -SOURCES += [ - '%s.cpp' % s for s in sorted(SIMPLE_PROGRAMS) -] - XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini'] CppUnitTests([ @@ -114,8 +110,6 @@ if CONFIG['MOZ_DEBUG'] and CONFIG['OS_ARCH'] not in ('WINNT'): 'TestDeadlockDetectorScalability', ]) -SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) - LOCAL_INCLUDES += [ '../ds', ] diff --git a/xpcom/tests/windows/moz.build b/xpcom/tests/windows/moz.build index 5214490f2d1..0f06c8f8d1c 100644 --- a/xpcom/tests/windows/moz.build +++ b/xpcom/tests/windows/moz.build @@ -9,8 +9,6 @@ CppUnitTests([ 'TestNtPathToDosPath', ]) -SOURCES += sorted('%s.cpp' % t for t in CPP_UNIT_TESTS) - USE_LIBS += [ 'mozalloc', 'nspr', diff --git a/xpcom/typelib/xpt/tests/moz.build b/xpcom/typelib/xpt/tests/moz.build index e00c19f7b72..6fe20a8b6cf 100644 --- a/xpcom/typelib/xpt/tests/moz.build +++ b/xpcom/typelib/xpt/tests/moz.build @@ -9,10 +9,6 @@ SimplePrograms([ 'SimpleTypeLib', ]) -SOURCES += [ - '%s.cpp' % s for s in SIMPLE_PROGRAMS -] - FAIL_ON_WARNINGS = True USE_LIBS += [ diff --git a/xpcom/windbgdlg/moz.build b/xpcom/windbgdlg/moz.build index 744ecca5d9a..e5a9c0859d0 100644 --- a/xpcom/windbgdlg/moz.build +++ b/xpcom/windbgdlg/moz.build @@ -4,10 +4,6 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -SOURCES += [ - 'windbgdlg.cpp', -] - SimplePrograms([ 'windbgdlg' ]) From 37614d55483e5dae828d8c8637ed9b78f5b3cfea Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Wed, 3 Sep 2014 14:19:55 +0900 Subject: [PATCH 24/68] Bug 1059126 - Always allow to add a StrictOrderingOnAppendList to another. r=gps --- python/mozbuild/mozbuild/test/test_util.py | 10 ++++++++++ python/mozbuild/mozbuild/util.py | 3 +++ 2 files changed, 13 insertions(+) diff --git a/python/mozbuild/mozbuild/test/test_util.py b/python/mozbuild/mozbuild/test/test_util.py index ecd5f103556..5e3a6e5c4db 100644 --- a/python/mozbuild/mozbuild/test/test_util.py +++ b/python/mozbuild/mozbuild/test/test_util.py @@ -337,6 +337,16 @@ class TestStrictOrderingOnAppendList(unittest.TestCase): self.assertEqual(len(l), 2) + def test_add_StrictOrderingOnAppendList(self): + l = StrictOrderingOnAppendList() + l += ['c', 'd'] + l += ['a', 'b'] + l2 = StrictOrderingOnAppendList() + with self.assertRaises(UnsortedError): + l2 += list(l) + # Adding a StrictOrderingOnAppendList to another shouldn't throw + l2 += l + class TestStrictOrderingOnAppendListWithFlagsFactory(unittest.TestCase): def test_strict_ordering_on_append_list_with_flags_factory(self): diff --git a/python/mozbuild/mozbuild/util.py b/python/mozbuild/mozbuild/util.py index e2b0bd478ac..6ebc13f8a50 100644 --- a/python/mozbuild/mozbuild/util.py +++ b/python/mozbuild/mozbuild/util.py @@ -304,6 +304,9 @@ class StrictOrderingOnAppendList(list): """ @staticmethod def ensure_sorted(l): + if isinstance(l, StrictOrderingOnAppendList): + return + srtd = sorted(l, key=lambda x: x.lower()) if srtd != l: From a653121671279d67212775da56cb8054c0af3037 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Thu, 4 Sep 2014 09:04:45 +0900 Subject: [PATCH 25/68] Bug 1059113 - Use templates for shared libraries and frameworks. r=gps Also force to use the existing template for XPCOM components. --- accessible/interfaces/ia2/moz.build | 4 +- accessible/interfaces/msaa/moz.build | 4 +- build/docs/defining-binaries.rst | 22 ++++---- build/templates.mozbuild | 16 ++++++ build/win32/crashinjectdll/moz.build | 4 +- build/win32/vmwarerecordinghelper/moz.build | 4 +- config/external/nss/moz.build | 6 +-- config/external/sqlite/moz.build | 6 +-- dom/media/gmp-plugin/moz.build | 3 +- dom/plugins/ipc/interpose/moz.build | 4 +- .../test/testplugin/javaplugin/moz.build | 2 +- dom/plugins/test/testplugin/moz.build | 2 +- .../test/testplugin/secondplugin/moz.build | 2 +- .../test/testplugin/testplugin.mozbuild | 2 - gfx/angle/src/libEGL/moz.build | 3 +- gfx/angle/src/libGLESv2/moz.build | 3 +- js/src/moz.build | 6 +-- layout/media/moz.build | 7 +-- media/omx-plugin/froyo/moz.build | 4 +- media/omx-plugin/gb/moz.build | 4 +- media/omx-plugin/gb235/moz.build | 4 +- media/omx-plugin/hc/moz.build | 4 +- media/omx-plugin/kk/moz.build | 4 +- .../lib/froyo/libstagefright/moz.build | 4 +- .../lib/gb/libstagefright/moz.build | 4 +- .../libstagefright_color_conversion/moz.build | 4 +- media/omx-plugin/lib/gb/libutils/moz.build | 4 +- .../lib/gb235/libstagefright/moz.build | 4 +- .../lib/hc/libstagefright/moz.build | 4 +- .../lib/ics/libstagefright/moz.build | 4 +- media/omx-plugin/lib/ics/libutils/moz.build | 4 +- .../lib/ics/libvideoeditorplayer/moz.build | 4 +- media/omx-plugin/moz.build | 4 +- memory/mozalloc/moz.build | 6 +-- memory/replace/dmd/moz.build | 4 +- memory/replace/dummy/moz.build | 4 +- memory/replace/jemalloc/moz.build | 4 +- mozglue/build/moz.build | 7 +-- python/mozbuild/mozbuild/frontend/context.py | 36 +++++++++++++ python/mozbuild/mozbuild/frontend/emitter.py | 12 ----- .../ssl/tests/unit/pkcs11testmodule/moz.build | 3 +- security/sandbox/linux/moz.build | 3 +- .../sandbox/win/src/sandboxbroker/moz.build | 4 +- toolkit/components/ctypes/tests/moz.build | 4 +- toolkit/crashreporter/injector/moz.build | 4 +- toolkit/crashreporter/test/moz.build | 4 +- toolkit/library/gtest/moz.build | 4 +- toolkit/library/libxul.mozbuild | 52 ------------------- toolkit/library/moz.build | 52 +++++++++++++++++-- tools/jprof/stub/moz.build | 4 +- widget/gtk/mozgtk/gtk2/moz.build | 4 +- widget/gtk/mozgtk/gtk3/moz.build | 4 +- widget/gtk/mozgtk/stub/moz.build | 4 +- 53 files changed, 169 insertions(+), 210 deletions(-) delete mode 100644 toolkit/library/libxul.mozbuild diff --git a/accessible/interfaces/ia2/moz.build b/accessible/interfaces/ia2/moz.build index 3aae77cd38b..08ce9733f2d 100644 --- a/accessible/interfaces/ia2/moz.build +++ b/accessible/interfaces/ia2/moz.build @@ -4,9 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -Library('IA2Marshal') - -FORCE_SHARED_LIB = True +SharedLibrary('IA2Marshal') DEFINES['REGISTER_PROXY_DLL'] = True diff --git a/accessible/interfaces/msaa/moz.build b/accessible/interfaces/msaa/moz.build index e6d5f2f0937..ff37abd0a07 100644 --- a/accessible/interfaces/msaa/moz.build +++ b/accessible/interfaces/msaa/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -Library('AccessibleMarshal') +SharedLibrary('AccessibleMarshal') GENERATED_SOURCES += [ 'dlldata.c', @@ -16,8 +16,6 @@ GENERATED_SOURCES += [ 'ISimpleDOMText_p.c', ] -FORCE_SHARED_LIB = True - DEFINES['REGISTER_PROXY_DLL'] = True DEFFILE = SRCDIR + '/AccessibleMarshal.def' diff --git a/build/docs/defining-binaries.rst b/build/docs/defining-binaries.rst index cb52870cbc7..a4501f8557a 100644 --- a/build/docs/defining-binaries.rst +++ b/build/docs/defining-binaries.rst @@ -95,15 +95,15 @@ Shared Libraries ================ Sometimes, we want shared libraries, a.k.a. dynamic libraries. Such libraries -are defined with the same variables as static libraries, with the addition of -the ``FORCE_SHARED_LIB`` boolean variable: +are defined similarly to static libraries, using the ``SharedLibrary`` template +instead of ``Library``. - FORCE_SHARED_LIB = True + SharedLibrary('foo') -When this variable is set, no static library is built. See further below to +When this template is used, no static library is built. See further below to build both types of libraries. -With a ``Library`` name of ``foo``, the library file name will be +With a ``SharedLibrary`` name of ``foo``, the library file name will be ``libfoo.dylib`` on OSX, ``libfoo.so`` on ELF systems (Linux, etc.), and ``foo.dll`` on Windows. On Windows, there is also an import library named ``foo.lib``, used on the linker command line. ``libfoo.dylib`` and @@ -111,18 +111,18 @@ With a ``Library`` name of ``foo``, the library file name will be systems. On OSX, one may want to create a special kind of dynamic library: frameworks. -This is done with the ``IS_FRAMEWORK`` boolean variable. +This is done with the ``Framework`` template. - IS_FRAMEWORK = True + Framework('foo') -With a ``Library`` name of ``foo``, the framework file name will be ``foo``. -This variable however affects the behavior on all platforms, so it needs to +With a ``Framework`` name of ``foo``, the framework file name will be ``foo``. +This template however affects the behavior on all platforms, so it needs to be set only on OSX. Another special kind of library, XPCOM-specific, are XPCOM components. One can -build such a component with the ``IS_COMPONENT`` boolean variable. +build such a component with the ``XPCOMBinaryComponent`` template. - IS_COMPONENT = True + XPCOMBinaryComponent('foo') Executables diff --git a/build/templates.mozbuild b/build/templates.mozbuild index 0a347091ce9..3abcb807f9f 100644 --- a/build/templates.mozbuild +++ b/build/templates.mozbuild @@ -36,6 +36,22 @@ def Library(name): LIBRARY_NAME = name +@template +def SharedLibrary(name): + '''Template for shared libraries.''' + Library(name) + + FORCE_SHARED_LIB = True + + +@template +def Framework(name): + '''Template for OSX Frameworks.''' + Library(name) + + IS_FRAMEWORK = True + + @template def HostProgram(name): '''Template for build tools executables.''' diff --git a/build/win32/crashinjectdll/moz.build b/build/win32/crashinjectdll/moz.build index 6f1fc4cab12..6670f6a43a3 100644 --- a/build/win32/crashinjectdll/moz.build +++ b/build/win32/crashinjectdll/moz.build @@ -8,9 +8,7 @@ SOURCES += [ 'crashinjectdll.cpp', ] -Library('crashinjectdll') - -FORCE_SHARED_LIB = True +SharedLibrary('crashinjectdll') DEFFILE = SRCDIR + '/crashinjectdll.def' diff --git a/build/win32/vmwarerecordinghelper/moz.build b/build/win32/vmwarerecordinghelper/moz.build index 55e842e2b98..61e40fe8bf0 100644 --- a/build/win32/vmwarerecordinghelper/moz.build +++ b/build/win32/vmwarerecordinghelper/moz.build @@ -8,9 +8,7 @@ SOURCES += [ 'vmwarerecordinghelper.cpp', ] -Library('vmwarerecordinghelper') - -FORCE_SHARED_LIB = True +SharedLibrary('vmwarerecordinghelper') DEFFILE = '%s/%s.def' % (SRCDIR, LIBRARY_NAME) diff --git a/config/external/nss/moz.build b/config/external/nss/moz.build index b7b69e7017b..dc7a8d757da 100644 --- a/config/external/nss/moz.build +++ b/config/external/nss/moz.build @@ -4,17 +4,16 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -Library('nss') - DIRS += ['crmf'] if CONFIG['MOZ_NATIVE_NSS']: + Library('nss') OS_LIBS += CONFIG['NSS_LIBS'] elif CONFIG['MOZ_FOLD_LIBS']: + SharedLibrary('nss') # TODO: The library name can be changed when bug 845217 is fixed. SHARED_LIBRARY_NAME = 'nss3' - FORCE_SHARED_LIB = True SDK_LIBRARY = True # Normally, there should be /something/ to ensure nspr is built @@ -38,6 +37,7 @@ elif CONFIG['MOZ_FOLD_LIBS']: if CONFIG['OS_ARCH'] == 'Linux' and CONFIG['GCC_USE_GNU_LD']: LD_VERSION_SCRIPT = 'nss3.def' else: + Library('nss') USE_LIBS += [ '/security/nss/lib/nss/nss3', '/security/nss/lib/smime/smime3', diff --git a/config/external/sqlite/moz.build b/config/external/sqlite/moz.build index 9826ced3f77..b6f500727f4 100644 --- a/config/external/sqlite/moz.build +++ b/config/external/sqlite/moz.build @@ -4,19 +4,19 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -Library('sqlite') - if CONFIG['MOZ_NATIVE_SQLITE']: + Library('sqlite') OS_LIBS += CONFIG['SQLITE_LIBS'] else: DIRS += ['../../../db/sqlite3/src'] if CONFIG['MOZ_FOLD_LIBS']: + Library('sqlite') # When folding libraries, sqlite is actually in the nss library. USE_LIBS += [ 'nss', ] else: - FORCE_SHARED_LIB = True + SharedLibrary('sqlite') SHARED_LIBRARY_NAME = 'mozsqlite3' if CONFIG['OS_ARCH'] == 'Linux' and CONFIG['GCC_USE_GNU_LD']: diff --git a/dom/media/gmp-plugin/moz.build b/dom/media/gmp-plugin/moz.build index 27774758ff2..1d497a87f6f 100644 --- a/dom/media/gmp-plugin/moz.build +++ b/dom/media/gmp-plugin/moz.build @@ -9,10 +9,9 @@ SOURCES += [ 'gmp-fake.cpp' ] -Library("fake") +SharedLibrary("fake") USE_STATIC_LIBS = True -FORCE_SHARED_LIB = True NO_VISIBILITY_FLAGS = True # Don't use STL wrappers; this isn't Gecko code DISABLE_STL_WRAPPING = True diff --git a/dom/plugins/ipc/interpose/moz.build b/dom/plugins/ipc/interpose/moz.build index e80b868b419..66c6d561777 100644 --- a/dom/plugins/ipc/interpose/moz.build +++ b/dom/plugins/ipc/interpose/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -Library('plugin_child_interpose') +SharedLibrary('plugin_child_interpose') UNIFIED_SOURCES += [ "%s.mm" % (LIBRARY_NAME) ] @@ -12,6 +12,4 @@ UNIFIED_SOURCES += [ 'plugin_child_quirks.mm', ] -FORCE_SHARED_LIB = True - OS_LIBS += ['-framework Carbon'] diff --git a/dom/plugins/test/testplugin/javaplugin/moz.build b/dom/plugins/test/testplugin/javaplugin/moz.build index 2c7f6a0f73c..e01c72aa6e6 100644 --- a/dom/plugins/test/testplugin/javaplugin/moz.build +++ b/dom/plugins/test/testplugin/javaplugin/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -Library('nptestjava') +SharedLibrary('nptestjava') relative_path = '..' include('../testplugin.mozbuild') diff --git a/dom/plugins/test/testplugin/moz.build b/dom/plugins/test/testplugin/moz.build index 705995b20cd..37e085cb95e 100644 --- a/dom/plugins/test/testplugin/moz.build +++ b/dom/plugins/test/testplugin/moz.build @@ -6,7 +6,7 @@ DIRS += ['secondplugin', 'javaplugin'] -Library('nptest') +SharedLibrary('nptest') FAIL_ON_WARNINGS = not CONFIG['_MSC_VER'] diff --git a/dom/plugins/test/testplugin/secondplugin/moz.build b/dom/plugins/test/testplugin/secondplugin/moz.build index c9c6215ee2e..3bc2bfa966c 100644 --- a/dom/plugins/test/testplugin/secondplugin/moz.build +++ b/dom/plugins/test/testplugin/secondplugin/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -Library('npsecondtest') +SharedLibrary('npsecondtest') relative_path = '..' include('../testplugin.mozbuild') diff --git a/dom/plugins/test/testplugin/testplugin.mozbuild b/dom/plugins/test/testplugin/testplugin.mozbuild index 5bafddfa86d..e194773d6b2 100644 --- a/dom/plugins/test/testplugin/testplugin.mozbuild +++ b/dom/plugins/test/testplugin/testplugin.mozbuild @@ -40,8 +40,6 @@ elif toolkit == 'windows': 'msimg32', ] -FORCE_SHARED_LIB = True - # must link statically with the CRT; nptest isn't Gecko code USE_STATIC_LIBS = True diff --git a/gfx/angle/src/libEGL/moz.build b/gfx/angle/src/libEGL/moz.build index 96f105e7652..1542034fd06 100644 --- a/gfx/angle/src/libEGL/moz.build +++ b/gfx/angle/src/libEGL/moz.build @@ -54,8 +54,7 @@ DISABLE_STL_WRAPPING = True LOCAL_INCLUDES += [ '../../include', '../../src' ] USE_LIBS += [ 'libGLESv2' ] -Library('libEGL') -FORCE_SHARED_LIB = True +SharedLibrary('libEGL') RCFILE = SRCDIR + '/libEGL.rc' DEFFILE = SRCDIR + '/libEGL.def' diff --git a/gfx/angle/src/libGLESv2/moz.build b/gfx/angle/src/libGLESv2/moz.build index 131868dd09f..997d0562362 100644 --- a/gfx/angle/src/libGLESv2/moz.build +++ b/gfx/angle/src/libGLESv2/moz.build @@ -204,8 +204,7 @@ else: '\'%s/lib/%s/dxguid.lib\'' % (CONFIG['MOZ_DIRECTX_SDK_PATH'], CONFIG['MOZ_D3D_CPU_SUFFIX']), ] -Library('libGLESv2') -FORCE_SHARED_LIB = True +SharedLibrary('libGLESv2') RCFILE = SRCDIR + '/libGLESv2.rc' DEFFILE = SRCDIR + '/libGLESv2.def' diff --git a/js/src/moz.build b/js/src/moz.build index 82ff6ff3669..9a3fb6c2222 100644 --- a/js/src/moz.build +++ b/js/src/moz.build @@ -435,12 +435,12 @@ HostSimplePrograms([ # In fact, we now build both a static and a shared library, as the # JS shell would like to link to the static library. -Library('js') - if CONFIG['JS_SHARED_LIBRARY']: - FORCE_SHARED_LIB = True + SharedLibrary('js') SHARED_LIBRARY_NAME = CONFIG['JS_LIBRARY_NAME'] SDK_LIBRARY = True +else: + Library('js') FORCE_STATIC_LIB = True STATIC_LIBRARY_NAME = 'js_static' diff --git a/layout/media/moz.build b/layout/media/moz.build index fd2101cf99f..4fe8ea8fc76 100644 --- a/layout/media/moz.build +++ b/layout/media/moz.build @@ -4,14 +4,15 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -Library('gkmedias') - if CONFIG['GKMEDIAS_SHARED_LIBRARY']: - FORCE_SHARED_LIB = True + SharedLibrary('gkmedias') USE_LIBS += [ 'mozalloc', 'nspr', ] +else: + Library('gkmedias') + if CONFIG['MOZ_WEBRTC']: DIRS += ['webrtc'] diff --git a/media/omx-plugin/froyo/moz.build b/media/omx-plugin/froyo/moz.build index dc530b2134c..9e98c9e553d 100644 --- a/media/omx-plugin/froyo/moz.build +++ b/media/omx-plugin/froyo/moz.build @@ -8,9 +8,7 @@ SOURCES += [ 'OmxPluginFroyo.cpp', ] -Library('omxpluginfroyo') - -FORCE_SHARED_LIB = True +SharedLibrary('omxpluginfroyo') LOCAL_INCLUDES += [ '../include/froyo', diff --git a/media/omx-plugin/gb/moz.build b/media/omx-plugin/gb/moz.build index c7616aaa8dd..27b0436d700 100644 --- a/media/omx-plugin/gb/moz.build +++ b/media/omx-plugin/gb/moz.build @@ -8,9 +8,7 @@ SOURCES += [ 'OmxPlugin236.cpp', ] -Library('omxplugingb') - -FORCE_SHARED_LIB = True +SharedLibrary('omxplugingb') LOCAL_INCLUDES += [ '../include/gb', diff --git a/media/omx-plugin/gb235/moz.build b/media/omx-plugin/gb235/moz.build index c25bed8b144..b20ec04595b 100644 --- a/media/omx-plugin/gb235/moz.build +++ b/media/omx-plugin/gb235/moz.build @@ -8,9 +8,7 @@ SOURCES += [ 'OmxPlugin235.cpp', ] -Library('omxplugingb235') - -FORCE_SHARED_LIB = True +SharedLibrary('omxplugingb235') LOCAL_INCLUDES += [ '../include/gb', diff --git a/media/omx-plugin/hc/moz.build b/media/omx-plugin/hc/moz.build index 9ad3794f7e2..9047a5100bc 100644 --- a/media/omx-plugin/hc/moz.build +++ b/media/omx-plugin/hc/moz.build @@ -8,9 +8,7 @@ SOURCES += [ 'OmxPluginHoneycomb.cpp', ] -Library('omxpluginhc') - -FORCE_SHARED_LIB = True +SharedLibrary('omxpluginhc') LOCAL_INCLUDES += [ '../include/gb', diff --git a/media/omx-plugin/kk/moz.build b/media/omx-plugin/kk/moz.build index 4667493d803..e33f26aac0b 100644 --- a/media/omx-plugin/kk/moz.build +++ b/media/omx-plugin/kk/moz.build @@ -8,9 +8,7 @@ SOURCES += [ 'OmxPluginKitKat.cpp', ] -Library('omxpluginkk') - -FORCE_SHARED_LIB = True +SharedLibrary('omxpluginkk') LOCAL_INCLUDES += [ '../include/ics', diff --git a/media/omx-plugin/lib/froyo/libstagefright/moz.build b/media/omx-plugin/lib/froyo/libstagefright/moz.build index 0632ae65f5b..a5562ab76aa 100644 --- a/media/omx-plugin/lib/froyo/libstagefright/moz.build +++ b/media/omx-plugin/lib/froyo/libstagefright/moz.build @@ -10,9 +10,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk': 'libstagefright.cpp', ] -Library('stagefright') - -FORCE_SHARED_LIB = True +SharedLibrary('stagefright') LOCAL_INCLUDES += [ '/media/omx-plugin/include/froyo', diff --git a/media/omx-plugin/lib/gb/libstagefright/moz.build b/media/omx-plugin/lib/gb/libstagefright/moz.build index 209ceb46d1b..273f530f362 100644 --- a/media/omx-plugin/lib/gb/libstagefright/moz.build +++ b/media/omx-plugin/lib/gb/libstagefright/moz.build @@ -10,9 +10,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk': 'libstagefright.cpp', ] -Library('stagefright') - -FORCE_SHARED_LIB = True +SharedLibrary('stagefright') LOCAL_INCLUDES += [ '/media/omx-plugin/include/gb', diff --git a/media/omx-plugin/lib/gb/libstagefright_color_conversion/moz.build b/media/omx-plugin/lib/gb/libstagefright_color_conversion/moz.build index efbd44f49e8..31bc2885bfc 100644 --- a/media/omx-plugin/lib/gb/libstagefright_color_conversion/moz.build +++ b/media/omx-plugin/lib/gb/libstagefright_color_conversion/moz.build @@ -10,9 +10,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk': 'libstagefright_color_conversion.cpp', ] -Library('stagefright_color_conversion') - -FORCE_SHARED_LIB = True +SharedLibrary('stagefright_color_conversion') LOCAL_INCLUDES += [ '/media/omx-plugin/include/gb', diff --git a/media/omx-plugin/lib/gb/libutils/moz.build b/media/omx-plugin/lib/gb/libutils/moz.build index a131edf0ad6..5c5ce7c3cbb 100644 --- a/media/omx-plugin/lib/gb/libutils/moz.build +++ b/media/omx-plugin/lib/gb/libutils/moz.build @@ -10,9 +10,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk': 'libutils.cpp', ] -Library('utils') - -FORCE_SHARED_LIB = True +SharedLibrary('utils') LOCAL_INCLUDES += [ '/media/omx-plugin/include/gb', diff --git a/media/omx-plugin/lib/gb235/libstagefright/moz.build b/media/omx-plugin/lib/gb235/libstagefright/moz.build index 209ceb46d1b..273f530f362 100644 --- a/media/omx-plugin/lib/gb235/libstagefright/moz.build +++ b/media/omx-plugin/lib/gb235/libstagefright/moz.build @@ -10,9 +10,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk': 'libstagefright.cpp', ] -Library('stagefright') - -FORCE_SHARED_LIB = True +SharedLibrary('stagefright') LOCAL_INCLUDES += [ '/media/omx-plugin/include/gb', diff --git a/media/omx-plugin/lib/hc/libstagefright/moz.build b/media/omx-plugin/lib/hc/libstagefright/moz.build index 209ceb46d1b..273f530f362 100644 --- a/media/omx-plugin/lib/hc/libstagefright/moz.build +++ b/media/omx-plugin/lib/hc/libstagefright/moz.build @@ -10,9 +10,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk': 'libstagefright.cpp', ] -Library('stagefright') - -FORCE_SHARED_LIB = True +SharedLibrary('stagefright') LOCAL_INCLUDES += [ '/media/omx-plugin/include/gb', diff --git a/media/omx-plugin/lib/ics/libstagefright/moz.build b/media/omx-plugin/lib/ics/libstagefright/moz.build index c22b723f5cc..f5aebaca8c4 100644 --- a/media/omx-plugin/lib/ics/libstagefright/moz.build +++ b/media/omx-plugin/lib/ics/libstagefright/moz.build @@ -10,9 +10,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk': 'libstagefright.cpp', ] -Library('stagefright') - -FORCE_SHARED_LIB = True +SharedLibrary('stagefright') LOCAL_INCLUDES += [ '/media/omx-plugin/include/ics', diff --git a/media/omx-plugin/lib/ics/libutils/moz.build b/media/omx-plugin/lib/ics/libutils/moz.build index 409b4e712ba..04aedf67043 100644 --- a/media/omx-plugin/lib/ics/libutils/moz.build +++ b/media/omx-plugin/lib/ics/libutils/moz.build @@ -10,9 +10,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk': 'libutils.cpp', ] -Library('utils') - -FORCE_SHARED_LIB = True +SharedLibrary('utils') LOCAL_INCLUDES += [ '/media/omx-plugin/include/ics', diff --git a/media/omx-plugin/lib/ics/libvideoeditorplayer/moz.build b/media/omx-plugin/lib/ics/libvideoeditorplayer/moz.build index b250510128d..a65d24f489e 100644 --- a/media/omx-plugin/lib/ics/libvideoeditorplayer/moz.build +++ b/media/omx-plugin/lib/ics/libvideoeditorplayer/moz.build @@ -10,9 +10,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk': 'libvideoeditorplayer.cpp', ] -Library('videoeditorplayer') - -FORCE_SHARED_LIB = True +SharedLibrary('videoeditorplayer') # Don't use STL wrappers; this isn't Gecko code DISABLE_STL_WRAPPING = True diff --git a/media/omx-plugin/moz.build b/media/omx-plugin/moz.build index 1507a4094c0..490a40501bb 100644 --- a/media/omx-plugin/moz.build +++ b/media/omx-plugin/moz.build @@ -18,9 +18,7 @@ SOURCES += [ 'OmxPlugin.cpp', ] -Library('omxplugin') - -FORCE_SHARED_LIB = True +SharedLibrary('omxplugin') if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk': pass diff --git a/memory/mozalloc/moz.build b/memory/mozalloc/moz.build index d279faaedf0..ccbbf2ac4c9 100644 --- a/memory/mozalloc/moz.build +++ b/memory/mozalloc/moz.build @@ -57,12 +57,10 @@ else: 'VolatileBufferFallback.cpp', ] -Library('mozalloc') - if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk': - FORCE_STATIC_LIB = True + Library('mozalloc') else: - FORCE_SHARED_LIB = True + SharedLibrary('mozalloc') SDK_LIBRARY = True # The strndup declaration in string.h is in an ifdef __USE_GNU section diff --git a/memory/replace/dmd/moz.build b/memory/replace/dmd/moz.build index c8f15f2dae3..d50d631ae88 100644 --- a/memory/replace/dmd/moz.build +++ b/memory/replace/dmd/moz.build @@ -18,9 +18,7 @@ SOURCES += [ '../../../nsprpub/lib/libc/src/strcpy.c', ] -Library('dmd') - -FORCE_SHARED_LIB = True +SharedLibrary('dmd') DEFINES['MOZ_NO_MOZALLOC'] = True diff --git a/memory/replace/dummy/moz.build b/memory/replace/dummy/moz.build index 2aeda4fb26c..88b7d6fb612 100644 --- a/memory/replace/dummy/moz.build +++ b/memory/replace/dummy/moz.build @@ -9,8 +9,6 @@ SOURCES += [ 'dummy_replace_malloc.c', ] -Library('replace_malloc') - -FORCE_SHARED_LIB = True +SharedLibrary('replace_malloc') DISABLE_STL_WRAPPING = True diff --git a/memory/replace/jemalloc/moz.build b/memory/replace/jemalloc/moz.build index 65c5999f6c8..74d03e99c39 100644 --- a/memory/replace/jemalloc/moz.build +++ b/memory/replace/jemalloc/moz.build @@ -17,14 +17,12 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android': 'pthread_atfork.c', ] -Library('replace_jemalloc') +SharedLibrary('replace_jemalloc') USE_LIBS += [ 'jemalloc', ] -FORCE_SHARED_LIB = True - DEFINES['MOZ_JEMALLOC3'] = True DEFINES['MOZ_REPLACE_JEMALLOC'] = True diff --git a/mozglue/build/moz.build b/mozglue/build/moz.build index e97a8f258d2..ee209e73a00 100644 --- a/mozglue/build/moz.build +++ b/mozglue/build/moz.build @@ -7,10 +7,9 @@ # Build mozglue as a shared lib on Windows, OSX and Android. # If this is ever changed, update MOZ_SHARED_MOZGLUE in browser/installer/Makefile.in if CONFIG['OS_TARGET'] in ('WINNT', 'Darwin', 'Android'): - FORCE_SHARED_LIB = True + SharedLibrary('mozglue') else: - FORCE_SHARED_LIB = False - FORCE_STATIC_LIB = True + Library('mozglue') SDK_LIBRARY = True @@ -69,8 +68,6 @@ if CONFIG['MOZ_ASAN']: ] -Library('mozglue') - USE_LIBS += [ 'mfbt', ] diff --git a/python/mozbuild/mozbuild/frontend/context.py b/python/mozbuild/mozbuild/frontend/context.py index 346cae03ccd..7d1fdac124c 100644 --- a/python/mozbuild/mozbuild/frontend/context.py +++ b/python/mozbuild/mozbuild/frontend/context.py @@ -954,9 +954,12 @@ for name, (storage_type, input_types, docs, tier) in VARIABLES.items(): # Set of variables that are only allowed in templates: TEMPLATE_VARIABLES = { 'CPP_UNIT_TESTS', + 'FORCE_SHARED_LIB', 'HOST_PROGRAM', 'HOST_LIBRARY_NAME', 'HOST_SIMPLE_PROGRAMS', + 'IS_COMPONENT', + 'IS_FRAMEWORK', 'LIBRARY_NAME', 'PROGRAM', 'SIMPLE_PROGRAMS', @@ -1307,6 +1310,39 @@ DEPRECATION_HINTS = { SIMPLE_PROGRAMS += ['foo', 'bar']" ''', + 'FORCE_SHARED_LIB': ''' + Please use + + SharedLibrary('foo') + + instead of + + Library('foo') [ or LIBRARY_NAME = 'foo' ] + FORCE_SHARED_LIB = True + ''', + + 'IS_COMPONENT': ''' + Please use + + XPCOMBinaryComponent('foo') + + instead of + + Library('foo') [ or LIBRARY_NAME = 'foo' ] + IS_COMPONENT = True + ''', + + 'IS_FRAMEWORK': ''' + Please use + + Framework('foo') + + instead of + + Library('foo') [ or LIBRARY_NAME = 'foo' ] + IS_FRAMEWORK = True + ''', + 'TOOL_DIRS': 'Please use the DIRS variable instead.', 'TEST_TOOL_DIRS': 'Please use the TEST_DIRS variable instead.', diff --git a/python/mozbuild/mozbuild/frontend/emitter.py b/python/mozbuild/mozbuild/frontend/emitter.py index 34513fa6380..3ad348323a2 100644 --- a/python/mozbuild/mozbuild/frontend/emitter.py +++ b/python/mozbuild/mozbuild/frontend/emitter.py @@ -638,14 +638,6 @@ class TreeMetadataEmitter(LoggingMixin): if libname: if is_component: - if shared_lib: - raise SandboxValidationError( - 'IS_COMPONENT implies FORCE_SHARED_LIB. ' - 'Please remove the latter.', context) - if is_framework: - raise SandboxValidationError( - 'IS_COMPONENT conflicts with IS_FRAMEWORK. ' - 'Please remove one.', context) if static_lib: raise SandboxValidationError( 'IS_COMPONENT conflicts with FORCE_STATIC_LIB. ' @@ -654,10 +646,6 @@ class TreeMetadataEmitter(LoggingMixin): shared_args['variant'] = SharedLibrary.COMPONENT if is_framework: - if shared_lib: - raise SandboxValidationError( - 'IS_FRAMEWORK implies FORCE_SHARED_LIB. ' - 'Please remove the latter.', context) if soname: raise SandboxValidationError( 'IS_FRAMEWORK conflicts with SONAME. ' diff --git a/security/manager/ssl/tests/unit/pkcs11testmodule/moz.build b/security/manager/ssl/tests/unit/pkcs11testmodule/moz.build index 9543ee60073..7f2f079a4f8 100644 --- a/security/manager/ssl/tests/unit/pkcs11testmodule/moz.build +++ b/security/manager/ssl/tests/unit/pkcs11testmodule/moz.build @@ -8,9 +8,8 @@ UNIFIED_SOURCES += [ 'pkcs11testmodule.cpp', ] -Library('pkcs11testmodule') +SharedLibrary('pkcs11testmodule') -FORCE_SHARED_LIB = True # C_GetFunctionList needs to be exported. As it turns out, it's much easier to # just export all the symbols. NO_VISIBILITY_FLAGS = True diff --git a/security/sandbox/linux/moz.build b/security/sandbox/linux/moz.build index 74c1736a4b4..2cbbccf3bf4 100644 --- a/security/sandbox/linux/moz.build +++ b/security/sandbox/linux/moz.build @@ -6,8 +6,7 @@ FAIL_ON_WARNINGS = True -Library('mozsandbox') -FORCE_SHARED_LIB = True +SharedLibrary('mozsandbox') EXPORTS.mozilla += [ 'Sandbox.h', diff --git a/security/sandbox/win/src/sandboxbroker/moz.build b/security/sandbox/win/src/sandboxbroker/moz.build index eed82492d5a..0164e8e4ad9 100644 --- a/security/sandbox/win/src/sandboxbroker/moz.build +++ b/security/sandbox/win/src/sandboxbroker/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -Library('sandboxbroker') +SharedLibrary('sandboxbroker') USE_LIBS += [ 'nspr', @@ -19,8 +19,6 @@ EXPORTS += [ 'sandboxBroker.h', ] -FORCE_SHARED_LIB = True - for var in ('UNICODE', '_UNICODE', 'NS_NO_XPCOM', 'NOMINMAX', 'SANDBOX_EXPORTS'): DEFINES[var] = True diff --git a/toolkit/components/ctypes/tests/moz.build b/toolkit/components/ctypes/tests/moz.build index 749ccd4622c..7085c9df8a3 100644 --- a/toolkit/components/ctypes/tests/moz.build +++ b/toolkit/components/ctypes/tests/moz.build @@ -14,9 +14,7 @@ UNIFIED_SOURCES += [ 'jsctypes-test.cpp', ] -Library('jsctypes-test') - -FORCE_SHARED_LIB = True +SharedLibrary('jsctypes-test') LOCAL_INCLUDES += [ '/js/src/ctypes', diff --git a/toolkit/crashreporter/injector/moz.build b/toolkit/crashreporter/injector/moz.build index 83d02b14c30..53af1e12818 100644 --- a/toolkit/crashreporter/injector/moz.build +++ b/toolkit/crashreporter/injector/moz.build @@ -8,12 +8,10 @@ SOURCES += [ 'injector.cpp', ] -Library('breakpadinjector') +SharedLibrary('breakpadinjector') include('/ipc/chromium/chromium-config.mozbuild') -FORCE_SHARED_LIB = True - LOCAL_INCLUDES += [ '/toolkit/crashreporter/google-breakpad/src', ] diff --git a/toolkit/crashreporter/test/moz.build b/toolkit/crashreporter/test/moz.build index 9d93cbf94d4..5334228684b 100644 --- a/toolkit/crashreporter/test/moz.build +++ b/toolkit/crashreporter/test/moz.build @@ -17,14 +17,12 @@ UNIFIED_SOURCES += [ 'nsTestCrasher.cpp', ] -Library('testcrasher') +SharedLibrary('testcrasher') EXTRA_JS_MODULES += [ 'CrashTestUtils.jsm', ] -FORCE_SHARED_LIB = True - DEFINES['SHARED_LIBRARY'] = '%s%s%s' % ( CONFIG['DLL_PREFIX'], LIBRARY_NAME, diff --git a/toolkit/library/gtest/moz.build b/toolkit/library/gtest/moz.build index 04dc296bcb4..0d0fd939c1b 100644 --- a/toolkit/library/gtest/moz.build +++ b/toolkit/library/gtest/moz.build @@ -4,12 +4,10 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -Library('xul-gtest') +Libxul('xul-gtest') FINAL_TARGET = 'dist/bin/gtest' USE_LIBS += [ 'static:xul', ] - -include('../libxul.mozbuild') diff --git a/toolkit/library/libxul.mozbuild b/toolkit/library/libxul.mozbuild deleted file mode 100644 index fcb2ec435d8..00000000000 --- a/toolkit/library/libxul.mozbuild +++ /dev/null @@ -1,52 +0,0 @@ -# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -MSVC_ENABLE_PGO = True - -if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': - # This is going to be a framework named "XUL", not an ordinary library named - # "libxul.dylib" - SHARED_LIBRARY_NAME = 'XUL' - IS_FRAMEWORK = True -else: - SHARED_LIBRARY_NAME = 'xul' - FORCE_SHARED_LIB = True - - -DELAYLOAD_DLLS += [ - 'comdlg32.dll', - 'dbghelp.dll', - 'psapi.dll', - 'rasapi32.dll', - 'rasdlg.dll', - 'secur32.dll', - 'wininet.dll', - 'winspool.drv' -] - -if CONFIG['MOZ_METRO']: - DELAYLOAD_DLLS += [ - 'API-MS-WIN-CORE-WINRT-L' + CONFIG['CRTEXPDLLVERSION'] + '.DLL', - 'API-MS-WIN-CORE-WINRT-STRING-L' + CONFIG['CRTEXPDLLVERSION'] + '.DLL', - 'uiautomationcore.dll' - ] - -if CONFIG['ACCESSIBILITY']: - DELAYLOAD_DLLS += ['oleacc.dll'] - -if CONFIG['MOZ_WEBRTC']: - DELAYLOAD_DLLS += ['msdmo.dll'] - -if CONFIG['OS_ARCH'] == 'WINNT' and not CONFIG['GNU_CC']: - LOCAL_INCLUDES += [ - '/widget/windows', - '/xpcom/base', - ] - # config/version.mk says $(srcdir)/$(RCINCLUDE), and this needs to - # be valid in both toolkit/library and toolkit/library/gtest. - # Eventually, the make backend would do its own path canonicalization - # and config/version.mk would lift the $(srcdir) - RCINCLUDE = '$(DEPTH)/toolkit/library/xulrunner.rc' diff --git a/toolkit/library/moz.build b/toolkit/library/moz.build index f3784c5eb1a..8ace917aa5a 100644 --- a/toolkit/library/moz.build +++ b/toolkit/library/moz.build @@ -4,7 +4,55 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -Library('xul') +@template +def Libxul(name): + MSVC_ENABLE_PGO = True + + if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': + # This is going to be a framework named "XUL", not an ordinary library named + # "libxul.dylib" + Framework(name) + SHARED_LIBRARY_NAME = 'XUL' + else: + SharedLibrary(name) + SHARED_LIBRARY_NAME = 'xul' + + DELAYLOAD_DLLS += [ + 'comdlg32.dll', + 'dbghelp.dll', + 'psapi.dll', + 'rasapi32.dll', + 'rasdlg.dll', + 'secur32.dll', + 'wininet.dll', + 'winspool.drv' + ] + + if CONFIG['MOZ_METRO']: + DELAYLOAD_DLLS += [ + 'API-MS-WIN-CORE-WINRT-L' + CONFIG['CRTEXPDLLVERSION'] + '.DLL', + 'API-MS-WIN-CORE-WINRT-STRING-L' + CONFIG['CRTEXPDLLVERSION'] + '.DLL', + 'uiautomationcore.dll' + ] + + if CONFIG['ACCESSIBILITY']: + DELAYLOAD_DLLS += ['oleacc.dll'] + + if CONFIG['MOZ_WEBRTC']: + DELAYLOAD_DLLS += ['msdmo.dll'] + + if CONFIG['OS_ARCH'] == 'WINNT' and not CONFIG['GNU_CC']: + LOCAL_INCLUDES += [ + '/widget/windows', + '/xpcom/base', + ] + # config/version.mk says $(srcdir)/$(RCINCLUDE), and this needs to + # be valid in both toolkit/library and toolkit/library/gtest. + # Eventually, the make backend would do its own path canonicalization + # and config/version.mk would lift the $(srcdir) + RCINCLUDE = '$(DEPTH)/toolkit/library/xulrunner.rc' + +Libxul('xul') SDK_LIBRARY = True @@ -46,8 +94,6 @@ FAIL_ON_WARNINGS = True DIRS += ['gtest'] -include('libxul.mozbuild') - # js needs to come after xul for now, because it is an archive and its content # is discarded when it comes first. USE_LIBS += [ diff --git a/tools/jprof/stub/moz.build b/tools/jprof/stub/moz.build index 1ed19f49227..9a56e0efd90 100644 --- a/tools/jprof/stub/moz.build +++ b/tools/jprof/stub/moz.build @@ -12,8 +12,6 @@ SOURCES += [ 'libmalloc.cpp', ] -Library('jprof') - -FORCE_SHARED_LIB = True +SharedLibrary('jprof') DEFINES['_IMPL_JPROF_API'] = True diff --git a/widget/gtk/mozgtk/gtk2/moz.build b/widget/gtk/mozgtk/gtk2/moz.build index b9f7d2f6237..acc9fbf76dd 100644 --- a/widget/gtk/mozgtk/gtk2/moz.build +++ b/widget/gtk/mozgtk/gtk2/moz.build @@ -10,12 +10,10 @@ SOURCES += [ DEFINES['GTK3_SYMBOLS'] = True -Library('mozgtk2') +SharedLibrary('mozgtk2') SONAME = 'mozgtk' -FORCE_SHARED_LIB = True - # If LDFLAGS contains -Wl,--as-needed, we need to add -Wl,--no-as-needed # before the gtk libraries, otherwise the linker will drop those dependencies # because no symbols are used from them. But those dependencies need to be diff --git a/widget/gtk/mozgtk/gtk3/moz.build b/widget/gtk/mozgtk/gtk3/moz.build index c8b5c3b7c91..fb62856b1ee 100644 --- a/widget/gtk/mozgtk/gtk3/moz.build +++ b/widget/gtk/mozgtk/gtk3/moz.build @@ -10,12 +10,10 @@ SOURCES += [ DEFINES['GTK2_SYMBOLS'] = True -Library('mozgtk') +SharedLibrary('mozgtk') SONAME = 'mozgtk' -FORCE_SHARED_LIB = True - # If LDFLAGS contains -Wl,--as-needed, we need to add -Wl,--no-as-needed # before the gtk libraries, otherwise the linker will drop those dependencies # because no symbols are used from them. But those dependencies need to be diff --git a/widget/gtk/mozgtk/stub/moz.build b/widget/gtk/mozgtk/stub/moz.build index c1611acbbf9..245136426a6 100644 --- a/widget/gtk/mozgtk/stub/moz.build +++ b/widget/gtk/mozgtk/stub/moz.build @@ -11,8 +11,6 @@ SOURCES += [ for var in ('COMMON_SYMBOLS', 'GTK2_SYMBOLS', 'GTK3_SYMBOLS'): DEFINES[var] = True -Library('mozgtk_stub') +SharedLibrary('mozgtk_stub') SONAME = 'mozgtk' - -FORCE_SHARED_LIB = True From 22206d6d183124a29cd5813b49e4da2c035e4446 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Thu, 4 Sep 2014 09:05:12 +0900 Subject: [PATCH 26/68] Bug 1059129 - Move the addition of stdc++compat to templates. r=mshal --- build/templates.mozbuild | 32 ++++++++++++++++++-- python/mozbuild/mozbuild/frontend/emitter.py | 12 +------- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/build/templates.mozbuild b/build/templates.mozbuild index 3abcb807f9f..bfc67c80c42 100644 --- a/build/templates.mozbuild +++ b/build/templates.mozbuild @@ -4,11 +4,21 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +@template +def StdCppCompat(): + '''Template for libstdc++ compatibility for target binaries.''' + + if CONFIG['MOZ_LIBSTDCXX_TARGET_VERSION']: + USE_LIBS += ['stdc++compat'] + + @template def Program(name): '''Template for program executables.''' PROGRAM = name + StdCppCompat() + @template def SimplePrograms(names, ext='.cpp'): @@ -19,6 +29,8 @@ def SimplePrograms(names, ext='.cpp'): SIMPLE_PROGRAMS += names SOURCES += ['%s%s' % (name, ext) for name in names] + StdCppCompat() + @template def CppUnitTests(names, ext='.cpp'): @@ -29,6 +41,8 @@ def CppUnitTests(names, ext='.cpp'): CPP_UNIT_TESTS += names SOURCES += ['%s%s' % (name, ext) for name in names] + StdCppCompat() + @template def Library(name): @@ -43,20 +57,32 @@ def SharedLibrary(name): FORCE_SHARED_LIB = True + StdCppCompat() + @template def Framework(name): '''Template for OSX Frameworks.''' - Library(name) + SharedLibrary(name) IS_FRAMEWORK = True +@template +def HostStdCppCompat(): + '''Template for libstdc++ compatibility for host binaries.''' + + if CONFIG['MOZ_LIBSTDCXX_HOST_VERSION']: + HOST_USE_LIBS += ['host_stdc++compat'] + + @template def HostProgram(name): '''Template for build tools executables.''' HOST_PROGRAM = name + HostStdCppCompat() + @template def HostSimplePrograms(names, ext='.cpp'): @@ -68,6 +94,8 @@ def HostSimplePrograms(names, ext='.cpp'): HOST_SOURCES += ['%s%s' % (name.replace('host_', ''), ext) for name in names] + HostStdCppCompat() + @template def HostLibrary(name): @@ -95,7 +123,7 @@ def XPCOMBinaryComponent(name): name is the name of the component. ''' - LIBRARY_NAME = name + SharedLibrary(name) GeckoBinary() diff --git a/python/mozbuild/mozbuild/frontend/emitter.py b/python/mozbuild/mozbuild/frontend/emitter.py index 3ad348323a2..5e1ab2a3629 100644 --- a/python/mozbuild/mozbuild/frontend/emitter.py +++ b/python/mozbuild/mozbuild/frontend/emitter.py @@ -240,17 +240,7 @@ class TreeMetadataEmitter(LoggingMixin): """Add linkage declarations to a given object.""" assert isinstance(obj, Linkable) - extra = [] - # Add stdc++compat library when wanted and needed - compat_varname = 'MOZ_LIBSTDCXX_%s_VERSION' % obj.KIND.upper() - if context.config.substs.get(compat_varname) \ - and not isinstance(obj, (StaticLibrary, HostLibrary)): - extra.append({ - 'target': 'stdc++compat', - 'host': 'host_stdc++compat', - }[obj.KIND]) - - for path in context.get(variable, []) + extra: + for path in context.get(variable, []): force_static = path.startswith('static:') and obj.KIND == 'target' if force_static: path = path[7:] From b6bb51e10402fe7f1b87b8ae27c57afb077ab548 Mon Sep 17 00:00:00 2001 From: Botond Ballo Date: Wed, 3 Sep 2014 12:54:26 -0400 Subject: [PATCH 27/68] Bug 1062411 - Make FrameMetrics::mContentDescription an nsCString so there is no limit to its length. r=BenWa --- gfx/layers/FrameMetrics.h | 30 ++++++++++--------- gfx/layers/apz/src/AsyncPanZoomController.cpp | 2 +- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/gfx/layers/FrameMetrics.h b/gfx/layers/FrameMetrics.h index ea4e72f0bf3..2763c5bfcf3 100644 --- a/gfx/layers/FrameMetrics.h +++ b/gfx/layers/FrameMetrics.h @@ -60,10 +60,6 @@ namespace layers { * time of a layer-tree transaction. These metrics are especially * useful for shadow layers, because the metrics values are updated * atomically with new pixels. - * - * Note that the FrameMetrics struct is sometimes stored in shared - * memory and shared across processes, so it should be a "Plain Old - * Data (POD)" type with no members that use dynamic memory. */ struct FrameMetrics { friend struct IPC::ParamTraits; @@ -101,7 +97,6 @@ public: , mViewport(0, 0, 0, 0) , mBackgroundColor(0, 0, 0, 0) { - mContentDescription[0] = '\0'; } // Default copy ctor and operator= are fine @@ -128,8 +123,7 @@ public: mScrollOffset == aOther.mScrollOffset && mHasScrollgrab == aOther.mHasScrollgrab && mUpdateScrollOffset == aOther.mUpdateScrollOffset && - mBackgroundColor == aOther.mBackgroundColor && - !strcmp(mContentDescription, aOther.mContentDescription); + mBackgroundColor == aOther.mBackgroundColor; } bool operator!=(const FrameMetrics& aOther) const { @@ -247,6 +241,16 @@ public: mScrollGeneration = aOther.mScrollGeneration; } + // Make a copy of this FrameMetrics object which does not have any pointers + // to heap-allocated memory (i.e. is Plain Old Data, or 'POD'), and is + // therefore safe to be placed into shared memory. + FrameMetrics MakePODObject() const + { + FrameMetrics copy = *this; + copy.mContentDescription.Truncate(); + return copy; + } + // --------------------------------------------------------------------------- // The following metrics are all in widget space/device pixels. // @@ -484,16 +488,14 @@ public: mBackgroundColor = aBackgroundColor; } - nsCString GetContentDescription() const + const nsCString& GetContentDescription() const { - return nsCString(mContentDescription); + return mContentDescription; } void SetContentDescription(const nsCString& aContentDescription) { - strncpy(mContentDescription, aContentDescription.get(), - sizeof(mContentDescription)); - mContentDescription[sizeof(mContentDescription) - 1] = 0; + mContentDescription = aContentDescription; } private: @@ -569,9 +571,9 @@ private: gfxRGBA mBackgroundColor; // A description of the content element corresponding to this frame. - // This is empty unless this is a scrollable ContainerLayer and the + // This is empty unless this is a scrollable layer and the // apz.printtree pref is turned on. - char mContentDescription[20]; + nsCString mContentDescription; }; /** diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index d397afa4fc4..817894b7713 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -2868,7 +2868,7 @@ void AsyncPanZoomController::UpdateSharedCompositorFrameMetrics() if (frame && mSharedLock && gfxPrefs::UseProgressiveTilePainting()) { mSharedLock->Lock(); - *frame = mFrameMetrics; + *frame = mFrameMetrics.MakePODObject(); mSharedLock->Unlock(); } } From 27f6269f74f229bae0f2b79ab3894e1448ca577f Mon Sep 17 00:00:00 2001 From: Catalin Badea Date: Wed, 27 Aug 2014 10:24:09 -0700 Subject: [PATCH 28/68] Bug 982726 - Patch 1 - Service Worker: ServiceWorkerClients and Client interfaces with getServiced(). r=baku --HG-- extra : rebase_source : f8dd649fd30cfffb2a361aa24868e83413e7b54c --- dom/bindings/Bindings.conf | 10 + dom/webidl/ServiceWorkerClient.webidl | 14 ++ dom/webidl/ServiceWorkerClients.webidl | 19 ++ dom/webidl/ServiceWorkerGlobalScope.webidl | 5 +- dom/webidl/moz.build | 2 + dom/workers/ServiceWorkerClient.cpp | 29 +++ dom/workers/ServiceWorkerClient.h | 59 +++++ dom/workers/ServiceWorkerClients.cpp | 229 ++++++++++++++++++ dom/workers/ServiceWorkerClients.h | 56 +++++ dom/workers/ServiceWorkerManager.cpp | 51 ++++ dom/workers/ServiceWorkerManager.h | 4 + dom/workers/WorkerScope.cpp | 8 + dom/workers/WorkerScope.h | 16 ++ dom/workers/moz.build | 4 + .../serviceworkers/get_serviced_worker.js | 16 ++ dom/workers/test/serviceworkers/mochitest.ini | 3 + .../serviceworkers/sw_clients/simple.html | 25 ++ .../serviceworkers/test_get_serviced.html | 57 +++++ 18 files changed, 603 insertions(+), 4 deletions(-) create mode 100644 dom/webidl/ServiceWorkerClient.webidl create mode 100644 dom/webidl/ServiceWorkerClients.webidl create mode 100644 dom/workers/ServiceWorkerClient.cpp create mode 100644 dom/workers/ServiceWorkerClient.h create mode 100644 dom/workers/ServiceWorkerClients.cpp create mode 100644 dom/workers/ServiceWorkerClients.h create mode 100644 dom/workers/test/serviceworkers/get_serviced_worker.js create mode 100644 dom/workers/test/serviceworkers/sw_clients/simple.html create mode 100644 dom/workers/test/serviceworkers/test_get_serviced.html diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index 969b3e7809d..0bb7f8dbb8b 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -1058,6 +1058,16 @@ DOMInterfaces = { 'headerFile': 'mozilla/dom/workers/bindings/ServiceWorker.h', }, +'ServiceWorkerClient': { + 'nativeType': 'mozilla::dom::workers::ServiceWorkerClient', + 'headerFile': 'mozilla/dom/workers/bindings/ServiceWorkerClient.h', +}, + +'ServiceWorkerClients': { + 'nativeType': 'mozilla::dom::workers::ServiceWorkerClients', + 'headerFile': 'mozilla/dom/workers/bindings/ServiceWorkerClients.h', +}, + 'ServiceWorkerGlobalScope': { 'headerFile': 'mozilla/dom/WorkerScope.h', 'workers': True, diff --git a/dom/webidl/ServiceWorkerClient.webidl b/dom/webidl/ServiceWorkerClient.webidl new file mode 100644 index 00000000000..2473fb572fe --- /dev/null +++ b/dom/webidl/ServiceWorkerClient.webidl @@ -0,0 +1,14 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * The origin of this IDL file is + * http://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html + * + */ + +[Exposed=ServiceWorker] +interface ServiceWorkerClient { + readonly attribute unsigned long id; +}; diff --git a/dom/webidl/ServiceWorkerClients.webidl b/dom/webidl/ServiceWorkerClients.webidl new file mode 100644 index 00000000000..8d88181ddc0 --- /dev/null +++ b/dom/webidl/ServiceWorkerClients.webidl @@ -0,0 +1,19 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * The origin of this IDL file is + * http://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html + * + */ + +[Exposed=ServiceWorker] +interface ServiceWorkerClients { + // A list of client objects, identifiable by ID, that correspond to windows + // (or workers) that are "controlled" by this SW + [Throws] + Promise?> getServiced(); + [Throws] + Promise reloadAll(); +}; diff --git a/dom/webidl/ServiceWorkerGlobalScope.webidl b/dom/webidl/ServiceWorkerGlobalScope.webidl index 5f2518a4f70..6fa74e66f62 100644 --- a/dom/webidl/ServiceWorkerGlobalScope.webidl +++ b/dom/webidl/ServiceWorkerGlobalScope.webidl @@ -16,10 +16,7 @@ interface ServiceWorkerGlobalScope : WorkerGlobalScope { // FIXME(nsm): Bug 982725 // readonly attribute CacheList caches; - // FIXME(nsm): Bug 982726 - // A container for a list of window objects, identifiable by ID, that - // correspond to windows (or workers) that are "controlled" by this SW - // readonly attribute ServiceWorkerClients clients; + readonly attribute ServiceWorkerClients clients; [Unforgeable] readonly attribute DOMString scope; diff --git a/dom/webidl/moz.build b/dom/webidl/moz.build index 7959d65243b..565b9f2dff3 100644 --- a/dom/webidl/moz.build +++ b/dom/webidl/moz.build @@ -331,6 +331,8 @@ WEBIDL_FILES = [ 'ScrollAreaEvent.webidl', 'Selection.webidl', 'ServiceWorker.webidl', + 'ServiceWorkerClient.webidl', + 'ServiceWorkerClients.webidl', 'ServiceWorkerContainer.webidl', 'ServiceWorkerGlobalScope.webidl', 'ServiceWorkerRegistration.webidl', diff --git a/dom/workers/ServiceWorkerClient.cpp b/dom/workers/ServiceWorkerClient.cpp new file mode 100644 index 00000000000..2a2e1c28b3e --- /dev/null +++ b/dom/workers/ServiceWorkerClient.cpp @@ -0,0 +1,29 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "ServiceWorkerClient.h" + +#include "mozilla/dom/ServiceWorkerClientBinding.h" + +using namespace mozilla::dom; +using namespace mozilla::dom::workers; + +NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(ServiceWorkerClient, mOwner) + +NS_IMPL_CYCLE_COLLECTING_ADDREF(ServiceWorkerClient) +NS_IMPL_CYCLE_COLLECTING_RELEASE(ServiceWorkerClient) + +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ServiceWorkerClient) + NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY + NS_INTERFACE_MAP_ENTRY(nsISupports) +NS_INTERFACE_MAP_END + +JSObject* +ServiceWorkerClient::WrapObject(JSContext* aCx) +{ + return ServiceWorkerClientBinding::Wrap(aCx, this); +} + diff --git a/dom/workers/ServiceWorkerClient.h b/dom/workers/ServiceWorkerClient.h new file mode 100644 index 00000000000..7ad4c4aff80 --- /dev/null +++ b/dom/workers/ServiceWorkerClient.h @@ -0,0 +1,59 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef mozilla_dom_workers_serviceworkerclient_h +#define mozilla_dom_workers_serviceworkerclient_h + +#include "nsCOMPtr.h" +#include "nsWrapperCache.h" + +namespace mozilla { +namespace dom { + +class Promise; + +namespace workers { + +class ServiceWorkerClient MOZ_FINAL : public nsISupports, + public nsWrapperCache +{ +public: + NS_DECL_CYCLE_COLLECTING_ISUPPORTS + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ServiceWorkerClient) + + ServiceWorkerClient(nsISupports* aOwner, uint64_t aId) + : mOwner(aOwner), + mId(aId) + { + SetIsDOMBinding(); + } + + uint32_t Id() const + { + return mId; + } + + nsISupports* GetParentObject() const + { + return mOwner; + } + + JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; + +private: + ~ServiceWorkerClient() + { + } + + nsCOMPtr mOwner; + uint64_t mId; +}; + +} // namespace workers +} // namespace dom +} // namespace mozilla + +#endif // mozilla_dom_workers_serviceworkerclient_h diff --git a/dom/workers/ServiceWorkerClients.cpp b/dom/workers/ServiceWorkerClients.cpp new file mode 100644 index 00000000000..cc2129cf875 --- /dev/null +++ b/dom/workers/ServiceWorkerClients.cpp @@ -0,0 +1,229 @@ +/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "ServiceWorkerClient.h" +#include "ServiceWorkerClients.h" +#include "ServiceWorkerManager.h" + +#include "WorkerPrivate.h" +#include "WorkerRunnable.h" +#include "WorkerScope.h" + +#include "mozilla/dom/Promise.h" +#include "mozilla/dom/ServiceWorkerClientsBinding.h" + +using namespace mozilla; +using namespace mozilla::dom; +using namespace mozilla::dom::workers; + +NS_IMPL_CYCLE_COLLECTING_ADDREF(ServiceWorkerClients) +NS_IMPL_CYCLE_COLLECTING_RELEASE(ServiceWorkerClients) +NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(ServiceWorkerClients, mWorkerScope) + +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ServiceWorkerClients) + NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY + NS_INTERFACE_MAP_ENTRY(nsISupports) +NS_INTERFACE_MAP_END + +ServiceWorkerClients::ServiceWorkerClients(ServiceWorkerGlobalScope* aWorkerScope) + : mWorkerScope(aWorkerScope) +{ + MOZ_ASSERT(mWorkerScope); + SetIsDOMBinding(); +} + +JSObject* +ServiceWorkerClients::WrapObject(JSContext* aCx) +{ + return ServiceWorkerClientsBinding::Wrap(aCx, this); +} + +namespace { + +// Helper class used for passing the promise between threads while +// keeping the worker alive. +class PromiseHolder MOZ_FINAL : public WorkerFeature +{ + NS_INLINE_DECL_THREADSAFE_REFCOUNTING(PromiseHolder) + +public: + PromiseHolder(WorkerPrivate* aWorkerPrivate, + Promise* aPromise) + : mWorkerPrivate(aWorkerPrivate), + mPromise(aPromise), + mClean(false) + { + MOZ_ASSERT(mWorkerPrivate); + mWorkerPrivate->AssertIsOnWorkerThread(); + MOZ_ASSERT(mPromise); + + if (NS_WARN_IF(!mWorkerPrivate->AddFeature(mWorkerPrivate->GetJSContext(), this))) { + // Worker has been canceled and will go away. + // The ResolvePromiseWorkerRunnable won't run, so we can set mPromise to + // nullptr. + mPromise = nullptr; + mClean = true; + } + } + + Promise* + Get() const + { + return mPromise; + } + + void + Clean() + { + mWorkerPrivate->AssertIsOnWorkerThread(); + + if (mClean) { + return; + } + + mPromise = nullptr; + mWorkerPrivate->RemoveFeature(mWorkerPrivate->GetJSContext(), this); + mClean = true; + } + + bool + Notify(JSContext* aCx, Status aStatus) + { + mWorkerPrivate->AssertIsOnWorkerThread(); + + if (aStatus > Running) { + Clean(); + } + + return true; + } + +private: + ~PromiseHolder() + { + MOZ_ASSERT(mClean); + } + + WorkerPrivate* mWorkerPrivate; + nsRefPtr mPromise; + + bool mClean; +}; + +class ResolvePromiseWorkerRunnable MOZ_FINAL : public WorkerRunnable +{ + nsRefPtr mPromiseHolder; + nsAutoPtr> mValue; + +public: + ResolvePromiseWorkerRunnable(WorkerPrivate* aWorkerPrivate, + PromiseHolder* aPromiseHolder, + nsAutoPtr>& aValue) + : WorkerRunnable(aWorkerPrivate, WorkerThreadModifyBusyCount), + mPromiseHolder(aPromiseHolder), + mValue(aValue) + { + AssertIsOnMainThread(); + } + + bool + WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) + { + MOZ_ASSERT(aWorkerPrivate); + aWorkerPrivate->AssertIsOnWorkerThread(); + + Promise* promise = mPromiseHolder->Get(); + MOZ_ASSERT(promise); + + nsTArray> ret; + for (size_t i = 0; i < mValue->Length(); i++) { + ret.AppendElement(nsRefPtr( + new ServiceWorkerClient(promise->GetParentObject(), + mValue->ElementAt(i)))); + } + promise->MaybeResolve(ret); + + // release the reference on the worker thread. + mPromiseHolder->Clean(); + + return true; + } +}; + +class GetServicedRunnable MOZ_FINAL : public nsRunnable +{ + WorkerPrivate* mWorkerPrivate; + nsCString mScope; + nsRefPtr mPromiseHolder; +public: + GetServicedRunnable(WorkerPrivate* aWorkerPrivate, + Promise* aPromise, + const nsCString& aScope) + : mWorkerPrivate(aWorkerPrivate), + mScope(aScope) + { + MOZ_ASSERT(aWorkerPrivate); + aWorkerPrivate->AssertIsOnWorkerThread(); + mPromiseHolder = new PromiseHolder(aWorkerPrivate, aPromise); + } + + NS_IMETHOD + Run() MOZ_OVERRIDE + { + AssertIsOnMainThread(); + + nsRefPtr swm = ServiceWorkerManager::GetInstance(); + nsAutoPtr> result(new nsTArray()); + + swm->GetServicedClients(mScope, result); + nsRefPtr r = + new ResolvePromiseWorkerRunnable(mWorkerPrivate, mPromiseHolder, result); + + AutoSafeJSContext cx; + r->Dispatch(cx); + return NS_OK; + } +}; + +} // anonymous namespace + +already_AddRefed +ServiceWorkerClients::GetServiced(ErrorResult& aRv) +{ + WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate(); + MOZ_ASSERT(workerPrivate); + workerPrivate->AssertIsOnWorkerThread(); + + DOMString scope; + mWorkerScope->GetScope(scope); + + nsRefPtr promise = Promise::Create(mWorkerScope, aRv); + if (NS_WARN_IF(aRv.Failed())) { + return nullptr; + } + + nsRefPtr r = + new GetServicedRunnable(workerPrivate, promise, NS_ConvertUTF16toUTF8(scope)); + nsresult rv = NS_DispatchToMainThread(r); + + if (NS_WARN_IF(NS_FAILED(rv))) { + promise->MaybeReject(NS_ERROR_NOT_AVAILABLE); + } + + return promise.forget(); +} + +// FIXME(catalinb): Bug 1045257 - Implement ReloadAll +already_AddRefed +ServiceWorkerClients::ReloadAll(ErrorResult& aRv) +{ + nsRefPtr promise = Promise::Create(mWorkerScope, aRv); + if (NS_WARN_IF(aRv.Failed())) { + return nullptr; + } + promise->MaybeReject(NS_ERROR_NOT_AVAILABLE); + return promise.forget(); +} + diff --git a/dom/workers/ServiceWorkerClients.h b/dom/workers/ServiceWorkerClients.h new file mode 100644 index 00000000000..39cf03a6dab --- /dev/null +++ b/dom/workers/ServiceWorkerClients.h @@ -0,0 +1,56 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef mozilla_dom_workers_serviceworkerclients_h +#define mozilla_dom_workers_serviceworkerclients_h + +#include "nsAutoPtr.h" +#include "nsWrapperCache.h" + +namespace mozilla { + +class ErrorResult; + +namespace dom { + +class Promise; + +namespace workers { + +class ServiceWorkerGlobalScope; + +class ServiceWorkerClients MOZ_FINAL : public nsISupports, + public nsWrapperCache +{ +public: + NS_DECL_CYCLE_COLLECTING_ISUPPORTS + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ServiceWorkerClients) + + ServiceWorkerClients(ServiceWorkerGlobalScope* aWorkerScope); + + already_AddRefed GetServiced(ErrorResult& aRv); + already_AddRefed ReloadAll(ErrorResult& aRv); + + JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; + + ServiceWorkerGlobalScope* GetParentObject() const + { + return mWorkerScope; + } + +private: + ~ServiceWorkerClients() + { + } + + nsRefPtr mWorkerScope; +}; + +} // namespace workers +} // namespace dom +} // namespace mozilla + +#endif // mozilla_dom_workers_serviceworkerclients_h diff --git a/dom/workers/ServiceWorkerManager.cpp b/dom/workers/ServiceWorkerManager.cpp index 32aa670c4f4..15b40cedc5f 100644 --- a/dom/workers/ServiceWorkerManager.cpp +++ b/dom/workers/ServiceWorkerManager.cpp @@ -24,6 +24,7 @@ #include "RuntimeService.h" #include "ServiceWorker.h" +#include "ServiceWorkerClient.h" #include "ServiceWorkerRegistration.h" #include "ServiceWorkerEvents.h" #include "WorkerInlines.h" @@ -2173,4 +2174,54 @@ ServiceWorkerManager::InvalidateServiceWorkerRegistrationWorker(ServiceWorkerReg } } +namespace { + +class MOZ_STACK_CLASS FilterRegistrationData +{ +public: + FilterRegistrationData(nsTArray* aDocuments, + ServiceWorkerRegistrationInfo* aRegistration) + : mDocuments(aDocuments), + mRegistration(aRegistration) + { + } + + nsTArray* mDocuments; + nsRefPtr mRegistration; +}; + +static PLDHashOperator +EnumControlledDocuments(nsISupports* aKey, + ServiceWorkerRegistrationInfo* aRegistration, + void* aData) +{ + FilterRegistrationData* data = static_cast(aData); + if (data->mRegistration != aRegistration) { + return PL_DHASH_NEXT; + } + nsCOMPtr document = do_QueryInterface(aKey); + if (!document || !document->GetInnerWindow()) { + return PL_DHASH_NEXT; + } + + data->mDocuments->AppendElement(document->GetInnerWindow()->WindowID()); + return PL_DHASH_NEXT; +} + +} // anonymous namespace + +void +ServiceWorkerManager::GetServicedClients(const nsCString& aScope, + nsTArray* aControlledDocuments) +{ + nsRefPtr domainInfo = GetDomainInfo(aScope); + nsRefPtr registration = + domainInfo->GetRegistration(aScope); + MOZ_ASSERT(registration); + FilterRegistrationData data(aControlledDocuments, registration); + + domainInfo->mControlledDocuments.EnumerateRead(EnumControlledDocuments, + &data); +} + END_WORKERS_NAMESPACE diff --git a/dom/workers/ServiceWorkerManager.h b/dom/workers/ServiceWorkerManager.h index 68f80165479..2fb58bb63ca 100644 --- a/dom/workers/ServiceWorkerManager.h +++ b/dom/workers/ServiceWorkerManager.h @@ -318,6 +318,10 @@ public: uint32_t aColumnNumber, uint32_t aFlags); + void + GetServicedClients(const nsCString& aScope, + nsTArray* aControlledDocuments); + static already_AddRefed GetInstance(); diff --git a/dom/workers/WorkerScope.cpp b/dom/workers/WorkerScope.cpp index ef2475ad3e5..d353cbf55a2 100644 --- a/dom/workers/WorkerScope.cpp +++ b/dom/workers/WorkerScope.cpp @@ -346,6 +346,14 @@ SharedWorkerGlobalScope::WrapGlobalObject(JSContext* aCx) true); } +NS_IMPL_CYCLE_COLLECTION_INHERITED(ServiceWorkerGlobalScope, WorkerGlobalScope, + mClients) +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(ServiceWorkerGlobalScope) +NS_INTERFACE_MAP_END_INHERITING(WorkerGlobalScope) + +NS_IMPL_ADDREF_INHERITED(ServiceWorkerGlobalScope, WorkerGlobalScope) +NS_IMPL_RELEASE_INHERITED(ServiceWorkerGlobalScope, WorkerGlobalScope) + ServiceWorkerGlobalScope::ServiceWorkerGlobalScope(WorkerPrivate* aWorkerPrivate, const nsACString& aScope) : WorkerGlobalScope(aWorkerPrivate), diff --git a/dom/workers/WorkerScope.h b/dom/workers/WorkerScope.h index ea4918d5805..eed5fb4592e 100644 --- a/dom/workers/WorkerScope.h +++ b/dom/workers/WorkerScope.h @@ -8,6 +8,7 @@ #include "Workers.h" #include "mozilla/DOMEventTargetHelper.h" +#include "ServiceWorkerClients.h" namespace mozilla { namespace dom { @@ -163,9 +164,15 @@ public: class ServiceWorkerGlobalScope MOZ_FINAL : public WorkerGlobalScope { const nsString mScope; + nsRefPtr mClients; + ~ServiceWorkerGlobalScope() { } public: + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ServiceWorkerGlobalScope, + WorkerGlobalScope) + ServiceWorkerGlobalScope(WorkerPrivate* aWorkerPrivate, const nsACString& aScope); virtual JSObject* @@ -195,6 +202,15 @@ public: // FIXME(nsm): Bug 982728 } + ServiceWorkerClients* + Clients() { + if (!mClients) { + mClients = new ServiceWorkerClients(this); + } + + return mClients; + } + IMPL_EVENT_HANDLER(activate) IMPL_EVENT_HANDLER(beforeevicted) IMPL_EVENT_HANDLER(evicted) diff --git a/dom/workers/moz.build b/dom/workers/moz.build index 1502dc5a605..305cfc3b913 100644 --- a/dom/workers/moz.build +++ b/dom/workers/moz.build @@ -29,6 +29,8 @@ EXPORTS.mozilla.dom.workers.bindings += [ 'Navigator.h', 'Performance.h', 'ServiceWorker.h', + 'ServiceWorkerClient.h', + 'ServiceWorkerClients.h', 'SharedWorker.h', 'URL.h', 'WorkerFeature.h', @@ -51,6 +53,8 @@ SOURCES += [ 'RuntimeService.cpp', 'ScriptLoader.cpp', 'ServiceWorker.cpp', + 'ServiceWorkerClient.cpp', + 'ServiceWorkerClients.cpp', 'ServiceWorkerContainer.cpp', 'ServiceWorkerEvents.cpp', 'ServiceWorkerManager.cpp', diff --git a/dom/workers/test/serviceworkers/get_serviced_worker.js b/dom/workers/test/serviceworkers/get_serviced_worker.js new file mode 100644 index 00000000000..b97e4145034 --- /dev/null +++ b/dom/workers/test/serviceworkers/get_serviced_worker.js @@ -0,0 +1,16 @@ +function loop() { + self.clients.getServiced().then(function(result) { + setTimeout(loop, 0); + }); +} + +onactivate = function(e) { + // spam getServiced until the worker is closed. + loop(); +} + +onclose = function(e) { + for (var i = 0; i < 100; ++i) { + self.clients.getServiced(); + } +} diff --git a/dom/workers/test/serviceworkers/mochitest.ini b/dom/workers/test/serviceworkers/mochitest.ini index 20da13ab8a9..c8e7660cc5b 100644 --- a/dom/workers/test/serviceworkers/mochitest.ini +++ b/dom/workers/test/serviceworkers/mochitest.ini @@ -10,7 +10,10 @@ support-files = simpleregister/ready.html controller/index.html unregister/index.html + sw_clients/simple.html + get_serviced_worker.js +[test_get_serviced.html] [test_installation_simple.html] [test_install_event.html] [test_navigator.html] diff --git a/dom/workers/test/serviceworkers/sw_clients/simple.html b/dom/workers/test/serviceworkers/sw_clients/simple.html new file mode 100644 index 00000000000..6b1551928d3 --- /dev/null +++ b/dom/workers/test/serviceworkers/sw_clients/simple.html @@ -0,0 +1,25 @@ + + + + + Bug 982726 - test get_serviced not crashing + + + + +

+ +

+
+
+
+
+
diff --git a/dom/workers/test/serviceworkers/test_get_serviced.html b/dom/workers/test/serviceworkers/test_get_serviced.html
new file mode 100644
index 00000000000..8c47401a079
--- /dev/null
+++ b/dom/workers/test/serviceworkers/test_get_serviced.html
@@ -0,0 +1,57 @@
+
+
+
+
+  Bug 982726 - test get_serviced not crashing
+  
+  
+
+
+

+ +

+
+
+
+
+

From 9ab95e5bd70b7ec48dae8c5d9b1242f40773940d Mon Sep 17 00:00:00 2001
From: Catalin Badea 
Date: Fri, 15 Aug 2014 00:43:00 -0700
Subject: [PATCH 29/68] Bug 982726 - Patch 2 - Add postMessage to service
 worker. r=baku

--HG--
extra : rebase_source : 55474dcece43eb53a99829ec0a076f2f1e09ce22
extra : amend_source : 39daf21dd3187542754f82115d75eaca20b838b5
---
 dom/webidl/ServiceWorker.webidl |  6 ++++--
 dom/workers/ServiceWorker.cpp   | 12 ++++++++++++
 dom/workers/ServiceWorker.h     |  5 +++++
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/dom/webidl/ServiceWorker.webidl b/dom/webidl/ServiceWorker.webidl
index ad0b02ea83a..a4fe588b783 100644
--- a/dom/webidl/ServiceWorker.webidl
+++ b/dom/webidl/ServiceWorker.webidl
@@ -8,8 +8,6 @@
  *
  */
 
-// Still unclear what should be subclassed.
-// https://github.com/slightlyoff/ServiceWorker/issues/189
 [Pref="dom.serviceWorkers.enabled",
  // XXXbz I have no idea where this should be exposed.  The spec makes
  // no sense.  But since it's got a pref, let's say window.
@@ -20,6 +18,10 @@ interface ServiceWorker : EventTarget {
 
   readonly attribute ServiceWorkerState state;
   attribute EventHandler onstatechange;
+
+  // FIXME(catalinb): Bug 1053483 - This should be inherited from MessageUtils
+  [Throws]
+  void postMessage(any message, optional sequence transferable);
 };
 
 ServiceWorker implements AbstractWorker;
diff --git a/dom/workers/ServiceWorker.cpp b/dom/workers/ServiceWorker.cpp
index ee2eab96a4a..f9cbf3820ab 100644
--- a/dom/workers/ServiceWorker.cpp
+++ b/dom/workers/ServiceWorker.cpp
@@ -11,6 +11,7 @@
 
 #include "mozilla/dom/Promise.h"
 
+using mozilla::ErrorResult;
 using namespace mozilla::dom;
 USING_WORKERS_NAMESPACE
 
@@ -46,6 +47,17 @@ ServiceWorker::WrapObject(JSContext* aCx)
   return ServiceWorkerBinding::Wrap(aCx, this);
 }
 
+void
+ServiceWorker::PostMessage(JSContext* aCx, JS::Handle aMessage,
+                           const Optional>& aTransferable,
+                           ErrorResult& aRv)
+{
+  WorkerPrivate* workerPrivate = GetWorkerPrivate();
+  MOZ_ASSERT(workerPrivate);
+
+  workerPrivate->PostMessage(aCx, aMessage, aTransferable, aRv);
+}
+
 WorkerPrivate*
 ServiceWorker::GetWorkerPrivate() const
 {
diff --git a/dom/workers/ServiceWorker.h b/dom/workers/ServiceWorker.h
index 0883ad525b8..3c3b7e612ab 100644
--- a/dom/workers/ServiceWorker.h
+++ b/dom/workers/ServiceWorker.h
@@ -52,6 +52,11 @@ public:
     aURL = mURL;
   }
 
+  void
+  PostMessage(JSContext* aCx, JS::Handle aMessage,
+              const Optional>& aTransferable,
+              ErrorResult& aRv);
+
   WorkerPrivate*
   GetWorkerPrivate() const;
 

From 0f93dac9a31c26336037cb2e37850bbbbd45f7e9 Mon Sep 17 00:00:00 2001
From: Catalin Badea 
Date: Sun, 24 Aug 2014 21:17:21 -0700
Subject: [PATCH 30/68] Bug 982726 - Patch 3 - Implement client.postMessage and
 add tests for getServiced(). r=baku

--HG--
extra : rebase_source : 0062dc40cd5cb1248bdce4c70b8abf389eed073d
extra : amend_source : 615bc61390c7e323ddca5a16352387bd4a7c920a
---
 dom/webidl/ServiceWorkerClient.webidl         |   2 +
 dom/workers/ServiceWorkerClient.cpp           | 130 ++++++++++++++++++
 dom/workers/ServiceWorkerClient.h             |   9 ++
 .../get_serviced_worker_advanced.js           |  12 ++
 .../get_serviced_worker_enumerate.js          |   7 +
 .../serviceworkers/message_posting_worker.js  |   9 ++
 dom/workers/test/serviceworkers/mochitest.ini |   7 +
 .../sw_clients/service_worker_controlled.html |  39 ++++++
 .../test_get_serviced_advanced.html           |  80 +++++++++++
 .../test_get_serviced_enumerate.html          |  82 +++++++++++
 .../serviceworkers/test_post_message.html     |  62 +++++++++
 11 files changed, 439 insertions(+)
 create mode 100644 dom/workers/test/serviceworkers/get_serviced_worker_advanced.js
 create mode 100644 dom/workers/test/serviceworkers/get_serviced_worker_enumerate.js
 create mode 100644 dom/workers/test/serviceworkers/message_posting_worker.js
 create mode 100644 dom/workers/test/serviceworkers/sw_clients/service_worker_controlled.html
 create mode 100644 dom/workers/test/serviceworkers/test_get_serviced_advanced.html
 create mode 100644 dom/workers/test/serviceworkers/test_get_serviced_enumerate.html
 create mode 100644 dom/workers/test/serviceworkers/test_post_message.html

diff --git a/dom/webidl/ServiceWorkerClient.webidl b/dom/webidl/ServiceWorkerClient.webidl
index 2473fb572fe..3543b4b49f8 100644
--- a/dom/webidl/ServiceWorkerClient.webidl
+++ b/dom/webidl/ServiceWorkerClient.webidl
@@ -11,4 +11,6 @@
 [Exposed=ServiceWorker]
 interface ServiceWorkerClient {
   readonly attribute unsigned long id;
+  [Throws]
+  void postMessage(any message, optional sequence transfer);
 };
diff --git a/dom/workers/ServiceWorkerClient.cpp b/dom/workers/ServiceWorkerClient.cpp
index 2a2e1c28b3e..f183b593611 100644
--- a/dom/workers/ServiceWorkerClient.cpp
+++ b/dom/workers/ServiceWorkerClient.cpp
@@ -6,8 +6,13 @@
 
 #include "ServiceWorkerClient.h"
 
+#include "mozilla/dom/MessageEvent.h"
+#include "nsGlobalWindow.h"
+#include "WorkerPrivate.h"
+
 #include "mozilla/dom/ServiceWorkerClientBinding.h"
 
+using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::dom::workers;
 
@@ -27,3 +32,128 @@ ServiceWorkerClient::WrapObject(JSContext* aCx)
   return ServiceWorkerClientBinding::Wrap(aCx, this);
 }
 
+namespace {
+
+class ServiceWorkerClientPostMessageRunnable MOZ_FINAL : public nsRunnable
+{
+  uint64_t mId;
+  JSAutoStructuredCloneBuffer mBuffer;
+  nsTArray> mClonedObjects;
+
+public:
+  ServiceWorkerClientPostMessageRunnable(uint64_t aId,
+                              JSAutoStructuredCloneBuffer&& aData,
+                              nsTArray>& aClonedObjects)
+    : mId(aId),
+      mBuffer(Move(aData))
+  {
+    mClonedObjects.SwapElements(aClonedObjects);
+  }
+
+  NS_IMETHOD
+  Run()
+  {
+    AssertIsOnMainThread();
+    nsGlobalWindow* window = nsGlobalWindow::GetInnerWindowWithId(mId);
+    if (!window) {
+      return NS_ERROR_FAILURE;
+    }
+
+    AutoJSAPI jsapi;
+    jsapi.Init(window);
+    JSContext* cx = jsapi.cx();
+
+    return DispatchDOMEvent(cx, window);
+  }
+
+private:
+  NS_IMETHOD
+  DispatchDOMEvent(JSContext* aCx, nsGlobalWindow* aTargetWindow)
+  {
+    AssertIsOnMainThread();
+
+    // Release reference to objects that were AddRef'd for
+    // cloning into worker when array goes out of scope.
+    nsTArray> clonedObjects;
+    clonedObjects.SwapElements(mClonedObjects);
+
+    JS::Rooted messageData(aCx);
+    if (!mBuffer.read(aCx, &messageData,
+                      WorkerStructuredCloneCallbacks(true))) {
+      xpc::Throw(aCx, NS_ERROR_DOM_DATA_CLONE_ERR);
+      return NS_ERROR_FAILURE;
+    }
+
+    nsCOMPtr event = new MessageEvent(aTargetWindow,
+                                                          nullptr, nullptr);
+    nsresult rv =
+      event->InitMessageEvent(NS_LITERAL_STRING("message"),
+                              false /* non-bubbling */,
+                              false /* not cancelable */,
+                              messageData,
+                              EmptyString(),
+                              EmptyString(),
+                              nullptr);
+    if (NS_FAILED(rv)) {
+      xpc::Throw(aCx, rv);
+      return NS_ERROR_FAILURE;
+    }
+
+    event->SetTrusted(true);
+    bool status = false;
+    aTargetWindow->DispatchEvent(event, &status);
+
+    if (!status) {
+      return NS_ERROR_FAILURE;
+    }
+
+    return NS_OK;
+  }
+};
+
+} // anonymous namespace
+
+void
+ServiceWorkerClient::PostMessage(JSContext* aCx, JS::Handle aMessage,
+                                 const Optional>& aTransferable,
+                                 ErrorResult& aRv)
+{
+  WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
+  MOZ_ASSERT(workerPrivate);
+  workerPrivate->AssertIsOnWorkerThread();
+
+  JS::Rooted transferable(aCx, JS::UndefinedValue());
+  if (aTransferable.WasPassed()) {
+    const Sequence& realTransferable = aTransferable.Value();
+
+    JS::HandleValueArray elements =
+      JS::HandleValueArray::fromMarkedLocation(realTransferable.Length(),
+                                               realTransferable.Elements());
+
+    JSObject* array = JS_NewArrayObject(aCx, elements);
+    if (!array) {
+      aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
+      return;
+    }
+
+    transferable.setObject(*array);
+  }
+
+  JSStructuredCloneCallbacks* callbacks = WorkerStructuredCloneCallbacks(false);
+
+  nsTArray> clonedObjects;
+
+  JSAutoStructuredCloneBuffer buffer;
+  if (!buffer.write(aCx, aMessage, transferable, callbacks, &clonedObjects)) {
+    aRv.Throw(NS_ERROR_DOM_DATA_CLONE_ERR);
+    return;
+  }
+
+  nsRefPtr runnable =
+    new ServiceWorkerClientPostMessageRunnable(mId, Move(buffer), clonedObjects);
+  nsresult rv = NS_DispatchToMainThread(runnable);
+  if (NS_FAILED(rv)) {
+    aRv.Throw(NS_ERROR_FAILURE);
+  }
+}
+
diff --git a/dom/workers/ServiceWorkerClient.h b/dom/workers/ServiceWorkerClient.h
index 7ad4c4aff80..438f0ce7a11 100644
--- a/dom/workers/ServiceWorkerClient.h
+++ b/dom/workers/ServiceWorkerClient.h
@@ -11,9 +11,14 @@
 #include "nsWrapperCache.h"
 
 namespace mozilla {
+
+class ErrorResult;
+
 namespace dom {
 
 class Promise;
+template class Optional;
+template class Sequence;
 
 namespace workers {
 
@@ -36,6 +41,10 @@ public:
     return mId;
   }
 
+  void PostMessage(JSContext* aCx, JS::Handle aMessage,
+                   const Optional>& aTransferable,
+                   ErrorResult& aRv);
+
   nsISupports* GetParentObject() const
   {
     return mOwner;
diff --git a/dom/workers/test/serviceworkers/get_serviced_worker_advanced.js b/dom/workers/test/serviceworkers/get_serviced_worker_advanced.js
new file mode 100644
index 00000000000..28e4e4e3112
--- /dev/null
+++ b/dom/workers/test/serviceworkers/get_serviced_worker_advanced.js
@@ -0,0 +1,12 @@
+onmessage = function(e) {
+  if (!e.data) {
+    dump("ERROR: message has no data.\n");
+  }
+
+  self.clients.getServiced().then(function(res) {
+    if (res.length === 0) {
+      dump("ERROR: no client is currently being controlled.\n");
+    }
+    res[res.length - 1].postMessage(res.length);
+  });
+};
diff --git a/dom/workers/test/serviceworkers/get_serviced_worker_enumerate.js b/dom/workers/test/serviceworkers/get_serviced_worker_enumerate.js
new file mode 100644
index 00000000000..42be6681abe
--- /dev/null
+++ b/dom/workers/test/serviceworkers/get_serviced_worker_enumerate.js
@@ -0,0 +1,7 @@
+onmessage = function() {
+  self.clients.getServiced().then(function(result) {
+    for (i = 0; i < result.length; i++) {
+      result[i].postMessage(i);
+    }
+  });
+};
diff --git a/dom/workers/test/serviceworkers/message_posting_worker.js b/dom/workers/test/serviceworkers/message_posting_worker.js
new file mode 100644
index 00000000000..f4b0b09979f
--- /dev/null
+++ b/dom/workers/test/serviceworkers/message_posting_worker.js
@@ -0,0 +1,9 @@
+onmessage = function(e) {
+  self.clients.getServiced().then(function(res) {
+    if (!res.length) {
+      dump("ERROR: no clients are currently controlled.\n");
+    }
+    res[0].postMessage(e.data);
+  });
+};
+
diff --git a/dom/workers/test/serviceworkers/mochitest.ini b/dom/workers/test/serviceworkers/mochitest.ini
index c8e7660cc5b..f141a3bcd06 100644
--- a/dom/workers/test/serviceworkers/mochitest.ini
+++ b/dom/workers/test/serviceworkers/mochitest.ini
@@ -12,11 +12,18 @@ support-files =
   unregister/index.html
   sw_clients/simple.html
   get_serviced_worker.js
+  get_serviced_worker_advanced.js
+  message_posting_worker.js
+  sw_clients/service_worker_controlled.html
+  get_serviced_worker_enumerate.js
 
 [test_get_serviced.html]
+[test_get_serviced_advanced.html]
+[test_get_serviced_enumerate.html]
 [test_installation_simple.html]
 [test_install_event.html]
 [test_navigator.html]
+[test_post_message.html]
 [test_scopes.html]
 [test_controller.html]
 [test_unregister.html]
diff --git a/dom/workers/test/serviceworkers/sw_clients/service_worker_controlled.html b/dom/workers/test/serviceworkers/sw_clients/service_worker_controlled.html
new file mode 100644
index 00000000000..a67679ee7d2
--- /dev/null
+++ b/dom/workers/test/serviceworkers/sw_clients/service_worker_controlled.html
@@ -0,0 +1,39 @@
+
+
+
+
+  controlled page
+  
+
+
+
+
+
+
+
diff --git a/dom/workers/test/serviceworkers/test_get_serviced_advanced.html b/dom/workers/test/serviceworkers/test_get_serviced_advanced.html
new file mode 100644
index 00000000000..539a3f1f10e
--- /dev/null
+++ b/dom/workers/test/serviceworkers/test_get_serviced_advanced.html
@@ -0,0 +1,80 @@
+
+
+
+
+  Bug 982726 - test get_serviced 
+  
+  
+
+
+

+ +

+
+
+
+
+
diff --git a/dom/workers/test/serviceworkers/test_get_serviced_enumerate.html b/dom/workers/test/serviceworkers/test_get_serviced_enumerate.html
new file mode 100644
index 00000000000..7ba0d190f8e
--- /dev/null
+++ b/dom/workers/test/serviceworkers/test_get_serviced_enumerate.html
@@ -0,0 +1,82 @@
+
+
+
+
+  Bug 982726 - test get_serviced 
+  
+  
+
+
+

+ +

+
+
+
+
+
diff --git a/dom/workers/test/serviceworkers/test_post_message.html b/dom/workers/test/serviceworkers/test_post_message.html
new file mode 100644
index 00000000000..e9c8c0f916a
--- /dev/null
+++ b/dom/workers/test/serviceworkers/test_post_message.html
@@ -0,0 +1,62 @@
+
+
+
+
+  Bug 982726 - Test service worker post message 
+  
+  
+
+
+

+ +

+
+
+
+
+

From c77f513ba7e646631c08925f257b2a0ded2c0572 Mon Sep 17 00:00:00 2001
From: Catalin Badea 
Date: Fri, 15 Aug 2014 00:52:00 -0700
Subject: [PATCH 31/68] Bug 982726 - Patch 4 - Extensive testing of
 postMessage. r=baku

--HG--
extra : rebase_source : c2a5b3e61cd314c995cc1935aa928247301cb9c5
extra : amend_source : a970a4e351b2b7064fbccbed6b74dedec609f878
---
 dom/workers/ServiceWorkerClient.cpp           |  4 +-
 dom/workers/test/serviceworkers/mochitest.ini |  1 +
 .../test_post_message_advanced.html           | 91 +++++++++++++++++++
 3 files changed, 94 insertions(+), 2 deletions(-)
 create mode 100644 dom/workers/test/serviceworkers/test_post_message_advanced.html

diff --git a/dom/workers/ServiceWorkerClient.cpp b/dom/workers/ServiceWorkerClient.cpp
index f183b593611..ef5e0ad5722 100644
--- a/dom/workers/ServiceWorkerClient.cpp
+++ b/dom/workers/ServiceWorkerClient.cpp
@@ -42,8 +42,8 @@ class ServiceWorkerClientPostMessageRunnable MOZ_FINAL : public nsRunnable
 
 public:
   ServiceWorkerClientPostMessageRunnable(uint64_t aId,
-                              JSAutoStructuredCloneBuffer&& aData,
-                              nsTArray>& aClonedObjects)
+                                         JSAutoStructuredCloneBuffer&& aData,
+                                         nsTArray>& aClonedObjects)
     : mId(aId),
       mBuffer(Move(aData))
   {
diff --git a/dom/workers/test/serviceworkers/mochitest.ini b/dom/workers/test/serviceworkers/mochitest.ini
index f141a3bcd06..36cf0912420 100644
--- a/dom/workers/test/serviceworkers/mochitest.ini
+++ b/dom/workers/test/serviceworkers/mochitest.ini
@@ -24,6 +24,7 @@ support-files =
 [test_install_event.html]
 [test_navigator.html]
 [test_post_message.html]
+[test_post_message_advanced.html]
 [test_scopes.html]
 [test_controller.html]
 [test_unregister.html]
diff --git a/dom/workers/test/serviceworkers/test_post_message_advanced.html b/dom/workers/test/serviceworkers/test_post_message_advanced.html
new file mode 100644
index 00000000000..b48d991ae9c
--- /dev/null
+++ b/dom/workers/test/serviceworkers/test_post_message_advanced.html
@@ -0,0 +1,91 @@
+
+
+
+
+  Bug 982726 - Test service worker post message advanced 
+  
+  
+
+
+

+ +

+
+
+
+
+

From ad714344d2b129bbddf94b1047078e580b110955 Mon Sep 17 00:00:00 2001
From: Daniel Holbert 
Date: Wed, 3 Sep 2014 17:22:37 -0700
Subject: [PATCH 32/68] Backing out 8dc381124409 (bug 1056459) for apparently
 causing crashes in B2G-on-OS-X "Gip" test runs.

---
 accessible/base/SelectionManager.cpp          |  3 +-
 accessible/tests/mochitest/events.js          | 11 +--
 accessible/tests/mochitest/events/a11y.ini    |  1 -
 accessible/tests/mochitest/events/scroll.html | 58 ------------
 .../mochitest/events/test_scroll_caret.xul    | 91 -------------------
 5 files changed, 4 insertions(+), 160 deletions(-)
 delete mode 100644 accessible/tests/mochitest/events/test_scroll_caret.xul

diff --git a/accessible/base/SelectionManager.cpp b/accessible/base/SelectionManager.cpp
index 32a721f765d..d846e356bc8 100644
--- a/accessible/base/SelectionManager.cpp
+++ b/accessible/base/SelectionManager.cpp
@@ -179,7 +179,8 @@ SelectionManager::NotifySelectionChanged(nsIDOMDocument* aDOMDocument,
     logging::SelChange(aSelection, document, aReason);
 #endif
 
-  if (document) {
+  // Don't fire events until document is loaded.
+  if (document && document->IsContentLoaded()) {
     // Selection manager has longer lifetime than any document accessible,
     // so that we are guaranteed that the notification is processed before
     // the selection manager is destroyed.
diff --git a/accessible/tests/mochitest/events.js b/accessible/tests/mochitest/events.js
index 06935d48a4d..7782ceffb30 100644
--- a/accessible/tests/mochitest/events.js
+++ b/accessible/tests/mochitest/events.js
@@ -1743,11 +1743,10 @@ function textChangeChecker(aID, aStart, aEnd, aTextOrFunc, aIsInserted, aFromUse
 /**
  * Caret move events checker.
  */
-function caretMoveChecker(aCaretOffset, aTargetOrFunc, aTargetFuncArg,
-                          aIsAsync)
+function caretMoveChecker(aCaretOffset, aTargetOrFunc, aTargetFuncArg)
 {
   this.__proto__ = new invokerChecker(EVENT_TEXT_CARET_MOVED,
-                                      aTargetOrFunc, aTargetFuncArg, aIsAsync);
+                                      aTargetOrFunc, aTargetFuncArg);
 
   this.check = function caretMoveChecker_check(aEvent)
   {
@@ -1757,12 +1756,6 @@ function caretMoveChecker(aCaretOffset, aTargetOrFunc, aTargetFuncArg,
   }
 }
 
-function asyncCaretMoveChecker(aCaretOffset, aTargetOrFunc, aTargetFuncArg)
-{
-  this.__proto__ = new caretMoveChecker(aCaretOffset, aTargetOrFunc,
-                                        aTargetFuncArg, true);
-}
-
 /**
  * Text selection change checker.
  */
diff --git a/accessible/tests/mochitest/events/a11y.ini b/accessible/tests/mochitest/events/a11y.ini
index 6b549c854ab..50dd2e8060d 100644
--- a/accessible/tests/mochitest/events/a11y.ini
+++ b/accessible/tests/mochitest/events/a11y.ini
@@ -46,7 +46,6 @@ skip-if = os == 'win' || os == 'linux'
 [test_namechange.xul]
 [test_namechange.html]
 [test_scroll.xul]
-[test_scroll_caret.xul]
 [test_selection.html]
 skip-if = buildapp == 'mulet'
 [test_selection.xul]
diff --git a/accessible/tests/mochitest/events/scroll.html b/accessible/tests/mochitest/events/scroll.html
index 562e0a38259..df71fd45946 100644
--- a/accessible/tests/mochitest/events/scroll.html
+++ b/accessible/tests/mochitest/events/scroll.html
@@ -119,63 +119,5 @@
     text text text text text text text text text text text text text text 
text text text text text text text text text text text text text text

- -

heading 1

-

- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
- text text text text text text text text text text text text text text
-

diff --git a/accessible/tests/mochitest/events/test_scroll_caret.xul b/accessible/tests/mochitest/events/test_scroll_caret.xul deleted file mode 100644 index 57e27747f13..00000000000 --- a/accessible/tests/mochitest/events/test_scroll_caret.xul +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - - - - - - - - Mozilla Bug 1056459 - - -

- -
-      
- - - -
-
From b818adb5c230882a7dfb3fc4109a70789357bb3d Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 3 Sep 2014 09:24:38 -0700 Subject: [PATCH 33/68] Bug 1050601 - Remove fix-linux-stack.pl. r=ted. --HG-- extra : rebase_source : f344aa5db9e16575835a7de3df34c311635c128b --- build/Makefile.in | 2 +- build/automation.py.in | 20 +- memory/replace/dmd/DMD.cpp | 2 +- memory/replace/dmd/check_test_output.py | 2 +- testing/mochitest/Makefile.in | 2 +- testing/mochitest/runtests.py | 49 ++--- tools/rb/fix-linux-stack.pl | 259 ------------------------ tools/rb/fix_linux_stack.py | 3 +- xpcom/base/CodeAddressService.h | 4 +- 9 files changed, 26 insertions(+), 317 deletions(-) delete mode 100755 tools/rb/fix-linux-stack.pl diff --git a/build/Makefile.in b/build/Makefile.in index 40c3514d2d2..5785278f507 100644 --- a/build/Makefile.in +++ b/build/Makefile.in @@ -108,7 +108,7 @@ libs:: $(topsrcdir)/tools/rb/fix_macosx_stack.py endif ifeq ($(OS_ARCH),Linux) -libs:: $(topsrcdir)/tools/rb/fix-linux-stack.pl +libs:: $(topsrcdir)/tools/rb/fix_linux_stack.py $(INSTALL) $< $(DIST)/bin endif diff --git a/build/automation.py.in b/build/automation.py.in index e25c9a5de64..d3cfa972632 100644 --- a/build/automation.py.in +++ b/build/automation.py.in @@ -68,7 +68,6 @@ _IS_CYGWIN = False #endif #expand _IS_CAMINO = __IS_CAMINO__ != 0 #expand _BIN_SUFFIX = __BIN_SUFFIX__ -#expand _PERL = __PERL__ #expand _DEFAULT_APP = "./" + __BROWSER_PATH__ #expand _CERTS_SRC_DIR = __CERTS_SRC_DIR__ @@ -143,7 +142,6 @@ class Automation(object): IS_CYGWIN = _IS_CYGWIN IS_CAMINO = _IS_CAMINO BIN_SUFFIX = _BIN_SUFFIX - PERL = _PERL UNIXISH = not IS_WIN32 and not IS_MAC @@ -671,7 +669,6 @@ class Automation(object): def waitForFinish(self, proc, utilityPath, timeout, maxTime, startTime, debuggerInfo, symbolsPath): """ Look for timeout or crashes and return the status after the process terminates """ - stackFixerProcess = None stackFixerFunction = None didTimeout = False hitMaxTime = False @@ -694,12 +691,12 @@ class Automation(object): stackFixerFunction = lambda line: stackFixerModule.fixSymbols(line) del sys.path[0] elif self.IS_DEBUG_BUILD and self.IS_LINUX: - # Run logsource through fix-linux-stack.pl (uses addr2line) + # Run each line through a function in fix_linux_stack.py (uses addr2line) # This method is preferred for developer machines, so we don't have to run "make buildsymbols". - stackFixerProcess = self.Process([self.PERL, os.path.join(utilityPath, "fix-linux-stack.pl")], - stdin=logsource, - stdout=subprocess.PIPE) - logsource = stackFixerProcess.stdout + sys.path.insert(0, utilityPath) + import fix_linux_stack as stackFixerModule + stackFixerFunction = lambda line: stackFixerModule.fixSymbols(line) + del sys.path[0] # With metro browser runs this script launches the metro test harness which launches the browser. # The metro test harness hands back the real browser process id via log output which we need to @@ -725,7 +722,7 @@ class Automation(object): self.log.info("INFO | automation.py | metro browser sub process id detected: %s", browserProcessId) if not hitMaxTime and maxTime and datetime.now() - startTime > timedelta(seconds = maxTime): - # Kill the application, but continue reading from stack fixer so as not to deadlock on stackFixerProcess.wait(). + # Kill the application. hitMaxTime = True self.log.info("TEST-UNEXPECTED-FAIL | %s | application ran for longer than allowed maximum time of %d seconds", self.lastTestSeen, int(maxTime)) self.killAndGetStack(proc.pid, utilityPath, debuggerInfo) @@ -743,11 +740,6 @@ class Automation(object): self.lastTestSeen = "Main app process exited normally" if status != 0 and not didTimeout and not hitMaxTime: self.log.info("TEST-UNEXPECTED-FAIL | %s | Exited with code %d during test run", self.lastTestSeen, status) - if stackFixerProcess is not None: - fixerStatus = stackFixerProcess.wait() - automationutils.printstatus(status, "stackFixerProcess") - if fixerStatus != 0 and not didTimeout and not hitMaxTime: - self.log.info("TEST-UNEXPECTED-FAIL | automation.py | Stack fixer process exited with code %d during test run", fixerStatus) return status def buildCommandLine(self, app, debuggerInfo, profileDir, testURL, extraArgs): diff --git a/memory/replace/dmd/DMD.cpp b/memory/replace/dmd/DMD.cpp index 8557964840b..6135bc74e0e 100644 --- a/memory/replace/dmd/DMD.cpp +++ b/memory/replace/dmd/DMD.cpp @@ -1745,7 +1745,7 @@ PrintSortedRecords(const Writer& aWriter, CodeAddressService* aLocService, StatusMsg(" printing %s heap block record array...\n", astr); size_t cumulativeUsableSize = 0; - // Limit the number of records printed, because fix-linux-stack.pl is too + // Limit the number of records printed, because fix_linux_stack.py is too // damn slow. Note that we don't break out of this loop because we need to // keep adding to |cumulativeUsableSize|. uint32_t numRecords = recordArray.length(); diff --git a/memory/replace/dmd/check_test_output.py b/memory/replace/dmd/check_test_output.py index d577f6b11c9..190880d2e36 100755 --- a/memory/replace/dmd/check_test_output.py +++ b/memory/replace/dmd/check_test_output.py @@ -50,7 +50,7 @@ def main(): sysname = platform.system() if sysname == "Linux": - fix = srcdir + os.sep + "tools/rb/fix-linux-stack.pl" + fix = srcdir + os.sep + "tools/rb/fix_linux_stack.py" elif sysname == "Darwin": fix = srcdir + os.sep + "tools/rb/fix_macosx_stack.py" else: diff --git a/testing/mochitest/Makefile.in b/testing/mochitest/Makefile.in index a8b6d3dacac..4adbd7d647e 100644 --- a/testing/mochitest/Makefile.in +++ b/testing/mochitest/Makefile.in @@ -131,7 +131,7 @@ TEST_HARNESS_BINS += fix_macosx_stack.py endif ifeq ($(OS_ARCH),Linux) -TEST_HARNESS_BINS += fix-linux-stack.pl +TEST_HARNESS_BINS += fix_linux_stack.py endif ifeq (gtk2_1,$(MOZ_WIDGET_TOOLKIT)_$(MOZ_X11)) diff --git a/testing/mochitest/runtests.py b/testing/mochitest/runtests.py index 0f7e83e5a1c..d68bd1aff27 100644 --- a/testing/mochitest/runtests.py +++ b/testing/mochitest/runtests.py @@ -1480,13 +1480,8 @@ class Mochitest(MochitestUtilsMixin): printstatus(status, "Main app process") runner.process_handler = None - if timeout is None: - didTimeout = False - else: - didTimeout = proc.didTimeout - # finalize output handler - outputHandler.finish(didTimeout) + outputHandler.finish() # record post-test information if status: @@ -1853,16 +1848,12 @@ class Mochitest(MochitestUtilsMixin): self.lsanLeaks = lsanLeaks self.bisectChunk = bisectChunk - # perl binary to use - self.perl = which('perl') - # With metro browser runs this script launches the metro test harness which launches the browser. # The metro test harness hands back the real browser process id via log output which we need to # pick up on and parse out. This variable tracks the real browser process id if we find it. self.browserProcessId = None - # stack fixer function and/or process - self.stackFixerFunction, self.stackFixerProcess = self.stackFixer() + self.stackFixerFunction = self.stackFixer() def processOutputLine(self, line): """per line handler of output for mozprocess""" @@ -1897,14 +1888,13 @@ class Mochitest(MochitestUtilsMixin): def stackFixer(self): """ - return 2-tuple, (stackFixerFunction, StackFixerProcess), - if any, to use on the output lines + return stackFixerFunction, if any, to use on the output lines """ if not mozinfo.info.get('debug'): - return None, None + return None - stackFixerFunction = stackFixerProcess = None + stackFixerFunction = None def import_stackFixerModule(module_name): sys.path.insert(0, self.utilityPath) @@ -1913,35 +1903,20 @@ class Mochitest(MochitestUtilsMixin): return module if self.symbolsPath and os.path.exists(self.symbolsPath): - # Run each line through a function in fix_stack_using_bpsyms.py (uses breakpad symbol files) + # Run each line through a function in fix_stack_using_bpsyms.py (uses breakpad symbol files). # This method is preferred for Tinderbox builds, since native symbols may have been stripped. stackFixerModule = import_stackFixerModule('fix_stack_using_bpsyms') stackFixerFunction = lambda line: stackFixerModule.fixSymbols(line, self.symbolsPath) - elif mozinfo.isLinux and self.perl: - # Run logsource through fix-linux-stack.pl (uses addr2line) + elif mozinfo.isLinux: + # Run each line through fix_linux_stack.py (uses addr2line). # This method is preferred for developer machines, so we don't have to run "make buildsymbols". - stackFixerCommand = [self.perl, os.path.join(self.utilityPath, "fix-linux-stack.pl")] - stackFixerProcess = subprocess.Popen(stackFixerCommand, stdin=subprocess.PIPE, - stdout=subprocess.PIPE) - def fixFunc(lines): - out = [] - for line in lines.split('\n'): - stackFixerProcess.stdin.write(line + '\n') - out.append(stackFixerProcess.stdout.readline().rstrip()) - return '\n'.join(out) + stackFixerModule = import_stackFixerModule('fix_linux_stack') + stackFixerFunction = lambda line: stackFixerModule.fixSymbols(line) - stackFixerFunction = fixFunc - - return (stackFixerFunction, stackFixerProcess) - - def finish(self, didTimeout): - if self.stackFixerProcess: - self.stackFixerProcess.communicate() - status = self.stackFixerProcess.returncode - if status and not didTimeout: - self.harness.log.info("TEST-UNEXPECTED-FAIL | runtests.py | Stack fixer process exited with code %d during test run" % status) + return stackFixerFunction + def finish(self): if self.shutdownLeaks: self.shutdownLeaks.process() diff --git a/tools/rb/fix-linux-stack.pl b/tools/rb/fix-linux-stack.pl deleted file mode 100755 index 3a171e37b37..00000000000 --- a/tools/rb/fix-linux-stack.pl +++ /dev/null @@ -1,259 +0,0 @@ -#!/usr/bin/perl -# vim:sw=4:ts=4:et: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -# $Id: fix-linux-stack.pl,v 1.16 2008/05/05 21:51:11 dbaron%dbaron.org Exp $ -# -# This script uses addr2line (part of binutils) to process the output of -# nsTraceRefcnt's Linux stack walking code. This is useful for two -# things: -# (1) Getting line number information out of -# |nsTraceRefcnt::WalkTheStack|'s output in debug builds. -# (2) Getting function names out of |nsTraceRefcnt::WalkTheStack|'s -# output on optimized builds (where it mostly prints UNKNOWN -# because only a handful of symbols are exported from component -# libraries). -# -# Use the script by piping output containing stacks (such as raw stacks -# or make-tree.pl balance trees) through this script. - -use strict; -use IPC::Open2; -use File::Basename; - -# XXX Hard-coded to gdb defaults (works on Fedora). -my $global_debug_dir = '/usr/lib/debug'; - -# We record several things for each file encountered. -# -# - {pipe_read}, {pipe_write}: these constitute a bidirectional pipe to an -# addr2line process that gives symbol information for a file. -# -# - {cache}: this table holds the results of lookups that we've done -# previously for (pre-adjustment) addresses, which lets us avoid redundant -# calls to addr2line. -# -# - {address_adjustment}: addr2line wants offsets relative to the base address -# for shared libraries, but it wants addresses including the base address -# offset for executables. This holds the appropriate address adjustment to -# add to an offset within file. See bug 230336. -# -my %file_infos; - -sub set_address_adjustment($$) { - my ($file, $file_info) = @_; - - # find out if it's an executable (as opposed to a shared library) - my $elftype; - open(ELFHDR, '-|', 'readelf', '-h', $file); - while () { - if (/^\s*Type:\s+(\S+)/) { - $elftype = $1; - last; - } - } - close(ELFHDR); - - # If it's an executable, make adjustment the base address. - # Otherwise, leave it zero. - my $adjustment = 0; - if ($elftype eq 'EXEC') { - open(ELFSECS, '-|', 'readelf', '-S', $file); - while () { - if (/^\s*\[\s*\d+\]\s+\.text\s+\w+\s+(\w+)\s+(\w+)\s+/) { - # Subtract the .text section's offset within the - # file from its base address. - $adjustment = hex($1) - hex($2); - last; - } - } - close(ELFSECS); - } - - $file_info->{address_adjustment} = $adjustment; -} - -# Files sometimes contain a link to a separate object file that contains -# the debug sections of the binary, removed so that a smaller file can -# be shipped, but kept separately so that it can be obtained by those -# who want it. -# See http://sources.redhat.com/gdb/current/onlinedocs/gdb_16.html#SEC154 -# for documentation of debugging information in separate files. -# On Fedora distributions, these files can be obtained by installing -# *-debuginfo RPM packages. -sub separate_debug_file_for($) { - my ($file) = @_; - # We can read the .gnu_debuglink section using either of: - # objdump -s --section=.gnu_debuglink $file - # readelf -x .gnu_debuglink $file - # Since readelf prints things backwards on little-endian platforms - # for some versions only (backwards on Fedora Core 6, forwards on - # Fedora 7), use objdump. - - # See if there's a .gnu_debuglink section - my $have_debuglink = 0; - open(ELFSECS, '-|', 'readelf', '-S', $file); - while () { - if (/^\s*\[\s*\d+\]\s+\.gnu_debuglink\s+\w+\s+(\w+)\s+(\w+)\s+/) { - $have_debuglink = 1; - last; - } - } - close(ELFSECS); - return '' unless ($have_debuglink); - - # Determine the endianness of the shared library. - my $endian = ''; - open(ELFHDR, '-|', 'readelf', '-h', $file); - while () { - if (/^\s*Data:\s+.*(little|big) endian.*$/) { - $endian = $1; - last; - } - } - close(ELFHDR); - if ($endian ne 'little' && $endian ne 'big') { - print STDERR "Warning: could not determine endianness of $file.\n"; - return ''; - } - - - # Read the debuglink section as an array of words, in hexidecimal. - open(DEBUGLINK, '-|', 'objdump', '-s', '--section=.gnu_debuglink', $file); - my @words; - while () { - if ($_ =~ /^ [0-9a-f]* ([0-9a-f ]{8}) ([0-9a-f ]{8}) ([0-9a-f ]{8}) ([0-9a-f ]{8}).*/) { - push @words, $1, $2, $3, $4; - } - } - close(DEBUGLINK); - - while (@words[$#words] eq ' ') { - pop @words; - } - - if ($#words < 1) { - print STDERR "Warning: .gnu_debuglink section in $file too short.\n"; - return ''; - } - - my @chars; - while ($#words >= 0) { - my $w = shift @words; - if ($w =~ /^([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/) { - push @chars, $1, $2, $3, $4; - } else { - print STDERR "Warning: malformed objdump output for $file.\n"; - return ''; - } - } - - my @hash_bytes = map(hex, @chars[$#chars - 3 .. $#chars]); - $#chars -= 4; - - my $hash; - if ($endian eq 'little') { - $hash = ($hash_bytes[3] << 24) | ($hash_bytes[2] << 16) | ($hash_bytes[1] << 8) | $hash_bytes[0]; - } else { - $hash = ($hash_bytes[0] << 24) | ($hash_bytes[1] << 16) | ($hash_bytes[2] << 8) | $hash_bytes[3]; - } - - # The string ends with a null-terminator and then 0 to three bytes - # of padding to fill the current 32-bit unit. (This padding is - # usually null bytes, but I've seen null-null-H, on Ubuntu x86_64.) - my $terminator = 1; - while ($chars[$terminator] ne '00') { - if ($terminator == $#chars) { - print STDERR "Warning: missing null terminator in " . - ".gnu_debuglink section of $file.\n"; - return ''; - } - ++$terminator; - } - if ($#chars - $terminator > 3) { - print STDERR "Warning: Excess padding in .gnu_debuglink section " . - "of $file.\n"; - return ''; - } - $#chars = $terminator - 1; - - my $basename = join('', map { chr(hex($_)) } @chars); - - # Now $basename and $hash represent the information in the - # .gnu_debuglink section. - #printf STDERR "%x: %s\n", $hash, $basename; - - my @possible_results = ( - dirname($file) . $basename, - dirname($file) . '.debug/' . $basename, - $global_debug_dir . dirname($file) . '/' . $basename - ); - foreach my $result (@possible_results) { - if (-f $result) { - # XXX We should check the hash. - return $result; - } - } - - return ''; -} - -sub get_file_info($) { - my ($file) = @_; - my $file_info = $file_infos{$file}; - unless (defined $file_info) { - my $debug_file = separate_debug_file_for($file); - $debug_file = $file if ($debug_file eq ''); - - my $pid = open2($file_info->{pipe_read}, $file_info->{pipe_write}, - '/usr/bin/addr2line', '-C', '-f', '-e', $debug_file); - - set_address_adjustment($file, $file_info); - - $file_infos{$file} = $file_info; - } - return $file_info; -} - -# Ignore SIGPIPE as a workaround for addr2line crashes in some situations. -$SIG{PIPE} = 'IGNORE'; - -select STDOUT; $| = 1; # make STDOUT unbuffered -while (<>) { - my $line = $_; - if ($line =~ /^([ \|0-9-]*)(.*) ?\[([^ ]*) \+(0x[0-9A-F]{1,8})\](.*)$/) { - my $before = $1; # allow preservation of balance trees - my $badsymbol = $2; - my $file = $3; - my $address = hex($4); - my $after = $5; # allow preservation of counts - - if (-f $file) { - my $file_info = get_file_info($file); - my $result = $file_info->{cache}->{$address}; - if (not defined $result) { - my $address2 = $address + $file_info->{address_adjustment}; - my $out = $file_info->{pipe_write}; - my $in = $file_info->{pipe_read}; - printf {$out} "0x%X\n", $address2; - chomp(my $symbol = <$in>); - chomp(my $fileandline = <$in>); - if (!$symbol || $symbol eq '??') { $symbol = $badsymbol; } - if (!$fileandline || $fileandline eq '??:0') { - $fileandline = $file; - } - $result = "$symbol ($fileandline)"; - $file_info->{cache}->{$address} = $result; - } - print "$before$result$after\n"; - } else { - print STDERR "Warning: File \"$file\" does not exist.\n"; - print $line; - } - - } else { - print $line; - } -} diff --git a/tools/rb/fix_linux_stack.py b/tools/rb/fix_linux_stack.py index b49f9990787..2380c05fabc 100755 --- a/tools/rb/fix_linux_stack.py +++ b/tools/rb/fix_linux_stack.py @@ -318,7 +318,8 @@ def fixSymbols(line): if fileline == "??:0" or fileline == "??:?": fileline = file - return "%s%s (%s)%s\n" % (before, name, fileline, after) + nl = '\n' if line[-1] == '\n' else '' + return "%s%s (%s)%s%s" % (before, name, fileline, after, nl) else: sys.stderr.write("Warning: File \"" + file + "\" does not exist.\n") return line diff --git a/xpcom/base/CodeAddressService.h b/xpcom/base/CodeAddressService.h index a5edebb0c1e..40cc040fdb9 100644 --- a/xpcom/base/CodeAddressService.h +++ b/xpcom/base/CodeAddressService.h @@ -167,7 +167,7 @@ public: uintptr_t entryPc = (uintptr_t)(entry.mPc); // Sometimes we get nothing useful. Just print "???" for the entire entry - // so that fix-linux-stack.pl doesn't complain about an empty filename. + // so that fix_linux_stack.py doesn't complain about an empty filename. if (!entry.mFunction && !entry.mLibrary[0] && entry.mLOffset == 0) { snprintf(aBuf, aBufLen, "??? 0x%" PRIxPTR, entryPc); } else { @@ -179,7 +179,7 @@ public: entryFunction, entry.mFileName, entry.mLineNo, entryPc); } else { // On Linux and Mac we cannot get the filename and line number at - // runtime, so we print the offset in a form that fix-linux-stack.pl and + // runtime, so we print the offset in a form that fix_linux_stack.py and // fix_macosx_stack.py can post-process. snprintf(aBuf, aBufLen, "%s[%s +0x%" PRIXPTR "] 0x%" PRIxPTR, entryFunction, entry.mLibrary, entry.mLOffset, entryPc); From 3164f3e5f78eb55d5a86a653db4bee8931e9f6de Mon Sep 17 00:00:00 2001 From: Ryan VanderMeulen Date: Wed, 3 Sep 2014 21:45:30 -0400 Subject: [PATCH 34/68] Backed out 4 changesets (bug 982726) for the same serviceworker perma-fails it hit last time it landed. Backed out changeset 9674f68df2e5 (bug 982726) Backed out changeset 9d397edb8e9a (bug 982726) Backed out changeset ebe7add5dd11 (bug 982726) Backed out changeset 2771520aa1b9 (bug 982726) --- dom/bindings/Bindings.conf | 10 - dom/webidl/ServiceWorker.webidl | 6 +- dom/webidl/ServiceWorkerClient.webidl | 16 -- dom/webidl/ServiceWorkerClients.webidl | 19 -- dom/webidl/ServiceWorkerGlobalScope.webidl | 5 +- dom/webidl/moz.build | 2 - dom/workers/ServiceWorker.cpp | 12 - dom/workers/ServiceWorker.h | 5 - dom/workers/ServiceWorkerClient.cpp | 159 ------------ dom/workers/ServiceWorkerClient.h | 68 ------ dom/workers/ServiceWorkerClients.cpp | 229 ------------------ dom/workers/ServiceWorkerClients.h | 56 ----- dom/workers/ServiceWorkerManager.cpp | 51 ---- dom/workers/ServiceWorkerManager.h | 4 - dom/workers/WorkerScope.cpp | 8 - dom/workers/WorkerScope.h | 16 -- dom/workers/moz.build | 4 - .../serviceworkers/get_serviced_worker.js | 16 -- .../get_serviced_worker_advanced.js | 12 - .../get_serviced_worker_enumerate.js | 7 - .../serviceworkers/message_posting_worker.js | 9 - dom/workers/test/serviceworkers/mochitest.ini | 11 - .../sw_clients/service_worker_controlled.html | 39 --- .../serviceworkers/sw_clients/simple.html | 25 -- .../serviceworkers/test_get_serviced.html | 57 ----- .../test_get_serviced_advanced.html | 80 ------ .../test_get_serviced_enumerate.html | 82 ------- .../serviceworkers/test_post_message.html | 62 ----- .../test_post_message_advanced.html | 91 ------- 29 files changed, 6 insertions(+), 1155 deletions(-) delete mode 100644 dom/webidl/ServiceWorkerClient.webidl delete mode 100644 dom/webidl/ServiceWorkerClients.webidl delete mode 100644 dom/workers/ServiceWorkerClient.cpp delete mode 100644 dom/workers/ServiceWorkerClient.h delete mode 100644 dom/workers/ServiceWorkerClients.cpp delete mode 100644 dom/workers/ServiceWorkerClients.h delete mode 100644 dom/workers/test/serviceworkers/get_serviced_worker.js delete mode 100644 dom/workers/test/serviceworkers/get_serviced_worker_advanced.js delete mode 100644 dom/workers/test/serviceworkers/get_serviced_worker_enumerate.js delete mode 100644 dom/workers/test/serviceworkers/message_posting_worker.js delete mode 100644 dom/workers/test/serviceworkers/sw_clients/service_worker_controlled.html delete mode 100644 dom/workers/test/serviceworkers/sw_clients/simple.html delete mode 100644 dom/workers/test/serviceworkers/test_get_serviced.html delete mode 100644 dom/workers/test/serviceworkers/test_get_serviced_advanced.html delete mode 100644 dom/workers/test/serviceworkers/test_get_serviced_enumerate.html delete mode 100644 dom/workers/test/serviceworkers/test_post_message.html delete mode 100644 dom/workers/test/serviceworkers/test_post_message_advanced.html diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index 0bb7f8dbb8b..969b3e7809d 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -1058,16 +1058,6 @@ DOMInterfaces = { 'headerFile': 'mozilla/dom/workers/bindings/ServiceWorker.h', }, -'ServiceWorkerClient': { - 'nativeType': 'mozilla::dom::workers::ServiceWorkerClient', - 'headerFile': 'mozilla/dom/workers/bindings/ServiceWorkerClient.h', -}, - -'ServiceWorkerClients': { - 'nativeType': 'mozilla::dom::workers::ServiceWorkerClients', - 'headerFile': 'mozilla/dom/workers/bindings/ServiceWorkerClients.h', -}, - 'ServiceWorkerGlobalScope': { 'headerFile': 'mozilla/dom/WorkerScope.h', 'workers': True, diff --git a/dom/webidl/ServiceWorker.webidl b/dom/webidl/ServiceWorker.webidl index a4fe588b783..ad0b02ea83a 100644 --- a/dom/webidl/ServiceWorker.webidl +++ b/dom/webidl/ServiceWorker.webidl @@ -8,6 +8,8 @@ * */ +// Still unclear what should be subclassed. +// https://github.com/slightlyoff/ServiceWorker/issues/189 [Pref="dom.serviceWorkers.enabled", // XXXbz I have no idea where this should be exposed. The spec makes // no sense. But since it's got a pref, let's say window. @@ -18,10 +20,6 @@ interface ServiceWorker : EventTarget { readonly attribute ServiceWorkerState state; attribute EventHandler onstatechange; - - // FIXME(catalinb): Bug 1053483 - This should be inherited from MessageUtils - [Throws] - void postMessage(any message, optional sequence transferable); }; ServiceWorker implements AbstractWorker; diff --git a/dom/webidl/ServiceWorkerClient.webidl b/dom/webidl/ServiceWorkerClient.webidl deleted file mode 100644 index 3543b4b49f8..00000000000 --- a/dom/webidl/ServiceWorkerClient.webidl +++ /dev/null @@ -1,16 +0,0 @@ -/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. - * - * The origin of this IDL file is - * http://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html - * - */ - -[Exposed=ServiceWorker] -interface ServiceWorkerClient { - readonly attribute unsigned long id; - [Throws] - void postMessage(any message, optional sequence transfer); -}; diff --git a/dom/webidl/ServiceWorkerClients.webidl b/dom/webidl/ServiceWorkerClients.webidl deleted file mode 100644 index 8d88181ddc0..00000000000 --- a/dom/webidl/ServiceWorkerClients.webidl +++ /dev/null @@ -1,19 +0,0 @@ -/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. - * - * The origin of this IDL file is - * http://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html - * - */ - -[Exposed=ServiceWorker] -interface ServiceWorkerClients { - // A list of client objects, identifiable by ID, that correspond to windows - // (or workers) that are "controlled" by this SW - [Throws] - Promise?> getServiced(); - [Throws] - Promise reloadAll(); -}; diff --git a/dom/webidl/ServiceWorkerGlobalScope.webidl b/dom/webidl/ServiceWorkerGlobalScope.webidl index 6fa74e66f62..5f2518a4f70 100644 --- a/dom/webidl/ServiceWorkerGlobalScope.webidl +++ b/dom/webidl/ServiceWorkerGlobalScope.webidl @@ -16,7 +16,10 @@ interface ServiceWorkerGlobalScope : WorkerGlobalScope { // FIXME(nsm): Bug 982725 // readonly attribute CacheList caches; - readonly attribute ServiceWorkerClients clients; + // FIXME(nsm): Bug 982726 + // A container for a list of window objects, identifiable by ID, that + // correspond to windows (or workers) that are "controlled" by this SW + // readonly attribute ServiceWorkerClients clients; [Unforgeable] readonly attribute DOMString scope; diff --git a/dom/webidl/moz.build b/dom/webidl/moz.build index 565b9f2dff3..7959d65243b 100644 --- a/dom/webidl/moz.build +++ b/dom/webidl/moz.build @@ -331,8 +331,6 @@ WEBIDL_FILES = [ 'ScrollAreaEvent.webidl', 'Selection.webidl', 'ServiceWorker.webidl', - 'ServiceWorkerClient.webidl', - 'ServiceWorkerClients.webidl', 'ServiceWorkerContainer.webidl', 'ServiceWorkerGlobalScope.webidl', 'ServiceWorkerRegistration.webidl', diff --git a/dom/workers/ServiceWorker.cpp b/dom/workers/ServiceWorker.cpp index f9cbf3820ab..ee2eab96a4a 100644 --- a/dom/workers/ServiceWorker.cpp +++ b/dom/workers/ServiceWorker.cpp @@ -11,7 +11,6 @@ #include "mozilla/dom/Promise.h" -using mozilla::ErrorResult; using namespace mozilla::dom; USING_WORKERS_NAMESPACE @@ -47,17 +46,6 @@ ServiceWorker::WrapObject(JSContext* aCx) return ServiceWorkerBinding::Wrap(aCx, this); } -void -ServiceWorker::PostMessage(JSContext* aCx, JS::Handle aMessage, - const Optional>& aTransferable, - ErrorResult& aRv) -{ - WorkerPrivate* workerPrivate = GetWorkerPrivate(); - MOZ_ASSERT(workerPrivate); - - workerPrivate->PostMessage(aCx, aMessage, aTransferable, aRv); -} - WorkerPrivate* ServiceWorker::GetWorkerPrivate() const { diff --git a/dom/workers/ServiceWorker.h b/dom/workers/ServiceWorker.h index 3c3b7e612ab..0883ad525b8 100644 --- a/dom/workers/ServiceWorker.h +++ b/dom/workers/ServiceWorker.h @@ -52,11 +52,6 @@ public: aURL = mURL; } - void - PostMessage(JSContext* aCx, JS::Handle aMessage, - const Optional>& aTransferable, - ErrorResult& aRv); - WorkerPrivate* GetWorkerPrivate() const; diff --git a/dom/workers/ServiceWorkerClient.cpp b/dom/workers/ServiceWorkerClient.cpp deleted file mode 100644 index ef5e0ad5722..00000000000 --- a/dom/workers/ServiceWorkerClient.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#include "ServiceWorkerClient.h" - -#include "mozilla/dom/MessageEvent.h" -#include "nsGlobalWindow.h" -#include "WorkerPrivate.h" - -#include "mozilla/dom/ServiceWorkerClientBinding.h" - -using namespace mozilla; -using namespace mozilla::dom; -using namespace mozilla::dom::workers; - -NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(ServiceWorkerClient, mOwner) - -NS_IMPL_CYCLE_COLLECTING_ADDREF(ServiceWorkerClient) -NS_IMPL_CYCLE_COLLECTING_RELEASE(ServiceWorkerClient) - -NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ServiceWorkerClient) - NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY - NS_INTERFACE_MAP_ENTRY(nsISupports) -NS_INTERFACE_MAP_END - -JSObject* -ServiceWorkerClient::WrapObject(JSContext* aCx) -{ - return ServiceWorkerClientBinding::Wrap(aCx, this); -} - -namespace { - -class ServiceWorkerClientPostMessageRunnable MOZ_FINAL : public nsRunnable -{ - uint64_t mId; - JSAutoStructuredCloneBuffer mBuffer; - nsTArray> mClonedObjects; - -public: - ServiceWorkerClientPostMessageRunnable(uint64_t aId, - JSAutoStructuredCloneBuffer&& aData, - nsTArray>& aClonedObjects) - : mId(aId), - mBuffer(Move(aData)) - { - mClonedObjects.SwapElements(aClonedObjects); - } - - NS_IMETHOD - Run() - { - AssertIsOnMainThread(); - nsGlobalWindow* window = nsGlobalWindow::GetInnerWindowWithId(mId); - if (!window) { - return NS_ERROR_FAILURE; - } - - AutoJSAPI jsapi; - jsapi.Init(window); - JSContext* cx = jsapi.cx(); - - return DispatchDOMEvent(cx, window); - } - -private: - NS_IMETHOD - DispatchDOMEvent(JSContext* aCx, nsGlobalWindow* aTargetWindow) - { - AssertIsOnMainThread(); - - // Release reference to objects that were AddRef'd for - // cloning into worker when array goes out of scope. - nsTArray> clonedObjects; - clonedObjects.SwapElements(mClonedObjects); - - JS::Rooted messageData(aCx); - if (!mBuffer.read(aCx, &messageData, - WorkerStructuredCloneCallbacks(true))) { - xpc::Throw(aCx, NS_ERROR_DOM_DATA_CLONE_ERR); - return NS_ERROR_FAILURE; - } - - nsCOMPtr event = new MessageEvent(aTargetWindow, - nullptr, nullptr); - nsresult rv = - event->InitMessageEvent(NS_LITERAL_STRING("message"), - false /* non-bubbling */, - false /* not cancelable */, - messageData, - EmptyString(), - EmptyString(), - nullptr); - if (NS_FAILED(rv)) { - xpc::Throw(aCx, rv); - return NS_ERROR_FAILURE; - } - - event->SetTrusted(true); - bool status = false; - aTargetWindow->DispatchEvent(event, &status); - - if (!status) { - return NS_ERROR_FAILURE; - } - - return NS_OK; - } -}; - -} // anonymous namespace - -void -ServiceWorkerClient::PostMessage(JSContext* aCx, JS::Handle aMessage, - const Optional>& aTransferable, - ErrorResult& aRv) -{ - WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate(); - MOZ_ASSERT(workerPrivate); - workerPrivate->AssertIsOnWorkerThread(); - - JS::Rooted transferable(aCx, JS::UndefinedValue()); - if (aTransferable.WasPassed()) { - const Sequence& realTransferable = aTransferable.Value(); - - JS::HandleValueArray elements = - JS::HandleValueArray::fromMarkedLocation(realTransferable.Length(), - realTransferable.Elements()); - - JSObject* array = JS_NewArrayObject(aCx, elements); - if (!array) { - aRv.Throw(NS_ERROR_OUT_OF_MEMORY); - return; - } - - transferable.setObject(*array); - } - - JSStructuredCloneCallbacks* callbacks = WorkerStructuredCloneCallbacks(false); - - nsTArray> clonedObjects; - - JSAutoStructuredCloneBuffer buffer; - if (!buffer.write(aCx, aMessage, transferable, callbacks, &clonedObjects)) { - aRv.Throw(NS_ERROR_DOM_DATA_CLONE_ERR); - return; - } - - nsRefPtr runnable = - new ServiceWorkerClientPostMessageRunnable(mId, Move(buffer), clonedObjects); - nsresult rv = NS_DispatchToMainThread(runnable); - if (NS_FAILED(rv)) { - aRv.Throw(NS_ERROR_FAILURE); - } -} - diff --git a/dom/workers/ServiceWorkerClient.h b/dom/workers/ServiceWorkerClient.h deleted file mode 100644 index 438f0ce7a11..00000000000 --- a/dom/workers/ServiceWorkerClient.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#ifndef mozilla_dom_workers_serviceworkerclient_h -#define mozilla_dom_workers_serviceworkerclient_h - -#include "nsCOMPtr.h" -#include "nsWrapperCache.h" - -namespace mozilla { - -class ErrorResult; - -namespace dom { - -class Promise; -template class Optional; -template class Sequence; - -namespace workers { - -class ServiceWorkerClient MOZ_FINAL : public nsISupports, - public nsWrapperCache -{ -public: - NS_DECL_CYCLE_COLLECTING_ISUPPORTS - NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ServiceWorkerClient) - - ServiceWorkerClient(nsISupports* aOwner, uint64_t aId) - : mOwner(aOwner), - mId(aId) - { - SetIsDOMBinding(); - } - - uint32_t Id() const - { - return mId; - } - - void PostMessage(JSContext* aCx, JS::Handle aMessage, - const Optional>& aTransferable, - ErrorResult& aRv); - - nsISupports* GetParentObject() const - { - return mOwner; - } - - JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; - -private: - ~ServiceWorkerClient() - { - } - - nsCOMPtr mOwner; - uint64_t mId; -}; - -} // namespace workers -} // namespace dom -} // namespace mozilla - -#endif // mozilla_dom_workers_serviceworkerclient_h diff --git a/dom/workers/ServiceWorkerClients.cpp b/dom/workers/ServiceWorkerClients.cpp deleted file mode 100644 index cc2129cf875..00000000000 --- a/dom/workers/ServiceWorkerClients.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "ServiceWorkerClient.h" -#include "ServiceWorkerClients.h" -#include "ServiceWorkerManager.h" - -#include "WorkerPrivate.h" -#include "WorkerRunnable.h" -#include "WorkerScope.h" - -#include "mozilla/dom/Promise.h" -#include "mozilla/dom/ServiceWorkerClientsBinding.h" - -using namespace mozilla; -using namespace mozilla::dom; -using namespace mozilla::dom::workers; - -NS_IMPL_CYCLE_COLLECTING_ADDREF(ServiceWorkerClients) -NS_IMPL_CYCLE_COLLECTING_RELEASE(ServiceWorkerClients) -NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(ServiceWorkerClients, mWorkerScope) - -NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ServiceWorkerClients) - NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY - NS_INTERFACE_MAP_ENTRY(nsISupports) -NS_INTERFACE_MAP_END - -ServiceWorkerClients::ServiceWorkerClients(ServiceWorkerGlobalScope* aWorkerScope) - : mWorkerScope(aWorkerScope) -{ - MOZ_ASSERT(mWorkerScope); - SetIsDOMBinding(); -} - -JSObject* -ServiceWorkerClients::WrapObject(JSContext* aCx) -{ - return ServiceWorkerClientsBinding::Wrap(aCx, this); -} - -namespace { - -// Helper class used for passing the promise between threads while -// keeping the worker alive. -class PromiseHolder MOZ_FINAL : public WorkerFeature -{ - NS_INLINE_DECL_THREADSAFE_REFCOUNTING(PromiseHolder) - -public: - PromiseHolder(WorkerPrivate* aWorkerPrivate, - Promise* aPromise) - : mWorkerPrivate(aWorkerPrivate), - mPromise(aPromise), - mClean(false) - { - MOZ_ASSERT(mWorkerPrivate); - mWorkerPrivate->AssertIsOnWorkerThread(); - MOZ_ASSERT(mPromise); - - if (NS_WARN_IF(!mWorkerPrivate->AddFeature(mWorkerPrivate->GetJSContext(), this))) { - // Worker has been canceled and will go away. - // The ResolvePromiseWorkerRunnable won't run, so we can set mPromise to - // nullptr. - mPromise = nullptr; - mClean = true; - } - } - - Promise* - Get() const - { - return mPromise; - } - - void - Clean() - { - mWorkerPrivate->AssertIsOnWorkerThread(); - - if (mClean) { - return; - } - - mPromise = nullptr; - mWorkerPrivate->RemoveFeature(mWorkerPrivate->GetJSContext(), this); - mClean = true; - } - - bool - Notify(JSContext* aCx, Status aStatus) - { - mWorkerPrivate->AssertIsOnWorkerThread(); - - if (aStatus > Running) { - Clean(); - } - - return true; - } - -private: - ~PromiseHolder() - { - MOZ_ASSERT(mClean); - } - - WorkerPrivate* mWorkerPrivate; - nsRefPtr mPromise; - - bool mClean; -}; - -class ResolvePromiseWorkerRunnable MOZ_FINAL : public WorkerRunnable -{ - nsRefPtr mPromiseHolder; - nsAutoPtr> mValue; - -public: - ResolvePromiseWorkerRunnable(WorkerPrivate* aWorkerPrivate, - PromiseHolder* aPromiseHolder, - nsAutoPtr>& aValue) - : WorkerRunnable(aWorkerPrivate, WorkerThreadModifyBusyCount), - mPromiseHolder(aPromiseHolder), - mValue(aValue) - { - AssertIsOnMainThread(); - } - - bool - WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) - { - MOZ_ASSERT(aWorkerPrivate); - aWorkerPrivate->AssertIsOnWorkerThread(); - - Promise* promise = mPromiseHolder->Get(); - MOZ_ASSERT(promise); - - nsTArray> ret; - for (size_t i = 0; i < mValue->Length(); i++) { - ret.AppendElement(nsRefPtr( - new ServiceWorkerClient(promise->GetParentObject(), - mValue->ElementAt(i)))); - } - promise->MaybeResolve(ret); - - // release the reference on the worker thread. - mPromiseHolder->Clean(); - - return true; - } -}; - -class GetServicedRunnable MOZ_FINAL : public nsRunnable -{ - WorkerPrivate* mWorkerPrivate; - nsCString mScope; - nsRefPtr mPromiseHolder; -public: - GetServicedRunnable(WorkerPrivate* aWorkerPrivate, - Promise* aPromise, - const nsCString& aScope) - : mWorkerPrivate(aWorkerPrivate), - mScope(aScope) - { - MOZ_ASSERT(aWorkerPrivate); - aWorkerPrivate->AssertIsOnWorkerThread(); - mPromiseHolder = new PromiseHolder(aWorkerPrivate, aPromise); - } - - NS_IMETHOD - Run() MOZ_OVERRIDE - { - AssertIsOnMainThread(); - - nsRefPtr swm = ServiceWorkerManager::GetInstance(); - nsAutoPtr> result(new nsTArray()); - - swm->GetServicedClients(mScope, result); - nsRefPtr r = - new ResolvePromiseWorkerRunnable(mWorkerPrivate, mPromiseHolder, result); - - AutoSafeJSContext cx; - r->Dispatch(cx); - return NS_OK; - } -}; - -} // anonymous namespace - -already_AddRefed -ServiceWorkerClients::GetServiced(ErrorResult& aRv) -{ - WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate(); - MOZ_ASSERT(workerPrivate); - workerPrivate->AssertIsOnWorkerThread(); - - DOMString scope; - mWorkerScope->GetScope(scope); - - nsRefPtr promise = Promise::Create(mWorkerScope, aRv); - if (NS_WARN_IF(aRv.Failed())) { - return nullptr; - } - - nsRefPtr r = - new GetServicedRunnable(workerPrivate, promise, NS_ConvertUTF16toUTF8(scope)); - nsresult rv = NS_DispatchToMainThread(r); - - if (NS_WARN_IF(NS_FAILED(rv))) { - promise->MaybeReject(NS_ERROR_NOT_AVAILABLE); - } - - return promise.forget(); -} - -// FIXME(catalinb): Bug 1045257 - Implement ReloadAll -already_AddRefed -ServiceWorkerClients::ReloadAll(ErrorResult& aRv) -{ - nsRefPtr promise = Promise::Create(mWorkerScope, aRv); - if (NS_WARN_IF(aRv.Failed())) { - return nullptr; - } - promise->MaybeReject(NS_ERROR_NOT_AVAILABLE); - return promise.forget(); -} - diff --git a/dom/workers/ServiceWorkerClients.h b/dom/workers/ServiceWorkerClients.h deleted file mode 100644 index 39cf03a6dab..00000000000 --- a/dom/workers/ServiceWorkerClients.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#ifndef mozilla_dom_workers_serviceworkerclients_h -#define mozilla_dom_workers_serviceworkerclients_h - -#include "nsAutoPtr.h" -#include "nsWrapperCache.h" - -namespace mozilla { - -class ErrorResult; - -namespace dom { - -class Promise; - -namespace workers { - -class ServiceWorkerGlobalScope; - -class ServiceWorkerClients MOZ_FINAL : public nsISupports, - public nsWrapperCache -{ -public: - NS_DECL_CYCLE_COLLECTING_ISUPPORTS - NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ServiceWorkerClients) - - ServiceWorkerClients(ServiceWorkerGlobalScope* aWorkerScope); - - already_AddRefed GetServiced(ErrorResult& aRv); - already_AddRefed ReloadAll(ErrorResult& aRv); - - JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; - - ServiceWorkerGlobalScope* GetParentObject() const - { - return mWorkerScope; - } - -private: - ~ServiceWorkerClients() - { - } - - nsRefPtr mWorkerScope; -}; - -} // namespace workers -} // namespace dom -} // namespace mozilla - -#endif // mozilla_dom_workers_serviceworkerclients_h diff --git a/dom/workers/ServiceWorkerManager.cpp b/dom/workers/ServiceWorkerManager.cpp index 15b40cedc5f..32aa670c4f4 100644 --- a/dom/workers/ServiceWorkerManager.cpp +++ b/dom/workers/ServiceWorkerManager.cpp @@ -24,7 +24,6 @@ #include "RuntimeService.h" #include "ServiceWorker.h" -#include "ServiceWorkerClient.h" #include "ServiceWorkerRegistration.h" #include "ServiceWorkerEvents.h" #include "WorkerInlines.h" @@ -2174,54 +2173,4 @@ ServiceWorkerManager::InvalidateServiceWorkerRegistrationWorker(ServiceWorkerReg } } -namespace { - -class MOZ_STACK_CLASS FilterRegistrationData -{ -public: - FilterRegistrationData(nsTArray* aDocuments, - ServiceWorkerRegistrationInfo* aRegistration) - : mDocuments(aDocuments), - mRegistration(aRegistration) - { - } - - nsTArray* mDocuments; - nsRefPtr mRegistration; -}; - -static PLDHashOperator -EnumControlledDocuments(nsISupports* aKey, - ServiceWorkerRegistrationInfo* aRegistration, - void* aData) -{ - FilterRegistrationData* data = static_cast(aData); - if (data->mRegistration != aRegistration) { - return PL_DHASH_NEXT; - } - nsCOMPtr document = do_QueryInterface(aKey); - if (!document || !document->GetInnerWindow()) { - return PL_DHASH_NEXT; - } - - data->mDocuments->AppendElement(document->GetInnerWindow()->WindowID()); - return PL_DHASH_NEXT; -} - -} // anonymous namespace - -void -ServiceWorkerManager::GetServicedClients(const nsCString& aScope, - nsTArray* aControlledDocuments) -{ - nsRefPtr domainInfo = GetDomainInfo(aScope); - nsRefPtr registration = - domainInfo->GetRegistration(aScope); - MOZ_ASSERT(registration); - FilterRegistrationData data(aControlledDocuments, registration); - - domainInfo->mControlledDocuments.EnumerateRead(EnumControlledDocuments, - &data); -} - END_WORKERS_NAMESPACE diff --git a/dom/workers/ServiceWorkerManager.h b/dom/workers/ServiceWorkerManager.h index 2fb58bb63ca..68f80165479 100644 --- a/dom/workers/ServiceWorkerManager.h +++ b/dom/workers/ServiceWorkerManager.h @@ -318,10 +318,6 @@ public: uint32_t aColumnNumber, uint32_t aFlags); - void - GetServicedClients(const nsCString& aScope, - nsTArray* aControlledDocuments); - static already_AddRefed GetInstance(); diff --git a/dom/workers/WorkerScope.cpp b/dom/workers/WorkerScope.cpp index d353cbf55a2..ef2475ad3e5 100644 --- a/dom/workers/WorkerScope.cpp +++ b/dom/workers/WorkerScope.cpp @@ -346,14 +346,6 @@ SharedWorkerGlobalScope::WrapGlobalObject(JSContext* aCx) true); } -NS_IMPL_CYCLE_COLLECTION_INHERITED(ServiceWorkerGlobalScope, WorkerGlobalScope, - mClients) -NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(ServiceWorkerGlobalScope) -NS_INTERFACE_MAP_END_INHERITING(WorkerGlobalScope) - -NS_IMPL_ADDREF_INHERITED(ServiceWorkerGlobalScope, WorkerGlobalScope) -NS_IMPL_RELEASE_INHERITED(ServiceWorkerGlobalScope, WorkerGlobalScope) - ServiceWorkerGlobalScope::ServiceWorkerGlobalScope(WorkerPrivate* aWorkerPrivate, const nsACString& aScope) : WorkerGlobalScope(aWorkerPrivate), diff --git a/dom/workers/WorkerScope.h b/dom/workers/WorkerScope.h index eed5fb4592e..ea4918d5805 100644 --- a/dom/workers/WorkerScope.h +++ b/dom/workers/WorkerScope.h @@ -8,7 +8,6 @@ #include "Workers.h" #include "mozilla/DOMEventTargetHelper.h" -#include "ServiceWorkerClients.h" namespace mozilla { namespace dom { @@ -164,15 +163,9 @@ public: class ServiceWorkerGlobalScope MOZ_FINAL : public WorkerGlobalScope { const nsString mScope; - nsRefPtr mClients; - ~ServiceWorkerGlobalScope() { } public: - NS_DECL_ISUPPORTS_INHERITED - NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ServiceWorkerGlobalScope, - WorkerGlobalScope) - ServiceWorkerGlobalScope(WorkerPrivate* aWorkerPrivate, const nsACString& aScope); virtual JSObject* @@ -202,15 +195,6 @@ public: // FIXME(nsm): Bug 982728 } - ServiceWorkerClients* - Clients() { - if (!mClients) { - mClients = new ServiceWorkerClients(this); - } - - return mClients; - } - IMPL_EVENT_HANDLER(activate) IMPL_EVENT_HANDLER(beforeevicted) IMPL_EVENT_HANDLER(evicted) diff --git a/dom/workers/moz.build b/dom/workers/moz.build index 305cfc3b913..1502dc5a605 100644 --- a/dom/workers/moz.build +++ b/dom/workers/moz.build @@ -29,8 +29,6 @@ EXPORTS.mozilla.dom.workers.bindings += [ 'Navigator.h', 'Performance.h', 'ServiceWorker.h', - 'ServiceWorkerClient.h', - 'ServiceWorkerClients.h', 'SharedWorker.h', 'URL.h', 'WorkerFeature.h', @@ -53,8 +51,6 @@ SOURCES += [ 'RuntimeService.cpp', 'ScriptLoader.cpp', 'ServiceWorker.cpp', - 'ServiceWorkerClient.cpp', - 'ServiceWorkerClients.cpp', 'ServiceWorkerContainer.cpp', 'ServiceWorkerEvents.cpp', 'ServiceWorkerManager.cpp', diff --git a/dom/workers/test/serviceworkers/get_serviced_worker.js b/dom/workers/test/serviceworkers/get_serviced_worker.js deleted file mode 100644 index b97e4145034..00000000000 --- a/dom/workers/test/serviceworkers/get_serviced_worker.js +++ /dev/null @@ -1,16 +0,0 @@ -function loop() { - self.clients.getServiced().then(function(result) { - setTimeout(loop, 0); - }); -} - -onactivate = function(e) { - // spam getServiced until the worker is closed. - loop(); -} - -onclose = function(e) { - for (var i = 0; i < 100; ++i) { - self.clients.getServiced(); - } -} diff --git a/dom/workers/test/serviceworkers/get_serviced_worker_advanced.js b/dom/workers/test/serviceworkers/get_serviced_worker_advanced.js deleted file mode 100644 index 28e4e4e3112..00000000000 --- a/dom/workers/test/serviceworkers/get_serviced_worker_advanced.js +++ /dev/null @@ -1,12 +0,0 @@ -onmessage = function(e) { - if (!e.data) { - dump("ERROR: message has no data.\n"); - } - - self.clients.getServiced().then(function(res) { - if (res.length === 0) { - dump("ERROR: no client is currently being controlled.\n"); - } - res[res.length - 1].postMessage(res.length); - }); -}; diff --git a/dom/workers/test/serviceworkers/get_serviced_worker_enumerate.js b/dom/workers/test/serviceworkers/get_serviced_worker_enumerate.js deleted file mode 100644 index 42be6681abe..00000000000 --- a/dom/workers/test/serviceworkers/get_serviced_worker_enumerate.js +++ /dev/null @@ -1,7 +0,0 @@ -onmessage = function() { - self.clients.getServiced().then(function(result) { - for (i = 0; i < result.length; i++) { - result[i].postMessage(i); - } - }); -}; diff --git a/dom/workers/test/serviceworkers/message_posting_worker.js b/dom/workers/test/serviceworkers/message_posting_worker.js deleted file mode 100644 index f4b0b09979f..00000000000 --- a/dom/workers/test/serviceworkers/message_posting_worker.js +++ /dev/null @@ -1,9 +0,0 @@ -onmessage = function(e) { - self.clients.getServiced().then(function(res) { - if (!res.length) { - dump("ERROR: no clients are currently controlled.\n"); - } - res[0].postMessage(e.data); - }); -}; - diff --git a/dom/workers/test/serviceworkers/mochitest.ini b/dom/workers/test/serviceworkers/mochitest.ini index 36cf0912420..20da13ab8a9 100644 --- a/dom/workers/test/serviceworkers/mochitest.ini +++ b/dom/workers/test/serviceworkers/mochitest.ini @@ -10,21 +10,10 @@ support-files = simpleregister/ready.html controller/index.html unregister/index.html - sw_clients/simple.html - get_serviced_worker.js - get_serviced_worker_advanced.js - message_posting_worker.js - sw_clients/service_worker_controlled.html - get_serviced_worker_enumerate.js -[test_get_serviced.html] -[test_get_serviced_advanced.html] -[test_get_serviced_enumerate.html] [test_installation_simple.html] [test_install_event.html] [test_navigator.html] -[test_post_message.html] -[test_post_message_advanced.html] [test_scopes.html] [test_controller.html] [test_unregister.html] diff --git a/dom/workers/test/serviceworkers/sw_clients/service_worker_controlled.html b/dom/workers/test/serviceworkers/sw_clients/service_worker_controlled.html deleted file mode 100644 index a67679ee7d2..00000000000 --- a/dom/workers/test/serviceworkers/sw_clients/service_worker_controlled.html +++ /dev/null @@ -1,39 +0,0 @@ - - - - - controlled page - - - - - - - - diff --git a/dom/workers/test/serviceworkers/sw_clients/simple.html b/dom/workers/test/serviceworkers/sw_clients/simple.html deleted file mode 100644 index 6b1551928d3..00000000000 --- a/dom/workers/test/serviceworkers/sw_clients/simple.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - Bug 982726 - test get_serviced not crashing - - - - -

- -

-
-
-
-
-
diff --git a/dom/workers/test/serviceworkers/test_get_serviced.html b/dom/workers/test/serviceworkers/test_get_serviced.html
deleted file mode 100644
index 8c47401a079..00000000000
--- a/dom/workers/test/serviceworkers/test_get_serviced.html
+++ /dev/null
@@ -1,57 +0,0 @@
-
-
-
-
-  Bug 982726 - test get_serviced not crashing
-  
-  
-
-
-

- -

-
-
-
-
-
diff --git a/dom/workers/test/serviceworkers/test_get_serviced_advanced.html b/dom/workers/test/serviceworkers/test_get_serviced_advanced.html
deleted file mode 100644
index 539a3f1f10e..00000000000
--- a/dom/workers/test/serviceworkers/test_get_serviced_advanced.html
+++ /dev/null
@@ -1,80 +0,0 @@
-
-
-
-
-  Bug 982726 - test get_serviced 
-  
-  
-
-
-

- -

-
-
-
-
-
diff --git a/dom/workers/test/serviceworkers/test_get_serviced_enumerate.html b/dom/workers/test/serviceworkers/test_get_serviced_enumerate.html
deleted file mode 100644
index 7ba0d190f8e..00000000000
--- a/dom/workers/test/serviceworkers/test_get_serviced_enumerate.html
+++ /dev/null
@@ -1,82 +0,0 @@
-
-
-
-
-  Bug 982726 - test get_serviced 
-  
-  
-
-
-

- -

-
-
-
-
-
diff --git a/dom/workers/test/serviceworkers/test_post_message.html b/dom/workers/test/serviceworkers/test_post_message.html
deleted file mode 100644
index e9c8c0f916a..00000000000
--- a/dom/workers/test/serviceworkers/test_post_message.html
+++ /dev/null
@@ -1,62 +0,0 @@
-
-
-
-
-  Bug 982726 - Test service worker post message 
-  
-  
-
-
-

- -

-
-
-
-
-
diff --git a/dom/workers/test/serviceworkers/test_post_message_advanced.html b/dom/workers/test/serviceworkers/test_post_message_advanced.html
deleted file mode 100644
index b48d991ae9c..00000000000
--- a/dom/workers/test/serviceworkers/test_post_message_advanced.html
+++ /dev/null
@@ -1,91 +0,0 @@
-
-
-
-
-  Bug 982726 - Test service worker post message advanced 
-  
-  
-
-
-

- -

-
-
-
-
-

From 6dd3cfc6877b1c4f6f2a0818ae942ad751f4a92e Mon Sep 17 00:00:00 2001
From: Josh Aas 
Date: Wed, 3 Sep 2014 22:52:59 -0500
Subject: [PATCH 35/68] Bug 1062064 - remove Chromium debug utils from IPC
 code. rs=bent

---
 ipc/chromium/moz.build                      |   9 -
 ipc/chromium/src/base/debug_on_start.cc     |  65 -----
 ipc/chromium/src/base/debug_on_start.h      |  67 -----
 ipc/chromium/src/base/debug_util.cc         |  77 ------
 ipc/chromium/src/base/debug_util.h          |  88 ------
 ipc/chromium/src/base/debug_util_mac.cc     |  35 ---
 ipc/chromium/src/base/debug_util_posix.cc   | 187 -------------
 ipc/chromium/src/base/debug_util_win.cc     | 290 --------------------
 ipc/chromium/src/base/process_util.h        |  52 ++++
 ipc/chromium/src/base/process_util_bsd.cc   |   1 -
 ipc/chromium/src/base/process_util_linux.cc |   1 -
 ipc/chromium/src/base/process_util_win.cc   |   1 -
 12 files changed, 52 insertions(+), 821 deletions(-)
 delete mode 100644 ipc/chromium/src/base/debug_on_start.cc
 delete mode 100644 ipc/chromium/src/base/debug_on_start.h
 delete mode 100644 ipc/chromium/src/base/debug_util.cc
 delete mode 100644 ipc/chromium/src/base/debug_util.h
 delete mode 100644 ipc/chromium/src/base/debug_util_mac.cc
 delete mode 100644 ipc/chromium/src/base/debug_util_posix.cc
 delete mode 100644 ipc/chromium/src/base/debug_util_win.cc

diff --git a/ipc/chromium/moz.build b/ipc/chromium/moz.build
index ece9a909590..adde7bae520 100644
--- a/ipc/chromium/moz.build
+++ b/ipc/chromium/moz.build
@@ -39,7 +39,6 @@ UNIFIED_SOURCES += [
     'src/base/at_exit.cc',
     'src/base/base_switches.cc',
     'src/base/command_line.cc',
-    'src/base/debug_util.cc',
     'src/base/file_path.cc',
     'src/base/file_util.cc',
     'src/base/histogram.cc',
@@ -85,7 +84,6 @@ if os_win:
     SOURCES += [
         'src/base/condition_variable_win.cc',
         'src/base/cpu.cc',
-        'src/base/debug_util_win.cc',
         'src/base/event_recorder.cc',
         'src/base/file_util_win.cc',
         'src/base/idle_timer.cc',
@@ -143,7 +141,6 @@ elif not CONFIG['MOZ_NATIVE_LIBEVENT']:
 if os_posix:
     SOURCES += [
         'src/base/condition_variable_posix.cc',
-        'src/base/debug_util_posix.cc',
         'src/base/event_recorder_stubs.cc',
         'src/base/file_descriptor_shuffle.cc',
         'src/base/file_util_posix.cc',
@@ -174,7 +171,6 @@ if os_posix:
 
 if os_macosx:
     UNIFIED_SOURCES += [
-        'src/base/debug_util_mac.cc',
         'src/base/idle_timer.cc',
         'src/base/sys_info_mac.cc',
         'src/base/time_mac.cc',
@@ -259,11 +255,6 @@ if os_bsd:
         ]
         LOCAL_INCLUDES += ['src/third_party/libevent/bsd']
 
-if CONFIG['_MSC_VER']:
-    SOURCES += [
-        'src/base/debug_on_start.cc',
-    ]
-
 ost = CONFIG['OS_TEST']
 if ost.find('86') == -1 and ost.find('arm') == -1 and ost.find('mips') == -1:
     SOURCES += [
diff --git a/ipc/chromium/src/base/debug_on_start.cc b/ipc/chromium/src/base/debug_on_start.cc
deleted file mode 100644
index c7d414965e0..00000000000
--- a/ipc/chromium/src/base/debug_on_start.cc
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include 
-
-#include "base/debug_on_start.h"
-
-#include "base/base_switches.h"
-#include "base/basictypes.h"
-#include "base/debug_util.h"
-
-// Minimalist implementation to try to find a command line argument. We can use
-// kernel32 exported functions but not the CRT functions because we're too early
-// in the process startup.
-// The code is not that bright and will find things like ---argument or
-// /-/argument.
-// Note: command_line is non-destructively modified.
-bool DebugOnStart::FindArgument(wchar_t* command_line, const wchar_t* argument)
-{
-  int argument_len = lstrlen(argument);
-  int command_line_len = lstrlen(command_line);
-  while (command_line_len > argument_len) {
-    wchar_t first_char = command_line[0];
-    wchar_t last_char = command_line[argument_len+1];
-    // Try to find an argument.
-    if ((first_char == L'-' || first_char == L'/') &&
-        (last_char == L' ' || last_char == 0 || last_char == L'=')) {
-      command_line[argument_len+1] = 0;
-      // Skip the - or /
-      if (lstrcmpi(command_line+1, argument) == 0) {
-        // Found it.
-        command_line[argument_len+1] = last_char;
-        return true;
-      }
-      // Fix back.
-      command_line[argument_len+1] = last_char;
-    }
-    // Continue searching.
-    ++command_line;
-    --command_line_len;
-  }
-  return false;
-}
-
-// static
-int __cdecl DebugOnStart::Init() {
-  // Try to find the argument.
-  if (FindArgument(GetCommandLine(), switches::kDebugOnStart)) {
-    // We can do 2 things here:
-    // - Ask for a debugger to attach to us. This involve reading the registry
-    //   key and creating the process.
-    // - Do a int3.
-
-    // It will fails if we run in a sandbox. That is expected.
-    DebugUtil::SpawnDebuggerOnProcess(GetCurrentProcessId());
-
-    // Wait for a debugger to come take us.
-    DebugUtil::WaitForDebugger(60, false);
-  } else if (FindArgument(GetCommandLine(), switches::kWaitForDebugger)) {
-    // Wait for a debugger to come take us.
-    DebugUtil::WaitForDebugger(60, true);
-  }
-  return 0;
-}
diff --git a/ipc/chromium/src/base/debug_on_start.h b/ipc/chromium/src/base/debug_on_start.h
deleted file mode 100644
index 42f39b2f1f7..00000000000
--- a/ipc/chromium/src/base/debug_on_start.h
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Define the necessary code and global data to look for kDebugOnStart command
-// line argument. When the command line argument is detected, it invokes the
-// debugger, if no system-wide debugger is registered, a debug break is done.
-
-#ifndef BASE_DEBUG_ON_START_H_
-#define BASE_DEBUG_ON_START_H_
-
-#include "base/basictypes.h"
-
-// This only works on MSVC.
-#if defined(COMPILER_MSVC)
-
-#ifndef DECLSPEC_SELECTANY
-#define DECLSPEC_SELECTANY  __declspec(selectany)
-#endif
-
-// Debug on start functions and data.
-class DebugOnStart {
- public:
-  // Expected function type in the .CRT$XI* section.
-  // Note: See VC\crt\src\internal.h for reference.
-  typedef int  (__cdecl *PIFV)(void);
-
-  // Looks at the command line for kDebugOnStart argument. If found, it invokes
-  // the debugger, if this fails, it crashes.
-  static int __cdecl Init();
-
-  // Returns true if the 'argument' is present in the 'command_line'. It does
-  // not use the CRT, only Kernel32 functions.
-  static bool FindArgument(wchar_t* command_line, const wchar_t* argument);
-};
-
-// Set the function pointer to our function to look for a crash on start. The
-// XIB section is started pretty early in the program initialization so in
-// theory it should be called before any user created global variable
-// initialization code and CRT initialization code.
-// Note: See VC\crt\src\defsects.inc and VC\crt\src\crt0.c for reference.
-#ifdef _WIN64
-
-// "Fix" the segment. On x64, the .CRT segment is merged into the .rdata segment
-// so it contains const data only.
-#pragma const_seg(push, ".CRT$XIB")
-// Declare the pointer so the CRT will find it.
-extern const DebugOnStart::PIFV debug_on_start;
-DECLSPEC_SELECTANY const DebugOnStart::PIFV debug_on_start =
-    &DebugOnStart::Init;
-// Fix back the segment.
-#pragma const_seg(pop)
-
-#else  // _WIN64
-
-// "Fix" the segment. On x86, the .CRT segment is merged into the .data segment
-// so it contains non-const data only.
-#pragma data_seg(push, ".CRT$XIB")
-// Declare the pointer so the CRT will find it.
-DECLSPEC_SELECTANY DebugOnStart::PIFV debug_on_start = &DebugOnStart::Init;
-// Fix back the segment.
-#pragma data_seg(pop)
-
-#endif  // _WIN64
-#endif  // defined(OS_WIN)
-
-#endif  // BASE_DEBUG_ON_START_H_
diff --git a/ipc/chromium/src/base/debug_util.cc b/ipc/chromium/src/base/debug_util.cc
deleted file mode 100644
index 8062fd8a7a2..00000000000
--- a/ipc/chromium/src/base/debug_util.cc
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/debug_util.h"
-
-#include "base/platform_thread.h"
-
-#include 
-#include 
-#include 
-
-#ifdef OS_WIN
-#include 
-#else
-#include 
-#endif
-
-#ifndef STDOUT_FILENO
-#define STDOUT_FILENO 1
-#endif
-
-bool DebugUtil::WaitForDebugger(int wait_seconds, bool silent) {
-  for (int i = 0; i < wait_seconds * 10; ++i) {
-    if (BeingDebugged()) {
-      if (!silent)
-        BreakDebugger();
-      return true;
-    }
-    PlatformThread::Sleep(100);
-  }
-  return false;
-}
-
-const void *const *StackTrace::Addresses(size_t* count) {
-  *count = trace_.size();
-  if (trace_.size())
-    return &trace_[0];
-  return NULL;
-}
-
-namespace mozilla {
-
-EnvironmentLog::EnvironmentLog(const char* varname)
-{
-  const char *e = getenv(varname);
-  if (e && *e)
-    fname_ = e;
-}
-
-EnvironmentLog::~EnvironmentLog()
-{
-}
-
-void
-EnvironmentLog::print(const char* format, ...)
-{
-  if (!fname_.size())
-    return;
-
-  FILE* f;
-  if (fname_.compare("-") == 0)
-    f = fdopen(dup(STDOUT_FILENO), "a");
-  else
-    f = fopen(fname_.c_str(), "a");
-
-  if (!f)
-    return;
-
-  va_list a;
-  va_start(a, format);
-  vfprintf(f, format, a);
-  va_end(a);
-  fclose(f);
-}
-
-} // namespace mozilla
diff --git a/ipc/chromium/src/base/debug_util.h b/ipc/chromium/src/base/debug_util.h
deleted file mode 100644
index 7ae9d6822e0..00000000000
--- a/ipc/chromium/src/base/debug_util.h
+++ /dev/null
@@ -1,88 +0,0 @@
-// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// This is a cross platform interface for helper functions related to debuggers.
-// You should use this to test if you're running under a debugger, and if you
-// would like to yield (breakpoint) into the debugger.
-
-#ifndef BASE_DEBUG_UTIL_H_
-#define BASE_DEBUG_UTIL_H_
-
-#include 
-#include 
-
-#include "base/basictypes.h"
-
-// A stacktrace can be helpful in debugging. For example, you can include a
-// stacktrace member in a object (probably around #ifndef NDEBUG) so that you
-// can later see where the given object was created from.
-class StackTrace {
- public:
-  // Create a stacktrace from the current location
-  StackTrace();
-  // Get an array of instruction pointer values.
-  //   count: (output) the number of elements in the returned array
-  const void *const *Addresses(size_t* count);
-  // Print a backtrace to stderr
-  void PrintBacktrace();
-
-  // Resolve backtrace to symbols and write to stream.
-  void OutputToStream(std::ostream* os);
-
- private:
-  std::vector trace_;
-
-  DISALLOW_EVIL_CONSTRUCTORS(StackTrace);
-};
-
-class DebugUtil {
- public:
-  // Starts the registered system-wide JIT debugger to attach it to specified
-  // process.
-  static bool SpawnDebuggerOnProcess(unsigned process_id);
-
-  // Waits wait_seconds seconds for a debugger to attach to the current process.
-  // When silent is false, an exception is thrown when a debugger is detected.
-  static bool WaitForDebugger(int wait_seconds, bool silent);
-
-  // Are we running under a debugger?
-  // On OS X, the underlying mechanism doesn't work when the sandbox is enabled.
-  // To get around this, this function caches its value.
-  // WARNING: Because of this, on OS X, a call MUST be made to this function
-  // BEFORE the sandbox is enabled.
-  static bool BeingDebugged();
-
-  // Break into the debugger, assumes a debugger is present.
-  static void BreakDebugger();
-
-#if defined(OS_MACOSX)
-  // On OS X, it can take a really long time for the OS Crash handler to
-  // process a Chrome crash.  This translates into a long wait till the process
-  // actually dies.
-  // This method disables OS Crash reporting entireley.
-  // TODO(playmobil): Remove this when we have Breakpad integration enabled -
-  // see http://crbug.com/7652
-  static void DisableOSCrashDumps();
-#endif  // defined(OS_MACOSX)
-};
-
-namespace mozilla {
-
-class EnvironmentLog
-{
-public:
-  explicit EnvironmentLog(const char* varname);
-  ~EnvironmentLog();
-
-  void print(const char* format, ...);
-
-private:
-  std::string fname_;
-
-  DISALLOW_EVIL_CONSTRUCTORS(EnvironmentLog);
-};
-
-} // namespace mozilla
-
-#endif  // BASE_DEBUG_UTIL_H_
diff --git a/ipc/chromium/src/base/debug_util_mac.cc b/ipc/chromium/src/base/debug_util_mac.cc
deleted file mode 100644
index 3a1b184a9ca..00000000000
--- a/ipc/chromium/src/base/debug_util_mac.cc
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/debug_util.h"
-
-#include 
-
-#include "base/basictypes.h"
-
-static void ExitSignalHandler(int sig) {
-  exit(128 + sig);
-}
-
-// static
-void DebugUtil::DisableOSCrashDumps() {
-  int signals_to_intercept[] ={SIGINT,
-                               SIGHUP,
-                               SIGTERM,
-                               SIGABRT,
-                               SIGILL,
-                               SIGTRAP,
-                               SIGEMT,
-                               SIGFPE,
-                               SIGBUS,
-                               SIGSEGV,
-                               SIGSYS,
-                               SIGPIPE,
-                               SIGXCPU,
-                               SIGXFSZ};
-  // For all these signals, just wire thing sup so we exit immediately.
-  for (size_t i = 0; i < arraysize(signals_to_intercept); ++i) {
-    signal(signals_to_intercept[i], ExitSignalHandler);
-  }
-}
diff --git a/ipc/chromium/src/base/debug_util_posix.cc b/ipc/chromium/src/base/debug_util_posix.cc
deleted file mode 100644
index 18e9a2dd150..00000000000
--- a/ipc/chromium/src/base/debug_util_posix.cc
+++ /dev/null
@@ -1,187 +0,0 @@
-// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "build/build_config.h"
-#include "base/debug_util.h"
-
-#define MOZ_HAVE_EXECINFO_H (defined(OS_LINUX) && !defined(ANDROID))
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#if MOZ_HAVE_EXECINFO_H
-#include 
-#endif
-
-#if defined(OS_MACOSX) || defined(OS_BSD)
-#if defined(OS_OPENBSD)
-#include 
-#endif
-#include 
-#endif
-
-#if defined(OS_DRAGONFLY) || defined(OS_FREEBSD)
-#include 
-#endif
-
-#include "base/basictypes.h"
-#include "base/eintr_wrapper.h"
-#include "base/logging.h"
-#include "base/scoped_ptr.h"
-#include "base/string_piece.h"
-
-#if defined(OS_NETBSD)
-#undef KERN_PROC
-#define KERN_PROC KERN_PROC2
-#define KINFO_PROC struct kinfo_proc2
-#else
-#define KINFO_PROC struct kinfo_proc
-#endif
-
-#if defined(OS_MACOSX)
-#define KP_FLAGS kp_proc.p_flag
-#elif defined(OS_DRAGONFLY)
-#define KP_FLAGS kp_flags
-#elif defined(OS_FREEBSD)
-#define KP_FLAGS ki_flag
-#elif defined(OS_OPENBSD) && !defined(_P_TRACED)
-#define KP_FLAGS p_psflags
-#define P_TRACED PS_TRACED
-#else
-#define KP_FLAGS p_flag
-#endif
-
-// static
-bool DebugUtil::SpawnDebuggerOnProcess(unsigned /* process_id */) {
-  NOTIMPLEMENTED();
-  return false;
-}
-
-#if defined(OS_MACOSX) || defined(OS_BSD)
-
-// Based on Apple's recommended method as described in
-// http://developer.apple.com/qa/qa2004/qa1361.html
-// static
-bool DebugUtil::BeingDebugged() {
-  // If the process is sandboxed then we can't use the sysctl, so cache the
-  // value.
-  static bool is_set = false;
-  static bool being_debugged = false;
-
-  if (is_set) {
-    return being_debugged;
-  }
-
-  // Initialize mib, which tells sysctl what info we want.  In this case,
-  // we're looking for information about a specific process ID.
-  int mib[] = {
-    CTL_KERN,
-    KERN_PROC,
-    KERN_PROC_PID,
-    getpid(),
-#if defined(OS_NETBSD) || defined(OS_OPENBSD)
-    sizeof(KINFO_PROC),
-    1,
-#endif
-  };
-
-  // Caution: struct kinfo_proc is marked __APPLE_API_UNSTABLE.  The source and
-  // binary interfaces may change.
-  KINFO_PROC info;
-  size_t info_size = sizeof(info);
-
-  int sysctl_result = sysctl(mib, arraysize(mib), &info, &info_size, NULL, 0);
-  DCHECK(sysctl_result == 0);
-  if (sysctl_result != 0) {
-    is_set = true;
-    being_debugged = false;
-    return being_debugged;
-  }
-
-  // This process is being debugged if the P_TRACED flag is set.
-  is_set = true;
-  being_debugged = (info.KP_FLAGS & P_TRACED) != 0;
-  return being_debugged;
-}
-
-#elif defined(OS_LINUX)
-
-// We can look in /proc/self/status for TracerPid.  We are likely used in crash
-// handling, so we are careful not to use the heap or have side effects.
-// Another option that is common is to try to ptrace yourself, but then we
-// can't detach without forking(), and that's not so great.
-// static
-bool DebugUtil::BeingDebugged() {
-  int status_fd = open("/proc/self/status", O_RDONLY);
-  if (status_fd == -1)
-    return false;
-
-  // We assume our line will be in the first 1024 characters and that we can
-  // read this much all at once.  In practice this will generally be true.
-  // This simplifies and speeds up things considerably.
-  char buf[1024];
-
-  ssize_t num_read = HANDLE_EINTR(read(status_fd, buf, sizeof(buf)));
-  HANDLE_EINTR(close(status_fd));
-
-  if (num_read <= 0)
-    return false;
-
-  StringPiece status(buf, num_read);
-  StringPiece tracer("TracerPid:\t");
-
-  StringPiece::size_type pid_index = status.find(tracer);
-  if (pid_index == StringPiece::npos)
-    return false;
-
-  // Our pid is 0 without a debugger, assume this for any pid starting with 0.
-  pid_index += tracer.size();
-  return pid_index < status.size() && status[pid_index] != '0';
-}
-
-#endif  // OS_LINUX
-
-// static
-void DebugUtil::BreakDebugger() {
-#if defined(ARCH_CPU_X86_FAMILY)
-  asm ("int3");
-#endif
-}
-
-StackTrace::StackTrace() {
-  const int kMaxCallers = 256;
-
-  void* callers[kMaxCallers];
-#if MOZ_HAVE_EXECINFO_H
-  int count = backtrace(callers, kMaxCallers);
-#else
-  int count = 0;
-#endif
-
-  // Though the backtrace API man page does not list any possible negative
-  // return values, we still still exclude them because they would break the
-  // memcpy code below.
-  if (count > 0) {
-    trace_.resize(count);
-    memcpy(&trace_[0], callers, sizeof(callers[0]) * count);
-  } else {
-    trace_.resize(0);
-  }
-}
-
-void StackTrace::PrintBacktrace() {
-  fflush(stderr);
-#if MOZ_HAVE_EXECINFO_H
-  backtrace_symbols_fd(&trace_[0], trace_.size(), STDERR_FILENO);
-#endif
-}
-
-void StackTrace::OutputToStream(std::ostream* os) {
-  return;
-}
diff --git a/ipc/chromium/src/base/debug_util_win.cc b/ipc/chromium/src/base/debug_util_win.cc
deleted file mode 100644
index b3eb7cd6b93..00000000000
--- a/ipc/chromium/src/base/debug_util_win.cc
+++ /dev/null
@@ -1,290 +0,0 @@
-// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/debug_util.h"
-
-#include 
-#include 
-#include 
-
-#include "base/basictypes.h"
-#include "base/lock.h"
-#include "base/logging.h"
-#include "base/singleton.h"
-
-namespace {
-
-// Minimalist key reader.
-// Note: Does not use the CRT.
-bool RegReadString(HKEY root, const wchar_t* subkey,
-                   const wchar_t* value_name, wchar_t* buffer, int* len) {
-  HKEY key = NULL;
-  DWORD res = RegOpenKeyEx(root, subkey, 0, KEY_READ, &key);
-  if (ERROR_SUCCESS != res || key == NULL)
-    return false;
-
-  DWORD type = 0;
-  DWORD buffer_size = *len * sizeof(wchar_t);
-  // We don't support REG_EXPAND_SZ.
-  res = RegQueryValueEx(key, value_name, NULL, &type,
-                        reinterpret_cast(buffer), &buffer_size);
-  if (ERROR_SUCCESS == res && buffer_size != 0 && type == REG_SZ) {
-    // Make sure the buffer is NULL terminated.
-    buffer[*len - 1] = 0;
-    *len = lstrlen(buffer);
-    RegCloseKey(key);
-    return true;
-  }
-  RegCloseKey(key);
-  return false;
-}
-
-// Replaces each "%ld" in input per a value. Not efficient but it works.
-// Note: Does not use the CRT.
-bool StringReplace(const wchar_t* input, int value, wchar_t* output,
-                   int output_len) {
-  memset(output, 0, output_len*sizeof(wchar_t));
-  int input_len = lstrlen(input);
-
-  for (int i = 0; i < input_len; ++i) {
-    int current_output_len = lstrlen(output);
-
-    if (input[i] == L'%' && input[i + 1] == L'l' && input[i + 2] == L'd') {
-      // Make sure we have enough place left.
-      if ((current_output_len + 12) >= output_len)
-        return false;
-
-      // Cheap _itow().
-      wsprintf(output+current_output_len, L"%d", value);
-      i += 2;
-    } else {
-      if (current_output_len >= output_len)
-        return false;
-      output[current_output_len] = input[i];
-    }
-  }
-  return true;
-}
-
-// SymbolContext is a threadsafe singleton that wraps the DbgHelp Sym* family
-// of functions.  The Sym* family of functions may only be invoked by one
-// thread at a time.  SymbolContext code may access a symbol server over the
-// network while holding the lock for this singleton.  In the case of high
-// latency, this code will adversly affect performance.
-//
-// There is also a known issue where this backtrace code can interact
-// badly with breakpad if breakpad is invoked in a separate thread while
-// we are using the Sym* functions.  This is because breakpad does now
-// share a lock with this function.  See this related bug:
-//
-//   http://code.google.com/p/google-breakpad/issues/detail?id=311
-//
-// This is a very unlikely edge case, and the current solution is to
-// just ignore it.
-class SymbolContext {
- public:
-  static SymbolContext* Get() {
-    // We use a leaky singleton because code may call this during process
-    // termination.
-    return
-      Singleton >::get();
-  }
-
-  // Initializes the symbols for the process if it hasn't been done yet.
-  // Subsequent calls will not reinitialize the symbol, but instead return
-  // the error code from the first call.
-  bool Init() {
-    AutoLock lock(lock_);
-    if (!initialized_) {
-      process_ = GetCurrentProcess();
-
-      // Defer symbol load until they're needed, use undecorated names, and
-      // get line numbers.
-      SymSetOptions(SYMOPT_DEFERRED_LOADS |
-                    SYMOPT_UNDNAME |
-                    SYMOPT_LOAD_LINES);
-      if (SymInitialize(process_, NULL, TRUE)) {
-        init_error_ = ERROR_SUCCESS;
-      } else {
-        init_error_ = GetLastError();
-      }
-    }
-
-    initialized_ = true;
-    return init_error_ == ERROR_SUCCESS;
-  }
-
-  // Returns the error code of a failed initialization.  This should only be
-  // called if Init() has been called.  We do not CHROMIUM_LOG(FATAL) here because
-  // this code is called might be triggered by a CHROMIUM_LOG(FATAL) itself.  Instead,
-  // we log an ERROR, and return ERROR_INVALID_DATA.
-  DWORD init_error() {
-    if (!initialized_) {
-      CHROMIUM_LOG(ERROR) << "Calling GetInitError() before Init() was called.  "
-                          << "Returning ERROR_INVALID_DATA.";
-      return ERROR_INVALID_DATA;
-    }
-
-    return init_error_;
-  }
-
-  // Returns the process this was initialized for.  This should only be
-  // called if Init() has been called.  We CHROMIUM_LOG(ERROR) in this situation.
-  // CHROMIUM_LOG(FATAL) is not used because this code is might be triggered 
-  // by a CHROMIUM_LOG(FATAL) itself.
-  HANDLE process() {
-    if (!initialized_) {
-      CHROMIUM_LOG(ERROR) << "Calling process() before Init() was called. "
-                          << "Returning NULL.";
-      return NULL;
-    }
-
-    return process_;
-  }
-
-  // For the given trace, attempts to resolve the symbols, and output a trace
-  // to the ostream os.  The format for each line of the backtrace is:
-  //
-  //    SymbolName[0xAddress+Offset] (FileName:LineNo)
-  // 
-  // This function should only be called if Init() has been called.  We do not
-  // CHROMIUM_LOG(FATAL) here because this code is called might be triggered by a
-  // CHROMIUM_LOG(FATAL) itself.
-  void OutputTraceToStream(const std::vector& trace, std::ostream* os) {
-    AutoLock lock(lock_);
-
-    for (size_t i = 0; (i < trace.size()) && os->good(); ++i) {
-      const int kMaxNameLength = 256;
-      DWORD_PTR frame = reinterpret_cast(trace[i]);
-
-      // Code adapted from MSDN example:
-      // http://msdn.microsoft.com/en-us/library/ms680578(VS.85).aspx
-      ULONG64 buffer[
-        (sizeof(SYMBOL_INFO) +
-          kMaxNameLength * sizeof(wchar_t) +
-          sizeof(ULONG64) - 1) /
-        sizeof(ULONG64)];
-
-      // Initialize symbol information retrieval structures.
-      DWORD64 sym_displacement = 0;
-      PSYMBOL_INFO symbol = reinterpret_cast(&buffer[0]);
-      symbol->SizeOfStruct = sizeof(SYMBOL_INFO);
-      symbol->MaxNameLen = kMaxNameLength;
-      BOOL has_symbol = SymFromAddr(process(), frame,
-                                    &sym_displacement, symbol);
-
-      // Attempt to retrieve line number information.
-      DWORD line_displacement = 0;
-      IMAGEHLP_LINE64 line = {};
-      line.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
-      BOOL has_line = SymGetLineFromAddr64(process(), frame,
-                                           &line_displacement, &line);
-
-      // Output the backtrace line.
-      (*os) << "\t";
-      if (has_symbol) {
-        (*os) << symbol->Name << " [0x" << trace[i] << "+"
-              << sym_displacement << "]";
-      } else {
-        // If there is no symbol informtion, add a spacer.
-        (*os) << "(No symbol) [0x" << trace[i] << "]";
-      }
-      if (has_line) {
-        (*os) << " (" << line.FileName << ":" << line.LineNumber << ")";
-      }
-      (*os) << "\n";
-    }
-  }
-
-  SymbolContext()
-    : initialized_(false),
-      process_(NULL),
-      init_error_(ERROR_SUCCESS) {
-  }
-
- private:
-  Lock lock_;
-  bool initialized_;
-  HANDLE process_;
-  DWORD init_error_;
-
-  DISALLOW_COPY_AND_ASSIGN(SymbolContext);
-};
-
-}  // namespace
-
-// Note: Does not use the CRT.
-bool DebugUtil::SpawnDebuggerOnProcess(unsigned process_id) {
-  wchar_t reg_value[1026];
-  int len = arraysize(reg_value);
-  if (RegReadString(HKEY_LOCAL_MACHINE,
-      L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug",
-      L"Debugger", reg_value, &len)) {
-    wchar_t command_line[1026];
-    if (StringReplace(reg_value, process_id, command_line,
-                      arraysize(command_line))) {
-      // We don't mind if the debugger is present because it will simply fail
-      // to attach to this process.
-      STARTUPINFO startup_info = {0};
-      startup_info.cb = sizeof(startup_info);
-      PROCESS_INFORMATION process_info = {0};
-
-      if (CreateProcess(NULL, command_line, NULL, NULL, FALSE, 0, NULL, NULL,
-                        &startup_info, &process_info)) {
-        CloseHandle(process_info.hThread);
-        WaitForInputIdle(process_info.hProcess, 10000);
-        CloseHandle(process_info.hProcess);
-        return true;
-      }
-    }
-  }
-  return false;
-}
-
-// static
-bool DebugUtil::BeingDebugged() {
-  return ::IsDebuggerPresent() != 0;
-}
-
-// static
-void DebugUtil::BreakDebugger() {
-  __debugbreak();
-}
-
-StackTrace::StackTrace() {
-  // From http://msdn.microsoft.com/en-us/library/bb204633(VS.85).aspx,
-  // the sum of FramesToSkip and FramesToCapture must be less than 63,
-  // so set it to 62.
-  const int kMaxCallers = 62;
-
-  void* callers[kMaxCallers];
-  // TODO(ajwong): Migrate this to StackWalk64.
-  int count = CaptureStackBackTrace(0, kMaxCallers, callers, NULL);
-  if (count > 0) {
-    trace_.resize(count);
-    memcpy(&trace_[0], callers, sizeof(callers[0]) * count);
-  } else {
-    trace_.resize(0);
-  }
-}
-
-void StackTrace::PrintBacktrace() {
-  OutputToStream(&std::cerr);
-}
-
-void StackTrace::OutputToStream(std::ostream* os) {
-  SymbolContext* context = SymbolContext::Get();
-
-  if (context->Init() != ERROR_SUCCESS) {
-    DWORD error = context->init_error();
-    (*os) << "Error initializing symbols (" << error
-          << ").  Dumping unresolved backtrace:\n";
-    for (size_t i = 0; (i < trace_.size()) && os->good(); ++i) {
-      (*os) << "\t" << trace_[i] << "\n";
-    }
-  } else {
-    (*os) << "Backtrace:\n";
-    context->OutputTraceToStream(trace_, os);
-  }
-}
diff --git a/ipc/chromium/src/base/process_util.h b/ipc/chromium/src/base/process_util.h
index 86a4f67496b..c12e64a7cdf 100644
--- a/ipc/chromium/src/base/process_util.h
+++ b/ipc/chromium/src/base/process_util.h
@@ -13,6 +13,10 @@
 #if defined(OS_WIN)
 #include 
 #include 
+#include 
+#ifndef STDOUT_FILENO
+#define STDOUT_FILENO 1
+#endif
 #elif defined(OS_LINUX) || defined(__GLIBC__)
 #include 
 #include 
@@ -24,6 +28,11 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#ifndef OS_WIN
+#include 
+#endif
 
 #include "base/command_line.h"
 #include "base/process.h"
@@ -249,6 +258,49 @@ class ProcessMetrics {
 
 }  // namespace base
 
+namespace mozilla {
+
+class EnvironmentLog
+{
+public:
+  explicit EnvironmentLog(const char* varname) {
+    const char *e = getenv(varname);
+    if (e && *e) {
+      fname_ = e;
+    }
+  }
+
+  ~EnvironmentLog() {}
+
+  void print(const char* format, ...) {
+    if (!fname_.size())
+      return;
+
+    FILE* f;
+    if (fname_.compare("-") == 0) {
+      f = fdopen(dup(STDOUT_FILENO), "a");
+    } else {
+      f = fopen(fname_.c_str(), "a");
+    }
+
+    if (!f)
+      return;
+
+    va_list a;
+    va_start(a, format);
+    vfprintf(f, format, a);
+    va_end(a);
+    fclose(f);
+  }
+
+private:
+  std::string fname_;
+
+  DISALLOW_EVIL_CONSTRUCTORS(EnvironmentLog);
+};
+
+} // namespace mozilla
+
 #if defined(OS_WIN)
 // Undo the windows.h damage
 #undef GetMessage
diff --git a/ipc/chromium/src/base/process_util_bsd.cc b/ipc/chromium/src/base/process_util_bsd.cc
index 63243dec2e1..44a3f9aebca 100644
--- a/ipc/chromium/src/base/process_util_bsd.cc
+++ b/ipc/chromium/src/base/process_util_bsd.cc
@@ -13,7 +13,6 @@
 
 #include 
 
-#include "base/debug_util.h"
 #include "base/eintr_wrapper.h"
 #include "base/file_util.h"
 #include "base/logging.h"
diff --git a/ipc/chromium/src/base/process_util_linux.cc b/ipc/chromium/src/base/process_util_linux.cc
index 741e912b8d9..592a286ff96 100644
--- a/ipc/chromium/src/base/process_util_linux.cc
+++ b/ipc/chromium/src/base/process_util_linux.cc
@@ -14,7 +14,6 @@
 #include 
 #include 
 
-#include "base/debug_util.h"
 #include "base/eintr_wrapper.h"
 #include "base/file_util.h"
 #include "base/logging.h"
diff --git a/ipc/chromium/src/base/process_util_win.cc b/ipc/chromium/src/base/process_util_win.cc
index 976f86845eb..724720a947a 100644
--- a/ipc/chromium/src/base/process_util_win.cc
+++ b/ipc/chromium/src/base/process_util_win.cc
@@ -12,7 +12,6 @@
 #include 
 #include 
 
-#include "base/debug_util.h"
 #include "base/histogram.h"
 #include "base/logging.h"
 #include "base/scoped_handle_win.h"

From 3b5cc99fad96a05719e539a93eac4c3587626b72 Mon Sep 17 00:00:00 2001
From: Ehsan Akhgari 
Date: Wed, 3 Sep 2014 18:25:13 -0400
Subject: [PATCH 36/68] Bug 1062073 - Mark BinarySearchDefaultComparator's
 constructor as explicit; r=froydnj

--HG--
extra : rebase_source : 373682d496f5e4bcf528593dc8cdff55fe9f9698
---
 mfbt/BinarySearch.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mfbt/BinarySearch.h b/mfbt/BinarySearch.h
index 676b82e416c..e4cebdf3a76 100644
--- a/mfbt/BinarySearch.h
+++ b/mfbt/BinarySearch.h
@@ -101,7 +101,7 @@ template
 class BinarySearchDefaultComparator
 {
 public:
-  BinarySearchDefaultComparator(const T& aTarget)
+  explicit BinarySearchDefaultComparator(const T& aTarget)
     : mTarget(aTarget)
   {}
 

From 440365701411b3806cbb1b2d1c93a1d0054316ae Mon Sep 17 00:00:00 2001
From: Ehsan Akhgari 
Date: Wed, 3 Sep 2014 18:25:36 -0400
Subject: [PATCH 37/68] Bug 1060974 - Fix more bad implicit constructors in
 places; r=mak

--HG--
extra : rebase_source : c8d465b4de55d000d1475994827766e33396ff12
---
 .../components/places/AsyncFaviconHelpers.h   |  2 +-
 toolkit/components/places/Helpers.h           |  8 +++----
 toolkit/components/places/History.cpp         | 22 +++++++++----------
 toolkit/components/places/History.h           |  2 +-
 toolkit/components/places/nsFaviconService.h  |  2 +-
 toolkit/components/places/nsMaybeWeakPtr.h    |  7 +++---
 toolkit/components/places/nsNavBookmarks.h    |  4 ++--
 toolkit/components/places/nsNavHistory.cpp    |  4 ++--
 toolkit/components/places/nsNavHistory.h      |  2 +-
 .../components/places/nsNavHistoryResult.h    |  4 ++--
 .../components/places/tests/cpp/mock_Link.h   |  4 ++--
 .../places/tests/cpp/places_test_harness.h    |  2 +-
 .../places/tests/cpp/test_IHistory.cpp        |  2 +-
 13 files changed, 33 insertions(+), 32 deletions(-)

diff --git a/toolkit/components/places/AsyncFaviconHelpers.h b/toolkit/components/places/AsyncFaviconHelpers.h
index 026d2b5678a..5d09ee045a0 100644
--- a/toolkit/components/places/AsyncFaviconHelpers.h
+++ b/toolkit/components/places/AsyncFaviconHelpers.h
@@ -100,7 +100,7 @@ struct PageData
 class AsyncFaviconHelperBase : public nsRunnable
 {
 protected:
-  AsyncFaviconHelperBase(nsCOMPtr& aCallback);
+  explicit AsyncFaviconHelperBase(nsCOMPtr& aCallback);
 
   virtual ~AsyncFaviconHelperBase();
 
diff --git a/toolkit/components/places/Helpers.h b/toolkit/components/places/Helpers.h
index 8d3a75c2e9f..5033b5db5a6 100644
--- a/toolkit/components/places/Helpers.h
+++ b/toolkit/components/places/Helpers.h
@@ -219,7 +219,7 @@ public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIRUNNABLE
 
-  PlacesEvent(const char* aTopic);
+  explicit PlacesEvent(const char* aTopic);
 protected:
   ~PlacesEvent() {}
   void Notify();
@@ -233,7 +233,7 @@ protected:
 class AsyncStatementCallbackNotifier : public AsyncStatementCallback
 {
 public:
-  AsyncStatementCallbackNotifier(const char* aTopic)
+  explicit AsyncStatementCallbackNotifier(const char* aTopic)
     : mTopic(aTopic)
   {
   }
@@ -250,8 +250,8 @@ private:
 class AsyncStatementTelemetryTimer : public AsyncStatementCallback
 {
 public:
-  AsyncStatementTelemetryTimer(Telemetry::ID aHistogramId,
-                               TimeStamp aStart = TimeStamp::Now())
+  explicit AsyncStatementTelemetryTimer(Telemetry::ID aHistogramId,
+                                        TimeStamp aStart = TimeStamp::Now())
     : mHistogramId(aHistogramId)
     , mStart(aStart)
   {
diff --git a/toolkit/components/places/History.cpp b/toolkit/components/places/History.cpp
index 7cfbb6dcf0b..f0aa0ebbee0 100644
--- a/toolkit/components/places/History.cpp
+++ b/toolkit/components/places/History.cpp
@@ -83,8 +83,8 @@ struct VisitData {
     title.SetIsVoid(true);
   }
 
-  VisitData(nsIURI* aURI,
-            nsIURI* aReferrer = nullptr)
+  explicit VisitData(nsIURI* aURI,
+                     nsIURI* aReferrer = nullptr)
   : placeId(0)
   , visitId(0)
   , hidden(true)
@@ -186,14 +186,14 @@ struct RemoveVisitsFilter {
 class PlaceHashKey : public nsCStringHashKey
 {
   public:
-    PlaceHashKey(const nsACString& aSpec)
+    explicit PlaceHashKey(const nsACString& aSpec)
     : nsCStringHashKey(&aSpec)
     , visitCount(-1)
     , bookmarked(-1)
     {
     }
 
-    PlaceHashKey(const nsACString* aSpec)
+    explicit PlaceHashKey(const nsACString* aSpec)
     : nsCStringHashKey(aSpec)
     , visitCount(-1)
     , bookmarked(-1)
@@ -551,9 +551,9 @@ public:
   }
 
 private:
-  VisitedQuery(nsIURI* aURI,
-               mozIVisitedStatusCallback *aCallback=nullptr,
-               bool aIsVisited=false)
+  explicit VisitedQuery(nsIURI* aURI,
+                        mozIVisitedStatusCallback *aCallback=nullptr,
+                        bool aIsVisited=false)
   : mURI(aURI)
   , mCallback(aCallback)
   , mIsVisited(aIsVisited)
@@ -758,7 +758,7 @@ private:
 class NotifyCompletion : public nsRunnable
 {
 public:
-  NotifyCompletion(mozIVisitInfoCallback* aCallback)
+  explicit NotifyCompletion(mozIVisitInfoCallback* aCallback)
   : mCallback(aCallback)
   {
     MOZ_ASSERT(aCallback, "Must pass a non-null callback!");
@@ -1462,7 +1462,7 @@ class SetDownloadAnnotations MOZ_FINAL : public mozIVisitInfoCallback
 public:
   NS_DECL_ISUPPORTS
 
-  SetDownloadAnnotations(nsIURI* aDestination)
+  explicit SetDownloadAnnotations(nsIURI* aDestination)
   : mDestination(aDestination)
   , mHistory(History::GetService())
   {
@@ -1611,7 +1611,7 @@ class NotifyRemoveVisits : public nsRunnable
 {
 public:
 
-  NotifyRemoveVisits(nsTHashtable& aPlaces)
+  explicit NotifyRemoveVisits(nsTHashtable& aPlaces)
     : mPlaces(VISITS_REMOVAL_INITIAL_HASH_LENGTH)
     , mHistory(History::GetService())
   {
@@ -2029,7 +2029,7 @@ class ConcurrentStatementsHolder MOZ_FINAL : public mozIStorageCompletionCallbac
 public:
   NS_DECL_ISUPPORTS
 
-  ConcurrentStatementsHolder(mozIStorageConnection* aDBConn)
+  explicit ConcurrentStatementsHolder(mozIStorageConnection* aDBConn)
   {
     DebugOnly rv = aDBConn->AsyncClone(true, this);
     MOZ_ASSERT(NS_SUCCEEDED(rv));
diff --git a/toolkit/components/places/History.h b/toolkit/components/places/History.h
index e486716d3db..476ca2f5c34 100644
--- a/toolkit/components/places/History.h
+++ b/toolkit/components/places/History.h
@@ -170,7 +170,7 @@ private:
   class KeyClass : public nsURIHashKey
   {
   public:
-    KeyClass(const nsIURI* aURI)
+    explicit KeyClass(const nsIURI* aURI)
     : nsURIHashKey(aURI)
     {
     }
diff --git a/toolkit/components/places/nsFaviconService.h b/toolkit/components/places/nsFaviconService.h
index 00406a1faf7..9fddbd95817 100644
--- a/toolkit/components/places/nsFaviconService.h
+++ b/toolkit/components/places/nsFaviconService.h
@@ -38,7 +38,7 @@ class mozIStorageStatementCallback;
 class UnassociatedIconHashKey : public nsURIHashKey
 {
 public:
-  UnassociatedIconHashKey(const nsIURI* aURI)
+  explicit UnassociatedIconHashKey(const nsIURI* aURI)
   : nsURIHashKey(aURI)
   {
   }
diff --git a/toolkit/components/places/nsMaybeWeakPtr.h b/toolkit/components/places/nsMaybeWeakPtr.h
index 4e66e9a3fee..08503ad60df 100644
--- a/toolkit/components/places/nsMaybeWeakPtr.h
+++ b/toolkit/components/places/nsMaybeWeakPtr.h
@@ -6,6 +6,7 @@
 #ifndef nsMaybeWeakPtr_h_
 #define nsMaybeWeakPtr_h_
 
+#include "mozilla/Attributes.h"
 #include "nsCOMPtr.h"
 #include "nsWeakReference.h"
 #include "nsTArray.h"
@@ -27,9 +28,9 @@ template
 class nsMaybeWeakPtr : private nsMaybeWeakPtr_base
 {
 public:
-  nsMaybeWeakPtr(nsISupports *ref) { mPtr = ref; }
-  nsMaybeWeakPtr(const nsCOMPtr &ref) { mPtr = ref; }
-  nsMaybeWeakPtr(const nsCOMPtr &ref) { mPtr = ref; }
+  MOZ_IMPLICIT nsMaybeWeakPtr(nsISupports *ref) { mPtr = ref; }
+  MOZ_IMPLICIT nsMaybeWeakPtr(const nsCOMPtr &ref) { mPtr = ref; }
+  MOZ_IMPLICIT nsMaybeWeakPtr(const nsCOMPtr &ref) { mPtr = ref; }
 
   bool operator==(const nsMaybeWeakPtr &other) const {
     return mPtr == other.mPtr;
diff --git a/toolkit/components/places/nsNavBookmarks.h b/toolkit/components/places/nsNavBookmarks.h
index 595f296aa39..a44eae3852b 100644
--- a/toolkit/components/places/nsNavBookmarks.h
+++ b/toolkit/components/places/nsNavBookmarks.h
@@ -64,7 +64,7 @@ namespace places {
   class BookmarkKeyClass : public nsTrimInt64HashKey
   {
     public:
-    BookmarkKeyClass(const int64_t* aItemId)
+    explicit BookmarkKeyClass(const int64_t* aItemId)
     : nsTrimInt64HashKey(aItemId)
     , creationTime(PR_Now())
     {
@@ -373,7 +373,7 @@ private:
 
   class RemoveFolderTransaction MOZ_FINAL : public nsITransaction {
   public:
-    RemoveFolderTransaction(int64_t aID) : mID(aID) {}
+    explicit RemoveFolderTransaction(int64_t aID) : mID(aID) {}
 
     NS_DECL_ISUPPORTS
 
diff --git a/toolkit/components/places/nsNavHistory.cpp b/toolkit/components/places/nsNavHistory.cpp
index dde3e0c8ecf..9886ac651d3 100644
--- a/toolkit/components/places/nsNavHistory.cpp
+++ b/toolkit/components/places/nsNavHistory.cpp
@@ -215,7 +215,7 @@ void GetTagsSqlFragment(int64_t aTagsFolder,
 class UpdateBatchScoper
 {
 public:
-  UpdateBatchScoper(nsNavHistory& aNavHistory) : mNavHistory(aNavHistory)
+  explicit UpdateBatchScoper(nsNavHistory& aNavHistory) : mNavHistory(aNavHistory)
   {
     mNavHistory.BeginUpdateBatch();
   }
@@ -3191,7 +3191,7 @@ class ConditionBuilder
 {
 public:
 
-  ConditionBuilder(int32_t aQueryIndex): mQueryIndex(aQueryIndex)
+  explicit ConditionBuilder(int32_t aQueryIndex): mQueryIndex(aQueryIndex)
   { }
 
   ConditionBuilder& Condition(const char* aStr)
diff --git a/toolkit/components/places/nsNavHistory.h b/toolkit/components/places/nsNavHistory.h
index b2ebcec72b6..7233734f52e 100644
--- a/toolkit/components/places/nsNavHistory.h
+++ b/toolkit/components/places/nsNavHistory.h
@@ -537,7 +537,7 @@ protected:
   class VisitHashKey : public nsURIHashKey
   {
   public:
-    VisitHashKey(const nsIURI* aURI)
+    explicit VisitHashKey(const nsIURI* aURI)
     : nsURIHashKey(aURI)
     {
     }
diff --git a/toolkit/components/places/nsNavHistoryResult.h b/toolkit/components/places/nsNavHistoryResult.h
index f0a636812ae..25baafe30e5 100644
--- a/toolkit/components/places/nsNavHistoryResult.h
+++ b/toolkit/components/places/nsNavHistoryResult.h
@@ -41,7 +41,7 @@ public:
   typedef const int64_t& KeyType;
   typedef const int64_t* KeyTypePointer;
 
-  nsTrimInt64HashKey(KeyTypePointer aKey) : mValue(*aKey) { }
+  explicit nsTrimInt64HashKey(KeyTypePointer aKey) : mValue(*aKey) { }
   nsTrimInt64HashKey(const nsTrimInt64HashKey& toCopy) : mValue(toCopy.mValue) { }
   ~nsTrimInt64HashKey() { }
 
@@ -135,7 +135,7 @@ public:
 
 public:
   // two-stage init, use NewHistoryResult to construct
-  nsNavHistoryResult(nsNavHistoryContainerResultNode* mRoot);
+  explicit nsNavHistoryResult(nsNavHistoryContainerResultNode* mRoot);
   nsresult Init(nsINavHistoryQuery** aQueries,
                 uint32_t aQueryCount,
                 nsNavHistoryQueryOptions *aOptions);
diff --git a/toolkit/components/places/tests/cpp/mock_Link.h b/toolkit/components/places/tests/cpp/mock_Link.h
index 7f049fbebd1..fdd0386cd59 100644
--- a/toolkit/components/places/tests/cpp/mock_Link.h
+++ b/toolkit/components/places/tests/cpp/mock_Link.h
@@ -20,8 +20,8 @@ class mock_Link : public mozilla::dom::Link
 public:
   NS_DECL_ISUPPORTS
 
-  mock_Link(void (*aHandlerFunction)(nsLinkState),
-            bool aRunNextTest = true)
+  explicit mock_Link(void (*aHandlerFunction)(nsLinkState),
+                     bool aRunNextTest = true)
   : mozilla::dom::Link(nullptr)
   , mHandler(aHandlerFunction)
   , mRunNextTest(aRunNextTest)
diff --git a/toolkit/components/places/tests/cpp/places_test_harness.h b/toolkit/components/places/tests/cpp/places_test_harness.h
index 16d12f660be..4fae57b678f 100644
--- a/toolkit/components/places/tests/cpp/places_test_harness.h
+++ b/toolkit/components/places/tests/cpp/places_test_harness.h
@@ -102,7 +102,7 @@ class WaitForTopicSpinner MOZ_FINAL : public nsIObserver
 public:
   NS_DECL_ISUPPORTS
 
-  WaitForTopicSpinner(const char* const aTopic)
+  explicit WaitForTopicSpinner(const char* const aTopic)
   : mTopicReceived(false)
   , mStartTime(PR_IntervalNow())
   {
diff --git a/toolkit/components/places/tests/cpp/test_IHistory.cpp b/toolkit/components/places/tests/cpp/test_IHistory.cpp
index dcc03dd67e9..351f92dc5d3 100644
--- a/toolkit/components/places/tests/cpp/test_IHistory.cpp
+++ b/toolkit/components/places/tests/cpp/test_IHistory.cpp
@@ -54,7 +54,7 @@ class VisitURIObserver MOZ_FINAL : public nsIObserver
 public:
   NS_DECL_ISUPPORTS
 
-  VisitURIObserver(int aExpectedVisits = 1) :
+  explicit VisitURIObserver(int aExpectedVisits = 1) :
     mVisits(0),
     mExpectedVisits(aExpectedVisits)
   {

From 19586b7c3c5a5b20fbe7a4738495498b87a95424 Mon Sep 17 00:00:00 2001
From: Ehsan Akhgari 
Date: Wed, 3 Sep 2014 18:25:57 -0400
Subject: [PATCH 38/68] Bug 1061053 - Fix more bad implicit constructors in
 storage; r=mak

--HG--
extra : rebase_source : a18eaa1cf7968fb5b8c8923d85bd99d77c427e6e
---
 storage/test/test_StatementCache.cpp                       | 7 ++++---
 .../test/test_async_callbacks_with_spun_event_loops.cpp    | 2 +-
 storage/test/test_true_async.cpp                           | 2 +-
 storage/test/test_unlock_notify.cpp                        | 2 +-
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/storage/test/test_StatementCache.cpp b/storage/test/test_StatementCache.cpp
index 620eaa2df30..731a858de9a 100644
--- a/storage/test/test_StatementCache.cpp
+++ b/storage/test/test_StatementCache.cpp
@@ -6,6 +6,7 @@
 
 #include "storage_test_harness.h"
 
+#include "mozilla/Attributes.h"
 #include "mozilla/storage/StatementCache.h"
 using namespace mozilla::storage;
 
@@ -19,7 +20,7 @@ using namespace mozilla::storage;
 class SyncCache : public StatementCache
 {
 public:
-  SyncCache(nsCOMPtr& aConnection)
+  explicit SyncCache(nsCOMPtr& aConnection)
   : StatementCache(aConnection)
   {
   }
@@ -28,7 +29,7 @@ public:
 class AsyncCache : public StatementCache
 {
 public:
-  AsyncCache(nsCOMPtr& aConnection)
+  explicit AsyncCache(nsCOMPtr& aConnection)
   : StatementCache(aConnection)
   {
   }
@@ -41,7 +42,7 @@ public:
 class StringWrapper : public nsCString
 {
 public:
-  StringWrapper(const char* aOther)
+  MOZ_IMPLICIT StringWrapper(const char* aOther)
   {
     this->Assign(aOther);
   }
diff --git a/storage/test/test_async_callbacks_with_spun_event_loops.cpp b/storage/test/test_async_callbacks_with_spun_event_loops.cpp
index f509aa277b1..063997ae547 100644
--- a/storage/test/test_async_callbacks_with_spun_event_loops.cpp
+++ b/storage/test/test_async_callbacks_with_spun_event_loops.cpp
@@ -41,7 +41,7 @@ public:
   // Whether an error was received.
   static bool sError;
 
-  UnownedCallback(mozIStorageConnection* aDBConn)
+  explicit UnownedCallback(mozIStorageConnection* aDBConn)
   : mDBConn(aDBConn)
   , mCompleted(false)
   {
diff --git a/storage/test/test_true_async.cpp b/storage/test/test_true_async.cpp
index 34ec873f2d1..4782494930b 100644
--- a/storage/test/test_true_async.cpp
+++ b/storage/test/test_true_async.cpp
@@ -107,7 +107,7 @@ void watch_for_mutex_use_on_this_thread()
 class ThreadWedger : public nsRunnable
 {
 public:
-  ThreadWedger(nsIEventTarget *aTarget)
+  explicit ThreadWedger(nsIEventTarget *aTarget)
   : mReentrantMonitor("thread wedger")
   , unwedged(false)
   {
diff --git a/storage/test/test_unlock_notify.cpp b/storage/test/test_unlock_notify.cpp
index 73ae74ebbd3..2726d0cea78 100644
--- a/storage/test/test_unlock_notify.cpp
+++ b/storage/test/test_unlock_notify.cpp
@@ -28,7 +28,7 @@ enum State {
 class DatabaseLocker : public nsRunnable
 {
 public:
-  DatabaseLocker(const char* aSQL)
+  explicit DatabaseLocker(const char* aSQL)
   : monitor("DatabaseLocker::monitor")
   , mSQL(aSQL)
   , mState(STARTING)

From db6fd5144c5f7a427900d0414df5daf072b21315 Mon Sep 17 00:00:00 2001
From: Josh Aas 
Date: Wed, 3 Sep 2014 23:56:40 -0500
Subject: [PATCH 39/68] Bug 1062715 - remove Chromium event recorder, memory
 debug, simple thread, drag and drop code. rs=bent

---
 dom/media/bridge/MediaModule.cpp              |   2 -
 ipc/chromium/moz.build                        |   4 -
 ipc/chromium/src/base/base_drag_source.h      |  46 ----
 ipc/chromium/src/base/base_drop_target.h      | 130 ---------
 ipc/chromium/src/base/event_recorder.cc       | 259 ------------------
 ipc/chromium/src/base/event_recorder.h        | 102 -------
 ipc/chromium/src/base/event_recorder_stubs.cc |  28 --
 ipc/chromium/src/base/memory_debug.cc         |  54 ----
 ipc/chromium/src/base/memory_debug.h          |  46 ----
 ipc/chromium/src/base/simple_thread.cc        | 118 --------
 ipc/chromium/src/base/simple_thread.h         | 189 -------------
 11 files changed, 978 deletions(-)
 delete mode 100644 ipc/chromium/src/base/base_drag_source.h
 delete mode 100644 ipc/chromium/src/base/base_drop_target.h
 delete mode 100644 ipc/chromium/src/base/event_recorder.cc
 delete mode 100644 ipc/chromium/src/base/event_recorder.h
 delete mode 100644 ipc/chromium/src/base/event_recorder_stubs.cc
 delete mode 100644 ipc/chromium/src/base/memory_debug.cc
 delete mode 100644 ipc/chromium/src/base/memory_debug.h
 delete mode 100644 ipc/chromium/src/base/simple_thread.cc
 delete mode 100644 ipc/chromium/src/base/simple_thread.h

diff --git a/dom/media/bridge/MediaModule.cpp b/dom/media/bridge/MediaModule.cpp
index 8d6afff795e..9a2fbb3e32b 100644
--- a/dom/media/bridge/MediaModule.cpp
+++ b/dom/media/bridge/MediaModule.cpp
@@ -2,8 +2,6 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "base/linked_ptr.h"
-
 #include "mozilla/ModuleUtils.h"
 #include "nsIClassInfoImpl.h"
 
diff --git a/ipc/chromium/moz.build b/ipc/chromium/moz.build
index adde7bae520..651e0a0016a 100644
--- a/ipc/chromium/moz.build
+++ b/ipc/chromium/moz.build
@@ -45,7 +45,6 @@ UNIFIED_SOURCES += [
     'src/base/lazy_instance.cc',
     'src/base/lock.cc',
     'src/base/logging.cc',
-    'src/base/memory_debug.cc',
     'src/base/message_loop.cc',
     'src/base/message_pump_default.cc',
     'src/base/non_thread_safe.cc',
@@ -54,7 +53,6 @@ UNIFIED_SOURCES += [
     'src/base/ref_counted.cc',
     'src/base/revocable_store.cc',
     'src/base/scoped_temp_dir.cc',
-    'src/base/simple_thread.cc',
     'src/base/string_piece.cc',
     'src/base/string_util.cc',
     'src/base/thread.cc',
@@ -84,7 +82,6 @@ if os_win:
     SOURCES += [
         'src/base/condition_variable_win.cc',
         'src/base/cpu.cc',
-        'src/base/event_recorder.cc',
         'src/base/file_util_win.cc',
         'src/base/idle_timer.cc',
         'src/base/lock_impl_win.cc',
@@ -141,7 +138,6 @@ elif not CONFIG['MOZ_NATIVE_LIBEVENT']:
 if os_posix:
     SOURCES += [
         'src/base/condition_variable_posix.cc',
-        'src/base/event_recorder_stubs.cc',
         'src/base/file_descriptor_shuffle.cc',
         'src/base/file_util_posix.cc',
         'src/base/lock_impl_posix.cc',
diff --git a/ipc/chromium/src/base/base_drag_source.h b/ipc/chromium/src/base/base_drag_source.h
deleted file mode 100644
index dea89aff022..00000000000
--- a/ipc/chromium/src/base/base_drag_source.h
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_BASE_DRAG_SOURCE_H_
-#define BASE_BASE_DRAG_SOURCE_H_
-
-#include 
-
-#include "base/basictypes.h"
-
-///////////////////////////////////////////////////////////////////////////////
-//
-// BaseDragSource
-//
-//  A base IDropSource implementation. Handles notifications sent by an active
-//  drag-drop operation as the user mouses over other drop targets on their
-//  system. This object tells Windows whether or not the drag should continue,
-//  and supplies the appropriate cursors.
-//
-class BaseDragSource : public IDropSource {
- public:
-  BaseDragSource();
-  virtual ~BaseDragSource() { }
-
-  // IDropSource implementation:
-  HRESULT __stdcall QueryContinueDrag(BOOL escape_pressed, DWORD key_state);
-  HRESULT __stdcall GiveFeedback(DWORD effect);
-
-  // IUnknown implementation:
-  HRESULT __stdcall QueryInterface(const IID& iid, void** object);
-  ULONG __stdcall AddRef();
-  ULONG __stdcall Release();
-
- protected:
-  virtual void OnDragSourceCancel() { }
-  virtual void OnDragSourceDrop() { }
-  virtual void OnDragSourceMove() { }
-
- private:
-  LONG ref_count_;
-
-  DISALLOW_EVIL_CONSTRUCTORS(BaseDragSource);
-};
-
-#endif  // BASE_BASE_DRAG_SOURCE_H_
diff --git a/ipc/chromium/src/base/base_drop_target.h b/ipc/chromium/src/base/base_drop_target.h
deleted file mode 100644
index a83f0eccb64..00000000000
--- a/ipc/chromium/src/base/base_drop_target.h
+++ /dev/null
@@ -1,130 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_BASE_DROP_TARGET_H_
-#define BASE_BASE_DROP_TARGET_H_
-
-#include 
-
-#include "base/ref_counted.h"
-
-struct IDropTargetHelper;
-
-// A DropTarget implementation that takes care of the nitty gritty
-// of dnd. While this class is concrete, subclasses will most likely
-// want to override various OnXXX methods.
-//
-// Because BaseDropTarget is ref counted you shouldn't delete it directly,
-// rather wrap it in a scoped_refptr. Be sure and invoke RevokeDragDrop(m_hWnd)
-// before the HWND is deleted too.
-//
-// This class is meant to be used in a STA and is not multithread-safe.
-class BaseDropTarget : public IDropTarget {
- public:
-  // Create a new BaseDropTarget associating it with the given HWND.
-  explicit BaseDropTarget(HWND hwnd);
-  virtual ~BaseDropTarget();
-
-  // When suspend is set to |true|, the drop target does not receive drops from
-  // drags initiated within the owning HWND.
-  // TODO(beng): (http://b/1085385) figure out how we will handle legitimate
-  //             drag-drop operations within the same HWND, such as dragging
-  //             selected text to an edit field.
-  void set_suspend(bool suspend) { suspend_ = suspend; }
-
-  // IDropTarget implementation:
-  HRESULT __stdcall DragEnter(IDataObject* data_object,
-                              DWORD key_state,
-                              POINTL cursor_position,
-                              DWORD* effect);
-  HRESULT __stdcall DragOver(DWORD key_state,
-                             POINTL cursor_position,
-                             DWORD* effect);
-  HRESULT __stdcall DragLeave();
-  HRESULT __stdcall Drop(IDataObject* data_object,
-                         DWORD key_state,
-                         POINTL cursor_position,
-                         DWORD* effect);
-
-  // IUnknown implementation:
-  HRESULT __stdcall QueryInterface(const IID& iid, void** object);
-  ULONG __stdcall AddRef();
-  ULONG __stdcall Release();
-
- protected:
-  // Returns the hosting HWND.
-  HWND GetHWND() { return hwnd_; }
-
-  // Invoked when the cursor first moves over the hwnd during a dnd session.
-  // This should return a bitmask of the supported drop operations:
-  // DROPEFFECT_NONE, DROPEFFECT_COPY, DROPEFFECT_LINK and/or
-  // DROPEFFECT_MOVE.
-  virtual DWORD OnDragEnter(IDataObject* data_object,
-                            DWORD key_state,
-                            POINT cursor_position,
-                            DWORD effect);
-
-  // Invoked when the cursor moves over the window during a dnd session.
-  // This should return a bitmask of the supported drop operations:
-  // DROPEFFECT_NONE, DROPEFFECT_COPY, DROPEFFECT_LINK and/or
-  // DROPEFFECT_MOVE.
-  virtual DWORD OnDragOver(IDataObject* data_object,
-                           DWORD key_state,
-                           POINT cursor_position,
-                           DWORD effect);
-
-  // Invoked when the cursor moves outside the bounds of the hwnd during a
-  // dnd session.
-  virtual void OnDragLeave(IDataObject* data_object);
-
-  // Invoked when the drop ends on the window. This should return the operation
-  // that was taken.
-  virtual DWORD OnDrop(IDataObject* data_object,
-                       DWORD key_state,
-                       POINT cursor_position,
-                       DWORD effect);
-
-  // Return the drag identity.
-  static int32_t GetDragIdentity() { return drag_identity_; }
-
- private:
-  // Returns the cached drop helper, creating one if necessary. The returned
-  // object is not addrefed. May return NULL if the object couldn't be created.
-  static IDropTargetHelper* DropHelper();
-
-  // The data object currently being dragged over this drop target.
-  scoped_refptr current_data_object_;
-
-  // A helper object that is used to provide drag image support while the mouse
-  // is dragging over the content area.
-  //
-  // DO NOT ACCESS DIRECTLY! Use DropHelper() instead, which will lazily create
-  // this if it doesn't exist yet. This object can take tens of milliseconds to
-  // create, and we don't want to block any window opening for this, especially
-  // since often, DnD will never be used. Instead, we force this penalty to the
-  // first time it is actually used.
-  static IDropTargetHelper* cached_drop_target_helper_;
-
-  // The drag identity (id). An up-counter that increases when the cursor first
-  // moves over the HWND in a DnD session (OnDragEnter). 0 is reserved to mean
-  // the "no/unknown" identity, and is used for initialization. The identity is
-  // sent to the renderer in drag enter notifications. Note: the identity value
-  // is passed over the renderer NPAPI interface to gears, so use int32_t instead
-  // of int here.
-  static int32_t drag_identity_;
-
-  // The HWND of the source. This HWND is used to determine coordinates for
-  // mouse events that are sent to the renderer notifying various drag states.
-  HWND hwnd_;
-
-  // Whether or not we are currently processing drag notifications for drags
-  // initiated in this window.
-  bool suspend_;
-
-  LONG ref_count_;
-
-  DISALLOW_EVIL_CONSTRUCTORS(BaseDropTarget);
-};
-
-#endif  // BASE_BASE_DROP_TARGET_H_
diff --git a/ipc/chromium/src/base/event_recorder.cc b/ipc/chromium/src/base/event_recorder.cc
deleted file mode 100644
index 92128af7035..00000000000
--- a/ipc/chromium/src/base/event_recorder.cc
+++ /dev/null
@@ -1,259 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "build/build_config.h"
-
-#include 
-#include 
-
-#include "base/event_recorder.h"
-#include "base/file_util.h"
-#include "base/logging.h"
-
-// A note about time.
-// For perfect playback of events, you'd like a very accurate timer
-// so that events are played back at exactly the same time that
-// they were recorded.  However, windows has a clock which is only
-// granular to ~15ms.  We see more consistent event playback when
-// using a higher resolution timer.  To do this, we use the
-// timeGetTime API instead of the default GetTickCount() API.
-
-namespace base {
-
-EventRecorder* EventRecorder::current_ = NULL;
-
-LRESULT CALLBACK StaticRecordWndProc(int nCode, WPARAM wParam,
-                                     LPARAM lParam) {
-  CHECK(EventRecorder::current());
-  return EventRecorder::current()->RecordWndProc(nCode, wParam, lParam);
-}
-
-LRESULT CALLBACK StaticPlaybackWndProc(int nCode, WPARAM wParam,
-                                       LPARAM lParam) {
-  CHECK(EventRecorder::current());
-  return EventRecorder::current()->PlaybackWndProc(nCode, wParam, lParam);
-}
-
-EventRecorder::~EventRecorder() {
-  // Try to assert early if the caller deletes the recorder
-  // while it is still in use.
-  DCHECK(!journal_hook_);
-  DCHECK(!is_recording_ && !is_playing_);
-}
-
-bool EventRecorder::StartRecording(const FilePath& filename) {
-  if (journal_hook_ != NULL)
-    return false;
-  if (is_recording_ || is_playing_)
-    return false;
-
-  // Open the recording file.
-  DCHECK(file_ == NULL);
-  file_ = file_util::OpenFile(filename, "wb+");
-  if (!file_) {
-    DLOG(ERROR) << "EventRecorder could not open log file";
-    return false;
-  }
-
-  // Set the faster clock, if possible.
-  ::timeBeginPeriod(1);
-
-  // Set the recording hook.  JOURNALRECORD can only be used as a global hook.
-  journal_hook_ = ::SetWindowsHookEx(WH_JOURNALRECORD, StaticRecordWndProc,
-                                     GetModuleHandle(NULL), 0);
-  if (!journal_hook_) {
-    DLOG(ERROR) << "EventRecorder Record Hook failed";
-    file_util::CloseFile(file_);
-    return false;
-  }
-
-  is_recording_ = true;
-  return true;
-}
-
-void EventRecorder::StopRecording() {
-  if (is_recording_) {
-    DCHECK(journal_hook_ != NULL);
-
-    if (!::UnhookWindowsHookEx(journal_hook_)) {
-      DLOG(ERROR) << "EventRecorder Unhook failed";
-      // Nothing else we can really do here.
-      return;
-    }
-
-    ::timeEndPeriod(1);
-
-    DCHECK(file_ != NULL);
-    file_util::CloseFile(file_);
-    file_ = NULL;
-
-    journal_hook_ = NULL;
-    is_recording_ = false;
-  }
-}
-
-bool EventRecorder::StartPlayback(const FilePath& filename) {
-  if (journal_hook_ != NULL)
-    return false;
-  if (is_recording_ || is_playing_)
-    return false;
-
-  // Open the recording file.
-  DCHECK(file_ == NULL);
-  file_ = file_util::OpenFile(filename, "rb");
-  if (!file_) {
-    DLOG(ERROR) << "EventRecorder Playback could not open log file";
-    return false;
-  }
-  // Read the first event from the record.
-  if (fread(&playback_msg_, sizeof(EVENTMSG), 1, file_) != 1) {
-    DLOG(ERROR) << "EventRecorder Playback has no records!";
-    file_util::CloseFile(file_);
-    return false;
-  }
-
-  // Set the faster clock, if possible.
-  ::timeBeginPeriod(1);
-
-  // Playback time is tricky.  When playing back, we read a series of events,
-  // each with timeouts.  Simply subtracting the delta between two timers will
-  // lead to fast playback (about 2x speed).  The API has two events, one
-  // which advances to the next event (HC_SKIP), and another that requests the
-  // event (HC_GETNEXT).  The same event will be requested multiple times.
-  // Each time the event is requested, we must calculate the new delay.
-  // To do this, we track the start time of the playback, and constantly
-  // re-compute the delay.   I mention this only because I saw two examples
-  // of how to use this code on the net, and both were broken :-)
-  playback_start_time_ = timeGetTime();
-  playback_first_msg_time_ = playback_msg_.time;
-
-  // Set the hook.  JOURNALPLAYBACK can only be used as a global hook.
-  journal_hook_ = ::SetWindowsHookEx(WH_JOURNALPLAYBACK, StaticPlaybackWndProc,
-                                     GetModuleHandle(NULL), 0);
-  if (!journal_hook_) {
-    DLOG(ERROR) << "EventRecorder Playback Hook failed";
-    return false;
-  }
-
-  is_playing_ = true;
-
-  return true;
-}
-
-void EventRecorder::StopPlayback() {
-  if (is_playing_) {
-    DCHECK(journal_hook_ != NULL);
-
-    if (!::UnhookWindowsHookEx(journal_hook_)) {
-      DLOG(ERROR) << "EventRecorder Unhook failed";
-      // Nothing else we can really do here.
-    }
-
-    DCHECK(file_ != NULL);
-    file_util::CloseFile(file_);
-    file_ = NULL;
-
-    ::timeEndPeriod(1);
-
-    journal_hook_ = NULL;
-    is_playing_ = false;
-  }
-}
-
-// Windows callback hook for the recorder.
-LRESULT EventRecorder::RecordWndProc(int nCode, WPARAM wParam, LPARAM lParam) {
-  static bool recording_enabled = true;
-  EVENTMSG* msg_ptr = NULL;
-
-  // The API says we have to do this.
-  // See http://msdn2.microsoft.com/en-us/library/ms644983(VS.85).aspx
-  if (nCode < 0)
-    return ::CallNextHookEx(journal_hook_, nCode, wParam, lParam);
-
-  // Check for the break key being pressed and stop recording.
-  if (::GetKeyState(VK_CANCEL) & 0x8000) {
-    StopRecording();
-    return ::CallNextHookEx(journal_hook_, nCode, wParam, lParam);
-  }
-
-  // The Journal Recorder must stop recording events when system modal
-  // dialogs are present. (see msdn link above)
-  switch(nCode) {
-    case HC_SYSMODALON:
-      recording_enabled = false;
-      break;
-    case HC_SYSMODALOFF:
-      recording_enabled = true;
-      break;
-  }
-
-  if (nCode == HC_ACTION && recording_enabled) {
-    // Aha - we have an event to record.
-    msg_ptr = reinterpret_cast(lParam);
-    msg_ptr->time = timeGetTime();
-    fwrite(msg_ptr, sizeof(EVENTMSG), 1, file_);
-    fflush(file_);
-  }
-
-  return CallNextHookEx(journal_hook_, nCode, wParam, lParam);
-}
-
-// Windows callback for the playback mode.
-LRESULT EventRecorder::PlaybackWndProc(int nCode, WPARAM wParam,
-                                       LPARAM lParam) {
-  static bool playback_enabled = true;
-  int delay = 0;
-
-  switch(nCode) {
-    // A system modal dialog box is being displayed.  Stop playing back
-    // messages.
-    case HC_SYSMODALON:
-      playback_enabled = false;
-      break;
-
-    // A system modal dialog box is destroyed.  We can start playing back
-    // messages again.
-    case HC_SYSMODALOFF:
-      playback_enabled = true;
-      break;
-
-    // Prepare to copy the next mouse or keyboard event to playback.
-    case HC_SKIP:
-      if (!playback_enabled)
-        break;
-
-      // Read the next event from the record.
-      if (fread(&playback_msg_, sizeof(EVENTMSG), 1, file_) != 1)
-        this->StopPlayback();
-      break;
-
-    // Copy the mouse or keyboard event to the EVENTMSG structure in lParam.
-    case HC_GETNEXT:
-      if (!playback_enabled)
-        break;
-
-      memcpy(reinterpret_cast(lParam), &playback_msg_,
-             sizeof(playback_msg_));
-
-      // The return value is the amount of time (in milliseconds) to wait
-      // before playing back the next message in the playback queue.  Each
-      // time this is called, we recalculate the delay relative to our current
-      // wall clock.
-      delay = (playback_msg_.time - playback_first_msg_time_) -
-              (timeGetTime() - playback_start_time_);
-      if (delay < 0)
-        delay = 0;
-      return delay;
-
-    // An application has called PeekMessage with wRemoveMsg set to PM_NOREMOVE
-    // indicating that the message is not removed from the message queue after
-    // PeekMessage processing.
-    case HC_NOREMOVE:
-      break;
-  }
-
-  return CallNextHookEx(journal_hook_, nCode, wParam, lParam);
-}
-
-}  // namespace base
diff --git a/ipc/chromium/src/base/event_recorder.h b/ipc/chromium/src/base/event_recorder.h
deleted file mode 100644
index 29ed350a6a3..00000000000
--- a/ipc/chromium/src/base/event_recorder.h
+++ /dev/null
@@ -1,102 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_EVENT_RECORDER_H_
-#define BASE_EVENT_RECORDER_H_
-
-#include 
-#if defined(OS_WIN)
-#include 
-#endif
-#include "base/basictypes.h"
-
-class FilePath;
-
-namespace base {
-
-// A class for recording and playing back keyboard and mouse input events.
-//
-// Note - if you record events, and the playback with the windows in
-//        different sizes or positions, the playback will fail.  When
-//        recording and playing, you should move the relevant windows
-//        to constant sizes and locations.
-// TODO(mbelshe) For now this is a singleton.  I believe that this class
-//        could be easily modified to:
-//             support two simultaneous recorders
-//             be playing back events while already recording events.
-//        Why?  Imagine if the product had a "record a macro" feature.
-//        You might be recording globally, while recording or playing back
-//        a macro.  I don't think two playbacks make sense.
-class EventRecorder {
- public:
-  // Get the singleton EventRecorder.
-  // We can only handle one recorder/player at a time.
-  static EventRecorder* current() {
-    if (!current_)
-      current_ = new EventRecorder();
-    return current_;
-  }
-
-  // Starts recording events.
-  // Will clobber the file if it already exists.
-  // Returns true on success, or false if an error occurred.
-  bool StartRecording(const FilePath& filename);
-
-  // Stops recording.
-  void StopRecording();
-
-  // Is the EventRecorder currently recording.
-  bool is_recording() const { return is_recording_; }
-
-  // Plays events previously recorded.
-  // Returns true on success, or false if an error occurred.
-  bool StartPlayback(const FilePath& filename);
-
-  // Stops playback.
-  void StopPlayback();
-
-  // Is the EventRecorder currently playing.
-  bool is_playing() const { return is_playing_; }
-
-#if defined(OS_WIN)
-  // C-style callbacks for the EventRecorder.
-  // Used for internal purposes only.
-  LRESULT RecordWndProc(int nCode, WPARAM wParam, LPARAM lParam);
-  LRESULT PlaybackWndProc(int nCode, WPARAM wParam, LPARAM lParam);
-#endif
-
- private:
-  // Create a new EventRecorder.  Events are saved to the file filename.
-  // If the file already exists, it will be deleted before recording
-  // starts.
-  explicit EventRecorder()
-      : is_recording_(false),
-        is_playing_(false),
-#if defined(OS_WIN)
-        journal_hook_(NULL),
-        file_(NULL),
-#endif
-        playback_first_msg_time_(0),
-        playback_start_time_(0) {
-  }
-  ~EventRecorder();
-
-  static EventRecorder* current_;  // Our singleton.
-
-  bool is_recording_;
-  bool is_playing_;
-#if defined(OS_WIN)
-  HHOOK journal_hook_;
-  FILE* file_;
-  EVENTMSG playback_msg_;
-#endif
-  int playback_first_msg_time_;
-  int playback_start_time_;
-
-  DISALLOW_EVIL_CONSTRUCTORS(EventRecorder);
-};
-
-}  // namespace base
-
-#endif // BASE_EVENT_RECORDER_H_
diff --git a/ipc/chromium/src/base/event_recorder_stubs.cc b/ipc/chromium/src/base/event_recorder_stubs.cc
deleted file mode 100644
index 91f2e072fc9..00000000000
--- a/ipc/chromium/src/base/event_recorder_stubs.cc
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/event_recorder.h"
-
-// This file implements a link stub for EventRecorder that can be used on
-// platforms that don't have a working EventRecorder implementation.
-
-namespace base {
-
-EventRecorder* EventRecorder::current_;  // Our singleton.
-
-bool EventRecorder::StartRecording(const FilePath& filename) {
-  return true;
-}
-
-void EventRecorder::StopRecording() {
-}
-
-bool EventRecorder::StartPlayback(const FilePath& filename) {
-  return false;
-}
-
-void EventRecorder::StopPlayback() {
-}
-
-}  // namespace
diff --git a/ipc/chromium/src/base/memory_debug.cc b/ipc/chromium/src/base/memory_debug.cc
deleted file mode 100644
index 7d048e65748..00000000000
--- a/ipc/chromium/src/base/memory_debug.cc
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/memory_debug.h"
-
-#ifdef PURIFY
-// this #define is used to prevent people from directly using pure.h
-// instead of memory_debug.h
-#define PURIFY_PRIVATE_INCLUDE
-#include "base/third_party/purify/pure.h"
-#endif
-
-namespace base {
-
-bool MemoryDebug::memory_in_use_ = false;
-
-void MemoryDebug::SetMemoryInUseEnabled(bool enabled) {
-  memory_in_use_ = enabled;
-}
-
-void MemoryDebug::DumpAllMemoryInUse() {
-#ifdef PURIFY
-  if (memory_in_use_)
-    PurifyAllInuse();
-#endif
-}
-
-void MemoryDebug::DumpNewMemoryInUse() {
-#ifdef PURIFY
-  if (memory_in_use_)
-    PurifyNewInuse();
-#endif
-}
-
-void MemoryDebug::DumpAllLeaks() {
-#ifdef PURIFY
-  PurifyAllLeaks();
-#endif
-}
-
-void MemoryDebug::DumpNewLeaks() {
-#ifdef PURIFY
-  PurifyNewLeaks();
-#endif
-}
-
-void MemoryDebug::MarkAsInitialized(void* addr, size_t size) {
-#ifdef PURIFY
-  PurifyMarkAsInitialized(addr, size);
-#endif
-}
-
-}  // namespace base
diff --git a/ipc/chromium/src/base/memory_debug.h b/ipc/chromium/src/base/memory_debug.h
deleted file mode 100644
index 19632689c9b..00000000000
--- a/ipc/chromium/src/base/memory_debug.h
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Functions used to debug memory usage, leaks, and other memory issues.
-// All methods are effectively no-ops unless this program is being run through
-// a supported memory tool (currently, only Purify)
-
-#ifndef BASE_MEMORY_DEBUG_H_
-#define BASE_MEMORY_DEBUG_H_
-
-#include "base/basictypes.h"
-
-namespace base {
-
-class MemoryDebug {
- public:
-  // Since MIU messages are a lot of data, and we don't always want this data,
-  // we have a global switch.  If disabled, *MemoryInUse are no-ops.
-  static void SetMemoryInUseEnabled(bool enabled);
-
-  // Dump information about all memory in use.
-  static void DumpAllMemoryInUse();
-  // Dump information about new memory in use since the last
-  // call to DumpAllMemoryInUse() or DumpNewMemoryInUse().
-  static void DumpNewMemoryInUse();
-
-  // Dump information about all current memory leaks.
-  static void DumpAllLeaks();
-  // Dump information about new memory leaks since the last
-  // call to DumpAllLeaks() or DumpNewLeaks()
-  static void DumpNewLeaks();
-
-  // Mark |size| bytes of memory as initialized, so it doesn't produce any UMRs
-  // or UMCs.
-  static void MarkAsInitialized(void* addr, size_t size);
-
- private:
-  static bool memory_in_use_;
-
-  DISALLOW_IMPLICIT_CONSTRUCTORS(MemoryDebug);
-};
-
-}  // namespace base
-
-#endif  // BASE_MEMORY_DEBUG_H_
diff --git a/ipc/chromium/src/base/simple_thread.cc b/ipc/chromium/src/base/simple_thread.cc
deleted file mode 100644
index f919562d72e..00000000000
--- a/ipc/chromium/src/base/simple_thread.cc
+++ /dev/null
@@ -1,118 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/simple_thread.h"
-
-#include "base/waitable_event.h"
-#include "base/logging.h"
-#include "base/platform_thread.h"
-#include "base/string_util.h"
-
-namespace base {
-
-void SimpleThread::Start() {
-  DCHECK(!HasBeenStarted()) << "Tried to Start a thread multiple times.";
-  bool success = PlatformThread::Create(options_.stack_size(), this, &thread_);
-  CHECK(success);
-  event_.Wait();  // Wait for the thread to complete initialization.
-}
-
-void SimpleThread::Join() {
-  DCHECK(HasBeenStarted()) << "Tried to Join a never-started thread.";
-  DCHECK(!HasBeenJoined()) << "Tried to Join a thread multiple times.";
-  PlatformThread::Join(thread_);
-  joined_ = true;
-}
-
-void SimpleThread::ThreadMain() {
-  tid_ = PlatformThread::CurrentId();
-  // Construct our full name of the form "name_prefix_/TID".
-  name_.push_back('/');
-  name_.append(IntToString(tid_));
-  PlatformThread::SetName(name_.c_str());
-
-  // We've initialized our new thread, signal that we're done to Start().
-  event_.Signal();
-
-  Run();
-}
-
-SimpleThread::~SimpleThread() {
-  DCHECK(HasBeenStarted()) << "SimpleThread was never started.";
-  DCHECK(HasBeenJoined()) << "SimpleThread destroyed without being Join()ed.";
-}
-
-void DelegateSimpleThread::Run() {
-  DCHECK(delegate_) << "Tried to call Run without a delegate (called twice?)";
-  delegate_->Run();
-  delegate_ = NULL;
-}
-
-DelegateSimpleThreadPool::~DelegateSimpleThreadPool() {
-  DCHECK(threads_.empty());
-  DCHECK(delegates_.empty());
-  DCHECK(!dry_.IsSignaled());
-}
-
-void DelegateSimpleThreadPool::Start() {
-  DCHECK(threads_.empty()) << "Start() called with outstanding threads.";
-  for (int i = 0; i < num_threads_; ++i) {
-    DelegateSimpleThread* thread = new DelegateSimpleThread(this, name_prefix_);
-    thread->Start();
-    threads_.push_back(thread);
-  }
-}
-
-void DelegateSimpleThreadPool::JoinAll() {
-  DCHECK(!threads_.empty()) << "JoinAll() called with no outstanding threads.";
-
-  // Tell all our threads to quit their worker loop.
-  AddWork(NULL, num_threads_);
-
-  // Join and destroy all the worker threads.
-  for (int i = 0; i < num_threads_; ++i) {
-    threads_[i]->Join();
-    delete threads_[i];
-  }
-  threads_.clear();
-  DCHECK(delegates_.empty());
-}
-
-void DelegateSimpleThreadPool::AddWork(Delegate* delegate, int repeat_count) {
-  AutoLock locked(lock_);
-  for (int i = 0; i < repeat_count; ++i)
-    delegates_.push(delegate);
-  // If we were empty, signal that we have work now.
-  if (!dry_.IsSignaled())
-    dry_.Signal();
-}
-
-void DelegateSimpleThreadPool::Run() {
-  Delegate* work;
-
-  while (true) {
-    dry_.Wait();
-    {
-      AutoLock locked(lock_);
-      if (!dry_.IsSignaled())
-        continue;
-
-      DCHECK(!delegates_.empty());
-      work = delegates_.front();
-      delegates_.pop();
-
-      // Signal to any other threads that we're currently out of work.
-      if (delegates_.empty())
-        dry_.Reset();
-    }
-
-    // A NULL delegate pointer signals us to quit.
-    if (!work)
-      break;
-
-    work->Run();
-  }
-}
-
-}  // namespace base
diff --git a/ipc/chromium/src/base/simple_thread.h b/ipc/chromium/src/base/simple_thread.h
deleted file mode 100644
index 17a2f6d1d3c..00000000000
--- a/ipc/chromium/src/base/simple_thread.h
+++ /dev/null
@@ -1,189 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// WARNING: You should probably be using Thread (thread.h) instead.  Thread is
-//          Chrome's message-loop based Thread abstraction, and if you are a
-//          thread running in the browser, there will likely be assumptions
-//          that your thread will have an associated message loop.
-//
-// This is a simple thread interface that backs to a native operating system
-// thread.  You should use this only when you want a thread that does not have
-// an associated MessageLoop.  Unittesting is the best example of this.
-//
-// The simplest interface to use is DelegateSimpleThread, which will create
-// a new thread, and execute the Delegate's virtual Run() in this new thread
-// until it has completed, exiting the thread.
-//
-// NOTE: You *MUST* call Join on the thread to clean up the underlying thread
-// resources.  You are also responsible for destructing the SimpleThread object.
-// It is invalid to destroy a SimpleThread while it is running, or without
-// Start() having been called (and a thread never created).  The Delegate
-// object should live as long as a DelegateSimpleThread.
-//
-// Thread Safety: A SimpleThread is not completely thread safe.  It is safe to
-// access it from the creating thread or from the newly created thread.  This
-// implies that the creator thread should be the thread that calls Join.
-//
-// Example:
-//   class MyThreadRunner : public DelegateSimpleThread::Delegate { ... };
-//   MyThreadRunner runner;
-//   DelegateSimpleThread thread(&runner, "good_name_here");
-//   thread.Start();
-//   // Start will return after the Thread has been successfully started and
-//   // initialized.  The newly created thread will invoke runner->Run(), and
-//   // run until it returns.
-//   thread.Join();  // Wait until the thread has exited.  You *MUST* Join!
-//   // The SimpleThread object is still valid, however you may not call Join
-//   // or Start again.
-
-#ifndef BASE_SIMPLE_THREAD_H_
-#define BASE_SIMPLE_THREAD_H_
-
-#include 
-#include 
-#include 
-
-#include "base/basictypes.h"
-#include "base/lock.h"
-#include "base/waitable_event.h"
-#include "base/platform_thread.h"
-
-namespace base {
-
-// This is the base SimpleThread.  You can derive from it and implement the
-// virtual Run method, or you can use the DelegateSimpleThread interface.
-class SimpleThread : public PlatformThread::Delegate {
- public:
-  class Options {
-   public:
-    Options() : stack_size_(0) { }
-    ~Options() { }
-
-    // We use the standard compiler-supplied copy constructor.
-
-    // A custom stack size, or 0 for the system default.
-    void set_stack_size(size_t size) { stack_size_ = size; }
-    size_t stack_size() const { return stack_size_; }
-   private:
-    size_t stack_size_;
-  };
-
-  // Create a SimpleThread.  |options| should be used to manage any specific
-  // configuration involving the thread creation and management.
-  // Every thread has a name, in the form of |name_prefix|/TID, for example
-  // "my_thread/321".  The thread will not be created until Start() is called.
-  explicit SimpleThread(const std::string& name_prefix)
-      : name_prefix_(name_prefix), name_(name_prefix),
-        thread_(), event_(true, false), tid_(0), joined_(false) { }
-  SimpleThread(const std::string& name_prefix, const Options& options)
-      : name_prefix_(name_prefix), name_(name_prefix), options_(options),
-        thread_(), event_(true, false), tid_(0), joined_(false) { }
-
-  virtual ~SimpleThread();
-
-  virtual void Start();
-  virtual void Join();
-
-  // We follow the PlatformThread Delegate interface.
-  virtual void ThreadMain();
-
-  // Subclasses should override the Run method.
-  virtual void Run() = 0;
-
-  // Return the thread name prefix, or "unnamed" if none was supplied.
-  std::string name_prefix() { return name_prefix_; }
-
-  // Return the completed name including TID, only valid after Start().
-  std::string name() { return name_; }
-
-  // Return the thread id, only valid after Start().
-  PlatformThreadId tid() { return tid_; }
-
-  // Return True if Start() has ever been called.
-  bool HasBeenStarted() { return event_.IsSignaled(); }
-
-  // Return True if Join() has evern been called.
-  bool HasBeenJoined() { return joined_; }
-
- private:
-  const std::string name_prefix_;
-  std::string name_;
-  const Options options_;
-  PlatformThreadHandle thread_;  // PlatformThread handle, invalid after Join!
-  WaitableEvent event_;          // Signaled if Start() was ever called.
-  PlatformThreadId tid_;         // The backing thread's id.
-  bool joined_;                  // True if Join has been called.
-};
-
-class DelegateSimpleThread : public SimpleThread {
- public:
-  class Delegate {
-   public:
-    Delegate() { }
-    virtual ~Delegate() { }
-    virtual void Run() = 0;
-  };
-
-  DelegateSimpleThread(Delegate* delegate,
-                       const std::string& name_prefix)
-      : SimpleThread(name_prefix), delegate_(delegate) { }
-  DelegateSimpleThread(Delegate* delegate,
-                       const std::string& name_prefix,
-                       const Options& options)
-      : SimpleThread(name_prefix, options), delegate_(delegate) { }
-
-  virtual ~DelegateSimpleThread() { }
-  virtual void Run();
- private:
-  Delegate* delegate_;
-};
-
-// DelegateSimpleThreadPool allows you to start up a fixed number of threads,
-// and then add jobs which will be dispatched to the threads.  This is
-// convenient when you have a lot of small work that you want done
-// multi-threaded, but don't want to spawn a thread for each small bit of work.
-//
-// You just call AddWork() to add a delegate to the list of work to be done.
-// JoinAll() will make sure that all outstanding work is processed, and wait
-// for everything to finish.  You can reuse a pool, so you can call Start()
-// again after you've called JoinAll().
-class DelegateSimpleThreadPool : public DelegateSimpleThread::Delegate {
- public:
-  typedef DelegateSimpleThread::Delegate Delegate;
-
-  DelegateSimpleThreadPool(const std::string name_prefix, int num_threads)
-      : name_prefix_(name_prefix), num_threads_(num_threads),
-        dry_(true, false) { }
-  ~DelegateSimpleThreadPool();
-
-  // Start up all of the underlying threads, and start processing work if we
-  // have any.
-  void Start();
-
-  // Make sure all outstanding work is finished, and wait for and destroy all
-  // of the underlying threads in the pool.
-  void JoinAll();
-
-  // It is safe to AddWork() any time, before or after Start().
-  // Delegate* should always be a valid pointer, NULL is reserved internally.
-  void AddWork(Delegate* work, int repeat_count);
-  void AddWork(Delegate* work) {
-    AddWork(work, 1);
-  }
-
-  // We implement the Delegate interface, for running our internal threads.
-  virtual void Run();
-
- private:
-  const std::string name_prefix_;
-  int num_threads_;
-  std::vector threads_;
-  std::queue delegates_;
-  Lock lock_;            // Locks delegates_
-  WaitableEvent dry_;    // Not signaled when there is no work to do.
-};
-
-}  // namespace base
-
-#endif  // BASE_SIMPLE_THREAD_H_

From c1c35560a8560b1185b2ff0f82722ba3f88b25d9 Mon Sep 17 00:00:00 2001
From: Josh Aas 
Date: Thu, 4 Sep 2014 00:24:27 -0500
Subject: [PATCH 40/68] Bug 1062719 - remove Chromium debug flags, task queue
 from IPC code. rs=bent

---
 ipc/chromium/moz.build                        |  2 -
 ipc/chromium/src/chrome/common/debug_flags.cc | 44 ------------------
 ipc/chromium/src/chrome/common/debug_flags.h  | 28 -----------
 ipc/chromium/src/chrome/common/task_queue.cc  | 46 -------------------
 ipc/chromium/src/chrome/common/task_queue.h   | 42 -----------------
 5 files changed, 162 deletions(-)
 delete mode 100644 ipc/chromium/src/chrome/common/debug_flags.cc
 delete mode 100644 ipc/chromium/src/chrome/common/debug_flags.h
 delete mode 100644 ipc/chromium/src/chrome/common/task_queue.cc
 delete mode 100644 ipc/chromium/src/chrome/common/task_queue.h

diff --git a/ipc/chromium/moz.build b/ipc/chromium/moz.build
index 651e0a0016a..cb87d12d5eb 100644
--- a/ipc/chromium/moz.build
+++ b/ipc/chromium/moz.build
@@ -66,7 +66,6 @@ UNIFIED_SOURCES += [
     'src/chrome/common/child_process_info.cc',
     'src/chrome/common/child_thread.cc',
     'src/chrome/common/chrome_switches.cc',
-    'src/chrome/common/debug_flags.cc',
     'src/chrome/common/env_vars.cc',
     'src/chrome/common/ipc_channel_proxy.cc',
     'src/chrome/common/ipc_logging.cc',
@@ -75,7 +74,6 @@ UNIFIED_SOURCES += [
     'src/chrome/common/ipc_sync_message.cc',
     'src/chrome/common/message_router.cc',
     'src/chrome/common/notification_service.cc',
-    'src/chrome/common/task_queue.cc',
 ]
 
 if os_win:
diff --git a/ipc/chromium/src/chrome/common/debug_flags.cc b/ipc/chromium/src/chrome/common/debug_flags.cc
deleted file mode 100644
index 97c2725f937..00000000000
--- a/ipc/chromium/src/chrome/common/debug_flags.cc
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/common/debug_flags.h"
-
-#include "base/base_switches.h"
-#include "base/command_line.h"
-#include "chrome/common/chrome_switches.h"
-
-bool DebugFlags::ProcessDebugFlags(CommandLine* command_line,
-                                   ChildProcessInfo::ProcessType type,
-                                   bool is_in_sandbox) {
-  bool should_help_child = false;
-  const CommandLine& current_cmd_line = *CommandLine::ForCurrentProcess();
-  if (current_cmd_line.HasSwitch(switches::kDebugChildren)) {
-    // Look to pass-on the kDebugOnStart flag.
-    std::wstring value;
-    value = current_cmd_line.GetSwitchValue(switches::kDebugChildren);
-    if (value.empty() ||
-        (type == ChildProcessInfo::RENDER_PROCESS &&
-         value == switches::kRendererProcess) ||
-        (type == ChildProcessInfo::PLUGIN_PROCESS &&
-         value == switches::kPluginProcess)) {
-      command_line->AppendSwitch(switches::kDebugOnStart);
-      should_help_child = true;
-    }
-    command_line->AppendSwitchWithValue(switches::kDebugChildren, value);
-  } else if (current_cmd_line.HasSwitch(switches::kWaitForDebuggerChildren)) {
-    // Look to pass-on the kWaitForDebugger flag.
-    std::wstring value;
-    value = current_cmd_line.GetSwitchValue(switches::kWaitForDebuggerChildren);
-    if (value.empty() ||
-        (type == ChildProcessInfo::RENDER_PROCESS &&
-         value == switches::kRendererProcess) ||
-        (type == ChildProcessInfo::PLUGIN_PROCESS &&
-         value == switches::kPluginProcess)) {
-      command_line->AppendSwitch(switches::kWaitForDebugger);
-    }
-    command_line->AppendSwitchWithValue(switches::kWaitForDebuggerChildren,
-                                        value);
-  }
-  return should_help_child;
-}
diff --git a/ipc/chromium/src/chrome/common/debug_flags.h b/ipc/chromium/src/chrome/common/debug_flags.h
deleted file mode 100644
index 231d2ca9676..00000000000
--- a/ipc/chromium/src/chrome/common/debug_flags.h
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_COMMON_DEBUG_FLAGS_H__
-#define CHROME_COMMON_DEBUG_FLAGS_H__
-
-#include "chrome/common/child_process_info.h"
-
-class CommandLine;
-
-class DebugFlags {
- public:
-
-  // Updates the command line arguments with debug-related flags. If
-  // debug flags have been used with this process, they will be
-  // filtered and added to command_line as needed. is_in_sandbox must
-  // be true if the child process will be in a sandbox.
-  //
-  // Returns true if the caller should "help" the child process by
-  // calling the JIT debugger on it. It may only happen if
-  // is_in_sandbox is true.
-  static bool ProcessDebugFlags(CommandLine* command_line,
-                                ChildProcessInfo::ProcessType type,
-                                bool is_in_sandbox);
-};
-
-#endif  // CHROME_COMMON_DEBUG_FLAGS_H__
diff --git a/ipc/chromium/src/chrome/common/task_queue.cc b/ipc/chromium/src/chrome/common/task_queue.cc
deleted file mode 100644
index 0d5aabb87df..00000000000
--- a/ipc/chromium/src/chrome/common/task_queue.cc
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/common/task_queue.h"
-
-#include "base/stl_util-inl.h"
-
-TaskQueue::TaskQueue() {
-}
-
-TaskQueue::~TaskQueue() {
-  // We own all the pointes in |queue_|.  It is our job to delete them.
-  STLDeleteElements(&queue_);
-}
-
-void TaskQueue::Run() {
-  // Nothing to run if our queue is empty.
-  if (queue_.empty())
-    return;
-
-  std::deque ready;
-  queue_.swap(ready);
-
-  // Run the tasks that are ready.
-  std::deque::const_iterator task;
-  for (task = ready.begin(); task != ready.end(); ++task) {
-    // Run the task and then delete it.
-    (*task)->Run();
-    delete (*task);
-  }
-}
-
-void TaskQueue::Push(Task* task) {
-  // Add the task to the back of the queue.
-  queue_.push_back(task);
-}
-
-void TaskQueue::Clear() {
-  // Delete all the elements in the queue and clear the dead pointers.
-  STLDeleteElements(&queue_);
-}
-
-bool TaskQueue::Empty() const {
-  return queue_.empty();
-}
diff --git a/ipc/chromium/src/chrome/common/task_queue.h b/ipc/chromium/src/chrome/common/task_queue.h
deleted file mode 100644
index 9e1c817a146..00000000000
--- a/ipc/chromium/src/chrome/common/task_queue.h
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_COMMON_TASK_QUEUE_H__
-#define CHROME_COMMON_TASK_QUEUE_H__
-
-#include 
-
-#include "base/task.h"
-
-// A TaskQueue is a queue of tasks waiting to be run.  To run the tasks, call
-// the Run method.  A task queue is itself a Task so that it can be placed in a
-// message loop or another task queue.
-class TaskQueue : public Task {
- public:
-  TaskQueue();
-  ~TaskQueue();
-
-  // Run all the tasks in the queue.  New tasks pushed onto the queue during
-  // a run will be run next time |Run| is called.
-  virtual void Run();
-
-  // Push the specified task onto the queue.  When the queue is run, the tasks
-  // will be run in the order they are pushed.
-  //
-  // This method takes ownership of |task| and will delete task after it is run
-  // (or when the TaskQueue is destroyed, if we never got a chance to run it).
-  void Push(Task* task);
-
-  // Remove all tasks from the queue.  The tasks are deleted.
-  void Clear();
-
-  // Returns true if this queue contains no tasks.
-  bool Empty() const;
-
- private:
-   // The list of tasks we are waiting to run.
-   std::deque queue_;
-};
-
-#endif  // CHROME_COMMON_TASK_QUEUE_H__

From f453c4e82864162ddf04d4927679632bc8343a14 Mon Sep 17 00:00:00 2001
From: Anuj Agarwal 
Date: Sat, 12 Jul 2014 10:34:00 +0200
Subject: [PATCH 41/68] Bug 1028143 - Privatizing public destructor of
 MediaPipeline. r=jesup

---
 .../signaling/src/mediapipeline/MediaPipeline.h       | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.h b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.h
index 00db9a013cc..c946cdc7553 100644
--- a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.h
+++ b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.h
@@ -68,14 +68,6 @@ class PeerIdentity;
 // For a receiving conduit, "input" is RTP and "output" is RTCP.
 //
 
-class MediaPipeline;
-
-template<>
-struct HasDangerousPublicDestructor
-{
-  static const bool value = true;
-};
-
 class MediaPipeline : public sigslot::has_slots<> {
  public:
   enum Direction { TRANSMIT, RECEIVE };
@@ -117,8 +109,6 @@ class MediaPipeline : public sigslot::has_slots<> {
       transport_ = new PipelineTransport(this);
   }
 
-  virtual ~MediaPipeline();
-
   // Must be called on the STS thread.  Must be called after ShutdownMedia_m().
   void ShutdownTransport_s();
 
@@ -172,6 +162,7 @@ class MediaPipeline : public sigslot::has_slots<> {
   } RtpType;
 
  protected:
+  virtual ~MediaPipeline();
   virtual void DetachMediaStream() {}
 
   // Separate class to allow ref counting

From 7d516de5ca27ef8c40d035b40afdae094d8e228f Mon Sep 17 00:00:00 2001
From: Irving Reid 
Date: Wed, 27 Aug 2014 22:21:07 -0400
Subject: [PATCH 42/68] Bug 1056170 - Expose pref service 'dirty' flag and test
 it. r=bsemdberg

---
 modules/libpref/Preferences.cpp              |  5 ++
 modules/libpref/nsIPrefService.idl           | 13 ++--
 modules/libpref/prefapi.cpp                  | 22 +++---
 modules/libpref/test/unit/head_libPrefs.js   |  2 +-
 modules/libpref/test/unit/test_dirtyPrefs.js | 75 ++++++++++++++++++++
 modules/libpref/test/unit/xpcshell.ini       |  1 +
 6 files changed, 101 insertions(+), 17 deletions(-)
 create mode 100644 modules/libpref/test/unit/test_dirtyPrefs.js

diff --git a/modules/libpref/Preferences.cpp b/modules/libpref/Preferences.cpp
index 6827afe219c..7b3cb03bf5a 100644
--- a/modules/libpref/Preferences.cpp
+++ b/modules/libpref/Preferences.cpp
@@ -788,6 +788,11 @@ Preferences::GetDefaultBranch(const char *aPrefRoot, nsIPrefBranch **_retval)
   return NS_OK;
 }
 
+NS_IMETHODIMP
+Preferences::GetDirty(bool *_retval) {
+  *_retval = gDirty;
+  return NS_OK;
+}
 
 nsresult
 Preferences::NotifyServiceObservers(const char *aTopic)
diff --git a/modules/libpref/nsIPrefService.idl b/modules/libpref/nsIPrefService.idl
index e29fc245e56..8766e3b3826 100644
--- a/modules/libpref/nsIPrefService.idl
+++ b/modules/libpref/nsIPrefService.idl
@@ -120,16 +120,19 @@ interface nsIPrefService : nsISupports
    */
   nsIPrefBranch getDefaultBranch(in string aPrefRoot);
 
+  /**
+   * The preference service is 'dirty' if there are changes to user preferences
+   * that have not been written to disk
+   */
+  readonly attribute boolean dirty;
 };
 
 %{C++
 
 #define NS_PREFSERVICE_CID                             \
-  { /* {1cd91b88-1dd2-11b2-92e1-ed22ed298000} */       \
-    0x91ca2441,                                        \
-    0x050f,                                            \
-    0x4f7c,                                            \
-    { 0x9d, 0xf8, 0x75, 0xb4, 0x0e, 0xa4, 0x01, 0x56 } \
+  { /* {410c269f-3f7a-4396-88ce-781071733182} */       \
+    0x410c269f, 0x3f7a, 0x4396,                        \
+    { 0x88, 0xce, 0x78, 0x10, 0x71, 0x73, 0x31, 0x82 } \
   }
 
 #define NS_PREFSERVICE_CONTRACTID "@mozilla.org/preferences-service;1"
diff --git a/modules/libpref/prefapi.cpp b/modules/libpref/prefapi.cpp
index 2dbe64eeb51..2be3ae9f375 100644
--- a/modules/libpref/prefapi.cpp
+++ b/modules/libpref/prefapi.cpp
@@ -312,7 +312,7 @@ pref_SetPref(const dom::PrefSetting& aPref)
     if (userValue.type() == dom::MaybePrefValue::TPrefValue) {
         rv = SetPrefValue(prefName, userValue.get_PrefValue(), USER_VALUE);
     } else {
-        rv = PREF_ClearUserPref(prefName);      
+        rv = PREF_ClearUserPref(prefName);
     }
 
     // NB: we should never try to clear a default value, that doesn't
@@ -725,7 +725,6 @@ static void pref_SetValue(PrefValue* existingValue, uint16_t *existingFlags,
     else {
         *existingValue = newValue;
     }
-    gDirty = true;
 }
 
 PrefHashEntry* pref_HashTableLookup(const void *key)
@@ -785,6 +784,8 @@ nsresult pref_HashPref(const char *key, PrefValue value, PrefType type, uint32_t
                 if (!PREF_HAS_USER_VALUE(pref))
                     valueChanged = true;
             }
+            // What if we change the default to be the same as the user value?
+            // Should we clear the user value?
         }
     }
     else
@@ -799,8 +800,10 @@ nsresult pref_HashPref(const char *key, PrefValue value, PrefType type, uint32_t
             {
                 /* XXX should we free a user-set string value if there is one? */
                 pref->flags &= ~PREF_USERSET;
-                if (!PREF_IS_LOCKED(pref))
+                if (!PREF_IS_LOCKED(pref)) {
+                    gDirty = true;
                     valueChanged = true;
+                }
             }
         }
         else if (!PREF_HAS_USER_VALUE(pref) ||
@@ -809,20 +812,17 @@ nsresult pref_HashPref(const char *key, PrefValue value, PrefType type, uint32_t
         {
             pref_SetValue(&pref->userPref, &pref->flags, value, type);
             pref->flags |= PREF_USERSET;
-            if (!PREF_IS_LOCKED(pref))
+            if (!PREF_IS_LOCKED(pref)) {
+                gDirty = true;
                 valueChanged = true;
+            }
         }
     }
 
-    nsresult rv = NS_OK;
     if (valueChanged) {
-        gDirty = true;
-
-        nsresult rv2 = pref_DoCallback(key);
-        if (NS_FAILED(rv2))
-            rv = rv2;
+        return pref_DoCallback(key);
     }
-    return rv;
+    return NS_OK;
 }
 
 size_t
diff --git a/modules/libpref/test/unit/head_libPrefs.js b/modules/libpref/test/unit/head_libPrefs.js
index 18a0cb6919b..cfa0f1a1e92 100644
--- a/modules/libpref/test/unit/head_libPrefs.js
+++ b/modules/libpref/test/unit/head_libPrefs.js
@@ -32,7 +32,7 @@ var provider = {
     persistent.value = true;
     if (prop == NS_APP_USER_PROFILE_50_DIR)
       return dirSvc.get("CurProcD", Ci.nsIFile);
-    throw Cr.NS_ERROR_FAILURE;
+    throw Components.Exception("Tried to get test directory '" + prop + "'", Cr.NS_ERROR_FAILURE);
   },
   QueryInterface: function(iid) {
     if (iid.equals(Ci.nsIDirectoryServiceProvider) ||
diff --git a/modules/libpref/test/unit/test_dirtyPrefs.js b/modules/libpref/test/unit/test_dirtyPrefs.js
new file mode 100644
index 00000000000..3611716165f
--- /dev/null
+++ b/modules/libpref/test/unit/test_dirtyPrefs.js
@@ -0,0 +1,75 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Tests for handling of the preferences 'dirty' flag (bug 985998) */
+
+const PREF_INVALID = 0;
+const PREF_BOOL    = 128;
+const PREF_INT     = 64;
+const PREF_STRING  = 32;
+
+function run_test() {
+
+  var ps = Cc["@mozilla.org/preferences-service;1"].
+            getService(Ci.nsIPrefService);
+
+  let defaultBranch = ps.getDefaultBranch("");
+  let userBranch = ps.getBranch("");
+
+  let prefFile = do_get_profile();
+  prefFile.append("prefs.js");
+
+  //**************************************************************************//
+  // prefs are not dirty after a write
+  ps.savePrefFile(prefFile);
+  do_check_false(ps.dirty);
+
+  // set a new a user value, we should become dirty
+  userBranch.setBoolPref("DirtyTest.new.bool", true);
+  do_check_true(ps.dirty);
+  ps.savePrefFile(prefFile);
+  // Overwrite a pref with the same value => not dirty
+  userBranch.setBoolPref("DirtyTest.new.bool", true);
+  do_check_false(ps.dirty);
+
+  // Repeat for the other two types
+  userBranch.setIntPref("DirtyTest.new.int", 1);
+  do_check_true(ps.dirty);
+  ps.savePrefFile(prefFile);
+  // Overwrite a pref with the same value => not dirty
+  userBranch.setIntPref("DirtyTest.new.int", 1);
+  do_check_false(ps.dirty);
+
+  userBranch.setCharPref("DirtyTest.new.char", "oop");
+  do_check_true(ps.dirty);
+  ps.savePrefFile(prefFile);
+  // Overwrite a pref with the same value => not dirty
+  userBranch.setCharPref("DirtyTest.new.char", "oop");
+  do_check_false(ps.dirty);
+
+  // change *type* of a user value -> dirty
+  userBranch.setBoolPref("DirtyTest.new.char", false);
+  do_check_true(ps.dirty);
+  ps.savePrefFile(prefFile);
+
+  // Set a default pref => not dirty (defaults don't go into prefs.js)
+  defaultBranch.setBoolPref("DirtyTest.existing.bool", true);
+  do_check_false(ps.dirty);
+  // Fail to change type of a pref with default value -> not dirty
+  do_check_throws(function() {
+    userBranch.setCharPref("DirtyTest.existing.bool", "boo"); }, Cr.NS_ERROR_UNEXPECTED);
+  do_check_false(ps.dirty);
+
+  // Set user value same as default, not dirty
+  userBranch.setBoolPref("DirtyTest.existing.bool", true);
+  do_check_false(ps.dirty);
+  // User value different from default, dirty
+  userBranch.setBoolPref("DirtyTest.existing.bool", false);
+  do_check_true(ps.dirty);
+  ps.savePrefFile(prefFile);
+  // Back to default value, dirty again
+  userBranch.setBoolPref("DirtyTest.existing.bool", true);
+  do_check_true(ps.dirty);
+  ps.savePrefFile(prefFile);
+}
diff --git a/modules/libpref/test/unit/xpcshell.ini b/modules/libpref/test/unit/xpcshell.ini
index 9c2052c9410..91227256cda 100644
--- a/modules/libpref/test/unit/xpcshell.ini
+++ b/modules/libpref/test/unit/xpcshell.ini
@@ -11,5 +11,6 @@ support-files =
 [test_bug577950.js]
 [test_bug790374.js]
 [test_changeType.js]
+[test_dirtyPrefs.js]
 [test_extprefs.js]
 [test_libPrefs.js]

From eac9946170e56c9e119571633a1dd6d5c07fcf7f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomasz=20Ko=C5=82odziejski?= 
Date: Wed, 3 Sep 2014 13:06:00 +0200
Subject: [PATCH 43/68] Bug 1057453 - 'mach test filename' should test a single
 file. r=gps

---
 testing/mochitest/mach_commands.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/testing/mochitest/mach_commands.py b/testing/mochitest/mach_commands.py
index d807e25df75..f6c6ae812a1 100644
--- a/testing/mochitest/mach_commands.py
+++ b/testing/mochitest/mach_commands.py
@@ -219,9 +219,9 @@ class MochitestRunner(MozbuildObject):
             print('Cannot specify both --rerun-failures and a test path.')
             return 1
 
-        # Need to call relpath before os.chdir() below.
+        # Make absolute paths relative before calling os.chdir() below.
         if test_paths:
-            test_paths = [self._wrap_path_argument(p).relpath() for p in test_paths]
+            test_paths = [self._wrap_path_argument(p).relpath() if os.path.isabs(p) else p for p in test_paths]
 
         failure_file_path = os.path.join(self.statedir, 'mochitest_failures.json')
 

From d731e43bb70adf67a671ab6f3a2a9f1e87e3d041 Mon Sep 17 00:00:00 2001
From: Chris Manchester 
Date: Wed, 3 Sep 2014 10:03:29 -0400
Subject: [PATCH 44/68] Bug 1060366 - Log a message about the expected status
 when an unexpected status is encountered and no message is provided.
 r=jgraham

---
 .../structured/formatters/tbplformatter.py    |   4 +
 .../mozbase/mozlog/tests/test_structured.py   | 106 +++++++++++++-----
 2 files changed, 79 insertions(+), 31 deletions(-)

diff --git a/testing/mozbase/mozlog/mozlog/structured/formatters/tbplformatter.py b/testing/mozbase/mozlog/mozlog/structured/formatters/tbplformatter.py
index 4114b5adb38..2ba8612da74 100644
--- a/testing/mozbase/mozlog/mozlog/structured/formatters/tbplformatter.py
+++ b/testing/mozbase/mozlog/mozlog/structured/formatters/tbplformatter.py
@@ -74,6 +74,8 @@ class TbplFormatter(BaseFormatter):
             message = message[:-1]
 
         if "expected" in data:
+            if not message:
+                message = "- expected %s\n" % data["expected"]
             failure_line = "TEST-UNEXPECTED-%s | %s | %s %s\n" % (
                 data["status"], self.id_str(data["test"]), data["subtest"],
                 message)
@@ -97,6 +99,8 @@ class TbplFormatter(BaseFormatter):
 
         if "expected" in data:
             message = data.get("message", "")
+            if not message:
+                message = "expected %s" % data["expected"]
             if "stack" in data:
                 message += "\n%s" % data["stack"]
             if message and message[-1] == "\n":
diff --git a/testing/mozbase/mozlog/tests/test_structured.py b/testing/mozbase/mozlog/tests/test_structured.py
index 85e0b7a4717..8730ce82ce0 100644
--- a/testing/mozbase/mozlog/tests/test_structured.py
+++ b/testing/mozbase/mozlog/tests/test_structured.py
@@ -396,14 +396,70 @@ class TestTypeconversions(BaseStructuredTest):
         self.logger.suite_end()
 
 
-class TestMachFormatter(unittest.TestCase):
+class FormatterTest(unittest.TestCase):
+
     def setUp(self):
-        self.logger = structuredlog.StructuredLogger("test")
+        self.position = 0
+        self.logger = structuredlog.StructuredLogger("test_%s" % type(self).__name__)
         self.output_file = StringIO.StringIO()
         self.handler = handlers.StreamHandler(
-            self.output_file, formatters.MachFormatter(disable_colors=True))
+            self.output_file, self.get_formatter())
         self.logger.add_handler(self.handler)
 
+    def set_position(self, pos=None):
+        if pos is None:
+            pos = self.output_file.tell()
+        self.position = pos
+
+    def get_formatter(self):
+        raise NotImplementedError("FormatterTest subclasses must implement get_formatter")
+
+    @property
+    def loglines(self):
+        self.output_file.seek(self.position)
+        return [line.rstrip() for line in self.output_file.readlines()]
+
+class TestTBPLFormatter(FormatterTest):
+
+    def get_formatter(self):
+        return formatters.TbplFormatter()
+
+    def test_unexpected_message(self):
+        self.logger.suite_start([])
+        self.logger.test_start("timeout_test")
+        self.logger.test_end("timeout_test",
+                             "TIMEOUT",
+                             message="timed out")
+        self.assertIn("TEST-UNEXPECTED-TIMEOUT | timeout_test | timed out",
+                      self.loglines)
+        self.logger.suite_end()
+
+    def test_default_unexpected_end_message(self):
+        self.logger.suite_start([])
+        self.logger.test_start("timeout_test")
+        self.logger.test_end("timeout_test",
+                             "TIMEOUT")
+        self.assertIn("TEST-UNEXPECTED-TIMEOUT | timeout_test | expected OK",
+                      self.loglines)
+        self.logger.suite_end()
+
+    def test_default_unexpected_status_message(self):
+        self.logger.suite_start([])
+        self.logger.test_start("timeout_test")
+        self.logger.test_status("timeout_test",
+                                "subtest",
+                                status="TIMEOUT")
+        self.assertIn("TEST-UNEXPECTED-TIMEOUT | timeout_test | subtest - expected PASS",
+                      self.loglines)
+        self.logger.test_end("timeout_test", "OK")
+        self.logger.suite_end()
+
+
+class TestMachFormatter(FormatterTest):
+
+    def get_formatter(self):
+        return formatters.MachFormatter(disable_colors=True)
+
     def test_summary(self):
         self.logger.suite_start([])
 
@@ -417,19 +473,15 @@ class TestMachFormatter(unittest.TestCase):
         self.logger.test_start("test3")
         self.logger.test_end("test3", status="FAIL", expected="PASS")
 
-        position = self.output_file.tell()
-
+        self.set_position()
         self.logger.suite_end()
 
-        self.output_file.seek(position)
-        lines = self.output_file.read().split("\n")
-
-        self.assertIn("Ran 3 tests", lines)
-        self.assertIn("Expected results: 1", lines)
-        self.assertIn("Unexpected results: 2 (FAIL: 1, PASS: 1)", lines)
-        self.assertNotIn("test1", lines)
-        self.assertIn("PASS expected TIMEOUT test2", lines)
-        self.assertIn("FAIL test3", lines)
+        self.assertIn("Ran 3 tests", self.loglines)
+        self.assertIn("Expected results: 1", self.loglines)
+        self.assertIn("Unexpected results: 2 (FAIL: 1, PASS: 1)", self.loglines)
+        self.assertNotIn("test1", self.loglines)
+        self.assertIn("PASS expected TIMEOUT test2", self.loglines)
+        self.assertIn("FAIL test3", self.loglines)
 
     def test_summary_subtests(self):
         self.logger.suite_start([])
@@ -443,16 +495,12 @@ class TestMachFormatter(unittest.TestCase):
         self.logger.test_status("test2", "subtest1", status="TIMEOUT", expected="PASS")
         self.logger.test_end("test2", status="TIMEOUT", expected="OK")
 
-        position = self.output_file.tell()
-
+        self.set_position()
         self.logger.suite_end()
 
-        self.output_file.seek(position)
-        lines = self.output_file.read().split("\n")
-
-        self.assertIn("Ran 5 tests (2 parents, 3 subtests)", lines)
-        self.assertIn("Expected results: 2", lines)
-        self.assertIn("Unexpected results: 3 (FAIL: 1, TIMEOUT: 2)", lines)
+        self.assertIn("Ran 5 tests (2 parents, 3 subtests)", self.loglines)
+        self.assertIn("Expected results: 2", self.loglines)
+        self.assertIn("Unexpected results: 3 (FAIL: 1, TIMEOUT: 2)", self.loglines)
 
     def test_summary_ok(self):
         self.logger.suite_start([])
@@ -466,16 +514,12 @@ class TestMachFormatter(unittest.TestCase):
         self.logger.test_status("test2", "subtest1", status="PASS", expected="PASS")
         self.logger.test_end("test2", status="OK", expected="OK")
 
-        position = self.output_file.tell()
-
+        self.set_position()
         self.logger.suite_end()
 
-        self.output_file.seek(position)
-        lines = self.output_file.read().split("\n")
-
-        self.assertIn("OK", lines)
-        self.assertIn("Expected results: 5", lines)
-        self.assertIn("Unexpected results: 0", lines)
+        self.assertIn("OK", self.loglines)
+        self.assertIn("Expected results: 5", self.loglines)
+        self.assertIn("Unexpected results: 0", self.loglines)
 
 
 class TestCommandline(unittest.TestCase):
@@ -486,7 +530,7 @@ class TestCommandline(unittest.TestCase):
     @property
     def loglines(self):
         self.logfile.seek(0)
-        return [line.strip() for line in self.logfile.readlines()]
+        return [line.rstrip() for line in self.logfile.readlines()]
 
     def test_setup_logging(self):
         parser = argparse.ArgumentParser()

From 3a1086521b7099829447c142047c44a5b751f7ac Mon Sep 17 00:00:00 2001
From: Arnaud Sourioux 
Date: Wed, 3 Sep 2014 12:14:00 +0200
Subject: [PATCH 45/68] Bug 105871 - Print full path of mozconfig file used on
 'mach ./configure' when error in mozconfig throws an exception. r=gps

---
 python/mozbuild/mozbuild/base.py | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/python/mozbuild/mozbuild/base.py b/python/mozbuild/mozbuild/base.py
index 2cc456eed21..66edad6563c 100644
--- a/python/mozbuild/mozbuild/base.py
+++ b/python/mozbuild/mozbuild/base.py
@@ -572,6 +572,19 @@ class MachCommandBase(MozbuildObject):
                     e.objdir2))
             sys.exit(1)
 
+        except MozconfigLoadException as e:
+            print('Error loading mozconfig: ' + e.path)
+            print('')
+            print(e.message)
+            if e.output:
+                print('')
+                print('mozconfig output:')
+                print('')
+                for line in e.output:
+                    print(line)
+
+            sys.exit(1)
+
         MozbuildObject.__init__(self, topsrcdir, context.settings,
             context.log_manager, topobjdir=topobjdir)
 

From 42b948f5dd153070466de2ab70dcb26b425e9795 Mon Sep 17 00:00:00 2001
From: Christoph Kerschbaumer 
Date: Wed, 6 Aug 2014 16:05:40 -0700
Subject: [PATCH 46/68] Bug 1062529 - Split GetChannelPrincipal into
 GetChannelResultPrincipal and GetChannelURIPrincipal. r=bz

---
 caps/nsIScriptSecurityManager.idl             | 10 ++++++++--
 caps/nsScriptSecurityManager.cpp              | 17 ++++++++++++-----
 content/base/src/ImportManager.cpp            |  4 ++--
 content/base/src/nsContentUtils.cpp           |  2 +-
 content/base/src/nsCrossSiteListenerProxy.cpp |  8 +++++---
 content/base/src/nsDocument.cpp               |  6 +++---
 content/base/src/nsScriptLoader.cpp           |  2 +-
 content/html/document/src/ImageDocument.cpp   |  2 +-
 content/media/MediaResource.cpp               |  4 ++--
 content/media/RtspMediaResource.cpp           |  2 +-
 content/xul/document/src/XULDocument.cpp      |  4 ++--
 docshell/base/nsDocShell.cpp                  |  2 +-
 dom/workers/ScriptLoader.cpp                  |  2 +-
 image/src/ImageFactory.cpp                    |  4 ++--
 image/src/imgRequest.cpp                      |  4 ++--
 layout/build/nsContentDLF.cpp                 |  2 +-
 layout/style/Loader.cpp                       |  2 +-
 netwerk/base/src/nsChannelClassifier.cpp      |  4 ++--
 netwerk/protocol/http/HttpBaseChannel.cpp     |  2 +-
 rdf/base/nsRDFXMLDataSource.cpp               |  2 +-
 20 files changed, 50 insertions(+), 35 deletions(-)

diff --git a/caps/nsIScriptSecurityManager.idl b/caps/nsIScriptSecurityManager.idl
index d9fedd96531..5b57756c280 100644
--- a/caps/nsIScriptSecurityManager.idl
+++ b/caps/nsIScriptSecurityManager.idl
@@ -19,7 +19,7 @@ interface nsILoadContext;
 [ptr] native JSContextPtr(JSContext);
 [ptr] native JSObjectPtr(JSObject);
 
-[scriptable, uuid(f6e1e37e-14d0-44fa-a9bb-712bfad6c5f7)]
+[scriptable, uuid(3b021962-975e-43b5-8a93-9fc2d20346e9)]
 interface nsIScriptSecurityManager : nsISupports
 {
     /**
@@ -199,7 +199,13 @@ interface nsIScriptSecurityManager : nsISupports
      * channel owner if there is one, and the codebase principal for the
      * channel's URI otherwise.  aChannel must not be null.
      */
-    nsIPrincipal getChannelPrincipal(in nsIChannel aChannel);
+    nsIPrincipal getChannelResultPrincipal(in nsIChannel aChannel);
+
+    /**
+     * Get the codebase principal for the channel's URI.
+     * aChannel must not be null.
+     */
+    nsIPrincipal getChannelURIPrincipal(in nsIChannel aChannel);
 
     /**
      * Check whether a given principal is a system principal.  This allows us
diff --git a/caps/nsScriptSecurityManager.cpp b/caps/nsScriptSecurityManager.cpp
index 506aa3cd031..c2825ffac72 100644
--- a/caps/nsScriptSecurityManager.cpp
+++ b/caps/nsScriptSecurityManager.cpp
@@ -306,8 +306,8 @@ nsScriptSecurityManager::AppStatusForPrincipal(nsIPrincipal *aPrin)
 }
 
 NS_IMETHODIMP
-nsScriptSecurityManager::GetChannelPrincipal(nsIChannel* aChannel,
-                                             nsIPrincipal** aPrincipal)
+nsScriptSecurityManager::GetChannelResultPrincipal(nsIChannel* aChannel,
+                                                   nsIPrincipal** aPrincipal)
 {
     NS_PRECONDITION(aChannel, "Must have channel!");
     nsCOMPtr owner;
@@ -336,14 +336,21 @@ nsScriptSecurityManager::GetChannelPrincipal(nsIChannel* aChannel,
             return NS_OK;
         }
     }
+    return GetChannelURIPrincipal(aChannel, aPrincipal);
+}
 
-    // OK, get the principal from the URI.  Make sure this does the same thing
+NS_IMETHODIMP
+nsScriptSecurityManager::GetChannelURIPrincipal(nsIChannel* aChannel,
+                                                nsIPrincipal** aPrincipal)
+{
+    NS_PRECONDITION(aChannel, "Must have channel!");
+
+    // Get the principal from the URI.  Make sure this does the same thing
     // as nsDocument::Reset and XULDocument::StartDocumentLoad.
     nsCOMPtr uri;
     nsresult rv = NS_GetFinalChannelURI(aChannel, getter_AddRefs(uri));
     NS_ENSURE_SUCCESS(rv, rv);
 
-
     nsCOMPtr loadContext;
     NS_QueryNotificationCallbacks(aChannel, loadContext);
 
@@ -1189,7 +1196,7 @@ nsScriptSecurityManager::AsyncOnChannelRedirect(nsIChannel* oldChannel,
                                                 nsIAsyncVerifyRedirectCallback *cb)
 {
     nsCOMPtr oldPrincipal;
-    GetChannelPrincipal(oldChannel, getter_AddRefs(oldPrincipal));
+    GetChannelResultPrincipal(oldChannel, getter_AddRefs(oldPrincipal));
 
     nsCOMPtr newURI;
     newChannel->GetURI(getter_AddRefs(newURI));
diff --git a/content/base/src/ImportManager.cpp b/content/base/src/ImportManager.cpp
index 63a2fcdd094..fc093375ceb 100644
--- a/content/base/src/ImportManager.cpp
+++ b/content/base/src/ImportManager.cpp
@@ -343,8 +343,8 @@ ImportLoader::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext)
   if (nsContentUtils::IsSystemPrincipal(principal)) {
     // We should never import non-system documents and run their scripts with system principal!
     nsCOMPtr channelPrincipal;
-    nsContentUtils::GetSecurityManager()->GetChannelPrincipal(channel,
-                                                              getter_AddRefs(channelPrincipal));
+    nsContentUtils::GetSecurityManager()->GetChannelResultPrincipal(channel,
+                                                                    getter_AddRefs(channelPrincipal));
     if (!nsContentUtils::IsSystemPrincipal(channelPrincipal)) {
       return NS_ERROR_FAILURE;
     }
diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp
index 90a6ef0dc4e..e99dc9e3db7 100644
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -5670,7 +5670,7 @@ nsContentUtils::CheckSameOrigin(nsIChannel *aOldChannel, nsIChannel *aNewChannel
 
   nsCOMPtr oldPrincipal;
   nsContentUtils::GetSecurityManager()->
-    GetChannelPrincipal(aOldChannel, getter_AddRefs(oldPrincipal));
+    GetChannelResultPrincipal(aOldChannel, getter_AddRefs(oldPrincipal));
 
   nsCOMPtr newURI;
   aNewChannel->GetURI(getter_AddRefs(newURI));
diff --git a/content/base/src/nsCrossSiteListenerProxy.cpp b/content/base/src/nsCrossSiteListenerProxy.cpp
index 22c2b3c063b..bcd521654b9 100644
--- a/content/base/src/nsCrossSiteListenerProxy.cpp
+++ b/content/base/src/nsCrossSiteListenerProxy.cpp
@@ -682,13 +682,15 @@ nsCORSListenerProxy::AsyncOnChannelRedirect(nsIChannel *aOldChannel,
 
     if (mHasBeenCrossSite) {
       // Once we've been cross-site, cross-origin redirects reset our source
-      // origin.
+      // origin. Note that we need to call GetChannelURIPrincipal() because
+      // we are looking for the principal that is actually being loaded and not
+      // the principal that initiated the load.
       nsCOMPtr oldChannelPrincipal;
       nsContentUtils::GetSecurityManager()->
-        GetChannelPrincipal(aOldChannel, getter_AddRefs(oldChannelPrincipal));
+        GetChannelURIPrincipal(aOldChannel, getter_AddRefs(oldChannelPrincipal));
       nsCOMPtr newChannelPrincipal;
       nsContentUtils::GetSecurityManager()->
-        GetChannelPrincipal(aNewChannel, getter_AddRefs(newChannelPrincipal));
+        GetChannelURIPrincipal(aNewChannel, getter_AddRefs(newChannelPrincipal));
       if (!oldChannelPrincipal || !newChannelPrincipal) {
         rv = NS_ERROR_OUT_OF_MEMORY;
       }
diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp
index 5d78a3b4cc2..ef81e2585b0 100644
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -2208,15 +2208,15 @@ nsDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup)
   nsCOMPtr principal;
   if (aChannel) {
     // Note: this code is duplicated in XULDocument::StartDocumentLoad and
-    // nsScriptSecurityManager::GetChannelPrincipal.
+    // nsScriptSecurityManager::GetChannelResultPrincipal.
     // Note: this should match nsDocShell::OnLoadingSite
     NS_GetFinalChannelURI(aChannel, getter_AddRefs(uri));
 
     nsIScriptSecurityManager *securityManager =
       nsContentUtils::GetSecurityManager();
     if (securityManager) {
-      securityManager->GetChannelPrincipal(aChannel,
-                                           getter_AddRefs(principal));
+      securityManager->GetChannelResultPrincipal(aChannel,
+                                                 getter_AddRefs(principal));
     }
   }
 
diff --git a/content/base/src/nsScriptLoader.cpp b/content/base/src/nsScriptLoader.cpp
index 2ddb1ed827f..ff20540f649 100644
--- a/content/base/src/nsScriptLoader.cpp
+++ b/content/base/src/nsScriptLoader.cpp
@@ -1461,7 +1461,7 @@ nsScriptLoader::PrepareLoadedRequest(nsScriptLoadRequest* aRequest,
   // principal as the origin principal
   if (aRequest->mCORSMode == CORS_NONE) {
     rv = nsContentUtils::GetSecurityManager()->
-      GetChannelPrincipal(channel, getter_AddRefs(aRequest->mOriginPrincipal));
+      GetChannelResultPrincipal(channel, getter_AddRefs(aRequest->mOriginPrincipal));
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
diff --git a/content/html/document/src/ImageDocument.cpp b/content/html/document/src/ImageDocument.cpp
index 8245a0d1915..08096a8a488 100644
--- a/content/html/document/src/ImageDocument.cpp
+++ b/content/html/document/src/ImageDocument.cpp
@@ -94,7 +94,7 @@ ImageListener::OnStartRequest(nsIRequest* request, nsISupports *ctxt)
   nsIScriptSecurityManager* secMan = nsContentUtils::GetSecurityManager();
   nsCOMPtr channelPrincipal;
   if (secMan) {
-    secMan->GetChannelPrincipal(channel, getter_AddRefs(channelPrincipal));
+    secMan->GetChannelResultPrincipal(channel, getter_AddRefs(channelPrincipal));
   }
 
   int16_t decision = nsIContentPolicy::ACCEPT;
diff --git a/content/media/MediaResource.cpp b/content/media/MediaResource.cpp
index 9a8b617183c..0c764313ed6 100644
--- a/content/media/MediaResource.cpp
+++ b/content/media/MediaResource.cpp
@@ -534,7 +534,7 @@ ChannelMediaResource::OnDataAvailable(nsIRequest* aRequest,
   CopySegmentClosure closure;
   nsIScriptSecurityManager* secMan = nsContentUtils::GetSecurityManager();
   if (secMan && mChannel) {
-    secMan->GetChannelPrincipal(mChannel, getter_AddRefs(closure.mPrincipal));
+    secMan->GetChannelResultPrincipal(mChannel, getter_AddRefs(closure.mPrincipal));
   }
   closure.mResource = this;
 
@@ -1406,7 +1406,7 @@ already_AddRefed FileMediaResource::GetCurrentPrincipal()
   nsIScriptSecurityManager* secMan = nsContentUtils::GetSecurityManager();
   if (!secMan || !mChannel)
     return nullptr;
-  secMan->GetChannelPrincipal(mChannel, getter_AddRefs(principal));
+  secMan->GetChannelResultPrincipal(mChannel, getter_AddRefs(principal));
   return principal.forget();
 }
 
diff --git a/content/media/RtspMediaResource.cpp b/content/media/RtspMediaResource.cpp
index 162aeca2123..16ab5a19129 100644
--- a/content/media/RtspMediaResource.cpp
+++ b/content/media/RtspMediaResource.cpp
@@ -740,7 +740,7 @@ already_AddRefed RtspMediaResource::GetCurrentPrincipal()
   nsIScriptSecurityManager* secMan = nsContentUtils::GetSecurityManager();
   if (!secMan || !mChannel)
     return nullptr;
-  secMan->GetChannelPrincipal(mChannel, getter_AddRefs(principal));
+  secMan->GetChannelResultPrincipal(mChannel, getter_AddRefs(principal));
   return principal.forget();
 }
 
diff --git a/content/xul/document/src/XULDocument.cpp b/content/xul/document/src/XULDocument.cpp
index 921bfe8bfd4..6a3a612eb2d 100644
--- a/content/xul/document/src/XULDocument.cpp
+++ b/content/xul/document/src/XULDocument.cpp
@@ -2004,7 +2004,7 @@ XULDocument::PrepareToLoad(nsISupports* aContainer,
     // Get the document's principal
     nsCOMPtr principal;
     nsContentUtils::GetSecurityManager()->
-        GetChannelPrincipal(aChannel, getter_AddRefs(principal));
+        GetChannelResultPrincipal(aChannel, getter_AddRefs(principal));
     return PrepareToLoadPrototype(mDocumentURI, aCommand, principal, aResult);
 }
 
@@ -4516,7 +4516,7 @@ XULDocument::ParserObserver::OnStartRequest(nsIRequest *request,
         nsIScriptSecurityManager* secMan = nsContentUtils::GetSecurityManager();
         if (channel && secMan) {
             nsCOMPtr principal;
-            secMan->GetChannelPrincipal(channel, getter_AddRefs(principal));
+            secMan->GetChannelResultPrincipal(channel, getter_AddRefs(principal));
 
             // Failure there is ok -- it'll just set a (safe) null principal
             mPrototype->SetDocumentPrincipal(principal);
diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp
index c30580d45be..fed0345c7c6 100644
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -6580,7 +6580,7 @@ NS_IMETHODIMP nsDocShell::SetupRefreshURI(nsIChannel * aChannel)
             NS_ENSURE_SUCCESS(rv, rv);
 
             nsCOMPtr principal;
-            rv = secMan->GetChannelPrincipal(aChannel, getter_AddRefs(principal));
+            rv = secMan->GetChannelResultPrincipal(aChannel, getter_AddRefs(principal));
             NS_ENSURE_SUCCESS(rv, rv);
 
             SetupReferrerFromChannel(aChannel);
diff --git a/dom/workers/ScriptLoader.cpp b/dom/workers/ScriptLoader.cpp
index ffc2a0d9c18..dee63087be4 100644
--- a/dom/workers/ScriptLoader.cpp
+++ b/dom/workers/ScriptLoader.cpp
@@ -502,7 +502,7 @@ private:
       NS_ASSERTION(ssm, "Should never be null!");
 
       nsCOMPtr channelPrincipal;
-      rv = ssm->GetChannelPrincipal(channel, getter_AddRefs(channelPrincipal));
+      rv = ssm->GetChannelResultPrincipal(channel, getter_AddRefs(channelPrincipal));
       NS_ENSURE_SUCCESS(rv, rv);
 
       // See if this is a resource URI. Since JSMs usually come from resource://
diff --git a/image/src/ImageFactory.cpp b/image/src/ImageFactory.cpp
index f2913aa55b4..e2249be237e 100644
--- a/image/src/ImageFactory.cpp
+++ b/image/src/ImageFactory.cpp
@@ -246,8 +246,8 @@ ImageFactory::CreateRasterImage(nsIRequest* aRequest,
       nsCOMPtr chan(do_QueryInterface(aRequest));
       nsCOMPtr principal;
       if (chan) {
-        nsContentUtils::GetSecurityManager()->GetChannelPrincipal(chan,
-                                                                  getter_AddRefs(principal));
+        nsContentUtils::GetSecurityManager()->GetChannelResultPrincipal(chan,
+                                                                        getter_AddRefs(principal));
       }
 
       if ((principal &&
diff --git a/image/src/imgRequest.cpp b/image/src/imgRequest.cpp
index 51030bf967b..fc984822cad 100644
--- a/image/src/imgRequest.cpp
+++ b/image/src/imgRequest.cpp
@@ -652,8 +652,8 @@ NS_IMETHODIMP imgRequest::OnStartRequest(nsIRequest *aRequest, nsISupports *ctxt
   if (chan) {
     nsCOMPtr secMan = nsContentUtils::GetSecurityManager();
     if (secMan) {
-      nsresult rv = secMan->GetChannelPrincipal(chan,
-                                                getter_AddRefs(mPrincipal));
+      nsresult rv = secMan->GetChannelResultPrincipal(chan,
+                                                      getter_AddRefs(mPrincipal));
       if (NS_FAILED(rv)) {
         return rv;
       }
diff --git a/layout/build/nsContentDLF.cpp b/layout/build/nsContentDLF.cpp
index c311b454816..0e0153f9eae 100644
--- a/layout/build/nsContentDLF.cpp
+++ b/layout/build/nsContentDLF.cpp
@@ -123,7 +123,7 @@ MayUseXULXBL(nsIChannel* aChannel)
   }
 
   nsCOMPtr principal;
-  securityManager->GetChannelPrincipal(aChannel, getter_AddRefs(principal));
+  securityManager->GetChannelResultPrincipal(aChannel, getter_AddRefs(principal));
   NS_ENSURE_TRUE(principal, false);
 
   return nsContentUtils::AllowXULXBLForPrincipal(principal);
diff --git a/layout/style/Loader.cpp b/layout/style/Loader.cpp
index 2605d0f2ca1..03f56b0a756 100644
--- a/layout/style/Loader.cpp
+++ b/layout/style/Loader.cpp
@@ -861,7 +861,7 @@ SheetLoadData::OnStreamComplete(nsIUnicharStreamLoader* aLoader,
     if (mUseSystemPrincipal) {
       result = secMan->GetSystemPrincipal(getter_AddRefs(principal));
     } else {
-      result = secMan->GetChannelPrincipal(channel, getter_AddRefs(principal));
+      result = secMan->GetChannelResultPrincipal(channel, getter_AddRefs(principal));
     }
   }
 
diff --git a/netwerk/base/src/nsChannelClassifier.cpp b/netwerk/base/src/nsChannelClassifier.cpp
index 80d8df94dd3..fae1ee4e776 100644
--- a/netwerk/base/src/nsChannelClassifier.cpp
+++ b/netwerk/base/src/nsChannelClassifier.cpp
@@ -226,8 +226,8 @@ nsChannelClassifier::Start(nsIChannel *aChannel)
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr principal;
-    rv = securityManager->GetChannelPrincipal(aChannel,
-                                              getter_AddRefs(principal));
+    rv = securityManager->GetChannelResultPrincipal(aChannel,
+                                                    getter_AddRefs(principal));
     NS_ENSURE_SUCCESS(rv, rv);
 
     bool expectCallback;
diff --git a/netwerk/protocol/http/HttpBaseChannel.cpp b/netwerk/protocol/http/HttpBaseChannel.cpp
index 24fae1ca27e..cb44b204cea 100644
--- a/netwerk/protocol/http/HttpBaseChannel.cpp
+++ b/netwerk/protocol/http/HttpBaseChannel.cpp
@@ -1736,7 +1736,7 @@ HttpBaseChannel::GetPrincipal(bool requireAppId)
       return nullptr;
   }
 
-  securityManager->GetChannelPrincipal(this, getter_AddRefs(mPrincipal));
+  securityManager->GetChannelResultPrincipal(this, getter_AddRefs(mPrincipal));
   if (!mPrincipal) {
       LOG(("HttpBaseChannel::GetPrincipal: No channel principal [this=%p]",
            this));
diff --git a/rdf/base/nsRDFXMLDataSource.cpp b/rdf/base/nsRDFXMLDataSource.cpp
index 0b2e094cc0c..b2a5700265e 100644
--- a/rdf/base/nsRDFXMLDataSource.cpp
+++ b/rdf/base/nsRDFXMLDataSource.cpp
@@ -882,7 +882,7 @@ RDFXMLDataSourceImpl::AsyncOnChannelRedirect(nsIChannel *aOldChannel,
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr oldPrincipal;
-    secMan->GetChannelPrincipal(aOldChannel, getter_AddRefs(oldPrincipal));
+    secMan->GetChannelResultPrincipal(aOldChannel, getter_AddRefs(oldPrincipal));
 
     nsCOMPtr newURI;
     aNewChannel->GetURI(getter_AddRefs(newURI));

From 59f71f5766d8fe6d352ff2f7a26f56bb0298f9bc Mon Sep 17 00:00:00 2001
From: Matthew Gregan 
Date: Thu, 4 Sep 2014 13:57:06 +1200
Subject: [PATCH 47/68] Bug 1059058 - Introduce abstraction to manager mapping
 between SourceBuffers and SourceBufferDecoders for the MediaSourceReader. 
 r=cajbir

---
 .../media/mediasource/MediaSourceDecoder.cpp  |  21 +
 .../media/mediasource/MediaSourceDecoder.h    |   4 +
 .../media/mediasource/MediaSourceReader.cpp   | 410 +++++++++---------
 content/media/mediasource/MediaSourceReader.h |  43 +-
 content/media/mediasource/SourceBuffer.cpp    | 140 ++----
 content/media/mediasource/SourceBuffer.h      |  13 +-
 .../media/mediasource/SourceBufferDecoder.cpp |   5 +-
 .../media/mediasource/SourceBufferDecoder.h   |  24 +-
 content/media/mediasource/TrackBuffer.cpp     | 339 +++++++++++++++
 content/media/mediasource/TrackBuffer.h       | 131 ++++++
 content/media/mediasource/moz.build           |   1 +
 content/media/mediasource/test/mochitest.ini  |   6 +
 .../mediasource/test/test_SplitAppend.html    |  83 ++++
 .../test/test_SplitAppendDelay.html           |  85 ++++
 14 files changed, 954 insertions(+), 351 deletions(-)
 create mode 100644 content/media/mediasource/TrackBuffer.cpp
 create mode 100644 content/media/mediasource/TrackBuffer.h
 create mode 100644 content/media/mediasource/test/test_SplitAppend.html
 create mode 100644 content/media/mediasource/test/test_SplitAppendDelay.html

diff --git a/content/media/mediasource/MediaSourceDecoder.cpp b/content/media/mediasource/MediaSourceDecoder.cpp
index 1a9e42af3d5..55a190cb96a 100644
--- a/content/media/mediasource/MediaSourceDecoder.cpp
+++ b/content/media/mediasource/MediaSourceDecoder.cpp
@@ -132,6 +132,27 @@ MediaSourceDecoder::CreateSubDecoder(const nsACString& aType)
   return mReader->CreateSubDecoder(aType);
 }
 
+void
+MediaSourceDecoder::AddTrackBuffer(TrackBuffer* aTrackBuffer)
+{
+  MOZ_ASSERT(mReader);
+  mReader->AddTrackBuffer(aTrackBuffer);
+}
+
+void
+MediaSourceDecoder::RemoveTrackBuffer(TrackBuffer* aTrackBuffer)
+{
+  MOZ_ASSERT(mReader);
+  mReader->RemoveTrackBuffer(aTrackBuffer);
+}
+
+void
+MediaSourceDecoder::OnTrackBufferConfigured(TrackBuffer* aTrackBuffer, const MediaInfo& aInfo)
+{
+  MOZ_ASSERT(mReader);
+  mReader->OnTrackBufferConfigured(aTrackBuffer, aInfo);
+}
+
 void
 MediaSourceDecoder::Ended()
 {
diff --git a/content/media/mediasource/MediaSourceDecoder.h b/content/media/mediasource/MediaSourceDecoder.h
index 591a36abee3..ec058f63b4d 100644
--- a/content/media/mediasource/MediaSourceDecoder.h
+++ b/content/media/mediasource/MediaSourceDecoder.h
@@ -20,6 +20,7 @@ class MediaResource;
 class MediaDecoderStateMachine;
 class MediaSourceReader;
 class SourceBufferDecoder;
+class TrackBuffer;
 
 namespace dom {
 
@@ -46,6 +47,9 @@ public:
   void DetachMediaSource();
 
   already_AddRefed CreateSubDecoder(const nsACString& aType);
+  void AddTrackBuffer(TrackBuffer* aTrackBuffer);
+  void RemoveTrackBuffer(TrackBuffer* aTrackBuffer);
+  void OnTrackBufferConfigured(TrackBuffer* aTrackBuffer, const MediaInfo& aInfo);
 
   void Ended();
 
diff --git a/content/media/mediasource/MediaSourceReader.cpp b/content/media/mediasource/MediaSourceReader.cpp
index d8b7311db77..906544e014b 100644
--- a/content/media/mediasource/MediaSourceReader.cpp
+++ b/content/media/mediasource/MediaSourceReader.cpp
@@ -14,6 +14,7 @@
 #include "MediaSourceDecoder.h"
 #include "MediaSourceUtils.h"
 #include "SourceBufferDecoder.h"
+#include "TrackBuffer.h"
 
 #ifdef MOZ_FMP4
 #include "MP4Decoder.h"
@@ -37,6 +38,8 @@ namespace mozilla {
 
 MediaSourceReader::MediaSourceReader(MediaSourceDecoder* aDecoder)
   : MediaDecoderReader(aDecoder)
+  , mLastAudioTime(-1)
+  , mLastVideoTime(-1)
   , mTimeThreshold(-1)
   , mDropAudioBeforeThreshold(false)
   , mDropVideoBeforeThreshold(false)
@@ -49,25 +52,35 @@ MediaSourceReader::MediaSourceReader(MediaSourceDecoder* aDecoder)
 bool
 MediaSourceReader::IsWaitingMediaResources()
 {
-  return mDecoders.IsEmpty() && mPendingDecoders.IsEmpty();
+  ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
+  for (uint32_t i = 0; i < mTrackBuffers.Length(); ++i) {
+    if (!mTrackBuffers[i]->IsReady()) {
+      return true;
+    }
+  }
+  return mTrackBuffers.IsEmpty();
 }
 
 void
 MediaSourceReader::RequestAudioData()
 {
+  MSE_DEBUGV("MediaSourceReader(%p)::RequestAudioData", this);
   if (!mAudioReader) {
     MSE_DEBUG("MediaSourceReader(%p)::RequestAudioData called with no audio reader", this);
-    MOZ_ASSERT(mPendingDecoders.IsEmpty());
     GetCallback()->OnDecodeError();
     return;
   }
-  SwitchReaders(SWITCH_OPTIONAL);
+  if (SwitchAudioReader(double(mLastAudioTime) / USECS_PER_S)) {
+    MSE_DEBUGV("MediaSourceReader(%p)::RequestAudioData switching audio reader", this);
+  }
   mAudioReader->RequestAudioData();
 }
 
 void
 MediaSourceReader::OnAudioDecoded(AudioData* aSample)
 {
+  MSE_DEBUGV("MediaSourceReader(%p)::OnAudioDecoded mTime=%lld mDuration=%lld d=%d",
+             this, aSample->mTime, aSample->mDuration, aSample->mDiscontinuity);
   if (mDropAudioBeforeThreshold) {
     if (aSample->mTime < mTimeThreshold) {
       MSE_DEBUG("MediaSourceReader(%p)::OnAudioDecoded mTime=%lld < mTimeThreshold=%lld",
@@ -86,21 +99,22 @@ MediaSourceReader::OnAudioDecoded(AudioData* aSample)
     mAudioIsSeeking = false;
     aSample->mDiscontinuity = true;
   }
+  mLastAudioTime = aSample->mTime + aSample->mDuration;
   GetCallback()->OnAudioDecoded(aSample);
 }
 
 void
 MediaSourceReader::OnAudioEOS()
 {
-  MSE_DEBUG("MediaSourceReader(%p)::OnAudioEOS reader=%p (readers=%u)",
-            this, mAudioReader.get(), mDecoders.Length());
-  if (SwitchReaders(SWITCH_FORCED)) {
+  MSE_DEBUG("MediaSourceReader(%p)::OnAudioEOS reader=%p (decoders=%u)",
+            this, mAudioReader.get(), mAudioTrack->Decoders().Length());
+  if (SwitchAudioReader(double(mLastAudioTime) / USECS_PER_S)) {
     // Success! Resume decoding with next audio decoder.
     RequestAudioData();
   } else if (IsEnded()) {
     // End of stream.
-    MSE_DEBUG("MediaSourceReader(%p)::OnAudioEOS reader=%p EOS (readers=%u)",
-              this, mAudioReader.get(), mDecoders.Length());
+    MSE_DEBUG("MediaSourceReader(%p)::OnAudioEOS reader=%p EOS (decoders=%u)",
+              this, mAudioReader.get(), mAudioTrack->Decoders().Length());
     GetCallback()->OnAudioEOS();
   }
 }
@@ -108,26 +122,35 @@ MediaSourceReader::OnAudioEOS()
 void
 MediaSourceReader::RequestVideoData(bool aSkipToNextKeyframe, int64_t aTimeThreshold)
 {
+  MSE_DEBUGV("MediaSourceReader(%p)::RequestVideoData(%d, %lld)",
+             this, aSkipToNextKeyframe, aTimeThreshold);
   if (!mVideoReader) {
     MSE_DEBUG("MediaSourceReader(%p)::RequestVideoData called with no video reader", this);
-    MOZ_ASSERT(mPendingDecoders.IsEmpty());
     GetCallback()->OnDecodeError();
     return;
   }
-  mTimeThreshold = aTimeThreshold;
-  SwitchReaders(SWITCH_OPTIONAL);
+  if (aSkipToNextKeyframe) {
+    mTimeThreshold = aTimeThreshold;
+    mDropAudioBeforeThreshold = true;
+    mDropVideoBeforeThreshold = true;
+  }
+  if (SwitchVideoReader(double(mLastVideoTime) / USECS_PER_S)) {
+    MSE_DEBUGV("MediaSourceReader(%p)::RequestVideoData switching video reader", this);
+  }
   mVideoReader->RequestVideoData(aSkipToNextKeyframe, aTimeThreshold);
 }
 
 void
 MediaSourceReader::OnVideoDecoded(VideoData* aSample)
 {
+  MSE_DEBUGV("MediaSourceReader(%p)::OnVideoDecoded mTime=%lld mDuration=%lld d=%d",
+             this, aSample->mTime, aSample->mDuration, aSample->mDiscontinuity);
   if (mDropVideoBeforeThreshold) {
     if (aSample->mTime < mTimeThreshold) {
       MSE_DEBUG("MediaSourceReader(%p)::OnVideoDecoded mTime=%lld < mTimeThreshold=%lld",
                 this, aSample->mTime, mTimeThreshold);
       delete aSample;
-      mVideoReader->RequestVideoData(false, mTimeThreshold);
+      mVideoReader->RequestVideoData(false, 0);
       return;
     }
     mDropVideoBeforeThreshold = false;
@@ -140,7 +163,7 @@ MediaSourceReader::OnVideoDecoded(VideoData* aSample)
     mVideoIsSeeking = false;
     aSample->mDiscontinuity = true;
   }
-
+  mLastVideoTime = aSample->mTime + aSample->mDuration;
   GetCallback()->OnVideoDecoded(aSample);
 }
 
@@ -148,15 +171,15 @@ void
 MediaSourceReader::OnVideoEOS()
 {
   // End of stream. See if we can switch to another video decoder.
-  MSE_DEBUG("MediaSourceReader(%p)::OnVideoEOS reader=%p (readers=%u)",
-            this, mVideoReader.get(), mDecoders.Length());
-  if (SwitchReaders(SWITCH_FORCED)) {
+  MSE_DEBUG("MediaSourceReader(%p)::OnVideoEOS reader=%p (decoders=%u)",
+            this, mVideoReader.get(), mVideoTrack->Decoders().Length());
+  if (SwitchVideoReader(double(mLastVideoTime) / USECS_PER_S)) {
     // Success! Resume decoding with next video decoder.
-    RequestVideoData(false, mTimeThreshold);
+    RequestVideoData(false, 0);
   } else if (IsEnded()) {
     // End of stream.
-    MSE_DEBUG("MediaSourceReader(%p)::OnVideoEOS reader=%p EOS (readers=%u)",
-              this, mVideoReader.get(), mDecoders.Length());
+    MSE_DEBUG("MediaSourceReader(%p)::OnVideoEOS reader=%p EOS (decoders=%u)",
+              this, mVideoReader.get(), mVideoTrack->Decoders().Length());
     GetCallback()->OnVideoEOS();
   }
 }
@@ -164,6 +187,7 @@ MediaSourceReader::OnVideoEOS()
 void
 MediaSourceReader::OnDecodeError()
 {
+  MSE_DEBUG("MediaSourceReader(%p)::OnDecodeError", this);
   GetCallback()->OnDecodeError();
 }
 
@@ -171,171 +195,105 @@ void
 MediaSourceReader::Shutdown()
 {
   MediaDecoderReader::Shutdown();
-  for (uint32_t i = 0; i < mDecoders.Length(); ++i) {
-    mDecoders[i]->GetReader()->Shutdown();
+  for (uint32_t i = 0; i < mTrackBuffers.Length(); ++i) {
+    mTrackBuffers[i]->Shutdown();
   }
+  mTrackBuffers.Clear();
+  mAudioTrack = nullptr;
+  mAudioReader = nullptr;
+  mVideoTrack = nullptr;
+  mVideoReader = nullptr;
 }
 
 void
 MediaSourceReader::BreakCycles()
 {
   MediaDecoderReader::BreakCycles();
-  for (uint32_t i = 0; i < mDecoders.Length(); ++i) {
-    mDecoders[i]->GetReader()->BreakCycles();
+    for (uint32_t i = 0; i < mTrackBuffers.Length(); ++i) {
+    mTrackBuffers[i]->BreakCycles();
   }
+  mTrackBuffers.Clear();
+  mAudioTrack = nullptr;
+  mAudioReader = nullptr;
+  mVideoTrack = nullptr;
+  mVideoReader = nullptr;
 }
 
 bool
-MediaSourceReader::SwitchAudioReader(MediaDecoderReader* aTargetReader)
+MediaSourceReader::SwitchAudioReader(double aTarget)
 {
-  if (aTargetReader == mAudioReader) {
+  ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
+  // XXX: Can't handle adding an audio track after ReadMetadata yet.
+  if (!mAudioTrack) {
     return false;
   }
-  if (mAudioReader) {
-    AudioInfo targetInfo = aTargetReader->GetMediaInfo().mAudio;
+  auto& decoders = mAudioTrack->Decoders();
+  for (uint32_t i = 0; i < decoders.Length(); ++i) {
+    nsRefPtr ranges = new dom::TimeRanges();
+    decoders[i]->GetBuffered(ranges);
+
+    MediaDecoderReader* newReader = decoders[i]->GetReader();
+    MSE_DEBUGV("MediaDecoderReader(%p)::SwitchAudioReader(%f) audioReader=%p reader=%p ranges=%s",
+               this, aTarget, mAudioReader.get(), newReader, DumpTimeRanges(ranges).get());
+
+    AudioInfo targetInfo = newReader->GetMediaInfo().mAudio;
     AudioInfo currentInfo = mAudioReader->GetMediaInfo().mAudio;
 
     // TODO: We can't handle switching audio formats yet.
     if (currentInfo.mRate != targetInfo.mRate ||
         currentInfo.mChannels != targetInfo.mChannels) {
-      return false;
+      continue;
     }
 
-    mAudioReader->SetIdle();
+    if (ranges->Find(aTarget) != dom::TimeRanges::NoIndex) {
+      if (newReader->AudioQueue().AtEndOfStream()) {
+        continue;
+      }
+      if (mAudioReader) {
+        mAudioReader->SetIdle();
+      }
+      mAudioReader = newReader;
+      MSE_DEBUG("MediaDecoderReader(%p)::SwitchAudioReader(%f) switching to audio reader %p",
+                this, aTarget, mAudioReader.get());
+      return true;
+    }
   }
-  mAudioReader = aTargetReader;
-  mDropAudioBeforeThreshold = true;
-  MSE_DEBUG("MediaDecoderReader(%p)::SwitchReaders(%p) switching audio reader",
-            this, mAudioReader.get());
-  return true;
+
+  return false;
 }
 
 bool
-MediaSourceReader::SwitchVideoReader(MediaDecoderReader* aTargetReader)
+MediaSourceReader::SwitchVideoReader(double aTarget)
 {
-  if (aTargetReader == mVideoReader) {
+  ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
+  // XXX: Can't handle adding a video track after ReadMetadata yet.
+  if (!mVideoTrack) {
     return false;
   }
-  if (mVideoReader) {
-    mVideoReader->SetIdle();
-  }
-  mVideoReader = aTargetReader;
-  mDropVideoBeforeThreshold = true;
-  MSE_DEBUG("MediaDecoderReader(%p)::SwitchVideoReader(%p) switching video reader",
-            this, mVideoReader.get());
-  return true;
-}
-
-bool
-MediaSourceReader::SwitchReaders(SwitchType aType)
-{
-  InitializePendingDecoders();
-
-  // This monitor must be held after the call to InitializePendingDecoders
-  // as that method also obtains the lock, and then attempts to exit it
-  // to call ReadMetadata on the readers. If we hold it before the call then
-  // it remains held during the ReadMetadata call causing a deadlock.
-  ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
-
-  bool didSwitch = false;
-  double decodeTarget = double(mTimeThreshold) / USECS_PER_S;
-
-  for (uint32_t i = 0; i < mDecoders.Length(); ++i) {
-    SourceBufferDecoder* decoder = mDecoders[i];
-    const MediaInfo& info = decoder->GetReader()->GetMediaInfo();
-
+  auto& decoders = mVideoTrack->Decoders();
+  for (uint32_t i = 0; i < decoders.Length(); ++i) {
     nsRefPtr ranges = new dom::TimeRanges();
-    decoder->GetBuffered(ranges);
+    decoders[i]->GetBuffered(ranges);
 
-    MSE_DEBUGV("MediaDecoderReader(%p)::SwitchReaders(%d) decoder=%u (%p) discarded=%d"
-               " reader=%p audioReader=%p videoReader=%p"
-               " hasAudio=%d hasVideo=%d decodeTarget=%f ranges=%s",
-               this, aType, i, decoder, decoder->IsDiscarded(),
-               decoder->GetReader(), mAudioReader.get(), mVideoReader.get(),
-               info.HasAudio(), info.HasVideo(), decodeTarget,
-               DumpTimeRanges(ranges).get());
+    MediaDecoderReader* newReader = decoders[i]->GetReader();
+    MSE_DEBUGV("MediaDecoderReader(%p)::SwitchVideoReader(%f) videoReader=%p reader=%p ranges=%s",
+               this, aTarget, mVideoReader.get(), newReader, DumpTimeRanges(ranges).get());
 
-    if (decoder->IsDiscarded()) {
-      continue;
-    }
-
-    if (aType == SWITCH_FORCED || ranges->Find(decodeTarget) != dom::TimeRanges::NoIndex) {
-      if (info.HasAudio()) {
-        didSwitch |= SwitchAudioReader(mDecoders[i]->GetReader());
+    if (ranges->Find(aTarget) != dom::TimeRanges::NoIndex) {
+      if (newReader->VideoQueue().AtEndOfStream()) {
+        continue;
       }
-      if (info.HasVideo()) {
-        didSwitch |= SwitchVideoReader(mDecoders[i]->GetReader());
+      if (mVideoReader) {
+        mVideoReader->SetIdle();
       }
+      mVideoReader = newReader;
+      MSE_DEBUG("MediaDecoderReader(%p)::SwitchVideoReader(%f) switching to video reader %p",
+                this, aTarget, mVideoReader.get());
+      return true;
     }
   }
 
-  return didSwitch;
-}
-
-class ReleaseDecodersTask : public nsRunnable {
-public:
-  explicit ReleaseDecodersTask(nsTArray>& aDecoders)
-  {
-    mDecoders.SwapElements(aDecoders);
-  }
-
-  NS_IMETHOD Run() MOZ_OVERRIDE MOZ_FINAL {
-    mDecoders.Clear();
-    return NS_OK;
-  }
-
-private:
-  nsTArray> mDecoders;
-};
-
-void
-MediaSourceReader::InitializePendingDecoders()
-{
-  ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
-  for (uint32_t i = 0; i < mPendingDecoders.Length(); ++i) {
-    nsRefPtr decoder = mPendingDecoders[i];
-    MediaDecoderReader* reader = decoder->GetReader();
-    MSE_DEBUG("MediaSourceReader(%p): Initializing subdecoder %p reader %p",
-              this, decoder.get(), reader);
-
-    MediaInfo mi;
-    nsAutoPtr tags; // TODO: Handle metadata.
-    nsresult rv;
-    {
-      ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
-      rv = reader->ReadMetadata(&mi, getter_Transfers(tags));
-    }
-    reader->SetIdle();
-    if (NS_FAILED(rv)) {
-      // XXX: Need to signal error back to owning SourceBuffer.
-      MSE_DEBUG("MediaSourceReader(%p): Reader %p failed to initialize rv=%x", this, reader, rv);
-      continue;
-    }
-
-    bool active = false;
-    if (mi.HasVideo() || mi.HasAudio()) {
-      MSE_DEBUG("MediaSourceReader(%p): Reader %p has video=%d audio=%d",
-                this, reader, mi.HasVideo(), mi.HasAudio());
-      if (mi.HasVideo()) {
-        MSE_DEBUG("MediaSourceReader(%p): Reader %p video resolution=%dx%d",
-                  this, reader, mi.mVideo.mDisplay.width, mi.mVideo.mDisplay.height);
-      }
-      if (mi.HasAudio()) {
-        MSE_DEBUG("MediaSourceReader(%p): Reader %p audio sampleRate=%d channels=%d",
-                  this, reader, mi.mAudio.mRate, mi.mAudio.mChannels);
-      }
-      active = true;
-    }
-
-    if (active) {
-      mDecoders.AppendElement(decoder);
-    } else {
-      MSE_DEBUG("MediaSourceReader(%p): Reader %p not activated", this, reader);
-    }
-  }
-  NS_DispatchToMainThread(new ReleaseDecodersTask(mPendingDecoders));
-  MOZ_ASSERT(mPendingDecoders.IsEmpty());
-  mDecoder->NotifyWaitingForResourcesStatusChanged();
+  return false;
 }
 
 MediaDecoderReader*
@@ -376,22 +334,51 @@ MediaSourceReader::CreateSubDecoder(const nsACString& aType)
   reader->SetCallback(callback);
   reader->SetTaskQueue(GetTaskQueue());
   reader->Init(nullptr);
-  ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
+
   MSE_DEBUG("MediaSourceReader(%p)::CreateSubDecoder subdecoder %p subreader %p",
             this, decoder.get(), reader.get());
   decoder->SetReader(reader);
-  mPendingDecoders.AppendElement(decoder);
-  RefPtr task =
-    NS_NewRunnableMethod(this, &MediaSourceReader::InitializePendingDecoders);
-  if (NS_FAILED(GetTaskQueue()->Dispatch(task))) {
-    MSE_DEBUG("MediaSourceReader(%p): Failed to enqueue decoder initialization task", this);
-    return nullptr;
-  }
-  mDecoder->NotifyWaitingForResourcesStatusChanged();
   return decoder.forget();
 }
 
-namespace {
+void
+MediaSourceReader::AddTrackBuffer(TrackBuffer* aTrackBuffer)
+{
+  ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
+  MSE_DEBUG("MediaSourceReader(%p)::AddTrackBuffer %p", this, aTrackBuffer);
+  mTrackBuffers.AppendElement(aTrackBuffer);
+}
+
+void
+MediaSourceReader::RemoveTrackBuffer(TrackBuffer* aTrackBuffer)
+{
+  ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
+  MSE_DEBUG("MediaSourceReader(%p)::RemoveTrackBuffer %p", this, aTrackBuffer);
+  mTrackBuffers.RemoveElement(aTrackBuffer);
+  if (mAudioTrack == aTrackBuffer) {
+    mAudioTrack = nullptr;
+  }
+  if (mVideoTrack == aTrackBuffer) {
+    mVideoTrack = nullptr;
+  }
+}
+
+void
+MediaSourceReader::OnTrackBufferConfigured(TrackBuffer* aTrackBuffer, const MediaInfo& aInfo)
+{
+  ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
+  MOZ_ASSERT(mTrackBuffers.Contains(aTrackBuffer));
+  if (aInfo.HasAudio() && !mAudioTrack) {
+    MSE_DEBUG("MediaSourceReader(%p)::OnTrackBufferConfigured %p audio", this, aTrackBuffer);
+    mAudioTrack = aTrackBuffer;
+  }
+  if (aInfo.HasVideo() && !mVideoTrack) {
+    MSE_DEBUG("MediaSourceReader(%p)::OnTrackBufferConfigured %p video", this, aTrackBuffer);
+    mVideoTrack = aTrackBuffer;
+  }
+  mDecoder->NotifyWaitingForResourcesStatusChanged();
+}
+
 class ChangeToHaveMetadata : public nsRunnable {
 public:
   explicit ChangeToHaveMetadata(AbstractMediaDecoder* aDecoder) :
@@ -410,23 +397,18 @@ public:
 private:
   nsRefPtr mDecoder;
 };
-}
 
 bool
-MediaSourceReader::DecodersContainTime(double aTime)
+MediaSourceReader::TrackBuffersContainTime(double aTime)
 {
-  bool found = false;
-
-  for (uint32_t i = 0; i < mDecoders.Length(); ++i) {
-    if (!mDecoders[i]->IsDiscarded()) {
-      if (!mDecoders[i]->ContainsTime(aTime)) {
-        // No use to continue searching, one source buffer isn't ready yet
-        return false;
-      }
-      found = true;
-    }
+  ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
+  if (mAudioTrack && !mAudioTrack->ContainsTime(aTime)) {
+    return false;
   }
-  return found;
+  if (mVideoTrack && !mVideoTrack->ContainsTime(aTime)) {
+    return false;
+  }
+  return true;
 }
 
 nsresult
@@ -435,8 +417,18 @@ MediaSourceReader::Seek(int64_t aTime, int64_t aStartTime, int64_t aEndTime,
 {
   MSE_DEBUG("MediaSourceReader(%p)::Seek(aTime=%lld, aStart=%lld, aEnd=%lld, aCurrent=%lld)",
             this, aTime, aStartTime, aEndTime, aCurrentTime);
+
+  ResetDecode();
+  for (uint32_t i = 0; i < mTrackBuffers.Length(); ++i) {
+    mTrackBuffers[i]->ResetDecode();
+  }
+
+  // Decoding discontinuity upon seek, reset last times to seek target.
+  mLastAudioTime = aTime;
+  mLastVideoTime = aTime;
+
   double target = static_cast(aTime) / USECS_PER_S;
-  if (!DecodersContainTime(target)) {
+  if (!TrackBuffersContainTime(target)) {
     MSE_DEBUG("MediaSourceReader(%p)::Seek no active buffer contains target=%f", this, target);
     NS_DispatchToMainThread(new ChangeToHaveMetadata(mDecoder));
   }
@@ -444,28 +436,30 @@ MediaSourceReader::Seek(int64_t aTime, int64_t aStartTime, int64_t aEndTime,
   // Loop until we have the requested time range in the source buffers.
   // This is a workaround for our lack of async functionality in the
   // MediaDecoderStateMachine. Bug 979104 implements what we need and
-  // we'll remove this for an async approach based on that in bug XXXXXXX.
-  while (!DecodersContainTime(target) && !IsShutdown() && !IsEnded()) {
+  // we'll remove this for an async approach based on that in bug 1056441.
+  while (!TrackBuffersContainTime(target) && !IsShutdown() && !IsEnded()) {
     MSE_DEBUG("MediaSourceReader(%p)::Seek waiting for target=%f", this, target);
     static_cast(mDecoder)->WaitForData();
-    SwitchReaders(SWITCH_FORCED);
   }
 
   if (IsShutdown()) {
     return NS_ERROR_FAILURE;
   }
 
-  ResetDecode();
-  if (mAudioReader) {
+  if (mAudioTrack) {
     mAudioIsSeeking = true;
+    DebugOnly ok = SwitchAudioReader(target);
+    MOZ_ASSERT(ok && static_cast(mAudioReader->GetDecoder())->ContainsTime(target));
     nsresult rv = mAudioReader->Seek(aTime, aStartTime, aEndTime, aCurrentTime);
     MSE_DEBUG("MediaSourceReader(%p)::Seek audio reader=%p rv=%x", this, mAudioReader.get(), rv);
     if (NS_FAILED(rv)) {
       return rv;
     }
   }
-  if (mVideoReader) {
+  if (mVideoTrack) {
     mVideoIsSeeking = true;
+    DebugOnly ok = SwitchVideoReader(target);
+    MOZ_ASSERT(ok && static_cast(mVideoReader->GetDecoder())->ContainsTime(target));
     nsresult rv = mVideoReader->Seek(aTime, aStartTime, aEndTime, aCurrentTime);
     MSE_DEBUG("MediaSourceReader(%p)::Seek video reader=%p rv=%x", this, mVideoReader.get(), rv);
     if (NS_FAILED(rv)) {
@@ -478,39 +472,41 @@ MediaSourceReader::Seek(int64_t aTime, int64_t aStartTime, int64_t aEndTime,
 nsresult
 MediaSourceReader::ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags)
 {
-  InitializePendingDecoders();
+  MSE_DEBUG("MediaSourceReader(%p)::ReadMetadata tracks=%u", this, mTrackBuffers.Length());
+  // ReadMetadata is called *before* checking IsWaitingMediaResources.
+  if (IsWaitingMediaResources()) {
+    return NS_OK;
+  }
+  if (!mAudioTrack && !mVideoTrack) {
+    MSE_DEBUG("MediaSourceReader(%p)::ReadMetadata missing track: mAudioTrack=%p mVideoTrack=%p",
+              this, mAudioTrack.get(), mVideoTrack.get());
+    return NS_ERROR_FAILURE;
+  }
 
-  MSE_DEBUG("MediaSourceReader(%p)::ReadMetadata decoders=%u", this, mDecoders.Length());
-
-  // XXX: Make subdecoder setup async, so that use cases like bug 989888 can
-  // work.  This will require teaching the state machine about dynamic track
-  // changes (and multiple tracks).
-  // Shorter term, make this block until we've got at least one video track
-  // and lie about having an audio track, then resample/remix as necessary
-  // to match any audio track added later to fit the format we lied about
-  // now.  For now we just configure what we've got and cross our fingers.
   int64_t maxDuration = -1;
-  for (uint32_t i = 0; i < mDecoders.Length(); ++i) {
-    MediaDecoderReader* reader = mDecoders[i]->GetReader();
 
-    MediaInfo mi = reader->GetMediaInfo();
+  if (mAudioTrack) {
+    MOZ_ASSERT(mAudioTrack->IsReady());
+    mAudioReader = mAudioTrack->Decoders()[0]->GetReader();
 
-    if (mi.HasVideo() && !mInfo.HasVideo()) {
-      MOZ_ASSERT(!mVideoReader);
-      mVideoReader = reader;
-      mInfo.mVideo = mi.mVideo;
-      maxDuration = std::max(maxDuration, mDecoders[i]->GetMediaDuration());
-      MSE_DEBUG("MediaSourceReader(%p)::ReadMetadata video reader=%p maxDuration=%lld",
-                this, reader, maxDuration);
-    }
-    if (mi.HasAudio() && !mInfo.HasAudio()) {
-      MOZ_ASSERT(!mAudioReader);
-      mAudioReader = reader;
-      mInfo.mAudio = mi.mAudio;
-      maxDuration = std::max(maxDuration, mDecoders[i]->GetMediaDuration());
-      MSE_DEBUG("MediaSourceReader(%p)::ReadMetadata audio reader=%p maxDuration=%lld",
-                this, reader, maxDuration);
-    }
+    const MediaInfo& info = mAudioReader->GetMediaInfo();
+    MOZ_ASSERT(info.HasAudio());
+    mInfo.mAudio = info.mAudio;
+    maxDuration = std::max(maxDuration, mAudioReader->GetDecoder()->GetMediaDuration());
+    MSE_DEBUG("MediaSourceReader(%p)::ReadMetadata audio reader=%p maxDuration=%lld",
+              this, mAudioReader.get(), maxDuration);
+  }
+
+  if (mVideoTrack) {
+    MOZ_ASSERT(mVideoTrack->IsReady());
+    mVideoReader = mVideoTrack->Decoders()[0]->GetReader();
+
+    const MediaInfo& info = mVideoReader->GetMediaInfo();
+    MOZ_ASSERT(info.HasVideo());
+    mInfo.mVideo = info.mVideo;
+    maxDuration = std::max(maxDuration, mVideoReader->GetDecoder()->GetMediaDuration());
+    MSE_DEBUG("MediaSourceReader(%p)::ReadMetadata video reader=%p maxDuration=%lld",
+              this, mVideoReader.get(), maxDuration);
   }
 
   if (maxDuration != -1) {
diff --git a/content/media/mediasource/MediaSourceReader.h b/content/media/mediasource/MediaSourceReader.h
index b30bfc7ab8f..9f49c15e372 100644
--- a/content/media/mediasource/MediaSourceReader.h
+++ b/content/media/mediasource/MediaSourceReader.h
@@ -19,6 +19,7 @@ namespace mozilla {
 
 class MediaSourceDecoder;
 class SourceBufferDecoder;
+class TrackBuffer;
 
 namespace dom {
 
@@ -70,22 +71,25 @@ public:
   nsresult ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags) MOZ_OVERRIDE;
   nsresult Seek(int64_t aTime, int64_t aStartTime, int64_t aEndTime,
                 int64_t aCurrentTime) MOZ_OVERRIDE;
+
   already_AddRefed CreateSubDecoder(const nsACString& aType);
 
+  void AddTrackBuffer(TrackBuffer* aTrackBuffer);
+  void RemoveTrackBuffer(TrackBuffer* aTrackBuffer);
+  void OnTrackBufferConfigured(TrackBuffer* aTrackBuffer, const MediaInfo& aInfo);
+
   void Shutdown();
 
   virtual void BreakCycles();
 
-  void InitializePendingDecoders();
-
   bool IsShutdown()
   {
     ReentrantMonitorAutoEnter decoderMon(mDecoder->GetReentrantMonitor());
     return mDecoder->IsShutdown();
   }
 
-  // Return true if any of the active decoders contain data for the given time
-  bool DecodersContainTime(double aTime);
+  // Return true if all of the active tracks contain data for the specified time.
+  bool TrackBuffersContainTime(double aTime);
 
   // Mark the reader to indicate that EndOfStream has been called on our MediaSource
   void Ended();
@@ -94,27 +98,24 @@ public:
   bool IsEnded();
 
 private:
-  enum SwitchType {
-    SWITCH_OPTIONAL,
-    SWITCH_FORCED
-  };
-
-  bool SwitchReaders(SwitchType aType);
-
-  bool SwitchAudioReader(MediaDecoderReader* aTargetReader);
-  bool SwitchVideoReader(MediaDecoderReader* aTargetReader);
-
-  // These are read and written on the decode task queue threads.
-  int64_t mTimeThreshold;
-  bool mDropAudioBeforeThreshold;
-  bool mDropVideoBeforeThreshold;
-
-  nsTArray> mPendingDecoders;
-  nsTArray> mDecoders;
+  bool SwitchAudioReader(double aTarget);
+  bool SwitchVideoReader(double aTarget);
 
   nsRefPtr mAudioReader;
   nsRefPtr mVideoReader;
 
+  nsTArray> mTrackBuffers;
+  nsRefPtr mAudioTrack;
+  nsRefPtr mVideoTrack;
+
+  // These are read and written on the decode task queue threads.
+  int64_t mLastAudioTime;
+  int64_t mLastVideoTime;
+
+  int64_t mTimeThreshold;
+  bool mDropAudioBeforeThreshold;
+  bool mDropVideoBeforeThreshold;
+
   bool mEnded;
 
   // For a seek to complete we need to send a sample with
diff --git a/content/media/mediasource/SourceBuffer.cpp b/content/media/mediasource/SourceBuffer.cpp
index d2c36f5b82e..d68359d83a6 100644
--- a/content/media/mediasource/SourceBuffer.cpp
+++ b/content/media/mediasource/SourceBuffer.cpp
@@ -6,14 +6,14 @@
 #include "SourceBuffer.h"
 
 #include "AsyncEventRunner.h"
-#include "DecoderTraits.h"
-#include "MediaDecoder.h"
-#include "MediaSourceDecoder.h"
 #include "MediaSourceUtils.h"
-#include "SourceBufferResource.h"
+#include "TrackBuffer.h"
+#include "VideoUtils.h"
+#include "WebMBufferedParser.h"
 #include "mozilla/Endian.h"
 #include "mozilla/ErrorResult.h"
 #include "mozilla/FloatingPoint.h"
+#include "mozilla/Preferences.h"
 #include "mozilla/dom/MediaSourceBinding.h"
 #include "mozilla/dom/TimeRanges.h"
 #include "mp4_demuxer/BufferStream.h"
@@ -23,10 +23,6 @@
 #include "nsIRunnable.h"
 #include "nsThreadUtils.h"
 #include "prlog.h"
-#include "SourceBufferDecoder.h"
-#include "mozilla/Preferences.h"
-
-#include "WebMBufferedParser.h"
 
 struct JSContext;
 class JSObject;
@@ -335,19 +331,8 @@ SourceBuffer::GetBuffered(ErrorResult& aRv)
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return nullptr;
   }
-  double highestEndTime = 0;
   nsRefPtr ranges = new TimeRanges();
-  // TODO: Need to adjust mDecoders so it only tracks active decoders.
-  // Once we have an abstraction for track buffers, this needs to report the
-  // intersection of buffered ranges within those track buffers.
-  for (uint32_t i = 0; i < mDecoders.Length(); ++i) {
-    nsRefPtr r = new TimeRanges();
-    mDecoders[i]->GetBuffered(r);
-    if (r->Length() > 0) {
-      highestEndTime = std::max(highestEndTime, r->GetEndTime());
-      ranges->Union(r);
-    }
-  }
+  double highestEndTime = mTrackBuffer->Buffered(ranges);
   if (mMediaSource->ReadyState() == MediaSourceReadyState::Ended) {
     // Set the end time on the last range to highestEndTime by adding a
     // new range spanning the current end time to highestEndTime, which
@@ -432,7 +417,7 @@ SourceBuffer::Abort(ErrorResult& aRv)
   mAppendWindowEnd = PositiveInfinity();
 
   MSE_DEBUG("SourceBuffer(%p)::Abort() Discarding decoder", this);
-  DiscardDecoder();
+  mTrackBuffer->DiscardDecoder();
 }
 
 void
@@ -464,8 +449,10 @@ SourceBuffer::Detach()
 {
   MOZ_ASSERT(NS_IsMainThread());
   MSE_DEBUG("SourceBuffer(%p)::Detach", this);
-  Ended();
-  DiscardDecoder();
+  if (mTrackBuffer) {
+    mTrackBuffer->Detach();
+  }
+  mTrackBuffer = nullptr;
   mMediaSource = nullptr;
 }
 
@@ -473,36 +460,34 @@ void
 SourceBuffer::Ended()
 {
   MOZ_ASSERT(NS_IsMainThread());
+  MOZ_ASSERT(IsAttached());
   MSE_DEBUG("SourceBuffer(%p)::Ended", this);
-  if (mDecoder) {
-    mDecoder->GetResource()->Ended();
-  }
+  mTrackBuffer->DiscardDecoder();
 }
 
 SourceBuffer::SourceBuffer(MediaSource* aMediaSource, const nsACString& aType)
   : DOMEventTargetHelper(aMediaSource->GetParentObject())
   , mMediaSource(aMediaSource)
   , mType(aType)
-  , mLastParsedTimestamp(UnspecifiedNaN())
   , mAppendWindowStart(0)
   , mAppendWindowEnd(PositiveInfinity())
   , mTimestampOffset(0)
   , mAppendMode(SourceBufferAppendMode::Segments)
   , mUpdating(false)
-  , mDecoderInitialized(false)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aMediaSource);
   mParser = ContainerParser::CreateForMIMEType(aType);
-  MSE_DEBUG("SourceBuffer(%p)::SourceBuffer: Creating initial decoder, mParser=%p", this, mParser.get());
-  InitNewDecoder();
+  mTrackBuffer = new TrackBuffer(aMediaSource->GetDecoder(), aType);
+  MSE_DEBUG("SourceBuffer(%p)::SourceBuffer: Create mParser=%p mTrackBuffer=%p",
+            this, mParser.get(), mTrackBuffer.get());
 }
 
 SourceBuffer::~SourceBuffer()
 {
   MOZ_ASSERT(NS_IsMainThread());
+  MOZ_ASSERT(!mMediaSource);
   MSE_DEBUG("SourceBuffer(%p)::~SourceBuffer", this);
-  DiscardDecoder();
 }
 
 MediaSource*
@@ -533,37 +518,6 @@ SourceBuffer::QueueAsyncSimpleEvent(const char* aName)
   NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
 }
 
-bool
-SourceBuffer::InitNewDecoder()
-{
-  MOZ_ASSERT(NS_IsMainThread());
-  MSE_DEBUG("SourceBuffer(%p)::InitNewDecoder", this);
-  MOZ_ASSERT(!mDecoder);
-  MediaSourceDecoder* parentDecoder = mMediaSource->GetDecoder();
-  nsRefPtr decoder = parentDecoder->CreateSubDecoder(mType);
-  if (!decoder) {
-    return false;
-  }
-  mDecoder = decoder;
-  mDecoderInitialized = false;
-  mDecoders.AppendElement(mDecoder);
-  return true;
-}
-
-void
-SourceBuffer::DiscardDecoder()
-{
-  MOZ_ASSERT(NS_IsMainThread());
-  MSE_DEBUG("SourceBuffer(%p)::DiscardDecoder mDecoder=%p", this, mDecoder.get());
-  if (mDecoder) {
-    mDecoder->SetDiscarded();
-  }
-  mDecoder = nullptr;
-  mDecoderInitialized = false;
-  // XXX: Parser reset may be required?
-  mLastParsedTimestamp = UnspecifiedNaN();
-}
-
 void
 SourceBuffer::StartUpdating()
 {
@@ -610,21 +564,14 @@ SourceBuffer::AppendData(const uint8_t* aData, uint32_t aLength, ErrorResult& aR
   // TODO: Run buffer append algorithm asynchronously (would call StopUpdating()).
   if (mParser->IsInitSegmentPresent(aData, aLength)) {
     MSE_DEBUG("SourceBuffer(%p)::AppendData: New initialization segment.", this);
-    if (mDecoderInitialized) {
-      // Existing decoder has been used, time for a new one.
-      DiscardDecoder();
-    }
-
-    // If we've got a decoder here, it's not initialized, so we can use it
-    // rather than creating a new one.
-    if (!mDecoder && !InitNewDecoder()) {
+    mTrackBuffer->DiscardDecoder();
+    if (!mTrackBuffer->NewDecoder()) {
       aRv.Throw(NS_ERROR_FAILURE); // XXX: Review error handling.
       return;
     }
     MSE_DEBUG("SourceBuffer(%p)::AppendData: Decoder marked as initialized.", this);
-    mDecoderInitialized = true;
-  } else if (!mDecoderInitialized) {
-    MSE_DEBUG("SourceBuffer(%p)::AppendData: Non-init segment appended during initialization.");
+  } else if (!mTrackBuffer->HasInitSegment()) {
+    MSE_DEBUG("SourceBuffer(%p)::AppendData: Non-init segment appended during initialization.", this);
     Optional decodeError(MediaSourceEndOfStreamError::Decode);
     ErrorResult dummy;
     mMediaSource->EndOfStream(decodeError, dummy);
@@ -633,37 +580,39 @@ SourceBuffer::AppendData(const uint8_t* aData, uint32_t aLength, ErrorResult& aR
   }
   double start, end;
   if (mParser->ParseStartAndEndTimestamps(aData, aLength, start, end)) {
+    double lastStart, lastEnd;
+    mTrackBuffer->LastTimestamp(lastStart, lastEnd);
     if (mParser->IsMediaSegmentPresent(aData, aLength) &&
-        (start < mLastParsedTimestamp || start - mLastParsedTimestamp > 0.1)) {
-      MSE_DEBUG("SourceBuffer(%p)::AppendData: Data (%f, %f) overlaps %f.",
-                this, start, end, mLastParsedTimestamp);
+        (start < lastEnd || start - lastEnd > 0.1)) {
+      MSE_DEBUG("SourceBuffer(%p)::AppendData: Data last=[%f, %f] overlaps [%f, %f]",
+                this, lastStart, lastEnd, start, end);
 
       // This data is earlier in the timeline than data we have already
       // processed, so we must create a new decoder to handle the decoding.
-      DiscardDecoder();
+      mTrackBuffer->DiscardDecoder();
 
       // If we've got a decoder here, it's not initialized, so we can use it
       // rather than creating a new one.
-      if (!InitNewDecoder()) {
+      if (!mTrackBuffer->NewDecoder()) {
         aRv.Throw(NS_ERROR_FAILURE); // XXX: Review error handling.
         return;
       }
       MSE_DEBUG("SourceBuffer(%p)::AppendData: Decoder marked as initialized.", this);
-      mDecoderInitialized = true;
       const nsTArray& initData = mParser->InitData();
-      mDecoder->NotifyDataArrived(reinterpret_cast(initData.Elements()),
-                                  initData.Length(),
-                                  0);
-      mDecoder->GetResource()->AppendData(initData.Elements(), initData.Length());
+      mTrackBuffer->AppendData(initData.Elements(), initData.Length());
+      mTrackBuffer->SetLastStartTimestamp(start);
     }
-    mLastParsedTimestamp = end;
-    MSE_DEBUG("SourceBuffer(%p)::AppendData: Segment start=%f end=%f", this, start, end);
+    mTrackBuffer->SetLastEndTimestamp(end);
+    MSE_DEBUG("SourceBuffer(%p)::AppendData: Segment last=[%f, %f] [%f, %f]",
+              this, lastStart, lastEnd, start, end);
+  }
+  if (!mTrackBuffer->AppendData(aData, aLength)) {
+    Optional decodeError(MediaSourceEndOfStreamError::Decode);
+    ErrorResult dummy;
+    mMediaSource->EndOfStream(decodeError, dummy);
+    aRv.Throw(NS_ERROR_FAILURE);
+    return;
   }
-  // XXX: For future reference: NDA call must run on the main thread.
-  mDecoder->NotifyDataArrived(reinterpret_cast(aData),
-                              aLength,
-                              mDecoder->GetResource()->GetLength());
-  mDecoder->GetResource()->AppendData(aData, aLength);
 
   // Eviction uses a byte threshold. If the buffer is greater than the
   // number of bytes then data is evicted. The time range for this
@@ -673,7 +622,7 @@ SourceBuffer::AppendData(const uint8_t* aData, uint32_t aLength, ErrorResult& aR
   // TODO: Make the eviction threshold smaller for audio-only streams.
   // TODO: Drive evictions off memory pressure notifications.
   const uint32_t evict_threshold = 75 * (1 << 20);
-  bool evicted = mDecoder->GetResource()->EvictData(evict_threshold);
+  bool evicted = mTrackBuffer->EvictData(evict_threshold);
   if (evicted) {
     MSE_DEBUG("SourceBuffer(%p)::AppendData Evict; current buffered start=%f",
               this, GetBufferedStart());
@@ -714,20 +663,13 @@ SourceBuffer::Evict(double aStart, double aEnd)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MSE_DEBUG("SourceBuffer(%p)::Evict(aStart=%f, aEnd=%f)", this, aStart, aEnd);
-  if (!mDecoder) {
-    return;
-  }
   double currentTime = mMediaSource->GetDecoder()->GetCurrentTime();
   double evictTime = aEnd;
   const double safety_threshold = 5;
   if (currentTime + safety_threshold >= evictTime) {
     evictTime -= safety_threshold;
   }
-  int64_t endOffset = mDecoder->ConvertToByteOffset(evictTime);
-  if (endOffset > 0) {
-    mDecoder->GetResource()->EvictBefore(endOffset);
-  }
-  MSE_DEBUG("SourceBuffer(%p)::Evict offset=%lld", this, endOffset);
+  mTrackBuffer->EvictBefore(evictTime);
 }
 
 NS_IMPL_CYCLE_COLLECTION_INHERITED(SourceBuffer, DOMEventTargetHelper,
diff --git a/content/media/mediasource/SourceBuffer.h b/content/media/mediasource/SourceBuffer.h
index 0b51923804a..f2aa2d6de6a 100644
--- a/content/media/mediasource/SourceBuffer.h
+++ b/content/media/mediasource/SourceBuffer.h
@@ -7,14 +7,13 @@
 #ifndef mozilla_dom_SourceBuffer_h_
 #define mozilla_dom_SourceBuffer_h_
 
-#include "MediaDecoderReader.h"
 #include "MediaSource.h"
 #include "js/RootingAPI.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/Attributes.h"
+#include "mozilla/DOMEventTargetHelper.h"
 #include "mozilla/dom/SourceBufferBinding.h"
 #include "mozilla/dom/TypedArray.h"
-#include "mozilla/DOMEventTargetHelper.h"
 #include "mozilla/mozalloc.h"
 #include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
@@ -31,8 +30,7 @@ namespace mozilla {
 
 class ContainerParser;
 class ErrorResult;
-class SourceBufferResource;
-class SourceBufferDecoder;
+class TrackBuffer;
 template  class AsyncEventRunner;
 
 namespace dom {
@@ -139,10 +137,7 @@ private:
 
   nsAutoPtr mParser;
 
-  double mLastParsedTimestamp;
-
-  nsRefPtr mDecoder;
-  nsTArray> mDecoders;
+  nsRefPtr mTrackBuffer;
 
   double mAppendWindowStart;
   double mAppendWindowEnd;
@@ -151,8 +146,6 @@ private:
 
   SourceBufferAppendMode mAppendMode;
   bool mUpdating;
-
-  bool mDecoderInitialized;
 };
 
 } // namespace dom
diff --git a/content/media/mediasource/SourceBufferDecoder.cpp b/content/media/mediasource/SourceBufferDecoder.cpp
index f7716dfac40..c95e97e5a46 100644
--- a/content/media/mediasource/SourceBufferDecoder.cpp
+++ b/content/media/mediasource/SourceBufferDecoder.cpp
@@ -38,7 +38,6 @@ SourceBufferDecoder::SourceBufferDecoder(MediaResource* aResource,
   , mParentDecoder(aParentDecoder)
   , mReader(nullptr)
   , mMediaDuration(-1)
-  , mDiscarded(false)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_COUNT_CTOR(SourceBufferDecoder);
@@ -147,6 +146,10 @@ SourceBufferDecoder::OnStateMachineThread() const
 bool
 SourceBufferDecoder::OnDecodeThread() const
 {
+  // During initialization we run on our TrackBuffer's task queue.
+  if (mTaskQueue) {
+    return mTaskQueue->IsCurrentThreadIn();
+  }
   return mParentDecoder->OnDecodeThread();
 }
 
diff --git a/content/media/mediasource/SourceBufferDecoder.h b/content/media/mediasource/SourceBufferDecoder.h
index fc11196f4b1..b9eeba5018a 100644
--- a/content/media/mediasource/SourceBufferDecoder.h
+++ b/content/media/mediasource/SourceBufferDecoder.h
@@ -8,9 +8,10 @@
 #define MOZILLA_SOURCEBUFFERDECODER_H_
 
 #include "AbstractMediaDecoder.h"
+#include "MediaDecoderReader.h"
+#include "SourceBufferResource.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/ReentrantMonitor.h"
-#include "SourceBufferResource.h"
 
 namespace mozilla {
 
@@ -74,33 +75,30 @@ public:
     return mReader;
   }
 
+  void SetTaskQueue(MediaTaskQueue* aTaskQueue)
+  {
+    MOZ_ASSERT((!mTaskQueue && aTaskQueue) || (mTaskQueue && !aTaskQueue));
+    mTaskQueue = aTaskQueue;
+  }
+
   // Given a time convert it into an approximate byte offset from the
   // cached data. Returns -1 if no such value is computable.
   int64_t ConvertToByteOffset(double aTime);
 
-  bool IsDiscarded()
-  {
-    return mDiscarded;
-  }
-
-  void SetDiscarded()
-  {
-    GetResource()->Ended();
-    mDiscarded = true;
-  }
-
   // Returns true if the data buffered by this decoder contains the given time.
   bool ContainsTime(double aTime);
 
 private:
   virtual ~SourceBufferDecoder();
 
+  // Our TrackBuffer's task queue, this is only non-null during initialization.
+  RefPtr mTaskQueue;
+
   nsRefPtr mResource;
 
   AbstractMediaDecoder* mParentDecoder;
   nsRefPtr mReader;
   int64_t mMediaDuration;
-  bool mDiscarded;
 };
 
 } // namespace mozilla
diff --git a/content/media/mediasource/TrackBuffer.cpp b/content/media/mediasource/TrackBuffer.cpp
new file mode 100644
index 00000000000..a1659bd366c
--- /dev/null
+++ b/content/media/mediasource/TrackBuffer.cpp
@@ -0,0 +1,339 @@
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "TrackBuffer.h"
+
+#include "MediaSourceDecoder.h"
+#include "SharedThreadPool.h"
+#include "MediaTaskQueue.h"
+#include "SourceBufferDecoder.h"
+#include "SourceBufferResource.h"
+#include "VideoUtils.h"
+#include "mozilla/FloatingPoint.h"
+#include "mozilla/dom/MediaSourceBinding.h"
+#include "mozilla/dom/TimeRanges.h"
+#include "nsError.h"
+#include "nsIRunnable.h"
+#include "nsThreadUtils.h"
+#include "prlog.h"
+
+struct JSContext;
+class JSObject;
+
+#ifdef PR_LOGGING
+extern PRLogModuleInfo* GetMediaSourceLog();
+extern PRLogModuleInfo* GetMediaSourceAPILog();
+
+#define MSE_DEBUG(...) PR_LOG(GetMediaSourceLog(), PR_LOG_DEBUG, (__VA_ARGS__))
+#define MSE_DEBUGV(...) PR_LOG(GetMediaSourceLog(), PR_LOG_DEBUG+1, (__VA_ARGS__))
+#define MSE_API(...) PR_LOG(GetMediaSourceAPILog(), PR_LOG_DEBUG, (__VA_ARGS__))
+#else
+#define MSE_DEBUG(...)
+#define MSE_DEBUGV(...)
+#define MSE_API(...)
+#endif
+
+namespace mozilla {
+
+TrackBuffer::TrackBuffer(MediaSourceDecoder* aParentDecoder, const nsACString& aType)
+  : mParentDecoder(aParentDecoder)
+  , mType(aType)
+  , mLastStartTimestamp(0)
+  , mLastEndTimestamp(UnspecifiedNaN())
+  , mHasInit(false)
+  , mHasAudio(false)
+  , mHasVideo(false)
+{
+  MOZ_COUNT_CTOR(TrackBuffer);
+  mTaskQueue = new MediaTaskQueue(GetMediaDecodeThreadPool());
+  aParentDecoder->AddTrackBuffer(this);
+}
+
+TrackBuffer::~TrackBuffer()
+{
+  MOZ_COUNT_DTOR(TrackBuffer);
+}
+
+class ReleaseDecoderTask : public nsRunnable {
+public:
+  explicit ReleaseDecoderTask(nsRefPtr aDecoder)
+  {
+    mDecoders.AppendElement(aDecoder);
+  }
+
+  explicit ReleaseDecoderTask(nsTArray>& aDecoders)
+  {
+    mDecoders.SwapElements(aDecoders);
+  }
+
+  NS_IMETHOD Run() MOZ_OVERRIDE MOZ_FINAL {
+    mDecoders.Clear();
+    return NS_OK;
+  }
+
+private:
+  nsTArray> mDecoders;
+};
+
+void
+TrackBuffer::Shutdown()
+{
+  // Shutdown waits for any pending events, which may require the monitor,
+  // so we must not hold the monitor during this call.
+  mParentDecoder->GetReentrantMonitor().AssertNotCurrentThreadIn();
+  mTaskQueue->Shutdown();
+  mTaskQueue = nullptr;
+
+  ReentrantMonitorAutoEnter mon(mParentDecoder->GetReentrantMonitor());
+  DiscardDecoder();
+  for (uint32_t i = 0; i < mDecoders.Length(); ++i) {
+    mDecoders[i]->GetReader()->Shutdown();
+  }
+  NS_DispatchToMainThread(new ReleaseDecoderTask(mDecoders));
+  MOZ_ASSERT(mDecoders.IsEmpty());
+  mParentDecoder = nullptr;
+}
+
+bool
+TrackBuffer::AppendData(const uint8_t* aData, uint32_t aLength)
+{
+  MOZ_ASSERT(NS_IsMainThread());
+  if (!mCurrentDecoder) {
+    return false;
+  }
+
+  SourceBufferResource* resource = mCurrentDecoder->GetResource();
+  // XXX: For future reference: NDA call must run on the main thread.
+  mCurrentDecoder->NotifyDataArrived(reinterpret_cast(aData),
+                                     aLength, resource->GetLength());
+  resource->AppendData(aData, aLength);
+  return true;
+}
+
+bool
+TrackBuffer::EvictData(uint32_t aThreshold)
+{
+  MOZ_ASSERT(NS_IsMainThread());
+  // XXX Call EvictData on mDecoders?
+  return mCurrentDecoder->GetResource()->EvictData(aThreshold);
+}
+
+void
+TrackBuffer::EvictBefore(double aTime)
+{
+  MOZ_ASSERT(NS_IsMainThread());
+  // XXX Call EvictBefore on mDecoders?
+  int64_t endOffset = mCurrentDecoder->ConvertToByteOffset(aTime);
+  if (endOffset > 0) {
+    mCurrentDecoder->GetResource()->EvictBefore(endOffset);
+  }
+  MSE_DEBUG("TrackBuffer(%p)::EvictBefore offset=%lld", this, endOffset);
+}
+
+double
+TrackBuffer::Buffered(dom::TimeRanges* aRanges)
+{
+  MOZ_ASSERT(NS_IsMainThread());
+  // XXX check default if mDecoders empty?
+  double highestEndTime = 0;
+
+  for (uint32_t i = 0; i < mDecoders.Length(); ++i) {
+    nsRefPtr r = new dom::TimeRanges();
+    mDecoders[i]->GetBuffered(r);
+    if (r->Length() > 0) {
+      highestEndTime = std::max(highestEndTime, r->GetEndTime());
+      aRanges->Union(r);
+    }
+  }
+
+  return highestEndTime;
+}
+
+bool
+TrackBuffer::NewDecoder()
+{
+  MOZ_ASSERT(NS_IsMainThread());
+  MOZ_ASSERT(!mCurrentDecoder && mParentDecoder);
+
+  nsRefPtr decoder = mParentDecoder->CreateSubDecoder(mType);
+  if (!decoder) {
+    return false;
+  }
+  ReentrantMonitorAutoEnter mon(mParentDecoder->GetReentrantMonitor());
+  mCurrentDecoder = decoder;
+
+  mLastStartTimestamp = 0;
+  mLastEndTimestamp = UnspecifiedNaN();
+  mHasInit = true;
+
+  return QueueInitializeDecoder(decoder);
+}
+
+bool
+TrackBuffer::QueueInitializeDecoder(nsRefPtr aDecoder)
+{
+  RefPtr task =
+    NS_NewRunnableMethodWithArg>(this,
+                                                               &TrackBuffer::InitializeDecoder,
+                                                               aDecoder);
+  aDecoder->SetTaskQueue(mTaskQueue);
+  if (NS_FAILED(mTaskQueue->Dispatch(task))) {
+    MSE_DEBUG("MediaSourceReader(%p): Failed to enqueue decoder initialization task", this);
+    return false;
+  }
+  return true;
+}
+
+void
+TrackBuffer::InitializeDecoder(nsRefPtr aDecoder)
+{
+  // ReadMetadata may block the thread waiting on data, so it must not be
+  // called with the monitor held.
+  mParentDecoder->GetReentrantMonitor().AssertNotCurrentThreadIn();
+
+  MediaDecoderReader* reader = aDecoder->GetReader();
+  MSE_DEBUG("TrackBuffer(%p): Initializing subdecoder %p reader %p",
+            this, aDecoder.get(), reader);
+
+  MediaInfo mi;
+  nsAutoPtr tags; // TODO: Handle metadata.
+  nsresult rv = reader->ReadMetadata(&mi, getter_Transfers(tags));
+  reader->SetIdle();
+  if (NS_FAILED(rv) || (!mi.HasVideo() && !mi.HasAudio())) {
+    // XXX: Need to signal error back to owning SourceBuffer.
+    MSE_DEBUG("TrackBuffer(%p): Reader %p failed to initialize rv=%x audio=%d video=%d",
+              this, reader, rv, mi.HasAudio(), mi.HasVideo());
+    aDecoder->SetTaskQueue(nullptr);
+    NS_DispatchToMainThread(new ReleaseDecoderTask(aDecoder));
+    return;
+  }
+
+  if (mi.HasVideo()) {
+    MSE_DEBUG("TrackBuffer(%p): Reader %p video resolution=%dx%d",
+              this, reader, mi.mVideo.mDisplay.width, mi.mVideo.mDisplay.height);
+  }
+  if (mi.HasAudio()) {
+    MSE_DEBUG("TrackBuffer(%p): Reader %p audio sampleRate=%d channels=%d",
+              this, reader, mi.mAudio.mRate, mi.mAudio.mChannels);
+  }
+
+  MSE_DEBUG("TrackBuffer(%p): Reader %p activated", this, reader);
+  RegisterDecoder(aDecoder);
+}
+
+void
+TrackBuffer::RegisterDecoder(nsRefPtr aDecoder)
+{
+  ReentrantMonitorAutoEnter mon(mParentDecoder->GetReentrantMonitor());
+  aDecoder->SetTaskQueue(nullptr);
+  const MediaInfo& info = aDecoder->GetReader()->GetMediaInfo();
+  // Initialize the track info since this is the first decoder.
+  if (mDecoders.IsEmpty()) {
+    mHasAudio = info.HasAudio();
+    mHasVideo = info.HasVideo();
+    mParentDecoder->OnTrackBufferConfigured(this, info);
+  } else if ((info.HasAudio() && !mHasAudio) || (info.HasVideo() && !mHasVideo)) {
+    MSE_DEBUG("TrackBuffer(%p)::RegisterDecoder with mismatched audio/video tracks", this);
+  }
+  mDecoders.AppendElement(aDecoder);
+}
+
+void
+TrackBuffer::DiscardDecoder()
+{
+  ReentrantMonitorAutoEnter mon(mParentDecoder->GetReentrantMonitor());
+  if (mCurrentDecoder) {
+    mCurrentDecoder->GetResource()->Ended();
+  }
+  mCurrentDecoder = nullptr;
+}
+
+void
+TrackBuffer::Detach()
+{
+  MOZ_ASSERT(NS_IsMainThread());
+  if (mCurrentDecoder) {
+    DiscardDecoder();
+  }
+}
+
+bool
+TrackBuffer::HasInitSegment()
+{
+  ReentrantMonitorAutoEnter mon(mParentDecoder->GetReentrantMonitor());
+  return mHasInit;
+}
+
+bool
+TrackBuffer::IsReady()
+{
+  ReentrantMonitorAutoEnter mon(mParentDecoder->GetReentrantMonitor());
+  MOZ_ASSERT((mHasAudio || mHasVideo) || mDecoders.IsEmpty());
+  return HasInitSegment() && (mHasAudio || mHasVideo);
+}
+
+void
+TrackBuffer::LastTimestamp(double& aStart, double& aEnd)
+{
+  MOZ_ASSERT(NS_IsMainThread());
+  aStart = mLastStartTimestamp;
+  aEnd = mLastEndTimestamp;
+}
+
+void
+TrackBuffer::SetLastStartTimestamp(double aStart)
+{
+  MOZ_ASSERT(NS_IsMainThread());
+  mLastStartTimestamp = aStart;
+}
+
+void
+TrackBuffer::SetLastEndTimestamp(double aEnd)
+{
+  MOZ_ASSERT(NS_IsMainThread());
+  mLastEndTimestamp = aEnd;
+}
+
+bool
+TrackBuffer::ContainsTime(double aTime)
+{
+  ReentrantMonitorAutoEnter mon(mParentDecoder->GetReentrantMonitor());
+  for (uint32_t i = 0; i < mDecoders.Length(); ++i) {
+    nsRefPtr r = new dom::TimeRanges();
+    mDecoders[i]->GetBuffered(r);
+    if (r->Find(aTime) != dom::TimeRanges::NoIndex) {
+      return true;
+    }
+  }
+
+  return false;
+}
+
+void
+TrackBuffer::BreakCycles()
+{
+  for (uint32_t i = 0; i < mDecoders.Length(); ++i) {
+    mDecoders[i]->GetReader()->BreakCycles();
+  }
+  mDecoders.Clear();
+  mParentDecoder = nullptr;
+}
+
+void
+TrackBuffer::ResetDecode()
+{
+  for (uint32_t i = 0; i < mDecoders.Length(); ++i) {
+    mDecoders[i]->GetReader()->ResetDecode();
+  }
+}
+
+const nsTArray>&
+TrackBuffer::Decoders()
+{
+  // XXX assert OnDecodeThread
+  return mDecoders;
+}
+
+} // namespace mozilla
diff --git a/content/media/mediasource/TrackBuffer.h b/content/media/mediasource/TrackBuffer.h
new file mode 100644
index 00000000000..ac6b18aefd5
--- /dev/null
+++ b/content/media/mediasource/TrackBuffer.h
@@ -0,0 +1,131 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef MOZILLA_TRACKBUFFER_H_
+#define MOZILLA_TRACKBUFFER_H_
+
+#include "SourceBufferDecoder.h"
+#include "mozilla/Assertions.h"
+#include "mozilla/Attributes.h"
+#include "mozilla/mozalloc.h"
+#include "nsCOMPtr.h"
+#include "nsString.h"
+#include "nscore.h"
+
+namespace mozilla {
+
+class MediaSourceDecoder;
+
+namespace dom {
+
+class TimeRanges;
+
+} // namespace dom
+
+class TrackBuffer MOZ_FINAL {
+public:
+  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(TrackBuffer);
+
+  TrackBuffer(MediaSourceDecoder* aParentDecoder, const nsACString& aType);
+
+  void Shutdown();
+
+  // Append data to the current decoder.  Also responsible for calling
+  // NotifyDataArrived on the decoder to keep buffered range computation up
+  // to date.  Returns false if the append failed.
+  bool AppendData(const uint8_t* aData, uint32_t aLength);
+  bool EvictData(uint32_t aThreshold);
+  void EvictBefore(double aTime);
+
+  // Returns the highest end time of all of the buffered ranges in the
+  // decoders managed by this TrackBuffer, and returns the union of the
+  // decoders buffered ranges in aRanges.
+  double Buffered(dom::TimeRanges* aRanges);
+
+  // Create a new decoder, set mCurrentDecoder to the new decoder, and queue
+  // the decoder for initialization.  The decoder is not considered
+  // initialized until it is added to mDecoders.
+  bool NewDecoder();
+
+  // Mark the current decoder's resource as ended, clear mCurrentDecoder and
+  // reset mLast{Start,End}Timestamp.
+  void DiscardDecoder();
+
+  void Detach();
+
+  // Returns true if an init segment has been appended.
+  bool HasInitSegment();
+
+  // Returns true iff HasInitSegment() and the decoder using that init
+  // segment has successfully initialized by setting mHas{Audio,Video}..
+  bool IsReady();
+
+  // Query and update mLast{Start,End}Timestamp.
+  void LastTimestamp(double& aStart, double& aEnd);
+  void SetLastStartTimestamp(double aStart);
+  void SetLastEndTimestamp(double aEnd);
+
+  // Returns true if any of the decoders managed by this track buffer
+  // contain aTime in their buffered ranges.
+  bool ContainsTime(double aTime);
+
+  void BreakCycles();
+
+  // Call ResetDecode() on each decoder in mDecoders.
+  void ResetDecode();
+
+  // Returns a reference to mDecoders, used by MediaSourceReader to select
+  // decoders.
+  // TODO: Refactor to a clenaer interface between TrackBuffer and MediaSourceReader.
+  const nsTArray>& Decoders();
+
+private:
+  ~TrackBuffer();
+
+  // Queue execution of InitializeDecoder on mTaskQueue.
+  bool QueueInitializeDecoder(nsRefPtr aDecoder);
+
+  // Runs decoder initialization including calling ReadMetadata.  Runs as an
+  // event on the decode thread pool.
+  void InitializeDecoder(nsRefPtr aDecoder);
+
+  // Adds a successfully initialized decoder to mDecoders and (if it's the
+  // first decoder initialized), initializes mHasAudio/mHasVideo.  Called
+  // from the decode thread pool.
+  void RegisterDecoder(nsRefPtr aDecoder);
+
+  // A task queue using the shared media thread pool.  Used exclusively to
+  // initialize (i.e. call ReadMetadata on) decoders as they are created via
+  // NewDecoder.
+  RefPtr mTaskQueue;
+
+  // All of the initialized decoders managed by this TrackBuffer.  Access
+  // protected by mParentDecoder's monitor.
+  nsTArray> mDecoders;
+
+  // The decoder that the owning SourceBuffer is currently appending data to.
+  nsRefPtr mCurrentDecoder;
+
+  nsRefPtr mParentDecoder;
+  const nsCString mType;
+
+  // The last start and end timestamps added to the TrackBuffer via
+  // AppendData.  Accessed on the main thread only.
+  double mLastStartTimestamp;
+  double mLastEndTimestamp;
+
+  // Set when the initialization segment is first seen and cached (implied
+  // by new decoder creation).  Protected by mParentDecoder's monitor.
+  bool mHasInit;
+
+  // Set when the first decoder used by this TrackBuffer is initialized.
+  // Protected by mParentDecoder's monitor.
+  bool mHasAudio;
+  bool mHasVideo;
+};
+
+} // namespace mozilla
+#endif /* MOZILLA_TRACKBUFFER_H_ */
diff --git a/content/media/mediasource/moz.build b/content/media/mediasource/moz.build
index be6247271ec..90232f79fcb 100644
--- a/content/media/mediasource/moz.build
+++ b/content/media/mediasource/moz.build
@@ -25,6 +25,7 @@ UNIFIED_SOURCES += [
     'SourceBufferDecoder.cpp',
     'SourceBufferList.cpp',
     'SourceBufferResource.cpp',
+    'TrackBuffer.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
diff --git a/content/media/mediasource/test/mochitest.ini b/content/media/mediasource/test/mochitest.ini
index ae9defc0d0f..f566151b471 100644
--- a/content/media/mediasource/test/mochitest.ini
+++ b/content/media/mediasource/test/mochitest.ini
@@ -4,3 +4,9 @@ support-files = seek.webm seek.webm^headers^
 
 [test_MediaSource.html]
 skip-if = buildapp == 'b2g' # b2g( ReferenceError: MediaSource is not defined)
+
+[test_SplitAppend.html]
+skip-if = buildapp == 'b2g' # b2g( ReferenceError: MediaSource is not defined)
+
+[test_SplitAppendDelay.html]
+skip-if = buildapp == 'b2g' # b2g( ReferenceError: MediaSource is not defined)
diff --git a/content/media/mediasource/test/test_SplitAppend.html b/content/media/mediasource/test/test_SplitAppend.html
new file mode 100644
index 00000000000..d0265b41f83
--- /dev/null
+++ b/content/media/mediasource/test/test_SplitAppend.html
@@ -0,0 +1,83 @@
+
+
+
+  Test whether we can create an MediaSource interface
+  
+  
+
+
+
+
+
+ + diff --git a/content/media/mediasource/test/test_SplitAppendDelay.html b/content/media/mediasource/test/test_SplitAppendDelay.html new file mode 100644 index 00000000000..4fc63bd5fe6 --- /dev/null +++ b/content/media/mediasource/test/test_SplitAppendDelay.html @@ -0,0 +1,85 @@ + + + + Test whether we can create an MediaSource interface + + + + +
+
+
+ + From 2e1b498181549f5a40d7bcd6180cc9c798a76ef2 Mon Sep 17 00:00:00 2001 From: "Carsten \"Tomcat\" Book" Date: Thu, 4 Sep 2014 09:40:01 +0200 Subject: [PATCH 48/68] Backed out changeset 4a4e0c618649 (bug 1056170) for XPC Test Failures --- modules/libpref/Preferences.cpp | 5 -- modules/libpref/nsIPrefService.idl | 13 ++-- modules/libpref/prefapi.cpp | 22 +++--- modules/libpref/test/unit/head_libPrefs.js | 2 +- modules/libpref/test/unit/test_dirtyPrefs.js | 75 -------------------- modules/libpref/test/unit/xpcshell.ini | 1 - 6 files changed, 17 insertions(+), 101 deletions(-) delete mode 100644 modules/libpref/test/unit/test_dirtyPrefs.js diff --git a/modules/libpref/Preferences.cpp b/modules/libpref/Preferences.cpp index 7b3cb03bf5a..6827afe219c 100644 --- a/modules/libpref/Preferences.cpp +++ b/modules/libpref/Preferences.cpp @@ -788,11 +788,6 @@ Preferences::GetDefaultBranch(const char *aPrefRoot, nsIPrefBranch **_retval) return NS_OK; } -NS_IMETHODIMP -Preferences::GetDirty(bool *_retval) { - *_retval = gDirty; - return NS_OK; -} nsresult Preferences::NotifyServiceObservers(const char *aTopic) diff --git a/modules/libpref/nsIPrefService.idl b/modules/libpref/nsIPrefService.idl index 8766e3b3826..e29fc245e56 100644 --- a/modules/libpref/nsIPrefService.idl +++ b/modules/libpref/nsIPrefService.idl @@ -120,19 +120,16 @@ interface nsIPrefService : nsISupports */ nsIPrefBranch getDefaultBranch(in string aPrefRoot); - /** - * The preference service is 'dirty' if there are changes to user preferences - * that have not been written to disk - */ - readonly attribute boolean dirty; }; %{C++ #define NS_PREFSERVICE_CID \ - { /* {410c269f-3f7a-4396-88ce-781071733182} */ \ - 0x410c269f, 0x3f7a, 0x4396, \ - { 0x88, 0xce, 0x78, 0x10, 0x71, 0x73, 0x31, 0x82 } \ + { /* {1cd91b88-1dd2-11b2-92e1-ed22ed298000} */ \ + 0x91ca2441, \ + 0x050f, \ + 0x4f7c, \ + { 0x9d, 0xf8, 0x75, 0xb4, 0x0e, 0xa4, 0x01, 0x56 } \ } #define NS_PREFSERVICE_CONTRACTID "@mozilla.org/preferences-service;1" diff --git a/modules/libpref/prefapi.cpp b/modules/libpref/prefapi.cpp index 2be3ae9f375..2dbe64eeb51 100644 --- a/modules/libpref/prefapi.cpp +++ b/modules/libpref/prefapi.cpp @@ -312,7 +312,7 @@ pref_SetPref(const dom::PrefSetting& aPref) if (userValue.type() == dom::MaybePrefValue::TPrefValue) { rv = SetPrefValue(prefName, userValue.get_PrefValue(), USER_VALUE); } else { - rv = PREF_ClearUserPref(prefName); + rv = PREF_ClearUserPref(prefName); } // NB: we should never try to clear a default value, that doesn't @@ -725,6 +725,7 @@ static void pref_SetValue(PrefValue* existingValue, uint16_t *existingFlags, else { *existingValue = newValue; } + gDirty = true; } PrefHashEntry* pref_HashTableLookup(const void *key) @@ -784,8 +785,6 @@ nsresult pref_HashPref(const char *key, PrefValue value, PrefType type, uint32_t if (!PREF_HAS_USER_VALUE(pref)) valueChanged = true; } - // What if we change the default to be the same as the user value? - // Should we clear the user value? } } else @@ -800,10 +799,8 @@ nsresult pref_HashPref(const char *key, PrefValue value, PrefType type, uint32_t { /* XXX should we free a user-set string value if there is one? */ pref->flags &= ~PREF_USERSET; - if (!PREF_IS_LOCKED(pref)) { - gDirty = true; + if (!PREF_IS_LOCKED(pref)) valueChanged = true; - } } } else if (!PREF_HAS_USER_VALUE(pref) || @@ -812,17 +809,20 @@ nsresult pref_HashPref(const char *key, PrefValue value, PrefType type, uint32_t { pref_SetValue(&pref->userPref, &pref->flags, value, type); pref->flags |= PREF_USERSET; - if (!PREF_IS_LOCKED(pref)) { - gDirty = true; + if (!PREF_IS_LOCKED(pref)) valueChanged = true; - } } } + nsresult rv = NS_OK; if (valueChanged) { - return pref_DoCallback(key); + gDirty = true; + + nsresult rv2 = pref_DoCallback(key); + if (NS_FAILED(rv2)) + rv = rv2; } - return NS_OK; + return rv; } size_t diff --git a/modules/libpref/test/unit/head_libPrefs.js b/modules/libpref/test/unit/head_libPrefs.js index cfa0f1a1e92..18a0cb6919b 100644 --- a/modules/libpref/test/unit/head_libPrefs.js +++ b/modules/libpref/test/unit/head_libPrefs.js @@ -32,7 +32,7 @@ var provider = { persistent.value = true; if (prop == NS_APP_USER_PROFILE_50_DIR) return dirSvc.get("CurProcD", Ci.nsIFile); - throw Components.Exception("Tried to get test directory '" + prop + "'", Cr.NS_ERROR_FAILURE); + throw Cr.NS_ERROR_FAILURE; }, QueryInterface: function(iid) { if (iid.equals(Ci.nsIDirectoryServiceProvider) || diff --git a/modules/libpref/test/unit/test_dirtyPrefs.js b/modules/libpref/test/unit/test_dirtyPrefs.js deleted file mode 100644 index 3611716165f..00000000000 --- a/modules/libpref/test/unit/test_dirtyPrefs.js +++ /dev/null @@ -1,75 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Tests for handling of the preferences 'dirty' flag (bug 985998) */ - -const PREF_INVALID = 0; -const PREF_BOOL = 128; -const PREF_INT = 64; -const PREF_STRING = 32; - -function run_test() { - - var ps = Cc["@mozilla.org/preferences-service;1"]. - getService(Ci.nsIPrefService); - - let defaultBranch = ps.getDefaultBranch(""); - let userBranch = ps.getBranch(""); - - let prefFile = do_get_profile(); - prefFile.append("prefs.js"); - - //**************************************************************************// - // prefs are not dirty after a write - ps.savePrefFile(prefFile); - do_check_false(ps.dirty); - - // set a new a user value, we should become dirty - userBranch.setBoolPref("DirtyTest.new.bool", true); - do_check_true(ps.dirty); - ps.savePrefFile(prefFile); - // Overwrite a pref with the same value => not dirty - userBranch.setBoolPref("DirtyTest.new.bool", true); - do_check_false(ps.dirty); - - // Repeat for the other two types - userBranch.setIntPref("DirtyTest.new.int", 1); - do_check_true(ps.dirty); - ps.savePrefFile(prefFile); - // Overwrite a pref with the same value => not dirty - userBranch.setIntPref("DirtyTest.new.int", 1); - do_check_false(ps.dirty); - - userBranch.setCharPref("DirtyTest.new.char", "oop"); - do_check_true(ps.dirty); - ps.savePrefFile(prefFile); - // Overwrite a pref with the same value => not dirty - userBranch.setCharPref("DirtyTest.new.char", "oop"); - do_check_false(ps.dirty); - - // change *type* of a user value -> dirty - userBranch.setBoolPref("DirtyTest.new.char", false); - do_check_true(ps.dirty); - ps.savePrefFile(prefFile); - - // Set a default pref => not dirty (defaults don't go into prefs.js) - defaultBranch.setBoolPref("DirtyTest.existing.bool", true); - do_check_false(ps.dirty); - // Fail to change type of a pref with default value -> not dirty - do_check_throws(function() { - userBranch.setCharPref("DirtyTest.existing.bool", "boo"); }, Cr.NS_ERROR_UNEXPECTED); - do_check_false(ps.dirty); - - // Set user value same as default, not dirty - userBranch.setBoolPref("DirtyTest.existing.bool", true); - do_check_false(ps.dirty); - // User value different from default, dirty - userBranch.setBoolPref("DirtyTest.existing.bool", false); - do_check_true(ps.dirty); - ps.savePrefFile(prefFile); - // Back to default value, dirty again - userBranch.setBoolPref("DirtyTest.existing.bool", true); - do_check_true(ps.dirty); - ps.savePrefFile(prefFile); -} diff --git a/modules/libpref/test/unit/xpcshell.ini b/modules/libpref/test/unit/xpcshell.ini index 91227256cda..9c2052c9410 100644 --- a/modules/libpref/test/unit/xpcshell.ini +++ b/modules/libpref/test/unit/xpcshell.ini @@ -11,6 +11,5 @@ support-files = [test_bug577950.js] [test_bug790374.js] [test_changeType.js] -[test_dirtyPrefs.js] [test_extprefs.js] [test_libPrefs.js] From f3a49ddd8df38a4a47fed6a20bbb9f321a606ec8 Mon Sep 17 00:00:00 2001 From: "Carsten \"Tomcat\" Book" Date: Thu, 4 Sep 2014 09:53:58 +0200 Subject: [PATCH 49/68] Backed out changeset cfdcf950e403 (bug 105871) for wrong bug number in commit --- python/mozbuild/mozbuild/base.py | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/python/mozbuild/mozbuild/base.py b/python/mozbuild/mozbuild/base.py index 66edad6563c..2cc456eed21 100644 --- a/python/mozbuild/mozbuild/base.py +++ b/python/mozbuild/mozbuild/base.py @@ -572,19 +572,6 @@ class MachCommandBase(MozbuildObject): e.objdir2)) sys.exit(1) - except MozconfigLoadException as e: - print('Error loading mozconfig: ' + e.path) - print('') - print(e.message) - if e.output: - print('') - print('mozconfig output:') - print('') - for line in e.output: - print(line) - - sys.exit(1) - MozbuildObject.__init__(self, topsrcdir, context.settings, context.log_manager, topobjdir=topobjdir) From afd69a98416e5ab33a461fc14fa6c69bfd5f1ee3 Mon Sep 17 00:00:00 2001 From: Arnaud Sourioux Date: Wed, 3 Sep 2014 12:14:00 +0200 Subject: [PATCH 50/68] Bug 1057871 - Print full path of mozconfig file used on 'mach ./configure' when error in mozconfig throws an exception r=gps --- python/mozbuild/mozbuild/base.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/python/mozbuild/mozbuild/base.py b/python/mozbuild/mozbuild/base.py index 2cc456eed21..66edad6563c 100644 --- a/python/mozbuild/mozbuild/base.py +++ b/python/mozbuild/mozbuild/base.py @@ -572,6 +572,19 @@ class MachCommandBase(MozbuildObject): e.objdir2)) sys.exit(1) + except MozconfigLoadException as e: + print('Error loading mozconfig: ' + e.path) + print('') + print(e.message) + if e.output: + print('') + print('mozconfig output:') + print('') + for line in e.output: + print(line) + + sys.exit(1) + MozbuildObject.__init__(self, topsrcdir, context.settings, context.log_manager, topobjdir=topobjdir) From 66b81de117f0a7e99e999882c53493749b76c3e8 Mon Sep 17 00:00:00 2001 From: William Lachance Date: Wed, 3 Sep 2014 14:37:22 -0400 Subject: [PATCH 51/68] Bug 1059331 - Additional options for reftest analyzer useful for treeherder. r=jmaher --- layout/tools/reftest/reftest-analyzer.xhtml | 23 +++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/layout/tools/reftest/reftest-analyzer.xhtml b/layout/tools/reftest/reftest-analyzer.xhtml index 06addaba380..3c16dd8e685 100644 --- a/layout/tools/reftest/reftest-analyzer.xhtml +++ b/layout/tools/reftest/reftest-analyzer.xhtml @@ -81,6 +81,7 @@ var gMagZoom = 16; // size of the zoomed in pixels var gImage1Data; // ImageData object for the reference image var gImage2Data; // ImageData object for the test output image var gFlashingPixels = []; // array of objects that should be flashed due to pixel color mismatch +var gParams; function ID(id) { if (!(id in gIDCache)) @@ -101,10 +102,20 @@ function hash_parameters() { function load() { gPhases = [ ID("entry"), ID("loading"), ID("viewer") ]; build_mag(); - var params = hash_parameters(); - if (params.log) { - ID("logentry").value = params.log; + gParams = hash_parameters(); + if (gParams.log) { + ID("logentry").value = gParams.log; log_pasted(); + } else if (gParams.logurl) { + var req = new XMLHttpRequest(); + req.onreadystatechange = function() { + if (req.readyState === 4) { + ID("logentry").value = req.responseText; + log_pasted(); + } + }; + req.open('GET', gParams.logurl, true); + req.send(); } window.addEventListener('keypress', maybe_load_image, false); ID("image1").addEventListener('error', image_load_error, false); @@ -262,7 +273,11 @@ function build_viewer() { for (var i in gTestItems) { var item = gTestItems[i]; - // XXX skip expected pass items until we have filtering UI + // optional url filter for only showing unexpected results + if (parseInt(gParams.only_show_unexpected) && !item.unexpected) + continue; + + // XXX regardless skip expected pass items until we have filtering UI if (item.pass && !item.unexpected) continue; From 00d165c73fa1fbdb1d29707bf80c2733ac32d499 Mon Sep 17 00:00:00 2001 From: Vicamo Yang Date: Thu, 4 Sep 2014 10:31:41 +0800 Subject: [PATCH 52/68] Bug 937485: [WebIcc] use Webidl enum for cardState. r=echen, r=smaug --- dom/icc/Assertions.cpp | 49 +++++++++++++ dom/icc/Icc.cpp | 19 ++--- dom/icc/Icc.h | 5 +- dom/icc/interfaces/nsIIccProvider.idl | 38 +++++++++- dom/icc/moz.build | 4 ++ dom/system/gonk/RILContentHelper.js | 4 +- dom/system/gonk/RadioInterfaceLayer.js | 8 +-- dom/system/gonk/ril_consts.js | 67 ++++++++--------- .../tests/test_ril_worker_icc_CardState.js | 72 ++++++++++++------- dom/webidl/MozIcc.webidl | 63 +++++++++++++--- 10 files changed, 241 insertions(+), 88 deletions(-) create mode 100644 dom/icc/Assertions.cpp diff --git a/dom/icc/Assertions.cpp b/dom/icc/Assertions.cpp new file mode 100644 index 00000000000..8d3a99900f2 --- /dev/null +++ b/dom/icc/Assertions.cpp @@ -0,0 +1,49 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "mozilla/dom/MozIccBinding.h" +#include "nsIIccProvider.h" + +namespace mozilla { +namespace dom { + +#define ASSERT_ICC_CARD_STATE_EQUALITY(webidlState, xpidlState) \ + static_assert(static_cast(IccCardState::webidlState) == nsIIccProvider::xpidlState, \ + "IccCardState::" #webidlState " should equal to nsIIccProvider::" #xpidlState) + +ASSERT_ICC_CARD_STATE_EQUALITY(Unknown, CARD_STATE_UNKNOWN); +ASSERT_ICC_CARD_STATE_EQUALITY(Ready, CARD_STATE_READY); +ASSERT_ICC_CARD_STATE_EQUALITY(PinRequired, CARD_STATE_PIN_REQUIRED); +ASSERT_ICC_CARD_STATE_EQUALITY(PukRequired, CARD_STATE_PUK_REQUIRED); +ASSERT_ICC_CARD_STATE_EQUALITY(PermanentBlocked, CARD_STATE_PERMANENT_BLOCKED); +ASSERT_ICC_CARD_STATE_EQUALITY(PersonalizationInProgress, CARD_STATE_PERSONALIZATION_IN_PROGRESS); +ASSERT_ICC_CARD_STATE_EQUALITY(PersonalizationReady, CARD_STATE_PERSONALIZATION_READY); +ASSERT_ICC_CARD_STATE_EQUALITY(NetworkLocked, CARD_STATE_NETWORK_LOCKED); +ASSERT_ICC_CARD_STATE_EQUALITY(NetworkSubsetLocked, CARD_STATE_NETWORK_SUBSET_LOCKED); +ASSERT_ICC_CARD_STATE_EQUALITY(CorporateLocked, CARD_STATE_CORPORATE_LOCKED); +ASSERT_ICC_CARD_STATE_EQUALITY(ServiceProviderLocked, CARD_STATE_SERVICE_PROVIDER_LOCKED); +ASSERT_ICC_CARD_STATE_EQUALITY(SimPersonalizationLocked, CARD_STATE_SIM_LOCKED); +ASSERT_ICC_CARD_STATE_EQUALITY(NetworkPukRequired, CARD_STATE_NETWORK_PUK_REQUIRED); +ASSERT_ICC_CARD_STATE_EQUALITY(NetworkSubsetPukRequired, CARD_STATE_NETWORK_SUBSET_PUK_REQUIRED); +ASSERT_ICC_CARD_STATE_EQUALITY(CorporatePukRequired, CARD_STATE_CORPORATE_PUK_REQUIRED); +ASSERT_ICC_CARD_STATE_EQUALITY(ServiceProviderPukRequired, CARD_STATE_SERVICE_PROVIDER_PUK_REQUIRED); +ASSERT_ICC_CARD_STATE_EQUALITY(SimPersonalizationPukRequired, CARD_STATE_SIM_PUK_REQUIRED); +ASSERT_ICC_CARD_STATE_EQUALITY(Network1Locked, CARD_STATE_NETWORK1_LOCKED); +ASSERT_ICC_CARD_STATE_EQUALITY(Network2Locked, CARD_STATE_NETWORK2_LOCKED); +ASSERT_ICC_CARD_STATE_EQUALITY(HrpdNetworkLocked, CARD_STATE_HRPD_NETWORK_LOCKED); +ASSERT_ICC_CARD_STATE_EQUALITY(RuimCorporateLocked, CARD_STATE_RUIM_CORPORATE_LOCKED); +ASSERT_ICC_CARD_STATE_EQUALITY(RuimServiceProviderLocked, CARD_STATE_RUIM_SERVICE_PROVIDER_LOCKED); +ASSERT_ICC_CARD_STATE_EQUALITY(RuimPersonalizationLocked, CARD_STATE_RUIM_LOCKED); +ASSERT_ICC_CARD_STATE_EQUALITY(Network1PukRequired, CARD_STATE_NETWORK1_PUK_REQUIRED); +ASSERT_ICC_CARD_STATE_EQUALITY(Network2PukRequired, CARD_STATE_NETWORK2_PUK_REQUIRED); +ASSERT_ICC_CARD_STATE_EQUALITY(HrpdNetworkPukRequired, CARD_STATE_HRPD_NETWORK_PUK_REQUIRED); +ASSERT_ICC_CARD_STATE_EQUALITY(RuimCorporatePukRequired, CARD_STATE_RUIM_CORPORATE_PUK_REQUIRED); +ASSERT_ICC_CARD_STATE_EQUALITY(RuimServiceProviderPukRequired, CARD_STATE_RUIM_SERVICE_PROVIDER_PUK_REQUIRED); +ASSERT_ICC_CARD_STATE_EQUALITY(RuimPersonalizationPukRequired, CARD_STATE_RUIM_PUK_REQUIRED); +ASSERT_ICC_CARD_STATE_EQUALITY(Illegal, CARD_STATE_ILLEGAL); + +#undef ASSERT_ICC_CARD_STATE_EQUALITY + +} // namespace dom +} // namespace mozilla diff --git a/dom/icc/Icc.cpp b/dom/icc/Icc.cpp index d99bc7948fd..865130b40ae 100644 --- a/dom/icc/Icc.cpp +++ b/dom/icc/Icc.cpp @@ -100,19 +100,20 @@ Icc::GetIccInfo() const return iccInfo.forget(); } -void -Icc::GetCardState(nsString& aCardState) const +Nullable +Icc::GetCardState() const { - aCardState.SetIsVoid(true); + Nullable result; - if (!mProvider) { - return; + uint32_t cardState = nsIIccProvider::CARD_STATE_UNDETECTED; + if (mProvider && + NS_SUCCEEDED(mProvider->GetCardState(mClientId, &cardState)) && + cardState != nsIIccProvider::CARD_STATE_UNDETECTED) { + MOZ_ASSERT(cardState < static_cast(IccCardState::EndGuard_)); + result.SetValue(static_cast(cardState)); } - nsresult rv = mProvider->GetCardState(mClientId, aCardState); - if (NS_FAILED(rv)) { - aCardState.SetIsVoid(true); - } + return result; } void diff --git a/dom/icc/Icc.h b/dom/icc/Icc.h index 04eec79f1d3..9356563f348 100644 --- a/dom/icc/Icc.h +++ b/dom/icc/Icc.h @@ -5,6 +5,7 @@ #ifndef mozilla_dom_Icc_h #define mozilla_dom_Icc_h +#include "mozilla/dom/MozIccBinding.h" // For IccCardState #include "mozilla/DOMEventTargetHelper.h" #include "nsIIccProvider.h" @@ -49,8 +50,8 @@ public: already_AddRefed GetIccInfo() const; - void - GetCardState(nsString& aCardState) const; + Nullable + GetCardState() const; void SendStkResponse(const JSContext* aCx, JS::Handle aCommand, diff --git a/dom/icc/interfaces/nsIIccProvider.idl b/dom/icc/interfaces/nsIIccProvider.idl index 066b42c9fd8..741af781cbe 100644 --- a/dom/icc/interfaces/nsIIccProvider.idl +++ b/dom/icc/interfaces/nsIIccProvider.idl @@ -20,9 +20,43 @@ interface nsIIccListener : nsISupports /** * XPCOM component (in the content process) that provides the ICC information. */ -[scriptable, uuid(7c67ab92-52a3-4e11-995c-c0ad2f66c4cb)] +[scriptable, uuid(aa404b6e-fcfa-4bd2-bc46-e4e94b603ca7)] interface nsIIccProvider : nsISupports { + // MUST match enum IccCardState in MozIcc.webidl! + const unsigned long CARD_STATE_UNKNOWN = 0; + const unsigned long CARD_STATE_READY = 1; + const unsigned long CARD_STATE_PIN_REQUIRED = 2; + const unsigned long CARD_STATE_PUK_REQUIRED = 3; + const unsigned long CARD_STATE_PERMANENT_BLOCKED = 4; + const unsigned long CARD_STATE_PERSONALIZATION_IN_PROGRESS = 5; + const unsigned long CARD_STATE_PERSONALIZATION_READY = 6; + const unsigned long CARD_STATE_NETWORK_LOCKED = 7; + const unsigned long CARD_STATE_NETWORK_SUBSET_LOCKED = 8; + const unsigned long CARD_STATE_CORPORATE_LOCKED = 9; + const unsigned long CARD_STATE_SERVICE_PROVIDER_LOCKED = 10; + const unsigned long CARD_STATE_SIM_LOCKED = 11; + const unsigned long CARD_STATE_NETWORK_PUK_REQUIRED = 12; + const unsigned long CARD_STATE_NETWORK_SUBSET_PUK_REQUIRED = 13; + const unsigned long CARD_STATE_CORPORATE_PUK_REQUIRED = 14; + const unsigned long CARD_STATE_SERVICE_PROVIDER_PUK_REQUIRED = 15; + const unsigned long CARD_STATE_SIM_PUK_REQUIRED = 16; + const unsigned long CARD_STATE_NETWORK1_LOCKED = 17; + const unsigned long CARD_STATE_NETWORK2_LOCKED = 18; + const unsigned long CARD_STATE_HRPD_NETWORK_LOCKED = 19; + const unsigned long CARD_STATE_RUIM_CORPORATE_LOCKED = 20; + const unsigned long CARD_STATE_RUIM_SERVICE_PROVIDER_LOCKED = 21; + const unsigned long CARD_STATE_RUIM_LOCKED = 22; + const unsigned long CARD_STATE_NETWORK1_PUK_REQUIRED = 23; + const unsigned long CARD_STATE_NETWORK2_PUK_REQUIRED = 24; + const unsigned long CARD_STATE_HRPD_NETWORK_PUK_REQUIRED = 25; + const unsigned long CARD_STATE_RUIM_CORPORATE_PUK_REQUIRED = 26; + const unsigned long CARD_STATE_RUIM_SERVICE_PROVIDER_PUK_REQUIRED = 27; + const unsigned long CARD_STATE_RUIM_PUK_REQUIRED = 28; + const unsigned long CARD_STATE_ILLEGAL = 29; + + const unsigned long CARD_STATE_UNDETECTED = 4294967295; // UINT32_MAX + /** * Called when a content process registers receiving unsolicited messages from * RadioInterfaceLayer in the chrome process. Only a content process that has @@ -39,7 +73,7 @@ interface nsIIccProvider : nsISupports /** * Card State */ - DOMString getCardState(in unsigned long clientId); + unsigned long getCardState(in unsigned long clientId); /** * STK interfaces. diff --git a/dom/icc/moz.build b/dom/icc/moz.build index 1af25714e01..5770fad9c86 100644 --- a/dom/icc/moz.build +++ b/dom/icc/moz.build @@ -11,6 +11,10 @@ EXPORTS.mozilla.dom += [ 'IccManager.h', ] +UNIFIED_SOURCES += [ + 'Assertions.cpp', +] + SOURCES += [ 'Icc.cpp', 'IccListener.cpp', diff --git a/dom/system/gonk/RILContentHelper.js b/dom/system/gonk/RILContentHelper.js index 8d9d9e65d71..01968d6c833 100644 --- a/dom/system/gonk/RILContentHelper.js +++ b/dom/system/gonk/RILContentHelper.js @@ -284,8 +284,8 @@ function RILContentHelper() { this.voicemailStatuses = []; for (let clientId = 0; clientId < this.numClients; clientId++) { this.rilContexts[clientId] = { - cardState: RIL.GECKO_CARDSTATE_UNKNOWN, - iccInfo: null + cardState: Ci.nsIIccProvider.CARD_STATE_UNKNOWN, + iccInfo: null }; this.voicemailInfos[clientId] = new VoicemailInfo(); diff --git a/dom/system/gonk/RadioInterfaceLayer.js b/dom/system/gonk/RadioInterfaceLayer.js index ae68cb14024..8b65d1e929c 100644 --- a/dom/system/gonk/RadioInterfaceLayer.js +++ b/dom/system/gonk/RadioInterfaceLayer.js @@ -559,8 +559,8 @@ XPCOMUtils.defineLazyGetter(this, "gRadioEnabledController", function() { _isCardPresentAtClient: function(clientId) { let cardState = _ril.getRadioInterface(clientId).rilContext.cardState; - return cardState !== RIL.GECKO_CARDSTATE_UNDETECTED && - cardState !== RIL.GECKO_CARDSTATE_UNKNOWN; + return cardState !== Ci.nsIIccProvider.CARD_STATE_UNDETECTED && + cardState !== Ci.nsIIccProvider.CARD_STATE_UNKNOWN; }, _isRadioAbleToEnableAtClient: function(clientId, numCards) { @@ -1873,7 +1873,7 @@ function RadioInterface(aClientId, aWorkerMessenger) { aWorkerMessenger.registerClient(aClientId, this); this.rilContext = { - cardState: RIL.GECKO_CARDSTATE_UNKNOWN, + cardState: Ci.nsIIccProvider.CARD_STATE_UNKNOWN, iccInfo: null, imsi: null }; @@ -3713,7 +3713,7 @@ RadioInterface.prototype = { } else if (radioState == RIL.GECKO_RADIOSTATE_DISABLED) { if (DEBUG) this.debug("Error! Radio is disabled when sending SMS."); errorCode = Ci.nsIMobileMessageCallback.RADIO_DISABLED_ERROR; - } else if (this.rilContext.cardState != "ready") { + } else if (this.rilContext.cardState != Ci.nsIIccProvider.CARD_STATE_READY) { if (DEBUG) this.debug("Error! SIM card is not ready when sending SMS."); errorCode = Ci.nsIMobileMessageCallback.NO_SIM_CARD_ERROR; } diff --git a/dom/system/gonk/ril_consts.js b/dom/system/gonk/ril_consts.js index 1c8ab37a471..a7c274770f0 100644 --- a/dom/system/gonk/ril_consts.js +++ b/dom/system/gonk/ril_consts.js @@ -2487,38 +2487,40 @@ this.GECKO_RADIOSTATE_ENABLED = "enabled"; this.GECKO_RADIOSTATE_DISABLING = "disabling"; this.GECKO_RADIOSTATE_DISABLED = "disabled"; -this.GECKO_CARDSTATE_UNINITIALIZED = "uninitialized"; -this.GECKO_CARDSTATE_UNDETECTED = null; -this.GECKO_CARDSTATE_ILLEGAL = "illegal"; -this.GECKO_CARDSTATE_UNKNOWN = "unknown"; -this.GECKO_CARDSTATE_PIN_REQUIRED = "pinRequired"; -this.GECKO_CARDSTATE_PUK_REQUIRED = "pukRequired"; -this.GECKO_CARDSTATE_PERSONALIZATION_IN_PROGRESS = "personalizationInProgress"; -this.GECKO_CARDSTATE_PERSONALIZATION_READY = "personalizationReady"; -this.GECKO_CARDSTATE_NETWORK_LOCKED = "networkLocked"; -this.GECKO_CARDSTATE_NETWORK_SUBSET_LOCKED = "networkSubsetLocked"; -this.GECKO_CARDSTATE_NETWORK1_LOCKED = "network1Locked"; -this.GECKO_CARDSTATE_NETWORK2_LOCKED = "network2Locked"; -this.GECKO_CARDSTATE_HRPD_NETWORK_LOCKED = "hrpdNetworkLocked"; -this.GECKO_CARDSTATE_CORPORATE_LOCKED = "corporateLocked"; -this.GECKO_CARDSTATE_SERVICE_PROVIDER_LOCKED = "serviceProviderLocked"; -this.GECKO_CARDSTATE_SIM_LOCKED = "simPersonalizationLock"; -this.GECKO_CARDSTATE_RUIM_CORPORATE_LOCKED = "ruimCorporateLocked"; -this.GECKO_CARDSTATE_RUIM_SERVICE_PROVIDER_LOCKED = "ruimServiceProviderLocked"; -this.GECKO_CARDSTATE_RUIM_LOCKED = "ruimPersonalizationLock"; -this.GECKO_CARDSTATE_NETWORK_PUK_REQUIRED = "networkPukRequired"; -this.GECKO_CARDSTATE_NETWORK_SUBSET_PUK_REQUIRED = "networkSubsetPukRequired"; -this.GECKO_CARDSTATE_NETWORK1_PUK_REQUIRED = "network1PukRequired"; -this.GECKO_CARDSTATE_NETWORK2_PUK_REQUIRED = "network2PukRequired"; -this.GECKO_CARDSTATE_HRPD_NETWORK_PUK_REQUIRED = "hrpdNetworkPukRequired"; -this.GECKO_CARDSTATE_CORPORATE_PUK_REQUIRED = "corporatePukRequired"; -this.GECKO_CARDSTATE_SERVICE_PROVIDER_PUK_REQUIRED = "serviceProviderPukRequired"; -this.GECKO_CARDSTATE_SIM_PUK_REQUIRED = "simPersonalizationPukRequired"; -this.GECKO_CARDSTATE_RUIM_CORPORATE_PUK_REQUIRED = "ruimCorporatePukRequired"; -this.GECKO_CARDSTATE_RUIM_SERVICE_PROVIDER_PUK_REQUIRED = "ruimServiceProviderPukRequired"; -this.GECKO_CARDSTATE_RUIM_PUK_REQUIRED = "ruimPersonalizationPukRequired"; -this.GECKO_CARDSTATE_READY = "ready"; -this.GECKO_CARDSTATE_PERMANENT_BLOCKED = "permanentBlocked"; +// Only used in ril_worker.js +this.GECKO_CARDSTATE_UNINITIALIZED = 4294967294; // UINT32_MAX - 1 +// See nsIIccProvider::CARD_STATE_* +this.GECKO_CARDSTATE_UNDETECTED = 4294967295; // UINT32_MAX +this.GECKO_CARDSTATE_UNKNOWN = 0; +this.GECKO_CARDSTATE_READY = 1; +this.GECKO_CARDSTATE_PIN_REQUIRED = 2; +this.GECKO_CARDSTATE_PUK_REQUIRED = 3; +this.GECKO_CARDSTATE_PERMANENT_BLOCKED = 4; +this.GECKO_CARDSTATE_PERSONALIZATION_IN_PROGRESS = 5; +this.GECKO_CARDSTATE_PERSONALIZATION_READY = 6; +this.GECKO_CARDSTATE_NETWORK_LOCKED = 7; +this.GECKO_CARDSTATE_NETWORK_SUBSET_LOCKED = 8; +this.GECKO_CARDSTATE_CORPORATE_LOCKED = 9; +this.GECKO_CARDSTATE_SERVICE_PROVIDER_LOCKED = 10; +this.GECKO_CARDSTATE_SIM_LOCKED = 11; +this.GECKO_CARDSTATE_NETWORK_PUK_REQUIRED = 12; +this.GECKO_CARDSTATE_NETWORK_SUBSET_PUK_REQUIRED = 13; +this.GECKO_CARDSTATE_CORPORATE_PUK_REQUIRED = 14; +this.GECKO_CARDSTATE_SERVICE_PROVIDER_PUK_REQUIRED = 15; +this.GECKO_CARDSTATE_SIM_PUK_REQUIRED = 16; +this.GECKO_CARDSTATE_NETWORK1_LOCKED = 17; +this.GECKO_CARDSTATE_NETWORK2_LOCKED = 18; +this.GECKO_CARDSTATE_HRPD_NETWORK_LOCKED = 19; +this.GECKO_CARDSTATE_RUIM_CORPORATE_LOCKED = 20; +this.GECKO_CARDSTATE_RUIM_SERVICE_PROVIDER_LOCKED = 21; +this.GECKO_CARDSTATE_RUIM_LOCKED = 22; +this.GECKO_CARDSTATE_NETWORK1_PUK_REQUIRED = 23; +this.GECKO_CARDSTATE_NETWORK2_PUK_REQUIRED = 24; +this.GECKO_CARDSTATE_HRPD_NETWORK_PUK_REQUIRED = 25; +this.GECKO_CARDSTATE_RUIM_CORPORATE_PUK_REQUIRED = 26; +this.GECKO_CARDSTATE_RUIM_SERVICE_PROVIDER_PUK_REQUIRED = 27; +this.GECKO_CARDSTATE_RUIM_PUK_REQUIRED = 28; +this.GECKO_CARDSTATE_ILLEGAL = 29; this.GECKO_CARDLOCK_PIN = "pin"; this.GECKO_CARDLOCK_PIN2 = "pin2"; @@ -2556,6 +2558,7 @@ PERSONSUBSTATE[CARD_PERSOSUBSTATE_SIM_NETWORK_PUK] = GECKO_CARDSTATE_NETWORK_PUK PERSONSUBSTATE[CARD_PERSOSUBSTATE_SIM_NETWORK_SUBSET_PUK] = GECKO_CARDSTATE_NETWORK_SUBSET_PUK_REQUIRED; PERSONSUBSTATE[CARD_PERSOSUBSTATE_SIM_CORPORATE_PUK] = GECKO_CARDSTATE_CORPORATE_PUK_REQUIRED; PERSONSUBSTATE[CARD_PERSOSUBSTATE_SIM_SERVICE_PROVIDER_PUK] = GECKO_CARDSTATE_SERVICE_PROVIDER_PUK_REQUIRED; +PERSONSUBSTATE[CARD_PERSOSUBSTATE_SIM_SIM_PUK] = GECKO_CARDSTATE_SIM_PUK_REQUIRED; PERSONSUBSTATE[CARD_PERSOSUBSTATE_RUIM_NETWORK1] = GECKO_CARDSTATE_NETWORK1_LOCKED; PERSONSUBSTATE[CARD_PERSOSUBSTATE_RUIM_NETWORK2] = GECKO_CARDSTATE_NETWORK2_LOCKED; PERSONSUBSTATE[CARD_PERSOSUBSTATE_RUIM_HRPD] = GECKO_CARDSTATE_HRPD_NETWORK_LOCKED; diff --git a/dom/system/gonk/tests/test_ril_worker_icc_CardState.js b/dom/system/gonk/tests/test_ril_worker_icc_CardState.js index fb072045617..5abcb80efce 100644 --- a/dom/system/gonk/tests/test_ril_worker_icc_CardState.js +++ b/dom/system/gonk/tests/test_ril_worker_icc_CardState.js @@ -33,45 +33,65 @@ add_test(function test_personalization_state() { // Test GSM personalization state. testPersonalization(false, CARD_PERSOSUBSTATE_SIM_NETWORK, - GECKO_CARDSTATE_NETWORK_LOCKED); + Ci.nsIIccProvider.CARD_STATE_NETWORK_LOCKED); + testPersonalization(false, CARD_PERSOSUBSTATE_SIM_NETWORK_SUBSET, + Ci.nsIIccProvider.CARD_STATE_NETWORK_SUBSET_LOCKED); testPersonalization(false, CARD_PERSOSUBSTATE_SIM_CORPORATE, - GECKO_CARDSTATE_CORPORATE_LOCKED); + Ci.nsIIccProvider.CARD_STATE_CORPORATE_LOCKED); testPersonalization(false, CARD_PERSOSUBSTATE_SIM_SERVICE_PROVIDER, - GECKO_CARDSTATE_SERVICE_PROVIDER_LOCKED); + Ci.nsIIccProvider.CARD_STATE_SERVICE_PROVIDER_LOCKED); + testPersonalization(false, CARD_PERSOSUBSTATE_SIM_SIM, + Ci.nsIIccProvider.CARD_STATE_SIM_LOCKED); testPersonalization(false, CARD_PERSOSUBSTATE_SIM_NETWORK_PUK, - GECKO_CARDSTATE_NETWORK_PUK_REQUIRED); + Ci.nsIIccProvider.CARD_STATE_NETWORK_PUK_REQUIRED); + testPersonalization(false, CARD_PERSOSUBSTATE_SIM_NETWORK_SUBSET_PUK, + Ci.nsIIccProvider.CARD_STATE_NETWORK_SUBSET_PUK_REQUIRED); testPersonalization(false, CARD_PERSOSUBSTATE_SIM_CORPORATE_PUK, - GECKO_CARDSTATE_CORPORATE_PUK_REQUIRED); + Ci.nsIIccProvider.CARD_STATE_CORPORATE_PUK_REQUIRED); testPersonalization(false, CARD_PERSOSUBSTATE_SIM_SERVICE_PROVIDER_PUK, - GECKO_CARDSTATE_SERVICE_PROVIDER_PUK_REQUIRED); + Ci.nsIIccProvider.CARD_STATE_SERVICE_PROVIDER_PUK_REQUIRED); + testPersonalization(false, CARD_PERSOSUBSTATE_SIM_SIM_PUK, + Ci.nsIIccProvider.CARD_STATE_SIM_PUK_REQUIRED); + + testPersonalization(false, CARD_PERSOSUBSTATE_UNKNOWN, + Ci.nsIIccProvider.CARD_STATE_UNKNOWN); + testPersonalization(false, CARD_PERSOSUBSTATE_IN_PROGRESS, + Ci.nsIIccProvider.CARD_STATE_PERSONALIZATION_IN_PROGRESS); testPersonalization(false, CARD_PERSOSUBSTATE_READY, - GECKO_CARDSTATE_PERSONALIZATION_READY); + Ci.nsIIccProvider.CARD_STATE_PERSONALIZATION_READY); // Test CDMA personalization state. testPersonalization(true, CARD_PERSOSUBSTATE_RUIM_NETWORK1, - GECKO_CARDSTATE_NETWORK1_LOCKED); + Ci.nsIIccProvider.CARD_STATE_NETWORK1_LOCKED); testPersonalization(true, CARD_PERSOSUBSTATE_RUIM_NETWORK2, - GECKO_CARDSTATE_NETWORK2_LOCKED); + Ci.nsIIccProvider.CARD_STATE_NETWORK2_LOCKED); testPersonalization(true, CARD_PERSOSUBSTATE_RUIM_HRPD, - GECKO_CARDSTATE_HRPD_NETWORK_LOCKED); + Ci.nsIIccProvider.CARD_STATE_HRPD_NETWORK_LOCKED); testPersonalization(true, CARD_PERSOSUBSTATE_RUIM_CORPORATE, - GECKO_CARDSTATE_RUIM_CORPORATE_LOCKED); + Ci.nsIIccProvider.CARD_STATE_RUIM_CORPORATE_LOCKED); testPersonalization(true, CARD_PERSOSUBSTATE_RUIM_SERVICE_PROVIDER, - GECKO_CARDSTATE_RUIM_SERVICE_PROVIDER_LOCKED); + Ci.nsIIccProvider.CARD_STATE_RUIM_SERVICE_PROVIDER_LOCKED); testPersonalization(true, CARD_PERSOSUBSTATE_RUIM_RUIM, - GECKO_CARDSTATE_RUIM_LOCKED); + Ci.nsIIccProvider.CARD_STATE_RUIM_LOCKED); testPersonalization(true, CARD_PERSOSUBSTATE_RUIM_NETWORK1_PUK, - GECKO_CARDSTATE_NETWORK1_PUK_REQUIRED); + Ci.nsIIccProvider.CARD_STATE_NETWORK1_PUK_REQUIRED); testPersonalization(true, CARD_PERSOSUBSTATE_RUIM_NETWORK2_PUK, - GECKO_CARDSTATE_NETWORK2_PUK_REQUIRED); + Ci.nsIIccProvider.CARD_STATE_NETWORK2_PUK_REQUIRED); testPersonalization(true, CARD_PERSOSUBSTATE_RUIM_HRPD_PUK, - GECKO_CARDSTATE_HRPD_NETWORK_PUK_REQUIRED); + Ci.nsIIccProvider.CARD_STATE_HRPD_NETWORK_PUK_REQUIRED); testPersonalization(true, CARD_PERSOSUBSTATE_RUIM_CORPORATE_PUK, - GECKO_CARDSTATE_RUIM_CORPORATE_PUK_REQUIRED); + Ci.nsIIccProvider.CARD_STATE_RUIM_CORPORATE_PUK_REQUIRED); testPersonalization(true, CARD_PERSOSUBSTATE_RUIM_SERVICE_PROVIDER_PUK, - GECKO_CARDSTATE_RUIM_SERVICE_PROVIDER_PUK_REQUIRED); + Ci.nsIIccProvider.CARD_STATE_RUIM_SERVICE_PROVIDER_PUK_REQUIRED); testPersonalization(true, CARD_PERSOSUBSTATE_RUIM_RUIM_PUK, - GECKO_CARDSTATE_RUIM_PUK_REQUIRED); + Ci.nsIIccProvider.CARD_STATE_RUIM_PUK_REQUIRED); + + testPersonalization(true, CARD_PERSOSUBSTATE_UNKNOWN, + Ci.nsIIccProvider.CARD_STATE_UNKNOWN); + testPersonalization(true, CARD_PERSOSUBSTATE_IN_PROGRESS, + Ci.nsIIccProvider.CARD_STATE_PERSONALIZATION_IN_PROGRESS); + testPersonalization(true, CARD_PERSOSUBSTATE_READY, + Ci.nsIIccProvider.CARD_STATE_PERSONALIZATION_READY); run_next_test(); }); @@ -101,17 +121,17 @@ add_test(function test_card_app_state() { } testCardAppState(CARD_APPSTATE_ILLEGAL, - GECKO_CARDSTATE_ILLEGAL); + Ci.nsIIccProvider.CARD_STATE_ILLEGAL); testCardAppState(CARD_APPSTATE_PIN, - GECKO_CARDSTATE_PIN_REQUIRED); + Ci.nsIIccProvider.CARD_STATE_PIN_REQUIRED); testCardAppState(CARD_APPSTATE_PUK, - GECKO_CARDSTATE_PUK_REQUIRED); + Ci.nsIIccProvider.CARD_STATE_PUK_REQUIRED); testCardAppState(CARD_APPSTATE_READY, - GECKO_CARDSTATE_READY); + Ci.nsIIccProvider.CARD_STATE_READY); testCardAppState(CARD_APPSTATE_UNKNOWN, - GECKO_CARDSTATE_UNKNOWN); + Ci.nsIIccProvider.CARD_STATE_UNKNOWN); testCardAppState(CARD_APPSTATE_DETECTED, - GECKO_CARDSTATE_UNKNOWN); + Ci.nsIIccProvider.CARD_STATE_UNKNOWN); run_next_test(); }); @@ -139,7 +159,7 @@ add_test(function test_icc_permanent_blocked() { }; ril._processICCStatus(iccStatus); - do_check_eq(ril.cardState, GECKO_CARDSTATE_PERMANENT_BLOCKED); + do_check_eq(ril.cardState, Ci.nsIIccProvider.CARD_STATE_PERMANENT_BLOCKED); } testPermanentBlocked(1, diff --git a/dom/webidl/MozIcc.webidl b/dom/webidl/MozIcc.webidl index 40621df0b1e..3defdc2bad2 100644 --- a/dom/webidl/MozIcc.webidl +++ b/dom/webidl/MozIcc.webidl @@ -4,6 +4,57 @@ interface MozIccInfo; +enum IccCardState { + "unknown", // ICC card state is either not yet reported from modem or in an + // unknown state. + "ready", + "pinRequired", + "pukRequired", + "permanentBlocked", + + /** + * Personalization States + */ + + "personalizationInProgress", + "personalizationReady", + + // SIM Personalization States. + + "networkLocked", + "networkSubsetLocked", + "corporateLocked", + "serviceProviderLocked", + "simPersonalizationLocked", + "networkPukRequired", + "networkSubsetPukRequired", + "corporatePukRequired", + "serviceProviderPukRequired", + "simPersonalizationPukRequired", + + // RUIM Personalization States. + + "network1Locked", + "network2Locked", + "hrpdNetworkLocked", + "ruimCorporateLocked", + "ruimServiceProviderLocked", + "ruimPersonalizationLocked", + "network1PukRequired", + "network2PukRequired", + "hrpdNetworkPukRequired", + "ruimCorporatePukRequired", + "ruimServiceProviderPukRequired", + "ruimPersonalizationPukRequired", + + /** + * Additional States. + */ + + "illegal" // See Bug 916000. An owed pay card will be rejected by the network + // and fall in this state. +}; + [Pref="dom.icc.enabled"] interface MozIcc : EventTarget { @@ -29,21 +80,11 @@ interface MozIcc : EventTarget /** * Indicates the state of the device's ICC. * - * Possible values: 'illegal', 'unknown', 'pinRequired', 'pukRequired', - * 'personalizationInProgress', 'networkLocked', 'network1Locked', - * 'network2Locked', 'hrpdNetworkLocked', 'corporateLocked', - * 'serviceProviderLocked', 'ruimCorporateLocked', 'ruimServiceProviderLocked', - * 'networkPukRequired', 'network1PukRequired', 'network2PukRequired', - * 'hrpdNetworkPukRequired', 'corporatePukRequired', - * 'serviceProviderPukRequired', 'ruimCorporatePukRequired', - * 'ruimServiceProviderPukRequired', 'personalizationReady', 'ready', - * 'permanentBlocked'. - * * Once the ICC becomes undetectable, cardstatechange event will be notified. * Also, the attribute is set to null and this MozIcc object becomes invalid. * Calling asynchronous functions raises exception then. */ - readonly attribute DOMString? cardState; + readonly attribute IccCardState? cardState; /** * The 'cardstatechange' event is notified when the 'cardState' attribute From 1e621c5f50d831d6ba0f2299ff9a91eb5096509e Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 3 Sep 2014 19:33:38 -0700 Subject: [PATCH 53/68] Bumping gaia.json for 2 gaia revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/b5cc16c2b281 Author: EragonJ Desc: Merge pull request #23358 from EragonJ/bug-1059106 Bug 1059106 - [settings] move root panel airplane mode item into panels/... ======== https://hg.mozilla.org/integration/gaia-central/rev/28806a48462f Author: EragonJ Desc: Bug 1059106 - [settings] move root panel airplane mode item into panels/root --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index a5172440c63..bfaeccf2741 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -4,6 +4,6 @@ "remote": "", "branch": "" }, - "revision": "7448e582578f9d88a6d24a8f372cb7a6343e25e3", + "revision": "b5cc16c2b2818570c0688dfaf7c78ba6ac63a5ec", "repo_path": "/integration/gaia-central" } From bf8c5541af6dc2ed1dcd4711a982be41f6e34c08 Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 3 Sep 2014 19:33:51 -0700 Subject: [PATCH 54/68] Bumping manifests a=b2g-bump --- b2g/config/dolphin/sources.xml | 2 +- b2g/config/emulator-ics/sources.xml | 2 +- b2g/config/emulator-jb/sources.xml | 2 +- b2g/config/emulator-kk/sources.xml | 2 +- b2g/config/emulator/sources.xml | 2 +- b2g/config/flame-kk/sources.xml | 2 +- b2g/config/flame/sources.xml | 2 +- b2g/config/hamachi/sources.xml | 2 +- b2g/config/helix/sources.xml | 2 +- b2g/config/nexus-4/sources.xml | 2 +- b2g/config/wasabi/sources.xml | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/b2g/config/dolphin/sources.xml b/b2g/config/dolphin/sources.xml index 6e0e28c3905..4b3f4ebef98 100644 --- a/b2g/config/dolphin/sources.xml +++ b/b2g/config/dolphin/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator-ics/sources.xml b/b2g/config/emulator-ics/sources.xml index 36bddf91964..1614b0d8c66 100644 --- a/b2g/config/emulator-ics/sources.xml +++ b/b2g/config/emulator-ics/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/emulator-jb/sources.xml b/b2g/config/emulator-jb/sources.xml index 5ae3e8f7f58..c3453bd3364 100644 --- a/b2g/config/emulator-jb/sources.xml +++ b/b2g/config/emulator-jb/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/emulator-kk/sources.xml b/b2g/config/emulator-kk/sources.xml index d0b117d0851..349b950865f 100644 --- a/b2g/config/emulator-kk/sources.xml +++ b/b2g/config/emulator-kk/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator/sources.xml b/b2g/config/emulator/sources.xml index 36bddf91964..1614b0d8c66 100644 --- a/b2g/config/emulator/sources.xml +++ b/b2g/config/emulator/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/flame-kk/sources.xml b/b2g/config/flame-kk/sources.xml index bb5dd2846dc..a48a382818b 100644 --- a/b2g/config/flame-kk/sources.xml +++ b/b2g/config/flame-kk/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/flame/sources.xml b/b2g/config/flame/sources.xml index 9d23cc471a9..f6356d434a8 100644 --- a/b2g/config/flame/sources.xml +++ b/b2g/config/flame/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/hamachi/sources.xml b/b2g/config/hamachi/sources.xml index c4763908009..1915e1bd7fd 100644 --- a/b2g/config/hamachi/sources.xml +++ b/b2g/config/hamachi/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/helix/sources.xml b/b2g/config/helix/sources.xml index f452213a9c7..54ec5abb9fe 100644 --- a/b2g/config/helix/sources.xml +++ b/b2g/config/helix/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/nexus-4/sources.xml b/b2g/config/nexus-4/sources.xml index 95ee33d3ae0..4e08d9f685f 100644 --- a/b2g/config/nexus-4/sources.xml +++ b/b2g/config/nexus-4/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/wasabi/sources.xml b/b2g/config/wasabi/sources.xml index 75cad5bfc5d..27b0135f26b 100644 --- a/b2g/config/wasabi/sources.xml +++ b/b2g/config/wasabi/sources.xml @@ -17,7 +17,7 @@ - + From e217341d02244bbf05a65ad2ef24bb447cb3257b Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 3 Sep 2014 19:45:56 -0700 Subject: [PATCH 55/68] Bumping gaia.json for 2 gaia revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/8379d69ea8a4 Author: Arthur Chen Desc: Merge pull request #23609 from crh0716/1061042 Bug 1061042 - Add the icon for EU roaming r=alive ======== https://hg.mozilla.org/integration/gaia-central/rev/db1e55a18c25 Author: Arthur Chen Desc: Bug 1061042 - Add the icon for EU roaming --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index bfaeccf2741..dd5d3e928f1 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -4,6 +4,6 @@ "remote": "", "branch": "" }, - "revision": "b5cc16c2b2818570c0688dfaf7c78ba6ac63a5ec", + "revision": "8379d69ea8a423bcf9fb8f26836079da7587fbbc", "repo_path": "/integration/gaia-central" } From 05b67b732995edc3b0234e1193572221cc0d623c Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 3 Sep 2014 19:52:08 -0700 Subject: [PATCH 56/68] Bumping manifests a=b2g-bump --- b2g/config/dolphin/sources.xml | 2 +- b2g/config/emulator-ics/sources.xml | 2 +- b2g/config/emulator-jb/sources.xml | 2 +- b2g/config/emulator-kk/sources.xml | 2 +- b2g/config/emulator/sources.xml | 2 +- b2g/config/flame-kk/sources.xml | 2 +- b2g/config/flame/sources.xml | 2 +- b2g/config/hamachi/sources.xml | 2 +- b2g/config/helix/sources.xml | 2 +- b2g/config/nexus-4/sources.xml | 2 +- b2g/config/wasabi/sources.xml | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/b2g/config/dolphin/sources.xml b/b2g/config/dolphin/sources.xml index 4b3f4ebef98..2cf6b739e0d 100644 --- a/b2g/config/dolphin/sources.xml +++ b/b2g/config/dolphin/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator-ics/sources.xml b/b2g/config/emulator-ics/sources.xml index 1614b0d8c66..a1c47253b16 100644 --- a/b2g/config/emulator-ics/sources.xml +++ b/b2g/config/emulator-ics/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/emulator-jb/sources.xml b/b2g/config/emulator-jb/sources.xml index c3453bd3364..413a4eebfa9 100644 --- a/b2g/config/emulator-jb/sources.xml +++ b/b2g/config/emulator-jb/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/emulator-kk/sources.xml b/b2g/config/emulator-kk/sources.xml index 349b950865f..2528b826bc6 100644 --- a/b2g/config/emulator-kk/sources.xml +++ b/b2g/config/emulator-kk/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator/sources.xml b/b2g/config/emulator/sources.xml index 1614b0d8c66..a1c47253b16 100644 --- a/b2g/config/emulator/sources.xml +++ b/b2g/config/emulator/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/flame-kk/sources.xml b/b2g/config/flame-kk/sources.xml index a48a382818b..495d984d842 100644 --- a/b2g/config/flame-kk/sources.xml +++ b/b2g/config/flame-kk/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/flame/sources.xml b/b2g/config/flame/sources.xml index f6356d434a8..5e09101ac2b 100644 --- a/b2g/config/flame/sources.xml +++ b/b2g/config/flame/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/hamachi/sources.xml b/b2g/config/hamachi/sources.xml index 1915e1bd7fd..9b503a5141a 100644 --- a/b2g/config/hamachi/sources.xml +++ b/b2g/config/hamachi/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/helix/sources.xml b/b2g/config/helix/sources.xml index 54ec5abb9fe..8555759c2e1 100644 --- a/b2g/config/helix/sources.xml +++ b/b2g/config/helix/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/nexus-4/sources.xml b/b2g/config/nexus-4/sources.xml index 4e08d9f685f..2be9d8baa4f 100644 --- a/b2g/config/nexus-4/sources.xml +++ b/b2g/config/nexus-4/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/wasabi/sources.xml b/b2g/config/wasabi/sources.xml index 27b0135f26b..ed0c6280254 100644 --- a/b2g/config/wasabi/sources.xml +++ b/b2g/config/wasabi/sources.xml @@ -17,7 +17,7 @@ - + From f1f889e5f0609af23b325a3c4139c2694c419d77 Mon Sep 17 00:00:00 2001 From: Vicamo Yang Date: Thu, 4 Sep 2014 11:15:41 +0800 Subject: [PATCH 57/68] Bug 1057915 - 1/2: [MobileMessage] Ability to return multiple entries in getMessages/getThreads cursor.result. DOM & IPDL changes. r=smaug --- .../MobileMessageCursorCallback.cpp | 111 ++++++++++++++++-- .../MobileMessageCursorCallback.h | 45 ++++++- dom/mobilemessage/MobileMessageManager.cpp | 10 +- dom/mobilemessage/gonk/MobileMessageDB.jsm | 4 +- .../nsIMobileMessageCursorCallback.idl | 5 +- dom/mobilemessage/ipc/SmsChild.cpp | 55 +++++++-- dom/mobilemessage/ipc/SmsChild.h | 7 ++ dom/mobilemessage/ipc/SmsParent.cpp | 67 +++++++---- dom/mobilemessage/ipc/SmsTypes.ipdlh | 15 ++- .../tests/marionette/mmdb_head.js | 6 +- 10 files changed, 264 insertions(+), 61 deletions(-) diff --git a/dom/mobilemessage/MobileMessageCursorCallback.cpp b/dom/mobilemessage/MobileMessageCursorCallback.cpp index 8816f716652..dbbcebe3320 100644 --- a/dom/mobilemessage/MobileMessageCursorCallback.cpp +++ b/dom/mobilemessage/MobileMessageCursorCallback.cpp @@ -8,11 +8,94 @@ #include "nsIDOMDOMRequest.h" #include "nsIDOMMozSmsMessage.h" #include "nsIMobileMessageCallback.h" -#include "DOMCursor.h" #include "nsServiceManagerUtils.h" // for do_GetService namespace mozilla { namespace dom { + +NS_IMPL_CYCLE_COLLECTION_INHERITED(MobileMessageCursor, DOMCursor, + mPendingResults) + +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(MobileMessageCursor) +NS_INTERFACE_MAP_END_INHERITING(DOMCursor) + +NS_IMPL_ADDREF_INHERITED(MobileMessageCursor, DOMCursor) +NS_IMPL_RELEASE_INHERITED(MobileMessageCursor, DOMCursor) + +MobileMessageCursor::MobileMessageCursor(nsPIDOMWindow* aWindow, + nsICursorContinueCallback* aCallback) + : DOMCursor(aWindow, aCallback) +{ +} + +NS_IMETHODIMP +MobileMessageCursor::Continue() +{ + // We have originally: + // + // DOMCursor::Continue() + // +-> DOMCursor::Continue(ErrorResult& aRv) + // + // Now it becomes: + // + // MobileMessageCursor::Continue() + // +-> DOMCursor::Continue() + // +-> MobileMessageCursor::Continue(ErrorResult& aRv) + // o-> DOMCursor::Continue(ErrorResult& aRv) + return DOMCursor::Continue(); +} + +void +MobileMessageCursor::Continue(ErrorResult& aRv) +{ + // An ordinary DOMCursor works in following flow: + // + // DOMCursor::Continue() + // +-> DOMCursor::Reset() + // +-> nsICursorContinueCallback::HandleContinue() + // +-> nsIMobileMessageCursorCallback::NotifyCursorResult() + // +-> DOMCursor::FireSuccess() + // + // With no pending result, we call to |DOMCursor::Continue()| as usual. + if (!mPendingResults.Length()) { + DOMCursor::Continue(aRv); + return; + } + + // Otherwise, reset current result and fire a success event with the last + // pending one. + Reset(); + + nsresult rv = FireSuccessWithNextPendingResult(); + if (NS_FAILED(rv)) { + aRv.Throw(rv); + } +} + +nsresult +MobileMessageCursor::FireSuccessWithNextPendingResult() +{ + // We're going to pop the last element from mPendingResults, so it must not + // be empty. + MOZ_ASSERT(mPendingResults.Length()); + + AutoJSAPI jsapi; + if (NS_WARN_IF(!jsapi.Init(GetOwner()))) { + return NS_ERROR_FAILURE; + } + + JSContext* cx = jsapi.cx(); + JS::Rooted val(cx); + nsresult rv = + nsContentUtils::WrapNative(cx, mPendingResults.LastElement(), &val); + NS_ENSURE_SUCCESS(rv, rv); + + mPendingResults.RemoveElementAt(mPendingResults.Length() - 1); + + FireSuccess(val); + return NS_OK; +} + namespace mobilemessage { NS_IMPL_CYCLE_COLLECTION(MobileMessageCursorCallback, mDOMCursor) @@ -55,21 +138,29 @@ MobileMessageCursorCallback::NotifyCursorError(int32_t aError) } NS_IMETHODIMP -MobileMessageCursorCallback::NotifyCursorResult(nsISupports* aResult) +MobileMessageCursorCallback::NotifyCursorResult(nsISupports** aResults, + uint32_t aSize) { MOZ_ASSERT(mDOMCursor); + // We should only be notified with valid results. Or, either + // |NotifyCursorDone()| or |NotifyCursorError()| should be called instead. + MOZ_ASSERT(aResults && *aResults && aSize); + // There shouldn't be unexpected notifications before |Continue()| is called. + nsTArray>& pending = mDOMCursor->mPendingResults; + MOZ_ASSERT(pending.Length() == 0); - AutoJSAPI jsapi; - if (NS_WARN_IF(!jsapi.Init(mDOMCursor->GetOwner()))) { - return NS_ERROR_FAILURE; + // Push pending results in reversed order. + pending.SetCapacity(pending.Length() + aSize); + while (aSize) { + --aSize; + pending.AppendElement(aResults[aSize]); } - JSContext* cx = jsapi.cx(); - JS::Rooted wrappedResult(cx); - nsresult rv = nsContentUtils::WrapNative(cx, aResult, &wrappedResult); - NS_ENSURE_SUCCESS(rv, rv); + nsresult rv = mDOMCursor->FireSuccessWithNextPendingResult(); + if (NS_FAILED(rv)) { + NotifyCursorError(nsIMobileMessageCallback::INTERNAL_ERROR); + } - mDOMCursor->FireSuccess(wrappedResult); return NS_OK; } diff --git a/dom/mobilemessage/MobileMessageCursorCallback.h b/dom/mobilemessage/MobileMessageCursorCallback.h index 460291063a6..890de232694 100644 --- a/dom/mobilemessage/MobileMessageCursorCallback.h +++ b/dom/mobilemessage/MobileMessageCursorCallback.h @@ -6,6 +6,8 @@ #ifndef mozilla_dom_mobilemessage_MobileMessageCursorCallback_h #define mozilla_dom_mobilemessage_MobileMessageCursorCallback_h +#include "mozilla/Attributes.h" +#include "mozilla/dom/DOMCursor.h" #include "nsIMobileMessageCursorCallback.h" #include "nsCycleCollectionParticipant.h" #include "nsCOMPtr.h" @@ -16,12 +18,46 @@ class nsICursorContinueCallback; namespace mozilla { namespace dom { -class DOMCursor; class MobileMessageManager; namespace mobilemessage { +class MobileMessageCursorCallback; +} // namespace mobilemessage -class MobileMessageCursorCallback : public nsIMobileMessageCursorCallback +class MobileMessageCursor MOZ_FINAL : public DOMCursor +{ + friend class mobilemessage::MobileMessageCursorCallback; + +public: + NS_DECL_ISUPPORTS_INHERITED + + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MobileMessageCursor, DOMCursor) + + MobileMessageCursor(nsPIDOMWindow* aWindow, + nsICursorContinueCallback* aCallback); + + // Override XPIDL continue function to suppress -Werror,-Woverloaded-virtual. + NS_IMETHOD + Continue(void) MOZ_OVERRIDE; + + virtual void + Continue(ErrorResult& aRv) MOZ_OVERRIDE; + +private: + // MOZ_FINAL suppresses -Werror,-Wdelete-non-virtual-dtor + ~MobileMessageCursor() {} + +private: + // List of read-ahead results in reversed order. + nsTArray> mPendingResults; + + nsresult + FireSuccessWithNextPendingResult(); +}; + +namespace mobilemessage { + +class MobileMessageCursorCallback MOZ_FINAL : public nsIMobileMessageCursorCallback { friend class mozilla::dom::MobileMessageManager; @@ -37,12 +73,13 @@ public: } private: - virtual ~MobileMessageCursorCallback() + // MOZ_FINAL suppresses -Werror,-Wdelete-non-virtual-dtor + ~MobileMessageCursorCallback() { MOZ_COUNT_DTOR(MobileMessageCursorCallback); } - nsRefPtr mDOMCursor; + nsRefPtr mDOMCursor; }; } // namespace mobilemessage diff --git a/dom/mobilemessage/MobileMessageManager.cpp b/dom/mobilemessage/MobileMessageManager.cpp index c5f62a1a784..b812baca855 100644 --- a/dom/mobilemessage/MobileMessageManager.cpp +++ b/dom/mobilemessage/MobileMessageManager.cpp @@ -439,9 +439,10 @@ MobileMessageManager::GetMessages(const MobileMessageFilter& aFilter, return nullptr; } - cursorCallback->mDOMCursor = new DOMCursor(GetOwner(), continueCallback); + cursorCallback->mDOMCursor = + new MobileMessageCursor(GetOwner(), continueCallback); - nsRefPtr cursor = cursorCallback->mDOMCursor; + nsRefPtr cursor(cursorCallback->mDOMCursor); return cursor.forget(); } @@ -491,9 +492,10 @@ MobileMessageManager::GetThreads(ErrorResult& aRv) return nullptr; } - cursorCallback->mDOMCursor = new DOMCursor(GetOwner(), continueCallback); + cursorCallback->mDOMCursor = + new MobileMessageCursor(GetOwner(), continueCallback); - nsRefPtr cursor = cursorCallback->mDOMCursor; + nsRefPtr cursor(cursorCallback->mDOMCursor); return cursor.forget(); } diff --git a/dom/mobilemessage/gonk/MobileMessageDB.jsm b/dom/mobilemessage/gonk/MobileMessageDB.jsm index 0f853ac7340..90a7199c36b 100644 --- a/dom/mobilemessage/gonk/MobileMessageDB.jsm +++ b/dom/mobilemessage/gonk/MobileMessageDB.jsm @@ -3807,7 +3807,7 @@ GetMessagesCursor.prototype = { } let domMessage = self.mmdb.createDomMessageFromRecord(event.target.result); - self.callback.notifyCursorResult(domMessage); + self.callback.notifyCursorResult([domMessage], 1); }; getRequest.onerror = function(event) { if (DEBUG) { @@ -3888,7 +3888,7 @@ GetThreadsCursor.prototype = { threadRecord.body, threadRecord.unreadCount, threadRecord.lastMessageType); - self.callback.notifyCursorResult(thread); + self.callback.notifyCursorResult([thread], 1); }; getRequest.onerror = function(event) { if (DEBUG) { diff --git a/dom/mobilemessage/interfaces/nsIMobileMessageCursorCallback.idl b/dom/mobilemessage/interfaces/nsIMobileMessageCursorCallback.idl index 004333d9a79..4072c3d3f6b 100644 --- a/dom/mobilemessage/interfaces/nsIMobileMessageCursorCallback.idl +++ b/dom/mobilemessage/interfaces/nsIMobileMessageCursorCallback.idl @@ -4,10 +4,11 @@ #include "nsISupports.idl" -[scriptable, builtinclass, uuid(8fd0dba2-032e-4190-a751-07cc3782e93e)] +[scriptable, builtinclass, uuid(134a6958-543b-46e2-b419-4631a2314164)] interface nsIMobileMessageCursorCallback : nsISupports { void notifyCursorError(in long error); - void notifyCursorResult(in nsISupports result); + void notifyCursorResult([array, size_is(size)] in nsISupports results, + in uint32_t size); void notifyCursorDone(); }; diff --git a/dom/mobilemessage/ipc/SmsChild.cpp b/dom/mobilemessage/ipc/SmsChild.cpp index 56b2552dbd9..54672e72510 100644 --- a/dom/mobilemessage/ipc/SmsChild.cpp +++ b/dom/mobilemessage/ipc/SmsChild.cpp @@ -293,22 +293,17 @@ MobileMessageCursorChild::RecvNotifyResult(const MobileMessageCursorData& aData) { MOZ_ASSERT(mCursorCallback); - nsCOMPtr result; switch(aData.type()) { - case MobileMessageCursorData::TMmsMessageData: - result = new MmsMessage(aData.get_MmsMessageData()); + case MobileMessageCursorData::TMobileMessageArrayData: + DoNotifyResult(aData.get_MobileMessageArrayData().messages()); break; - case MobileMessageCursorData::TSmsMessageData: - result = new SmsMessage(aData.get_SmsMessageData()); - break; - case MobileMessageCursorData::TThreadData: - result = new MobileMessageThread(aData.get_ThreadData()); + case MobileMessageCursorData::TThreadArrayData: + DoNotifyResult(aData.get_ThreadArrayData().threads()); break; default: MOZ_CRASH("Received invalid response parameters!"); } - mCursorCallback->NotifyCursorResult(result); return true; } @@ -338,6 +333,48 @@ MobileMessageCursorChild::HandleContinue() return NS_OK; } +void +MobileMessageCursorChild::DoNotifyResult(const nsTArray& aDataArray) +{ + const uint32_t length = aDataArray.Length(); + MOZ_ASSERT(length); + + AutoFallibleTArray autoArray; + NS_ENSURE_TRUE_VOID(autoArray.SetCapacity(length)); + + AutoFallibleTArray, 1> messages; + NS_ENSURE_TRUE_VOID(messages.SetCapacity(length)); + + for (uint32_t i = 0; i < length; i++) { + nsCOMPtr message = CreateMessageFromMessageData(aDataArray[i]); + NS_ENSURE_TRUE_VOID(messages.AppendElement(message)); + NS_ENSURE_TRUE_VOID(autoArray.AppendElement(message.get())); + } + + mCursorCallback->NotifyCursorResult(autoArray.Elements(), length); +} + +void +MobileMessageCursorChild::DoNotifyResult(const nsTArray& aDataArray) +{ + const uint32_t length = aDataArray.Length(); + MOZ_ASSERT(length); + + AutoFallibleTArray autoArray; + NS_ENSURE_TRUE_VOID(autoArray.SetCapacity(length)); + + AutoFallibleTArray, 1> threads; + NS_ENSURE_TRUE_VOID(threads.SetCapacity(length)); + + for (uint32_t i = 0; i < length; i++) { + nsCOMPtr thread = new MobileMessageThread(aDataArray[i]); + NS_ENSURE_TRUE_VOID(threads.AppendElement(thread)); + NS_ENSURE_TRUE_VOID(autoArray.AppendElement(thread.get())); + } + + mCursorCallback->NotifyCursorResult(autoArray.Elements(), length); +} + } // namespace mobilemessage } // namespace dom } // namespace mozilla diff --git a/dom/mobilemessage/ipc/SmsChild.h b/dom/mobilemessage/ipc/SmsChild.h index d541d3ea508..0445f70c529 100644 --- a/dom/mobilemessage/ipc/SmsChild.h +++ b/dom/mobilemessage/ipc/SmsChild.h @@ -129,6 +129,13 @@ protected: virtual bool Recv__delete__(const int32_t& aError) MOZ_OVERRIDE; + +private: + void + DoNotifyResult(const nsTArray& aData); + + void + DoNotifyResult(const nsTArray& aData); }; } // namespace mobilemessage diff --git a/dom/mobilemessage/ipc/SmsParent.cpp b/dom/mobilemessage/ipc/SmsParent.cpp index 3762c196679..c5171beb6ab 100644 --- a/dom/mobilemessage/ipc/SmsParent.cpp +++ b/dom/mobilemessage/ipc/SmsParent.cpp @@ -843,40 +843,59 @@ MobileMessageCursorParent::NotifyCursorError(int32_t aError) } NS_IMETHODIMP -MobileMessageCursorParent::NotifyCursorResult(nsISupports* aResult) +MobileMessageCursorParent::NotifyCursorResult(nsISupports** aResults, + uint32_t aSize) { + MOZ_ASSERT(aResults && *aResults && aSize); + // The child process could die before this asynchronous notification, in which // case ActorDestroy() was called and mContinueCallback is now null. Return an // error here to avoid sending a message to the dead process. NS_ENSURE_TRUE(mContinueCallback, NS_ERROR_FAILURE); - nsCOMPtr iSms = do_QueryInterface(aResult); - if (iSms) { - SmsMessage* message = static_cast(aResult); - return SendNotifyResult(MobileMessageCursorData(message->GetData())) - ? NS_OK : NS_ERROR_FAILURE; - } - - nsCOMPtr iMms = do_QueryInterface(aResult); - if (iMms) { - MmsMessage* message = static_cast(aResult); - ContentParent* parent = static_cast(Manager()->Manager()); - MmsMessageData data; - if (!message->GetData(parent, data)) { - return NS_ERROR_FAILURE; - } - return SendNotifyResult(MobileMessageCursorData(data)) - ? NS_OK : NS_ERROR_FAILURE; - } - - nsCOMPtr iThread = do_QueryInterface(aResult); + nsCOMPtr iThread = + do_QueryInterface(aResults[0]); if (iThread) { - MobileMessageThread* thread = static_cast(aResult); - return SendNotifyResult(MobileMessageCursorData(thread->GetData())) + nsTArray threads; + + for (uint32_t i = 0; i < aSize; i++) { + nsCOMPtr iThread = + do_QueryInterface(aResults[i]); + NS_ENSURE_TRUE(iThread, NS_ERROR_FAILURE); + + MobileMessageThread* thread = + static_cast(iThread.get()); + threads.AppendElement(thread->GetData()); + } + + return SendNotifyResult(MobileMessageCursorData(ThreadArrayData(threads))) ? NS_OK : NS_ERROR_FAILURE; } - MOZ_CRASH("Received invalid response parameters!"); + ContentParent* parent = static_cast(Manager()->Manager()); + nsTArray messages; + for (uint32_t i = 0; i < aSize; i++) { + nsCOMPtr iSms = do_QueryInterface(aResults[i]); + if (iSms) { + SmsMessage* sms = static_cast(iSms.get()); + messages.AppendElement(sms->GetData()); + continue; + } + + nsCOMPtr iMms = do_QueryInterface(aResults[i]); + if (iMms) { + MmsMessage* mms = static_cast(iMms.get()); + MmsMessageData mmsData; + NS_ENSURE_TRUE(mms->GetData(parent, mmsData), NS_ERROR_FAILURE); + messages.AppendElement(mmsData); + continue; + } + + return NS_ERROR_FAILURE; + } + + return SendNotifyResult(MobileMessageCursorData(MobileMessageArrayData(messages))) + ? NS_OK : NS_ERROR_FAILURE; } NS_IMETHODIMP diff --git a/dom/mobilemessage/ipc/SmsTypes.ipdlh b/dom/mobilemessage/ipc/SmsTypes.ipdlh index a3450a258a3..3ec0ed0a655 100644 --- a/dom/mobilemessage/ipc/SmsTypes.ipdlh +++ b/dom/mobilemessage/ipc/SmsTypes.ipdlh @@ -99,11 +99,20 @@ struct ThreadData MessageType lastMessageType; }; +struct MobileMessageArrayData +{ + MobileMessageData[] messages; +}; + +struct ThreadArrayData +{ + ThreadData[] threads; +}; + union MobileMessageCursorData { - MmsMessageData; - SmsMessageData; - ThreadData; + MobileMessageArrayData; + ThreadArrayData; }; struct DeletedMessageInfoData diff --git a/dom/mobilemessage/tests/marionette/mmdb_head.js b/dom/mobilemessage/tests/marionette/mmdb_head.js index 6537783cdd8..f6ace2c4cad 100644 --- a/dom/mobilemessage/tests/marionette/mmdb_head.js +++ b/dom/mobilemessage/tests/marionette/mmdb_head.js @@ -303,9 +303,9 @@ function createMmdbCursor(aMmdb, aMethodName) { deferred.reject([aRv, results]); }, - notifyCursorResult: function(aResult) { - ok(true, "notifyCursorResult: " + aResult.id); - results.push(aResult); + notifyCursorResult: function(aResults, aSize) { + ok(true, "notifyCursorResult: " + aResults.map(function(aElement) { return aElement.id; })); + results = results.concat(aResults); cursor.handleContinue(); }, From eb0f4edee3b2be0d6f24cd3e83da604e0ade43d7 Mon Sep 17 00:00:00 2001 From: Vicamo Yang Date: Thu, 4 Sep 2014 11:15:42 +0800 Subject: [PATCH 58/68] Bug 1057915 - 2/2: Gonk MobileMessage DB read ahead. r=bevistzeng --- b2g/chrome/content/settings.js | 4 + dom/mobilemessage/gonk/MobileMessageDB.jsm | 407 +++++++++++++++++---- modules/libpref/init/all.js | 6 + 3 files changed, 349 insertions(+), 68 deletions(-) diff --git a/b2g/chrome/content/settings.js b/b2g/chrome/content/settings.js index 11a37c4c36f..b5cc91c92bb 100644 --- a/b2g/chrome/content/settings.js +++ b/b2g/chrome/content/settings.js @@ -513,6 +513,10 @@ let settingsToObserve = { prefName: 'dom.sms.strict7BitEncoding', defaultValue: false }, + 'ril.sms.maxReadAheadEntries': { + prefName: 'dom.sms.maxReadAheadEntries', + defaultValue: 7 + }, 'ui.touch.radius.leftmm': { resetToPref: true }, diff --git a/dom/mobilemessage/gonk/MobileMessageDB.jsm b/dom/mobilemessage/gonk/MobileMessageDB.jsm index 90a7199c36b..2a437207f6e 100644 --- a/dom/mobilemessage/gonk/MobileMessageDB.jsm +++ b/dom/mobilemessage/gonk/MobileMessageDB.jsm @@ -65,6 +65,9 @@ const COLLECT_ID_END = 0; const COLLECT_ID_ERROR = -1; const COLLECT_TIMESTAMP_UNUSED = 0; +// Default value for integer preference "dom.sms.maxReadAheadEntries". +const DEFAULT_READ_AHEAD_ENTRIES = 7; + XPCOMUtils.defineLazyServiceGetter(this, "gMobileMessageService", "@mozilla.org/mobilemessage/mobilemessageservice;1", "nsIMobileMessageService"); @@ -3143,7 +3146,7 @@ MobileMessageDB.prototype = { let self = this; self.newTxn(READ_ONLY, function(error, txn, stores) { - let collector = cursor.collector; + let collector = cursor.collector.idCollector; let collect = collector.collect.bind(collector); FilterSearcherHelper.transact(self, txn, error, filter, aReverse, collect); }, [MESSAGE_STORE_NAME, PARTICIPANT_STORE_NAME]); @@ -3252,7 +3255,7 @@ MobileMessageDB.prototype = { let cursor = new GetThreadsCursor(this, callback); this.newTxn(READ_ONLY, function(error, txn, threadStore) { - let collector = cursor.collector; + let collector = cursor.collector.idCollector; if (error) { collector.collect(null, COLLECT_ID_ERROR, COLLECT_TIMESTAMP_UNUSED); return; @@ -3489,11 +3492,306 @@ let FilterSearcherHelper = { } }; -function ResultsCollector() { +/** + * Collector class for read-ahead result objects. Mmdb may now try to fetch + * message/thread records before it's requested explicitly. + * + * The read ahead behavior can be controlled by an integer mozSettings entry + * "ril.sms.maxReadAheadEntries" as well as an integer holding preference + * "dom.sms.maxReadAheadEntries". The meanings are: + * + * positive: finite read-ahead entries, + * 0: don't read ahead unless explicitly requested, (default) + * negative: read ahead all IDs if possible. + * + * The order of ID filtering objects are now: + * + * [UnionResultsCollector] + * +-> [IntersectionResultsCollector] + * +-> IDsCollector + * +-> ResultsCollector + * + * ResultsCollector has basically similar behaviour with IDsCollector. When + * RC::squeeze() is called, either RC::drip() is called instantly if we have + * already fetched results available, or the request is kept and IC::squeeze() + * is called. + * + * When RC::collect is called by IC::drip, it proceeds to fetch the + * corresponding record given that collected ID is neither an error nor an end + * mark. After the message/thread record being fetched, ResultsCollector::drip + * is called if we have pending request. Anyway, RC::maybeSqueezeIdCollector is + * called to determine whether we need to call IC::squeeze again. + * + * RC::squeeze is called when nsICursorContinueCallback::handleContinue() is + * called. ResultsCollector::drip will call to + * nsIMobileMessageCursorCallback::notifyFoo. + * + * In summary, the major call paths are: + * + * RC::squeeze + * o-> RC::drip + * +-> RC::notifyCallback + * +-> nsIMobileMessageCursorCallback::notifyFoo + * +-> RC::maybeSqueezeIdCollector + * o-> IC::squeeze + * o-> IC::drip + * +-> RC::collect + * o-> RC::readAhead + * +-> RC::notifyResult + * o-> RC::drip ... + * +-> RC::maybeSqueezeIdCollector ... + * o-> RC::notifyResult ... + */ +function ResultsCollector(readAheadFunc) { + this.idCollector = new IDsCollector(); + this.results = []; + this.readAhead = readAheadFunc; + + this.maxReadAhead = DEFAULT_READ_AHEAD_ENTRIES; + try { + // positive: finite read-ahead entries, + // 0: don't read ahead unless explicitly requested, + // negative: read ahead all IDs if possible. + this.maxReadAhead = + Services.prefs.getIntPref("dom.sms.maxReadAheadEntries"); + } catch (e) {} +} +ResultsCollector.prototype = { + /** + * Underlying ID collector object. + */ + idCollector: null, + + /** + * An array keeping fetched result objects. Replaced by a new empty array + * every time when |this.drip| is called. + */ + results: null, + + /** + * A function that takes (, , ). It fetches the object + * specified by and notify with that by calling + * |.notifyResult()|. If is null, this function should + * create a new read-only transaction itself. The returned result object may + * be null to indicate an error during the fetch process. + */ + readAhead: null, + + /** + * A boolean value inidicating a readAhead call is ongoing. Set before calling + * |this.readAhead| and reset in |this.notifyResult|. + */ + readingAhead: false, + + /** + * A numeric value read from preference "dom.sms.maxReadAheadEntries". + */ + maxReadAhead: 0, + + /** + * An active IDBTransaction object to be reused. + */ + activeTxn: null, + + /** + * A nsIMobileMessageCursorCallback. + */ + requestWaiting: null, + + /** + * A boolean value indicating either a COLLECT_ID_END or COLLECT_ID_ERROR has + * been received. + */ + done: false, + + /** + * When |this.done|, it's either COLLECT_ID_END or COLLECT_ID_ERROR. + */ + lastId: null, + + /** + * Receive collected id from IDsCollector and fetch the correspond result + * object if necessary. + * + * @param txn + * An IDBTransaction object. Null if there is no active transaction in + * IDsCollector. That is, the ID collecting transaction is completed. + * @param id + * A positive numeric id, COLLECT_ID_END(0), or COLLECT_ID_ERROR(-1). + */ + collect: function(txn, id) { + if (this.done) { + // If this callector has been terminated because of previous errors in + // |this.readAhead|, ignore any further IDs from IDsCollector. + return; + } + + if (DEBUG) debug("ResultsCollector::collect ID = " + id); + + // Reuse the active transaction cached if IDsCollector has no active + // transaction. + txn = txn || this.activeTxn; + + if (id > 0) { + this.readingAhead = true; + this.readAhead(txn, id, this); + } else { + this.notifyResult(txn, id, null); + } + }, + + /** + * Callback function for |this.readAhead|. + * + * This function pushes result object to |this.results| or updates + * |this.done|, |this.lastId| if an end mark or an error is found. Since we + * have already a valid result entry, check |this.requestWaiting| and deal + * with it. At last, call to |this.maybeSqueezeIdCollector| to ask more id + * again if necessary. + * + * @param txn + * An IDBTransaction object. Null if caller has no active transaction. + * @param id + * A positive numeric id, COLLECT_ID_END(0), or COLLECT_ID_ERROR(-1). + * @param result + * An object associated with id. Null if |this.readAhead| failed. + */ + notifyResult: function(txn, id, result) { + if (DEBUG) debug("notifyResult(txn, " + id + ", )"); + + this.readingAhead = false; + + if (id > 0) { + if (result != null) { + this.results.push(result); + } else { + id = COLLECT_ID_ERROR; + } + } + + if (id <= 0) { + this.lastId = id; + this.done = true; + } + + if (!this.requestWaiting) { + if (DEBUG) debug("notifyResult: cursor.continue() not called yet"); + } else { + let callback = this.requestWaiting; + this.requestWaiting = null; + + this.drip(callback); + } + + this.maybeSqueezeIdCollector(txn); + }, + + /** + * Request for one more ID if necessary. + * + * @param txn + * An IDBTransaction object. Null if caller has no active transaction. + */ + maybeSqueezeIdCollector: function(txn) { + if (this.done || // Nothing to be read. + this.readingAhead || // Already in progress. + this.idCollector.requestWaiting) { // Already requested. + return; + } + + let max = this.maxReadAhead; + if (!max && this.requestWaiting) { + // If |this.requestWaiting| is set, try to read ahead at least once. + max = 1; + } + if (max >= 0 && this.results.length >= max) { + // More-equal than entries has been read. Stop. + if (DEBUG) debug("maybeSqueezeIdCollector: max " + max + " entries read. Stop."); + return; + } + + // A hack to pass current txn to |this.collect| when it's called directly by + // |IDsCollector.squeeze|. + this.activeTxn = txn; + this.idCollector.squeeze(this.collect.bind(this)); + this.activeTxn = null; + }, + + /** + * Request to pass available results or wait. + * + * @param callback + * A nsIMobileMessageCursorCallback. + */ + squeeze: function(callback) { + if (this.requestWaiting) { + throw new Error("Already waiting for another request!"); + } + + if (this.results.length || this.done) { + // If |this.results.length| is non-zero, we have already some results to + // pass. Otherwise, if |this.done| evaluates to true, we have also a + // confirmed result to pass. + this.drip(callback); + } else { + this.requestWaiting = callback; + } + + // If we called |this.drip| in the last step, the fetched results have been + // consumed and we should ask some more for read-ahead now. + // + // Otherwise, kick start read-ahead again because it may be stopped + // previously because of |this.maxReadAhead| had been reached. + this.maybeSqueezeIdCollector(null); + }, + + /** + * Consume fetched resutls. + * + * @param callback + * A nsIMobileMessageCursorCallback. + */ + drip: function(callback) { + let results = this.results; + this.results = []; + + let func = this.notifyCallback.bind(this, callback, results, this.lastId); + Services.tm.currentThread.dispatch(func, Ci.nsIThread.DISPATCH_NORMAL); + }, + + /** + * Notify a nsIMobileMessageCursorCallback. + * + * @param callback + * A nsIMobileMessageCursorCallback. + * @param results + * An array of result objects. + * @param lastId + * Since we only call |this.drip| when either there are results + * available or the read-ahead has done, so lastId here will be + * COLLECT_ID_END or COLLECT_ID_ERROR when results is empty and null + * otherwise. + */ + notifyCallback: function(callback, results, lastId) { + if (DEBUG) { + debug("notifyCallback(results[" + results.length + "], " + lastId + ")"); + } + + if (results.length) { + callback.notifyCursorResult(results, results.length); + } else if (lastId == COLLECT_ID_END) { + callback.notifyCursorDone(); + } else { + callback.notifyCursorError(Ci.nsIMobileMessageCallback.INTERNAL_ERROR); + } + } +}; + +function IDsCollector() { this.results = []; this.done = false; } -ResultsCollector.prototype = { +IDsCollector.prototype = { results: null, requestWaiting: null, done: null, @@ -3517,20 +3815,16 @@ ResultsCollector.prototype = { return false; } - if (DEBUG) { - debug("collect: message ID = " + id); - } - if (id) { - // Queue up any id but '0' and replies later accordingly. - this.results.push(id); - } + if (DEBUG) debug("IDsCollector::collect ID = " + id); + // Queue up any id. + this.results.push(id); if (id <= 0) { // No more processing on '0' or negative values passed. this.done = true; } if (!this.requestWaiting) { - if (DEBUG) debug("Cursor.continue() not called yet"); + if (DEBUG) debug("IDsCollector::squeeze() not called yet"); return !this.done; } @@ -3575,22 +3869,11 @@ ResultsCollector.prototype = { * A callback function that accepts a numeric id. */ drip: function(txn, callback) { - if (!this.results.length) { - if (DEBUG) debug("No messages matching the filter criteria"); - callback(txn, COLLECT_ID_END); - return; + let firstId = this.results[0]; + if (firstId > 0) { + this.results.shift(); } - - if (this.results[0] < 0) { - // An previous error found. Keep the answer in results so that we can - // reply INTERNAL_ERROR for further requests. - if (DEBUG) debug("An previous error found"); - callback(txn, COLLECT_ID_ERROR); - return; - } - - let firstMessageId = this.results.shift(); - callback(txn, firstMessageId); + callback(txn, firstId); } }; @@ -3784,7 +4067,7 @@ UnionResultsCollector.prototype = { function GetMessagesCursor(mmdb, callback) { this.mmdb = mmdb; this.callback = callback; - this.collector = new ResultsCollector(); + this.collector = new ResultsCollector(this.getMessage.bind(this)); this.handleContinue(); // Trigger first run. } @@ -3796,7 +4079,7 @@ GetMessagesCursor.prototype = { callback: null, collector: null, - getMessageTxn: function(messageStore, messageId) { + getMessageTxn: function(txn, messageStore, messageId, collector) { if (DEBUG) debug ("Fetching message " + messageId); let getRequest = messageStore.get(messageId); @@ -3807,32 +4090,26 @@ GetMessagesCursor.prototype = { } let domMessage = self.mmdb.createDomMessageFromRecord(event.target.result); - self.callback.notifyCursorResult([domMessage], 1); + collector.notifyResult(txn, messageId, domMessage); }; getRequest.onerror = function(event) { + // Error reporting is done in ResultsCollector.notifyCallback. + event.stopPropagation(); + event.preventDefault(); + if (DEBUG) { debug("notifyCursorError - messageId: " + messageId); } - self.callback.notifyCursorError(Ci.nsIMobileMessageCallback.INTERNAL_ERROR); + collector.notifyResult(txn, messageId, null); }; }, - notify: function(txn, messageId) { - if (!messageId) { - this.callback.notifyCursorDone(); - return; - } - - if (messageId < 0) { - this.callback.notifyCursorError(Ci.nsIMobileMessageCallback.INTERNAL_ERROR); - return; - } - + getMessage: function(txn, messageId, collector) { // When filter transaction is not yet completed, we're called with current // ongoing transaction object. if (txn) { let messageStore = txn.objectStore(MESSAGE_STORE_NAME); - this.getMessageTxn(messageStore, messageId); + this.getMessageTxn(txn, messageStore, messageId, collector); return; } @@ -3840,10 +4117,11 @@ GetMessagesCursor.prototype = { let self = this; this.mmdb.newTxn(READ_ONLY, function(error, txn, messageStore) { if (error) { - self.callback.notifyCursorError(Ci.nsIMobileMessageCallback.INTERNAL_ERROR); - return; + debug("getMessage: failed to create new transaction"); + collector.notifyResult(null, messageId, null); + } else { + self.getMessageTxn(txn, messageStore, messageId, collector); } - self.getMessageTxn(messageStore, messageId); }, [MESSAGE_STORE_NAME]); }, @@ -3851,14 +4129,14 @@ GetMessagesCursor.prototype = { handleContinue: function() { if (DEBUG) debug("Getting next message in list"); - this.collector.squeeze(this.notify.bind(this)); + this.collector.squeeze(this.callback); } }; function GetThreadsCursor(mmdb, callback) { this.mmdb = mmdb; this.callback = callback; - this.collector = new ResultsCollector(); + this.collector = new ResultsCollector(this.getThread.bind(this)); this.handleContinue(); // Trigger first run. } @@ -3870,11 +4148,10 @@ GetThreadsCursor.prototype = { callback: null, collector: null, - getThreadTxn: function(threadStore, threadId) { + getThreadTxn: function(txn, threadStore, threadId, collector) { if (DEBUG) debug ("Fetching thread " + threadId); let getRequest = threadStore.get(threadId); - let self = this; getRequest.onsuccess = function(event) { let threadRecord = event.target.result; if (DEBUG) { @@ -3888,32 +4165,26 @@ GetThreadsCursor.prototype = { threadRecord.body, threadRecord.unreadCount, threadRecord.lastMessageType); - self.callback.notifyCursorResult([thread], 1); + collector.notifyResult(txn, threadId, thread); }; getRequest.onerror = function(event) { + // Error reporting is done in ResultsCollector.notifyCallback. + event.stopPropagation(); + event.preventDefault(); + if (DEBUG) { debug("notifyCursorError - threadId: " + threadId); } - self.callback.notifyCursorError(Ci.nsIMobileMessageCallback.INTERNAL_ERROR); + collector.notifyResult(txn, threadId, null); }; }, - notify: function(txn, threadId) { - if (!threadId) { - this.callback.notifyCursorDone(); - return; - } - - if (threadId < 0) { - this.callback.notifyCursorError(Ci.nsIMobileMessageCallback.INTERNAL_ERROR); - return; - } - + getThread: function(txn, threadId, collector) { // When filter transaction is not yet completed, we're called with current // ongoing transaction object. if (txn) { let threadStore = txn.objectStore(THREAD_STORE_NAME); - this.getThreadTxn(threadStore, threadId); + this.getThreadTxn(txn, threadStore, threadId, collector); return; } @@ -3921,10 +4192,10 @@ GetThreadsCursor.prototype = { let self = this; this.mmdb.newTxn(READ_ONLY, function(error, txn, threadStore) { if (error) { - self.callback.notifyCursorError(Ci.nsIMobileMessageCallback.INTERNAL_ERROR); - return; + collector.notifyResult(null, threadId, null); + } else { + self.getThreadTxn(txn, threadStore, threadId, collector); } - self.getThreadTxn(threadStore, threadId); }, [THREAD_STORE_NAME]); }, @@ -3932,7 +4203,7 @@ GetThreadsCursor.prototype = { handleContinue: function() { if (DEBUG) debug("Getting next thread in list"); - this.collector.squeeze(this.notify.bind(this)); + this.collector.squeeze(this.callback); } } diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index b3b4dea8237..0fb7362c820 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -3956,6 +3956,12 @@ pref("dom.sms.requestStatusReport", true); // Numeric default service id for SMS API calls with |serviceId| parameter // omitted. pref("dom.sms.defaultServiceId", 0); +// MobileMessage GetMessages/GetThreads read ahead aggressiveness. +// +// positive: finite read-ahead entries, +// 0: don't read ahead unless explicitly requested, (default) +// negative: read ahead all IDs if possible. +pref("dom.sms.maxReadAheadEntries", 0); // WebContacts pref("dom.mozContacts.enabled", false); From 622a30d8200a0b7f747af8472f82404764059c28 Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 3 Sep 2014 20:40:50 -0700 Subject: [PATCH 59/68] Bumping gaia.json for 2 gaia revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/65c9ad025b69 Author: EragonJ Desc: Merge pull request #23548 from EragonJ/bug-1034781-another-try Bug 1034781 - [Settings][OTA] When you're unable to OTA, it should promp... ======== https://hg.mozilla.org/integration/gaia-central/rev/d1534475a695 Author: EragonJ Desc: Bug 1034781 - [Settings][OTA] When you're unable to OTA, it should prompt what's the root cause --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index dd5d3e928f1..cab406e3355 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -4,6 +4,6 @@ "remote": "", "branch": "" }, - "revision": "8379d69ea8a423bcf9fb8f26836079da7587fbbc", + "revision": "65c9ad025b69a8184b7cce7c5e2bd503b168e558", "repo_path": "/integration/gaia-central" } From 3b540a59b4699667bed79656d2805d4bf5d3b231 Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 3 Sep 2014 20:47:01 -0700 Subject: [PATCH 60/68] Bumping manifests a=b2g-bump --- b2g/config/dolphin/sources.xml | 2 +- b2g/config/emulator-ics/sources.xml | 2 +- b2g/config/emulator-jb/sources.xml | 2 +- b2g/config/emulator-kk/sources.xml | 2 +- b2g/config/emulator/sources.xml | 2 +- b2g/config/flame-kk/sources.xml | 2 +- b2g/config/flame/sources.xml | 2 +- b2g/config/hamachi/sources.xml | 2 +- b2g/config/helix/sources.xml | 2 +- b2g/config/nexus-4/sources.xml | 2 +- b2g/config/wasabi/sources.xml | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/b2g/config/dolphin/sources.xml b/b2g/config/dolphin/sources.xml index 2cf6b739e0d..e45580a280e 100644 --- a/b2g/config/dolphin/sources.xml +++ b/b2g/config/dolphin/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator-ics/sources.xml b/b2g/config/emulator-ics/sources.xml index a1c47253b16..dfa117f76cf 100644 --- a/b2g/config/emulator-ics/sources.xml +++ b/b2g/config/emulator-ics/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/emulator-jb/sources.xml b/b2g/config/emulator-jb/sources.xml index 413a4eebfa9..bff2a62a0c5 100644 --- a/b2g/config/emulator-jb/sources.xml +++ b/b2g/config/emulator-jb/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/emulator-kk/sources.xml b/b2g/config/emulator-kk/sources.xml index 2528b826bc6..eca879414a7 100644 --- a/b2g/config/emulator-kk/sources.xml +++ b/b2g/config/emulator-kk/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator/sources.xml b/b2g/config/emulator/sources.xml index a1c47253b16..dfa117f76cf 100644 --- a/b2g/config/emulator/sources.xml +++ b/b2g/config/emulator/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/flame-kk/sources.xml b/b2g/config/flame-kk/sources.xml index 495d984d842..fa13deb9e6b 100644 --- a/b2g/config/flame-kk/sources.xml +++ b/b2g/config/flame-kk/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/flame/sources.xml b/b2g/config/flame/sources.xml index 5e09101ac2b..742de1aa5ee 100644 --- a/b2g/config/flame/sources.xml +++ b/b2g/config/flame/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/hamachi/sources.xml b/b2g/config/hamachi/sources.xml index 9b503a5141a..b0de3c87cd9 100644 --- a/b2g/config/hamachi/sources.xml +++ b/b2g/config/hamachi/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/helix/sources.xml b/b2g/config/helix/sources.xml index 8555759c2e1..9d583324859 100644 --- a/b2g/config/helix/sources.xml +++ b/b2g/config/helix/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/nexus-4/sources.xml b/b2g/config/nexus-4/sources.xml index 2be9d8baa4f..f817fd26fad 100644 --- a/b2g/config/nexus-4/sources.xml +++ b/b2g/config/nexus-4/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/wasabi/sources.xml b/b2g/config/wasabi/sources.xml index ed0c6280254..bf83284fb69 100644 --- a/b2g/config/wasabi/sources.xml +++ b/b2g/config/wasabi/sources.xml @@ -17,7 +17,7 @@ - + From 4776d75927e1eab1e27830f27f6fca79554ee9b7 Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 3 Sep 2014 22:25:49 -0700 Subject: [PATCH 61/68] Bumping gaia.json for 2 gaia revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/b2db3a261819 Author: Kevin Grandon Desc: Merge pull request #23693 from KevinGrandon/bug_967516_part_1_screen_timeout Bug 967516 - Part 1 - Decouple screen timeout from device debug config ======== https://hg.mozilla.org/integration/gaia-central/rev/42c4dcf84200 Author: Kevin Grandon Desc: Bug 967516 - Part 1 - Decouple screen timeout from device debug config r=ochameau --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index cab406e3355..d1d9181dcc7 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -4,6 +4,6 @@ "remote": "", "branch": "" }, - "revision": "65c9ad025b69a8184b7cce7c5e2bd503b168e558", + "revision": "b2db3a2618196343949ae5f46c9dee99c0c1b4bf", "repo_path": "/integration/gaia-central" } From fb1f8a95852ed0646c2a673e6267d6d17a6269a2 Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 3 Sep 2014 22:31:57 -0700 Subject: [PATCH 62/68] Bumping manifests a=b2g-bump --- b2g/config/dolphin/sources.xml | 2 +- b2g/config/emulator-ics/sources.xml | 2 +- b2g/config/emulator-jb/sources.xml | 2 +- b2g/config/emulator-kk/sources.xml | 2 +- b2g/config/emulator/sources.xml | 2 +- b2g/config/flame-kk/sources.xml | 2 +- b2g/config/flame/sources.xml | 2 +- b2g/config/hamachi/sources.xml | 2 +- b2g/config/helix/sources.xml | 2 +- b2g/config/nexus-4/sources.xml | 2 +- b2g/config/wasabi/sources.xml | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/b2g/config/dolphin/sources.xml b/b2g/config/dolphin/sources.xml index e45580a280e..d911cb00450 100644 --- a/b2g/config/dolphin/sources.xml +++ b/b2g/config/dolphin/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator-ics/sources.xml b/b2g/config/emulator-ics/sources.xml index dfa117f76cf..d75226fb502 100644 --- a/b2g/config/emulator-ics/sources.xml +++ b/b2g/config/emulator-ics/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/emulator-jb/sources.xml b/b2g/config/emulator-jb/sources.xml index bff2a62a0c5..4a16aa8fdd8 100644 --- a/b2g/config/emulator-jb/sources.xml +++ b/b2g/config/emulator-jb/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/emulator-kk/sources.xml b/b2g/config/emulator-kk/sources.xml index eca879414a7..3247f2314fa 100644 --- a/b2g/config/emulator-kk/sources.xml +++ b/b2g/config/emulator-kk/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator/sources.xml b/b2g/config/emulator/sources.xml index dfa117f76cf..d75226fb502 100644 --- a/b2g/config/emulator/sources.xml +++ b/b2g/config/emulator/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/flame-kk/sources.xml b/b2g/config/flame-kk/sources.xml index fa13deb9e6b..1abfed4df54 100644 --- a/b2g/config/flame-kk/sources.xml +++ b/b2g/config/flame-kk/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/flame/sources.xml b/b2g/config/flame/sources.xml index 742de1aa5ee..82ce8e1a283 100644 --- a/b2g/config/flame/sources.xml +++ b/b2g/config/flame/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/hamachi/sources.xml b/b2g/config/hamachi/sources.xml index b0de3c87cd9..0a7d4ecf61c 100644 --- a/b2g/config/hamachi/sources.xml +++ b/b2g/config/hamachi/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/helix/sources.xml b/b2g/config/helix/sources.xml index 9d583324859..71277c040b1 100644 --- a/b2g/config/helix/sources.xml +++ b/b2g/config/helix/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/nexus-4/sources.xml b/b2g/config/nexus-4/sources.xml index f817fd26fad..22a7dadd889 100644 --- a/b2g/config/nexus-4/sources.xml +++ b/b2g/config/nexus-4/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/wasabi/sources.xml b/b2g/config/wasabi/sources.xml index bf83284fb69..5e9289af16c 100644 --- a/b2g/config/wasabi/sources.xml +++ b/b2g/config/wasabi/sources.xml @@ -17,7 +17,7 @@ - + From 0154af9de873a9b4cf9f7c6149fbb706ae905e25 Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 3 Sep 2014 23:35:49 -0700 Subject: [PATCH 63/68] Bumping gaia.json for 2 gaia revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/ca1461dad726 Author: Arthur Chen Desc: Merge pull request #23663 from crh0716/1061450 Bug 1061450 - Use customized dialog for delete APN waring r=eragonj ======== https://hg.mozilla.org/integration/gaia-central/rev/bcb169892c96 Author: Arthur Chen Desc: Bug 1061450 - Use customized dialog for delete APN waring --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index d1d9181dcc7..5f14a1e5200 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -4,6 +4,6 @@ "remote": "", "branch": "" }, - "revision": "b2db3a2618196343949ae5f46c9dee99c0c1b4bf", + "revision": "ca1461dad7261213f77318133756f2493ca11f9f", "repo_path": "/integration/gaia-central" } From 8d75bbe6a375c23cbc5f3feb9912e843cbdb4552 Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 3 Sep 2014 23:37:37 -0700 Subject: [PATCH 64/68] Bumping manifests a=b2g-bump --- b2g/config/dolphin/sources.xml | 2 +- b2g/config/emulator-ics/sources.xml | 2 +- b2g/config/emulator-jb/sources.xml | 2 +- b2g/config/emulator-kk/sources.xml | 2 +- b2g/config/emulator/sources.xml | 2 +- b2g/config/flame-kk/sources.xml | 2 +- b2g/config/flame/sources.xml | 2 +- b2g/config/hamachi/sources.xml | 2 +- b2g/config/helix/sources.xml | 2 +- b2g/config/nexus-4/sources.xml | 2 +- b2g/config/wasabi/sources.xml | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/b2g/config/dolphin/sources.xml b/b2g/config/dolphin/sources.xml index d911cb00450..234565d327f 100644 --- a/b2g/config/dolphin/sources.xml +++ b/b2g/config/dolphin/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator-ics/sources.xml b/b2g/config/emulator-ics/sources.xml index d75226fb502..a0cf4212fab 100644 --- a/b2g/config/emulator-ics/sources.xml +++ b/b2g/config/emulator-ics/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/emulator-jb/sources.xml b/b2g/config/emulator-jb/sources.xml index 4a16aa8fdd8..2b0eaf65f83 100644 --- a/b2g/config/emulator-jb/sources.xml +++ b/b2g/config/emulator-jb/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/emulator-kk/sources.xml b/b2g/config/emulator-kk/sources.xml index 3247f2314fa..cc127fb58c5 100644 --- a/b2g/config/emulator-kk/sources.xml +++ b/b2g/config/emulator-kk/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator/sources.xml b/b2g/config/emulator/sources.xml index d75226fb502..a0cf4212fab 100644 --- a/b2g/config/emulator/sources.xml +++ b/b2g/config/emulator/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/flame-kk/sources.xml b/b2g/config/flame-kk/sources.xml index 1abfed4df54..1f94af821ee 100644 --- a/b2g/config/flame-kk/sources.xml +++ b/b2g/config/flame-kk/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/flame/sources.xml b/b2g/config/flame/sources.xml index 82ce8e1a283..7ac2a38130d 100644 --- a/b2g/config/flame/sources.xml +++ b/b2g/config/flame/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/hamachi/sources.xml b/b2g/config/hamachi/sources.xml index 0a7d4ecf61c..77f4cd296ad 100644 --- a/b2g/config/hamachi/sources.xml +++ b/b2g/config/hamachi/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/helix/sources.xml b/b2g/config/helix/sources.xml index 71277c040b1..7bc60be79fc 100644 --- a/b2g/config/helix/sources.xml +++ b/b2g/config/helix/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/nexus-4/sources.xml b/b2g/config/nexus-4/sources.xml index 22a7dadd889..faa381703c4 100644 --- a/b2g/config/nexus-4/sources.xml +++ b/b2g/config/nexus-4/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/wasabi/sources.xml b/b2g/config/wasabi/sources.xml index 5e9289af16c..5cdf99446bd 100644 --- a/b2g/config/wasabi/sources.xml +++ b/b2g/config/wasabi/sources.xml @@ -17,7 +17,7 @@ - + From 12582100467aa88d34e82627c684284407dd6f43 Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 3 Sep 2014 23:55:48 -0700 Subject: [PATCH 65/68] Bumping gaia.json for 3 gaia revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/8a07ec1fdecf Author: George Desc: Merge pull request #23585 from cctuan/997606 Bug 997606 - [NFC] Arrow truncate on shrinking UI ======== https://hg.mozilla.org/integration/gaia-central/rev/0b50d8cbfa2d Author: cctuan Desc: Bug 997606 - [NFC] Arrow truncate on shrinking UI ======== https://hg.mozilla.org/integration/gaia-central/rev/f14ef55daeaf Author: EragonJ Desc: Revert "Merge pull request #23358 from EragonJ/bug-1059106" This reverts commit 5567c7d0b4408032723231490ed7e7ba1a3e0dcf, reversing changes made to 008026e932b64b4a70b9931c3da96986583bc8d4. --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 5f14a1e5200..e50bdb7c83b 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -4,6 +4,6 @@ "remote": "", "branch": "" }, - "revision": "ca1461dad7261213f77318133756f2493ca11f9f", + "revision": "8a07ec1fdecfc5cb4a36c54f666a39657ba09e27", "repo_path": "/integration/gaia-central" } From 57bc5e165ea3eab039afdce3444a3d07da66602c Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Thu, 4 Sep 2014 00:01:58 -0700 Subject: [PATCH 66/68] Bumping manifests a=b2g-bump --- b2g/config/dolphin/sources.xml | 2 +- b2g/config/emulator-ics/sources.xml | 2 +- b2g/config/emulator-jb/sources.xml | 2 +- b2g/config/emulator-kk/sources.xml | 2 +- b2g/config/emulator/sources.xml | 2 +- b2g/config/flame-kk/sources.xml | 2 +- b2g/config/flame/sources.xml | 2 +- b2g/config/hamachi/sources.xml | 2 +- b2g/config/helix/sources.xml | 2 +- b2g/config/nexus-4/sources.xml | 2 +- b2g/config/wasabi/sources.xml | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/b2g/config/dolphin/sources.xml b/b2g/config/dolphin/sources.xml index 234565d327f..fc2f2d69873 100644 --- a/b2g/config/dolphin/sources.xml +++ b/b2g/config/dolphin/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator-ics/sources.xml b/b2g/config/emulator-ics/sources.xml index a0cf4212fab..09422a63442 100644 --- a/b2g/config/emulator-ics/sources.xml +++ b/b2g/config/emulator-ics/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/emulator-jb/sources.xml b/b2g/config/emulator-jb/sources.xml index 2b0eaf65f83..36f8e968a5f 100644 --- a/b2g/config/emulator-jb/sources.xml +++ b/b2g/config/emulator-jb/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/emulator-kk/sources.xml b/b2g/config/emulator-kk/sources.xml index cc127fb58c5..569b87113b3 100644 --- a/b2g/config/emulator-kk/sources.xml +++ b/b2g/config/emulator-kk/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator/sources.xml b/b2g/config/emulator/sources.xml index a0cf4212fab..09422a63442 100644 --- a/b2g/config/emulator/sources.xml +++ b/b2g/config/emulator/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/flame-kk/sources.xml b/b2g/config/flame-kk/sources.xml index 1f94af821ee..cf1a2e2dcd5 100644 --- a/b2g/config/flame-kk/sources.xml +++ b/b2g/config/flame-kk/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/flame/sources.xml b/b2g/config/flame/sources.xml index 7ac2a38130d..84ab0518e09 100644 --- a/b2g/config/flame/sources.xml +++ b/b2g/config/flame/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/hamachi/sources.xml b/b2g/config/hamachi/sources.xml index 77f4cd296ad..f4632f86afc 100644 --- a/b2g/config/hamachi/sources.xml +++ b/b2g/config/hamachi/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/helix/sources.xml b/b2g/config/helix/sources.xml index 7bc60be79fc..868c700ae37 100644 --- a/b2g/config/helix/sources.xml +++ b/b2g/config/helix/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/nexus-4/sources.xml b/b2g/config/nexus-4/sources.xml index faa381703c4..f5d51553e2c 100644 --- a/b2g/config/nexus-4/sources.xml +++ b/b2g/config/nexus-4/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/wasabi/sources.xml b/b2g/config/wasabi/sources.xml index 5cdf99446bd..d3200e3207f 100644 --- a/b2g/config/wasabi/sources.xml +++ b/b2g/config/wasabi/sources.xml @@ -17,7 +17,7 @@ - + From d302ff1c22888f265b4aa4f4775abc494e094465 Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Thu, 4 Sep 2014 00:10:49 -0700 Subject: [PATCH 67/68] Bumping gaia.json for 2 gaia revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/9c3a4beb0c7c Author: Arthur Chen Desc: Merge pull request #23602 from crh0716/1061391 Bug 1061391 - Remove the button of clear browsing data r=eragonj ======== https://hg.mozilla.org/integration/gaia-central/rev/aad0b9b0d558 Author: Arthur Chen Desc: Bug 1061391 - Remove the button of clear browsing data --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index e50bdb7c83b..09f8dbe9487 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -4,6 +4,6 @@ "remote": "", "branch": "" }, - "revision": "8a07ec1fdecfc5cb4a36c54f666a39657ba09e27", + "revision": "9c3a4beb0c7c08c6a20dd406210f3c671557e121", "repo_path": "/integration/gaia-central" } From dd19d0712981cbbe742ddd786823efdaea516aae Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Thu, 4 Sep 2014 00:17:03 -0700 Subject: [PATCH 68/68] Bumping manifests a=b2g-bump --- b2g/config/dolphin/sources.xml | 2 +- b2g/config/emulator-ics/sources.xml | 2 +- b2g/config/emulator-jb/sources.xml | 2 +- b2g/config/emulator-kk/sources.xml | 2 +- b2g/config/emulator/sources.xml | 2 +- b2g/config/flame-kk/sources.xml | 2 +- b2g/config/flame/sources.xml | 2 +- b2g/config/hamachi/sources.xml | 2 +- b2g/config/helix/sources.xml | 2 +- b2g/config/nexus-4/sources.xml | 2 +- b2g/config/wasabi/sources.xml | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/b2g/config/dolphin/sources.xml b/b2g/config/dolphin/sources.xml index fc2f2d69873..af1c30d5fbb 100644 --- a/b2g/config/dolphin/sources.xml +++ b/b2g/config/dolphin/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator-ics/sources.xml b/b2g/config/emulator-ics/sources.xml index 09422a63442..4e73d132025 100644 --- a/b2g/config/emulator-ics/sources.xml +++ b/b2g/config/emulator-ics/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/emulator-jb/sources.xml b/b2g/config/emulator-jb/sources.xml index 36f8e968a5f..44c525945af 100644 --- a/b2g/config/emulator-jb/sources.xml +++ b/b2g/config/emulator-jb/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/emulator-kk/sources.xml b/b2g/config/emulator-kk/sources.xml index 569b87113b3..70107e0c699 100644 --- a/b2g/config/emulator-kk/sources.xml +++ b/b2g/config/emulator-kk/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator/sources.xml b/b2g/config/emulator/sources.xml index 09422a63442..4e73d132025 100644 --- a/b2g/config/emulator/sources.xml +++ b/b2g/config/emulator/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/flame-kk/sources.xml b/b2g/config/flame-kk/sources.xml index cf1a2e2dcd5..c23c89ec575 100644 --- a/b2g/config/flame-kk/sources.xml +++ b/b2g/config/flame-kk/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/flame/sources.xml b/b2g/config/flame/sources.xml index 84ab0518e09..e18a9cbefbc 100644 --- a/b2g/config/flame/sources.xml +++ b/b2g/config/flame/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/hamachi/sources.xml b/b2g/config/hamachi/sources.xml index f4632f86afc..3dbfd01be80 100644 --- a/b2g/config/hamachi/sources.xml +++ b/b2g/config/hamachi/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/helix/sources.xml b/b2g/config/helix/sources.xml index 868c700ae37..3b117f23ce8 100644 --- a/b2g/config/helix/sources.xml +++ b/b2g/config/helix/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/nexus-4/sources.xml b/b2g/config/nexus-4/sources.xml index f5d51553e2c..b4c75b62e23 100644 --- a/b2g/config/nexus-4/sources.xml +++ b/b2g/config/nexus-4/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/wasabi/sources.xml b/b2g/config/wasabi/sources.xml index d3200e3207f..7afb3f02f17 100644 --- a/b2g/config/wasabi/sources.xml +++ b/b2g/config/wasabi/sources.xml @@ -17,7 +17,7 @@ - +