Backed out changeset f5ed560d297f (bug 1083285) for build bustage

This commit is contained in:
Wes Kocher 2014-11-18 15:47:57 -08:00
parent dad2b46632
commit b9e9211cc1
11 changed files with 45 additions and 191 deletions

View File

@ -1240,14 +1240,8 @@ BackgroundDatabaseChild::RecvPBackgroundIDBVersionChangeTransactionConstructor(
auto actor = static_cast<BackgroundVersionChangeTransactionChild*>(aActor);
nsRefPtr<IDBOpenDBRequest> request = mOpenRequestActor->GetOpenDBRequest();
MOZ_ASSERT(request);
nsRefPtr<IDBTransaction> transaction =
IDBTransaction::CreateVersionChange(mDatabase,
actor,
request,
aNextObjectStoreId,
IDBTransaction::CreateVersionChange(mDatabase, actor, aNextObjectStoreId,
aNextIndexId);
if (NS_WARN_IF(!transaction)) {
return false;
@ -1259,6 +1253,9 @@ BackgroundDatabaseChild::RecvPBackgroundIDBVersionChangeTransactionConstructor(
mDatabase->EnterSetVersionTransaction(aRequestedVersion);
nsRefPtr<IDBOpenDBRequest> request = mOpenRequestActor->GetOpenDBRequest();
MOZ_ASSERT(request);
request->SetTransaction(transaction);
nsCOMPtr<nsIDOMEvent> upgradeNeededEvent =
@ -1319,7 +1316,7 @@ BackgroundDatabaseChild::RecvVersionChange(const uint64_t& aOldVersion,
if (shouldAbortAndClose) {
// Invalidate() doesn't close the database in the parent, so we have
// to call Close() and AbortTransactions() manually.
mDatabase->AbortTransactions(/* aShouldWarn */ false);
mDatabase->AbortTransactions();
mDatabase->Close();
return true;
}

View File

@ -39,12 +39,9 @@
#include "mozilla/ipc/InputStreamParams.h"
#include "mozilla/ipc/InputStreamUtils.h"
#include "nsCOMPtr.h"
#include "nsContentUtils.h"
#include "nsIConsoleService.h"
#include "nsIDocument.h"
#include "nsIObserver.h"
#include "nsIObserverService.h"
#include "nsIScriptError.h"
#include "nsISupportsPrimitives.h"
#include "nsThreadUtils.h"
#include "ProfilerHelpers.h"
@ -317,7 +314,7 @@ IDBDatabase::InvalidateInternal()
AssertIsOnOwningThread();
InvalidateMutableFiles();
AbortTransactions(/* aShouldWarn */ true);
AbortTransactions();
CloseInternal();
}
@ -754,7 +751,7 @@ IDBDatabase::UnregisterTransaction(IDBTransaction* aTransaction)
}
void
IDBDatabase::AbortTransactions(bool aShouldWarn)
IDBDatabase::AbortTransactions()
{
AssertIsOnOwningThread();
@ -762,31 +759,27 @@ IDBDatabase::AbortTransactions(bool aShouldWarn)
{
public:
static void
AbortTransactions(nsTHashtable<nsPtrHashKey<IDBTransaction>>& aTable,
nsTArray<nsRefPtr<IDBTransaction>>& aAbortedTransactions)
AbortTransactions(nsTHashtable<nsPtrHashKey<IDBTransaction>>& aTable)
{
const uint32_t count = aTable.Count();
if (!count) {
return;
}
nsAutoTArray<nsRefPtr<IDBTransaction>, 20> transactions;
nsTArray<nsRefPtr<IDBTransaction>> transactions;
transactions.SetCapacity(count);
aTable.EnumerateEntries(Collect, &transactions);
MOZ_ASSERT(transactions.Length() == count);
IDB_REPORT_INTERNAL_ERR();
for (uint32_t index = 0; index < count; index++) {
nsRefPtr<IDBTransaction> transaction = Move(transactions[index]);
nsRefPtr<IDBTransaction> transaction = transactions[index].forget();
MOZ_ASSERT(transaction);
transaction->Abort(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
// We only care about warning for write transactions.
if (transaction->GetMode() != IDBTransaction::READ_ONLY) {
aAbortedTransactions.AppendElement(Move(transaction));
}
}
}
@ -805,25 +798,7 @@ IDBDatabase::AbortTransactions(bool aShouldWarn)
}
};
nsAutoTArray<nsRefPtr<IDBTransaction>, 5> abortedTransactions;
Helper::AbortTransactions(mTransactions, abortedTransactions);
if (aShouldWarn && !abortedTransactions.IsEmpty()) {
static const char kWarningMessage[] = "IndexedDBTransactionAbortNavigation";
for (uint32_t count = abortedTransactions.Length(), index = 0;
index < count;
index++) {
nsRefPtr<IDBTransaction>& transaction = abortedTransactions[index];
MOZ_ASSERT(transaction);
nsString filename;
uint32_t lineNo;
transaction->GetCallerLocation(filename, &lineNo);
LogWarning(kWarningMessage, filename, lineNo);
}
}
Helper::AbortTransactions(mTransactions);
}
PBackgroundIDBDatabaseFileChild*
@ -1180,65 +1155,6 @@ IDBDatabase::Invalidate()
}
}
void
IDBDatabase::LogWarning(const char* aMessageName,
const nsAString& aFilename,
uint32_t aLineNumber)
{
AssertIsOnOwningThread();
MOZ_ASSERT(aMessageName);
// For now this is main-thread only.
MOZ_ASSERT(NS_IsMainThread());
nsXPIDLString localizedMessage;
if (NS_WARN_IF(NS_FAILED(
nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
aMessageName,
localizedMessage)))) {
return;
}
nsAutoCString category;
if (mFactory->IsChrome()) {
category.AssignLiteral("chrome ");
} else {
category.AssignLiteral("content ");
}
category.AppendLiteral("javascript");
nsCOMPtr<nsIConsoleService> consoleService =
do_GetService(NS_CONSOLESERVICE_CONTRACTID);
MOZ_ASSERT(consoleService);
nsCOMPtr<nsIScriptError> scriptError =
do_CreateInstance(NS_SCRIPTERROR_CONTRACTID);
MOZ_ASSERT(consoleService);
if (mFactory->GetParentObject()) {
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
scriptError->InitWithWindowID(localizedMessage,
aFilename,
/* aSourceLine */ EmptyString(),
aLineNumber,
/* aColumnNumber */ 0,
nsIScriptError::warningFlag,
category,
mFactory->InnerWindowID())));
} else {
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
scriptError->Init(localizedMessage,
aFilename,
/* aSourceLine */ EmptyString(),
aLineNumber,
/* aColumnNumber */ 0,
nsIScriptError::warningFlag,
category.get())));
}
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(consoleService->LogMessage(scriptError)));
}
NS_IMPL_ADDREF_INHERITED(IDBDatabase, IDBWrapperCache)
NS_IMPL_RELEASE_INHERITED(IDBDatabase, IDBWrapperCache)

View File

@ -171,7 +171,7 @@ public:
UnregisterTransaction(IDBTransaction* aTransaction);
void
AbortTransactions(bool aShouldWarn);
AbortTransactions();
PBackgroundIDBDatabaseFileChild*
GetOrCreateFileActorForBlob(File* aBlob);
@ -299,11 +299,6 @@ private:
void
InvalidateMutableFiles();
void
LogWarning(const char* aMessageName,
const nsAString& aFilename,
uint32_t aLineNumber);
};
} // namespace indexedDB

View File

@ -29,7 +29,7 @@
#include "ActorsChild.h"
#ifdef DEBUG
#include "nsContentUtils.h" // For assertions.
#include "nsContentUtils.h" // For IsCallerChrome assertions.
#endif
namespace mozilla {
@ -110,7 +110,6 @@ struct IDBFactory::PendingRequestInfo
IDBFactory::IDBFactory()
: mOwningObject(nullptr)
, mBackgroundActor(nullptr)
, mInnerWindowID(0)
, mBackgroundActorFailed(false)
, mPrivateBrowsingMode(false)
{
@ -184,7 +183,6 @@ IDBFactory::CreateForWindow(nsPIDOMWindow* aWindow,
factory->mPrincipalInfo = Move(principalInfo);
factory->mWindow = aWindow;
factory->mTabChild = TabChild::GetFrom(aWindow);
factory->mInnerWindowID = aWindow->WindowID();
factory->mPrivateBrowsingMode = privateBrowsingMode;
factory.forget(aFactory);
@ -287,15 +285,6 @@ IDBFactory::AssertIsOnOwningThread() const
#endif // DEBUG
bool
IDBFactory::IsChrome() const
{
AssertIsOnOwningThread();
MOZ_ASSERT(mPrincipalInfo);
return mPrincipalInfo->type() == PrincipalInfo::TSystemPrincipalInfo;
}
void
IDBFactory::SetBackgroundActor(BackgroundFactoryChild* aBackgroundActor)
{
@ -535,20 +524,19 @@ IDBFactory::OpenInternal(nsIPrincipal* aPrincipal,
nsRefPtr<IDBOpenDBRequest> request;
if (mWindow) {
AutoJSContext cx;
if (NS_WARN_IF(!autoJS.Init(mWindow, cx))) {
if (NS_WARN_IF(!autoJS.Init(mWindow))) {
IDB_REPORT_INTERNAL_ERR();
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
JS::Rooted<JSObject*> scriptOwner(cx,
JS::Rooted<JSObject*> scriptOwner(autoJS.cx(),
static_cast<nsGlobalWindow*>(mWindow.get())->FastGetGlobalJSObject());
MOZ_ASSERT(scriptOwner);
request = IDBOpenDBRequest::CreateForWindow(this, mWindow, scriptOwner);
} else {
autoJS.Init(mOwningObject.get());
autoJS.Init();
JS::Rooted<JSObject*> scriptOwner(autoJS.cx(), mOwningObject);
request = IDBOpenDBRequest::CreateForJS(this, scriptOwner);

View File

@ -73,8 +73,6 @@ class IDBFactory MOZ_FINAL
PRThread* mOwningThread;
#endif
uint64_t mInnerWindowID;
bool mBackgroundActorFailed;
bool mPrivateBrowsingMode;
@ -132,17 +130,6 @@ public:
return mPrincipalInfo;
}
uint64_t
InnerWindowID() const
{
AssertIsOnOwningThread();
return mInnerWindowID;
}
bool
IsChrome() const;
already_AddRefed<IDBOpenDBRequest>
Open(const nsAString& aName,
uint64_t aVersion,

View File

@ -99,11 +99,12 @@ IDBRequest::Create(IDBDatabase* aDatabase,
aDatabase->AssertIsOnOwningThread();
nsRefPtr<IDBRequest> request = new IDBRequest(aDatabase);
CaptureCaller(request->mFilename, &request->mLineNo);
request->mTransaction = aTransaction;
request->SetScriptOwner(aDatabase->GetScriptOwner());
request->CaptureCaller();
return request.forget();
}
@ -139,26 +140,6 @@ IDBRequest::Create(IDBIndex* aSourceAsIndex,
return request.forget();
}
// static
void
IDBRequest::CaptureCaller(nsAString& aFilename, uint32_t* aLineNo)
{
MOZ_ASSERT(aFilename.IsEmpty());
MOZ_ASSERT(aLineNo);
ThreadsafeAutoJSContext cx;
const char* filename = nullptr;
uint32_t lineNo = 0;
if (!nsJSUtils::GetCallingLocation(cx, &filename, &lineNo)) {
*aLineNo = 0;
return;
}
aFilename.Assign(NS_ConvertUTF8toUTF16(filename));
*aLineNo = lineNo;
}
void
IDBRequest::GetSource(
Nullable<OwningIDBObjectStoreOrIDBIndexOrIDBCursor>& aSource) const
@ -246,13 +227,25 @@ IDBRequest::GetErrorCode() const
#endif // DEBUG
void
IDBRequest::GetCallerLocation(nsAString& aFilename, uint32_t* aLineNo) const
IDBRequest::CaptureCaller()
{
AssertIsOnOwningThread();
MOZ_ASSERT(aLineNo);
AutoJSContext cx;
aFilename = mFilename;
*aLineNo = mLineNo;
const char* filename = nullptr;
uint32_t lineNo = 0;
if (!nsJSUtils::GetCallingLocation(cx, &filename, &lineNo)) {
return;
}
mFilename.Assign(NS_ConvertUTF8toUTF16(filename));
mLineNo = lineNo;
}
void
IDBRequest::FillScriptErrorEvent(ErrorEventInit& aEventInit) const
{
aEventInit.mLineno = mLineNo;
aEventInit.mFilename = mFilename;
}
IDBRequestReadyState
@ -308,6 +301,7 @@ IDBRequest::SetResultCallback(ResultCallback* aCallback)
// See if our window is still valid.
if (NS_WARN_IF(NS_FAILED(CheckInnerWindowCorrectness()))) {
IDB_REPORT_INTERNAL_ERR();
SetError(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return;
}
@ -430,7 +424,7 @@ IDBOpenDBRequest::CreateForWindow(IDBFactory* aFactory,
MOZ_ASSERT(aScriptOwner);
nsRefPtr<IDBOpenDBRequest> request = new IDBOpenDBRequest(aFactory, aOwner);
CaptureCaller(request->mFilename, &request->mLineNo);
request->CaptureCaller();
request->SetScriptOwner(aScriptOwner);
@ -447,7 +441,7 @@ IDBOpenDBRequest::CreateForJS(IDBFactory* aFactory,
MOZ_ASSERT(aScriptOwner);
nsRefPtr<IDBOpenDBRequest> request = new IDBOpenDBRequest(aFactory, nullptr);
CaptureCaller(request->mFilename, &request->mLineNo);
request->CaptureCaller();
request->SetScriptOwner(aScriptOwner);

View File

@ -114,7 +114,7 @@ public:
GetError(ErrorResult& aRv);
void
GetCallerLocation(nsAString& aFilename, uint32_t* aLineNo) const;
FillScriptErrorEvent(ErrorEventInit& aEventInit) const;
bool
IsPending() const
@ -189,6 +189,9 @@ protected:
void
ConstructResult();
void
CaptureCaller();
};
class NS_NO_VTABLE IDBRequest::ResultCallback

View File

@ -48,7 +48,6 @@ IDBTransaction::IDBTransaction(IDBDatabase* aDatabase,
, mNextIndexId(0)
, mAbortCode(NS_OK)
, mPendingRequestCount(0)
, mLineNo(0)
, mReadyState(IDBTransaction::INITIAL)
, mMode(aMode)
, mCreating(false)
@ -128,14 +127,12 @@ already_AddRefed<IDBTransaction>
IDBTransaction::CreateVersionChange(
IDBDatabase* aDatabase,
BackgroundVersionChangeTransactionChild* aActor,
IDBOpenDBRequest* aOpenRequest,
int64_t aNextObjectStoreId,
int64_t aNextIndexId)
{
MOZ_ASSERT(aDatabase);
aDatabase->AssertIsOnOwningThread();
MOZ_ASSERT(aActor);
MOZ_ASSERT(aOpenRequest);
MOZ_ASSERT(aNextObjectStoreId > 0);
MOZ_ASSERT(aNextIndexId > 0);
@ -143,8 +140,6 @@ IDBTransaction::CreateVersionChange(
nsRefPtr<IDBTransaction> transaction =
new IDBTransaction(aDatabase, emptyObjectStoreNames, VERSION_CHANGE);
aOpenRequest->GetCallerLocation(transaction->mFilename,
&transaction->mLineNo);
transaction->SetScriptOwner(aDatabase->GetScriptOwner());
transaction->mBackgroundActor.mVersionChangeBackgroundActor = aActor;
@ -180,7 +175,6 @@ IDBTransaction::Create(IDBDatabase* aDatabase,
nsRefPtr<IDBTransaction> transaction =
new IDBTransaction(aDatabase, aObjectStoreNames, aMode);
IDBRequest::CaptureCaller(transaction->mFilename, &transaction->mLineNo);
transaction->SetScriptOwner(aDatabase->GetScriptOwner());
@ -397,16 +391,6 @@ IDBTransaction::IsOpen() const
return false;
}
void
IDBTransaction::GetCallerLocation(nsAString& aFilename, uint32_t* aLineNo) const
{
AssertIsOnOwningThread();
MOZ_ASSERT(aLineNo);
aFilename = mFilename;
*aLineNo = mLineNo;
}
already_AddRefed<IDBObjectStore>
IDBTransaction::CreateObjectStore(const ObjectStoreSpec& aSpec)
{

View File

@ -37,7 +37,6 @@ class BackgroundTransactionChild;
class BackgroundVersionChangeTransactionChild;
class IDBDatabase;
class IDBObjectStore;
class IDBOpenDBRequest;
class IDBRequest;
class IndexMetadata;
class ObjectStoreSpec;
@ -95,9 +94,6 @@ private:
nsresult mAbortCode;
uint32_t mPendingRequestCount;
nsString mFilename;
uint32_t mLineNo;
ReadyState mReadyState;
Mode mMode;
@ -113,7 +109,6 @@ public:
static already_AddRefed<IDBTransaction>
CreateVersionChange(IDBDatabase* aDatabase,
BackgroundVersionChangeTransactionChild* aActor,
IDBOpenDBRequest* aOpenRequest,
int64_t aNextObjectStoreId,
int64_t aNextIndexId);
@ -189,9 +184,6 @@ public:
return NS_FAILED(mAbortCode);
}
void
GetCallerLocation(nsAString& aFilename, uint32_t* aLineNo) const;
// 'Get' prefix is to avoid name collisions with the enum
Mode
GetMode() const

View File

@ -366,7 +366,7 @@ IndexedDatabaseManager::FireWindowOnError(nsPIDOMWindow* aOwner,
ThreadsafeAutoJSContext cx;
RootedDictionary<ErrorEventInit> init(cx);
request->GetCallerLocation(init.mFilename, &init.mLineno);
request->FillScriptErrorEvent(init);
init.mMessage = errorName;
init.mCancelable = true;

View File

@ -209,5 +209,3 @@ KeyNameZoomWarning=KeyboardEvent.key value "Zoom" is obsolete and will be rename
KeyNameDeadKeysWarning=KeyboardEvent.key values starting with "Dead" are obsolete and will be merged into just "Dead". For more help https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.key
ImportXULIntoContentWarning=Importing XUL nodes into a content document is deprecated. This functionality may be removed soon.
XMLDocumentLoadPrincipalMismatch=Use of document.load forbidden on Documents that come from other Windows. Only the Window in which a Document was created is allowed to call .load on that Document. Preferably, use XMLHttpRequest instead.
# LOCALIZATION NOTE: Do not translate "IndexedDB".
IndexedDBTransactionAbortNavigation=An IndexedDB transaction that was not yet complete has been aborted due to page navigation.