Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions dom/performance/Performance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,6 @@ already_AddRefed<PerformanceMark> Performance::Mark(
const PerformanceMarkOptions& aMarkOptions,
ErrorResult& aRv)
{
// Clear the buffer if it is full and throw an error informing the web dev.
if (mUserEntries.Length() >= mResourceTimingBufferSize) {
aRv.Throw(NS_ERROR_DOM_UT_QUOTA_ERR);
mUserEntries.Clear();
}

nsCOMPtr<nsIGlobalObject> parent = GetParentObject();
if (!parent || parent->IsDying() || !parent->GetGlobalJSObject()) {
aRv.Throw(NS_ERROR_DOM_UT_UNAVAILABLE_GLOBAL_OBJECT);
Expand Down Expand Up @@ -496,12 +490,6 @@ Performance::Measure(JSContext* aCx,
return nullptr;
}

// Clear the buffer if it is full and throw an error informing the web dev.
if (mUserEntries.Length() >= mResourceTimingBufferSize) {
aRv.Throw(NS_ERROR_DOM_UT_QUOTA_ERR);
mUserEntries.Clear();
}

// Maybe is more readable than using the union type directly.
Maybe<const PerformanceMeasureOptions&> options;
if (aStartOrMeasureOptions.IsPerformanceMeasureOptions()) {
Expand Down Expand Up @@ -561,7 +549,7 @@ Performance::Measure(JSContext* aCx,
}

RefPtr<PerformanceMeasure> performanceMeasure = new PerformanceMeasure(
GetAsISupports(), aName, startTime, endTime, detail);
GetParentObject(), aName, startTime, endTime, detail);
InsertUserEntry(performanceMeasure);

return performanceMeasure.forget();
Expand Down Expand Up @@ -779,5 +767,11 @@ Performance::IsObserverEnabled(JSContext* aCx, JSObject* aGlobal)
return runnable->Dispatch() && runnable->IsEnabled();
}

void
Performance::MemoryPressure()
{
mUserEntries.Clear();
}

} // dom namespace
} // mozilla namespace
13 changes: 8 additions & 5 deletions dom/performance/Performance.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ class Performance : public DOMEventTargetHelper
return false;
}

void MemoryPressure();

virtual void QueueNavigationTimingEntry() = 0;

protected:
Expand All @@ -138,8 +140,6 @@ class Performance : public DOMEventTargetHelper
void ClearUserEntries(const Optional<nsAString>& aEntryName,
const nsAString& aEntryType);

virtual nsISupports* GetAsISupports() = 0;

virtual void DispatchBufferFullEvent() = 0;

virtual TimeStamp CreationTimeStamp() const = 0;
Expand Down Expand Up @@ -169,11 +169,14 @@ class Performance : public DOMEventTargetHelper
nsTObserverArray<PerformanceObserver*> mObservers;

protected:
nsTArray<RefPtr<PerformanceEntry>> mUserEntries;
nsTArray<RefPtr<PerformanceEntry>> mResourceEntries;
static const uint64_t kDefaultResourceTimingBufferSize = 1500;

// When kDefaultResourceTimingBufferSize is increased or removed, these should
// be changed to use SegmentedVector
AutoTArray<RefPtr<PerformanceEntry>, kDefaultResourceTimingBufferSize> mUserEntries;
AutoTArray<RefPtr<PerformanceEntry>, kDefaultResourceTimingBufferSize> mResourceEntries;

uint64_t mResourceTimingBufferSize;
static const uint64_t kDefaultResourceTimingBufferSize = 16384;
bool mPendingNotificationObserversTask;

RefPtr<PerformanceService> mPerformanceService;
Expand Down
5 changes: 0 additions & 5 deletions dom/performance/PerformanceMainThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@ class PerformanceMainThread final : public Performance

void CreateNavigationTimingEntry();

nsISupports* GetAsISupports() override
{
return this;
}

void InsertUserEntry(PerformanceEntry* aEntry) override;

DOMHighResTimeStamp
Expand Down
5 changes: 5 additions & 0 deletions dom/performance/PerformanceMark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,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/. */

#include "Performance.h"
#include "PerformanceMark.h"
#include "MainThreadUtils.h"
#include "mozilla/HoldDropJSObjects.h"
#include "mozilla/dom/PerformanceBinding.h"
#include "mozilla/dom/PerformanceMarkBinding.h"
#include "mozilla/dom/MessagePortBinding.h"
#include "mozilla/ErrorResult.h"
#include "nsContentUtils.h"

using mozilla::ErrorResult;
using mozilla::dom::StructuredSerializeOptions;
using namespace mozilla::dom;

Expand Down
4 changes: 4 additions & 0 deletions dom/performance/PerformanceMark.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@

#include "mozilla/dom/PerformanceEntry.h"

class nsIGlobalObject;
namespace mozilla {

class ErrorResult;
namespace dom {

class GlobalObject;
struct PerformanceMarkOptions;

// http://www.w3.org/TR/user-timing/#performancemark
Expand Down
1 change: 1 addition & 0 deletions dom/performance/PerformanceMeasure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "PerformanceMeasure.h"
#include "MainThreadUtils.h"
#include "mozilla/HoldDropJSObjects.h"
#include "mozilla/dom/PerformanceMeasureBinding.h"

using namespace mozilla::dom;
Expand Down
4 changes: 2 additions & 2 deletions dom/performance/PerformanceTiming.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,15 @@ class PerformanceTiming final : public nsWrapperCache

DOMTimeMilliSec UnloadEventStart()
{
if (!nsContentUtils::IsPerformanceTimingEnabled()) {
if (!nsContentUtils::IsPerformanceTimingEnabled() || !mTimingData->AllRedirectsSameOrigin()) {
return 0;
}
return TimerClamping::ReduceMsTimeValue(GetDOMTiming()->GetUnloadEventStart());
}

DOMTimeMilliSec UnloadEventEnd()
{
if (!nsContentUtils::IsPerformanceTimingEnabled()) {
if (!nsContentUtils::IsPerformanceTimingEnabled() || !mTimingData->AllRedirectsSameOrigin()) {
return 0;
}
return TimerClamping::ReduceMsTimeValue(GetDOMTiming()->GetUnloadEventEnd());
Expand Down
5 changes: 0 additions & 5 deletions dom/performance/PerformanceWorker.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@ class PerformanceWorker final : public Performance
protected:
~PerformanceWorker();

nsISupports* GetAsISupports() override
{
return nullptr;
}

void InsertUserEntry(PerformanceEntry* aEntry) override;

void DispatchBufferFullEvent() override
Expand Down
56 changes: 23 additions & 33 deletions intl/icu/source/common/locmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1074,39 +1074,29 @@ uprv_convertToPosix(uint32_t hostid, char *posixID, int32_t posixIDCapacity, UEr
char16_t windowsLocaleName[LOCALE_NAME_MAX_LENGTH] = {};

// Note: LOCALE_ALLOW_NEUTRAL_NAMES was enabled in Windows7+, prior versions did not handle neutral (no-region) locale names.
tmpLen = LCIDToLocaleName(hostid, (PWSTR)windowsLocaleName, UPRV_LENGTHOF(windowsLocaleName), LOCALE_ALLOW_NEUTRAL_NAMES);
tmpLen = GetLocaleInfoA(hostid, LOCALE_SNAME, (LPSTR)locName, UPRV_LENGTHOF(locName));
if (tmpLen > 1) {
int32_t i = 0;
// Only need to look up in table if have _, eg for de-de_phoneb type alternate sort.
bLookup = false;
for (i = 0; i < UPRV_LENGTHOF(locName); i++)
{
locName[i] = (char)(windowsLocaleName[i]);

// Windows locale name may contain sorting variant, such as "es-ES_tradnl".
// In such cases, we need special mapping data found in the hardcoded table
// in this source file.
if (windowsLocaleName[i] == L'_')
{
// Keep the base locale, without variant
// TODO: Should these be mapped from _phoneb to @collation=phonebook, etc.?
locName[i] = '\0';
tmpLen = i;
bLookup = true;
break;
}
else if (windowsLocaleName[i] == L'-')
{
// Windows names use -, ICU uses _
locName[i] = '_';
}
else if (windowsLocaleName[i] == L'\0')
{
// No point in doing more work than necessary
break;
}
/* Windows locale name may contain sorting variant, such as "es-ES_tradnl".
In such case, we need special mapping data found in the hardcoded table
in this source file. */
char *p = uprv_strchr(locName, '_');
if (p) {
/* Keep the base locale, without variant */
*p = 0;
tmpLen = uprv_strlen(locName);
}
else {
/* No hardcoded table lookup necessary */
bLookup = FALSE;
}
// TODO: Need to understand this better, why isn't it an alias?
/* Change the tag separator from '-' to '_' */
p = locName;
while (*p) {
if (*p == '-') {
*p = '_';
}
p++;
}
FIX_LANGUAGE_ID_TAG(locName, tmpLen);
pPosixID = locName;
}
Expand Down Expand Up @@ -1163,7 +1153,7 @@ uprv_convertToPosix(uint32_t hostid, char *posixID, int32_t posixIDCapacity, UEr
//
/////////////////////////////////////
*/
U_CAPI uint32_t
/*U_CAPI uint32_t
uprv_convertToLCIDPlatform(const char* localeID, UErrorCode* status)
{
if (U_FAILURE(*status)) {
Expand Down Expand Up @@ -1241,7 +1231,7 @@ uprv_convertToLCIDPlatform(const char* localeID, UErrorCode* status)

// Nothing found, or not implemented.
return 0;
}
}*/

U_CAPI uint32_t
uprv_convertToLCID(const char *langID, const char* posixID, UErrorCode* status)
Expand Down
2 changes: 1 addition & 1 deletion intl/icu/source/common/locmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
U_CAPI int32_t uprv_convertToPosix(uint32_t hostid, char* posixID, int32_t posixIDCapacity, UErrorCode* status);

/* Don't call these functions directly. Use uloc_getLCID instead. */
U_CAPI uint32_t uprv_convertToLCIDPlatform(const char* localeID, UErrorCode* status); // Leverage platform conversion if possible
//U_CAPI uint32_t uprv_convertToLCIDPlatform(const char* localeID, UErrorCode* status); // Leverage platform conversion if possible
U_CAPI uint32_t uprv_convertToLCID(const char* langID, const char* posixID, UErrorCode* status);

#endif /* LOCMAP_H */
Expand Down
62 changes: 10 additions & 52 deletions intl/icu/source/common/putil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1803,58 +1803,16 @@ The leftmost codepage (.xxx) wins.
return gCorrectedPOSIXLocale;
}

// No cached value, need to determine the current value
static WCHAR windowsLocale[LOCALE_NAME_MAX_LENGTH] = {};
int length = GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, LOCALE_SNAME, windowsLocale, LOCALE_NAME_MAX_LENGTH);

// Now we should have a Windows locale name that needs converted to the POSIX style.
if (length > 0) // If length is 0, then the GetLocaleInfoEx failed.
{
// First we need to go from UTF-16 to char (and also convert from _ to - while we're at it.)
char modifiedWindowsLocale[LOCALE_NAME_MAX_LENGTH] = {};

int32_t i;
for (i = 0; i < UPRV_LENGTHOF(modifiedWindowsLocale); i++)
{
if (windowsLocale[i] == '_')
{
modifiedWindowsLocale[i] = '-';
}
else
{
modifiedWindowsLocale[i] = static_cast<char>(windowsLocale[i]);
}

if (modifiedWindowsLocale[i] == '\0')
{
break;
}
}

if (i >= UPRV_LENGTHOF(modifiedWindowsLocale))
{
// Ran out of room, can't really happen, maybe we'll be lucky about a matching
// locale when tags are dropped
modifiedWindowsLocale[UPRV_LENGTHOF(modifiedWindowsLocale) - 1] = '\0';
}

// Now normalize the resulting name
correctedPOSIXLocale = static_cast<char *>(uprv_malloc(POSIX_LOCALE_CAPACITY + 1));
/* TODO: Should we just exit on memory allocation failure? */
if (correctedPOSIXLocale)
{
int32_t posixLen = uloc_canonicalize(modifiedWindowsLocale, correctedPOSIXLocale, POSIX_LOCALE_CAPACITY, &status);
if (U_SUCCESS(status))
{
*(correctedPOSIXLocale + posixLen) = 0;
gCorrectedPOSIXLocale = correctedPOSIXLocale;
gCorrectedPOSIXLocaleHeapAllocated = true;
ucln_common_registerCleanup(UCLN_COMMON_PUTIL, putil_cleanup);
}
else
{
uprv_free(correctedPOSIXLocale);
}
LCID id = GetThreadLocale();
correctedPOSIXLocale = static_cast<char *>(uprv_malloc(POSIX_LOCALE_CAPACITY + 1));
if (correctedPOSIXLocale) {
int32_t posixLen = uprv_convertToPosix(id, correctedPOSIXLocale, POSIX_LOCALE_CAPACITY, &status);
if (U_SUCCESS(status)) {
*(correctedPOSIXLocale + posixLen) = 0;
gCorrectedPOSIXLocale = correctedPOSIXLocale;
ucln_common_registerCleanup(UCLN_COMMON_PUTIL, putil_cleanup);
} else {
uprv_free(correctedPOSIXLocale);
}
}

Expand Down
4 changes: 2 additions & 2 deletions intl/icu/source/common/uloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2289,14 +2289,14 @@ uloc_getLCID(const char* localeID)

// First, attempt Windows platform lookup if available, but fall
// through to catch any special cases (ICU vs Windows name differences).
lcid = uprv_convertToLCIDPlatform(localeID, &status);
/*lcid = uprv_convertToLCIDPlatform(localeID, &status);
if (U_FAILURE(status)) {
return 0;
}
if (lcid > 0) {
// Windows found an LCID, return that
return lcid;
}
}*/

CharString langID = ulocimp_getLanguage(localeID, status);
if (U_FAILURE(status)) {
Expand Down
2 changes: 2 additions & 0 deletions intl/icu/source/common/unicode/localpointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ class LocalPointer : public LocalPointerBase<T> {
src.ptr=nullptr;
}

LocalPointer(const LocalPointer<T> &src) noexcept : LocalPointerBase<T>(src.ptr) {}

/**
* Constructs a LocalPointer from a C++11 std::unique_ptr.
* The LocalPointer steals the object owned by the std::unique_ptr.
Expand Down
Loading
Loading