Bug 1200484 (part 10) - Use JS column numbers in indexedDB. r=khuey.
authorNicholas Nethercote <nnethercote@mozilla.com>
Tue, 01 Sep 2015 18:01:02 -0700
changeset 260449 82aade52497a133b5266351432a5f462666b7b87
parent 260448 ff59d437f2252d7a8b7af5d5bcc9d540f7580775
child 260450 63bf0b9aed0fced2510cb89a481cb51763f85087
push id64501
push usernnethercote@mozilla.com
push dateWed, 02 Sep 2015 05:40:33 +0000
treeherdermozilla-inbound@82aade52497a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs1200484
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1200484 (part 10) - Use JS column numbers in indexedDB. r=khuey.
dom/indexedDB/IDBDatabase.cpp
dom/indexedDB/IDBDatabase.h
dom/indexedDB/IDBRequest.cpp
dom/indexedDB/IDBRequest.h
dom/indexedDB/IDBTransaction.cpp
dom/indexedDB/IDBTransaction.h
dom/indexedDB/IndexedDatabaseManager.cpp
--- a/dom/indexedDB/IDBDatabase.cpp
+++ b/dom/indexedDB/IDBDatabase.cpp
@@ -182,38 +182,42 @@ private:
 } // namespace
 
 class IDBDatabase::LogWarningRunnable final
   : public nsRunnable
 {
   nsCString mMessageName;
   nsString mFilename;
   uint32_t mLineNumber;
+  uint32_t mColumnNumber;
   uint64_t mInnerWindowID;
   bool mIsChrome;
 
 public:
   LogWarningRunnable(const char* aMessageName,
                      const nsAString& aFilename,
                      uint32_t aLineNumber,
+                     uint32_t aColumnNumber,
                      bool aIsChrome,
                      uint64_t aInnerWindowID)
     : mMessageName(aMessageName)
     , mFilename(aFilename)
     , mLineNumber(aLineNumber)
+    , mColumnNumber(aColumnNumber)
     , mInnerWindowID(aInnerWindowID)
     , mIsChrome(aIsChrome)
   {
     MOZ_ASSERT(!NS_IsMainThread());
   }
 
   static void
   LogWarning(const char* aMessageName,
              const nsAString& aFilename,
              uint32_t aLineNumber,
+             uint32_t aColumnNumber,
              bool aIsChrome,
              uint64_t aInnerWindowID);
 
   NS_DECL_ISUPPORTS_INHERITED
 
 private:
   ~LogWarningRunnable()
   { }
@@ -954,20 +958,20 @@ IDBDatabase::AbortTransactions(bool aSho
 
       static const char kWarningMessage[] =
         "IndexedDBTransactionAbortNavigation";
 
       for (IDBTransaction* transaction : transactionsThatNeedWarning) {
         MOZ_ASSERT(transaction);
 
         nsString filename;
-        uint32_t lineNo;
-        transaction->GetCallerLocation(filename, &lineNo);
+        uint32_t lineNo, column;
+        transaction->GetCallerLocation(filename, &lineNo, &column);
 
-        aDatabase->LogWarning(kWarningMessage, filename, lineNo);
+        aDatabase->LogWarning(kWarningMessage, filename, lineNo, column);
       }
     }
   };
 
   Helper::AbortTransactions(this, aShouldWarn);
 }
 
 PBackgroundIDBDatabaseFileChild*
@@ -1332,32 +1336,35 @@ IDBDatabase::Invalidate()
 
     InvalidateInternal();
   }
 }
 
 void
 IDBDatabase::LogWarning(const char* aMessageName,
                         const nsAString& aFilename,
-                        uint32_t aLineNumber)
+                        uint32_t aLineNumber,
+                        uint32_t aColumnNumber)
 {
   AssertIsOnOwningThread();
   MOZ_ASSERT(aMessageName);
 
   if (NS_IsMainThread()) {
     LogWarningRunnable::LogWarning(aMessageName,
                                    aFilename,
                                    aLineNumber,
+                                   aColumnNumber,
                                    mFactory->IsChrome(),
                                    mFactory->InnerWindowID());
   } else {
     nsRefPtr<LogWarningRunnable> runnable =
       new LogWarningRunnable(aMessageName,
                              aFilename,
                              aLineNumber,
+                             aColumnNumber,
                              mFactory->IsChrome(),
                              mFactory->InnerWindowID());
     MOZ_ALWAYS_TRUE(NS_SUCCEEDED(NS_DispatchToMainThread(runnable)));
   }
 }
 
 NS_IMPL_ADDREF_INHERITED(IDBDatabase, IDBWrapperCache)
 NS_IMPL_RELEASE_INHERITED(IDBDatabase, IDBWrapperCache)
@@ -1623,16 +1630,17 @@ CreateFileHelper::Run()
 
 
 // static
 void
 IDBDatabase::
 LogWarningRunnable::LogWarning(const char* aMessageName,
                                const nsAString& aFilename,
                                uint32_t aLineNumber,
+                               uint32_t aColumnNumber,
                                bool aIsChrome,
                                uint64_t aInnerWindowID)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aMessageName);
 
   nsXPIDLString localizedMessage;
   if (NS_WARN_IF(NS_FAILED(
@@ -1659,27 +1667,27 @@ LogWarningRunnable::LogWarning(const cha
   MOZ_ASSERT(consoleService);
 
   if (aInnerWindowID) {
     MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
       scriptError->InitWithWindowID(localizedMessage,
                                     aFilename,
                                     /* aSourceLine */ EmptyString(),
                                     aLineNumber,
-                                    /* aColumnNumber */ 0,
+                                    aColumnNumber,
                                     nsIScriptError::warningFlag,
                                     category,
                                     aInnerWindowID)));
   } else {
     MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
       scriptError->Init(localizedMessage,
                         aFilename,
                         /* aSourceLine */ EmptyString(),
                         aLineNumber,
-                        /* aColumnNumber */ 0,
+                        aColumnNumber,
                         nsIScriptError::warningFlag,
                         category.get())));
   }
 
   MOZ_ALWAYS_TRUE(NS_SUCCEEDED(consoleService->LogMessage(scriptError)));
 }
 
 NS_IMPL_ISUPPORTS_INHERITED0(IDBDatabase::LogWarningRunnable, nsRunnable)
@@ -1688,16 +1696,17 @@ NS_IMETHODIMP
 IDBDatabase::
 LogWarningRunnable::Run()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   LogWarning(mMessageName.get(),
              mFilename,
              mLineNumber,
+             mColumnNumber,
              mIsChrome,
              mInnerWindowID);
 
   return NS_OK;
 }
 
 NS_IMPL_ISUPPORTS(IDBDatabase::Observer, nsIObserver)
 
--- a/dom/indexedDB/IDBDatabase.h
+++ b/dom/indexedDB/IDBDatabase.h
@@ -308,16 +308,17 @@ private:
   ExpireFileActors(bool aExpireAll);
 
   void
   InvalidateMutableFiles();
 
   void
   LogWarning(const char* aMessageName,
              const nsAString& aFilename,
-             uint32_t aLineNumber);
+             uint32_t aLineNumber,
+             uint32_t aColumnNumber);
 };
 
 } // namespace indexedDB
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_indexeddb_idbdatabase_h__
--- a/dom/indexedDB/IDBRequest.cpp
+++ b/dom/indexedDB/IDBRequest.cpp
@@ -87,29 +87,30 @@ IDBRequest::InitMembers()
   mOwningThread = PR_GetCurrentThread();
 #endif
   AssertIsOnOwningThread();
 
   mResultVal.setUndefined();
   mLoggingSerialNumber = NextSerialNumber();
   mErrorCode = NS_OK;
   mLineNo = 0;
+  mColumn = 0;
   mHaveResultOrErrorCode = false;
 }
 
 // static
 already_AddRefed<IDBRequest>
 IDBRequest::Create(IDBDatabase* aDatabase,
                    IDBTransaction* aTransaction)
 {
   MOZ_ASSERT(aDatabase);
   aDatabase->AssertIsOnOwningThread();
 
   nsRefPtr<IDBRequest> request = new IDBRequest(aDatabase);
-  CaptureCaller(request->mFilename, &request->mLineNo);
+  CaptureCaller(request->mFilename, &request->mLineNo, &request->mColumn);
 
   request->mTransaction = aTransaction;
   request->SetScriptOwner(aDatabase->GetScriptOwner());
 
   return request.forget();
 }
 
 // static
@@ -163,23 +164,25 @@ IDBRequest::SetLoggingSerialNumber(uint6
 {
   AssertIsOnOwningThread();
   MOZ_ASSERT(aLoggingSerialNumber > mLoggingSerialNumber);
 
   mLoggingSerialNumber = aLoggingSerialNumber;
 }
 
 void
-IDBRequest::CaptureCaller(nsAString& aFilename, uint32_t* aLineNo)
+IDBRequest::CaptureCaller(nsAString& aFilename, uint32_t* aLineNo,
+                          uint32_t* aColumn)
 {
   MOZ_ASSERT(aFilename.IsEmpty());
   MOZ_ASSERT(aLineNo);
+  MOZ_ASSERT(aColumn);
 
   ThreadsafeAutoJSContext cx;
-  nsJSUtils::GetCallingLocation(cx, aFilename, aLineNo);
+  nsJSUtils::GetCallingLocation(cx, aFilename, aLineNo, aColumn);
 }
 
 void
 IDBRequest::GetSource(
              Nullable<OwningIDBObjectStoreOrIDBIndexOrIDBCursor>& aSource) const
 {
   AssertIsOnOwningThread();
 
@@ -266,23 +269,26 @@ IDBRequest::GetErrorAfterResult() const
   MOZ_ASSERT(mHaveResultOrErrorCode);
 
   return mError;
 }
 
 #endif // DEBUG
 
 void
-IDBRequest::GetCallerLocation(nsAString& aFilename, uint32_t* aLineNo) const
+IDBRequest::GetCallerLocation(nsAString& aFilename, uint32_t* aLineNo,
+                              uint32_t* aColumn) const
 {
   AssertIsOnOwningThread();
   MOZ_ASSERT(aLineNo);
+  MOZ_ASSERT(aColumn);
 
   aFilename = mFilename;
   *aLineNo = mLineNo;
+  *aColumn = mColumn;
 }
 
 IDBRequestReadyState
 IDBRequest::ReadyState() const
 {
   AssertIsOnOwningThread();
 
   return IsPending() ?
@@ -511,34 +517,34 @@ IDBOpenDBRequest::CreateForWindow(IDBFac
                                   JS::Handle<JSObject*> aScriptOwner)
 {
   MOZ_ASSERT(aFactory);
   aFactory->AssertIsOnOwningThread();
   MOZ_ASSERT(aOwner);
   MOZ_ASSERT(aScriptOwner);
 
   nsRefPtr<IDBOpenDBRequest> request = new IDBOpenDBRequest(aFactory, aOwner);
-  CaptureCaller(request->mFilename, &request->mLineNo);
+  CaptureCaller(request->mFilename, &request->mLineNo, &request->mColumn);
 
   request->SetScriptOwner(aScriptOwner);
 
   return request.forget();
 }
 
 // static
 already_AddRefed<IDBOpenDBRequest>
 IDBOpenDBRequest::CreateForJS(IDBFactory* aFactory,
                               JS::Handle<JSObject*> aScriptOwner)
 {
   MOZ_ASSERT(aFactory);
   aFactory->AssertIsOnOwningThread();
   MOZ_ASSERT(aScriptOwner);
 
   nsRefPtr<IDBOpenDBRequest> request = new IDBOpenDBRequest(aFactory, nullptr);
-  CaptureCaller(request->mFilename, &request->mLineNo);
+  CaptureCaller(request->mFilename, &request->mLineNo, &request->mColumn);
 
   request->SetScriptOwner(aScriptOwner);
 
   if (!NS_IsMainThread()) {
     WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
     MOZ_ASSERT(workerPrivate);
 
     workerPrivate->AssertIsOnWorkerThread();
--- a/dom/indexedDB/IDBRequest.h
+++ b/dom/indexedDB/IDBRequest.h
@@ -58,16 +58,17 @@ protected:
 
   JS::Heap<JS::Value> mResultVal;
   nsRefPtr<DOMError> mError;
 
   nsString mFilename;
   uint64_t mLoggingSerialNumber;
   nsresult mErrorCode;
   uint32_t mLineNo;
+  uint32_t mColumn;
   bool mHaveResultOrErrorCode;
 
 public:
   class ResultCallback;
 
   static already_AddRefed<IDBRequest>
   Create(IDBDatabase* aDatabase, IDBTransaction* aTransaction);
 
@@ -77,17 +78,17 @@ public:
          IDBTransaction* aTransaction);
 
   static already_AddRefed<IDBRequest>
   Create(IDBIndex* aSource,
          IDBDatabase* aDatabase,
          IDBTransaction* aTransaction);
 
   static void
-  CaptureCaller(nsAString& aFilename, uint32_t* aLineNo);
+  CaptureCaller(nsAString& aFilename, uint32_t* aLineNo, uint32_t* aColumn);
 
   static uint64_t
   NextSerialNumber();
 
   // nsIDOMEventTarget
   virtual nsresult
   PreHandleEvent(EventChainPreVisitor& aVisitor) override;
 
@@ -125,17 +126,18 @@ public:
     return mError;
   }
 #endif
 
   DOMError*
   GetError(ErrorResult& aRv);
 
   void
-  GetCallerLocation(nsAString& aFilename, uint32_t* aLineNo) const;
+  GetCallerLocation(nsAString& aFilename, uint32_t* aLineNo,
+                    uint32_t* aColumn) const;
 
   bool
   IsPending() const
   {
     return !mHaveResultOrErrorCode;
   }
 
   uint64_t
--- a/dom/indexedDB/IDBTransaction.cpp
+++ b/dom/indexedDB/IDBTransaction.cpp
@@ -77,16 +77,17 @@ IDBTransaction::IDBTransaction(IDBDataba
   , mDatabase(aDatabase)
   , mObjectStoreNames(aObjectStoreNames)
   , mLoggingSerialNumber(0)
   , mNextObjectStoreId(0)
   , mNextIndexId(0)
   , mAbortCode(NS_OK)
   , mPendingRequestCount(0)
   , mLineNo(0)
+  , mColumn(0)
   , mReadyState(IDBTransaction::INITIAL)
   , mMode(aMode)
   , mCreating(false)
   , mRegistered(false)
   , mAbortedByScript(false)
 #ifdef DEBUG
   , mSentCommitOrAbort(false)
   , mFiredCompleteOrAbort(false)
@@ -181,17 +182,17 @@ IDBTransaction::CreateVersionChange(
 
   nsTArray<nsString> emptyObjectStoreNames;
 
   nsRefPtr<IDBTransaction> transaction =
     new IDBTransaction(aDatabase,
                        emptyObjectStoreNames,
                        VERSION_CHANGE);
   aOpenRequest->GetCallerLocation(transaction->mFilename,
-                                  &transaction->mLineNo);
+                                  &transaction->mLineNo, &transaction->mColumn);
 
   transaction->SetScriptOwner(aDatabase->GetScriptOwner());
 
   nsCOMPtr<nsIRunnable> runnable = do_QueryObject(transaction);
   nsContentUtils::RunInMetastableState(runnable.forget());
 
   transaction->mBackgroundActor.mVersionChangeBackgroundActor = aActor;
   transaction->mNextObjectStoreId = aNextObjectStoreId;
@@ -214,17 +215,18 @@ IDBTransaction::Create(IDBDatabase* aDat
   aDatabase->AssertIsOnOwningThread();
   MOZ_ASSERT(!aObjectStoreNames.IsEmpty());
   MOZ_ASSERT(aMode == READ_ONLY ||
              aMode == READ_WRITE ||
              aMode == READ_WRITE_FLUSH);
 
   nsRefPtr<IDBTransaction> transaction =
     new IDBTransaction(aDatabase, aObjectStoreNames, aMode);
-  IDBRequest::CaptureCaller(transaction->mFilename, &transaction->mLineNo);
+  IDBRequest::CaptureCaller(transaction->mFilename, &transaction->mLineNo,
+                            &transaction->mColumn);
 
   transaction->SetScriptOwner(aDatabase->GetScriptOwner());
 
   nsCOMPtr<nsIRunnable> runnable = do_QueryObject(transaction);
   nsContentUtils::RunInMetastableState(runnable.forget());
 
   transaction->mCreating = true;
 
@@ -487,23 +489,26 @@ IDBTransaction::IsOpen() const
       (mCreating || GetCurrent() == this)) {
     return true;
   }
 
   return false;
 }
 
 void
-IDBTransaction::GetCallerLocation(nsAString& aFilename, uint32_t* aLineNo) const
+IDBTransaction::GetCallerLocation(nsAString& aFilename, uint32_t* aLineNo,
+                                  uint32_t* aColumn) const
 {
   AssertIsOnOwningThread();
   MOZ_ASSERT(aLineNo);
+  MOZ_ASSERT(aColumn);
 
   aFilename = mFilename;
   *aLineNo = mLineNo;
+  *aColumn = mColumn;
 }
 
 already_AddRefed<IDBObjectStore>
 IDBTransaction::CreateObjectStore(const ObjectStoreSpec& aSpec)
 {
   AssertIsOnOwningThread();
   MOZ_ASSERT(aSpec.metadata().id());
   MOZ_ASSERT(VERSION_CHANGE == mMode);
--- a/dom/indexedDB/IDBTransaction.h
+++ b/dom/indexedDB/IDBTransaction.h
@@ -95,16 +95,17 @@ private:
   int64_t mNextObjectStoreId;
   int64_t mNextIndexId;
 
   nsresult mAbortCode;
   uint32_t mPendingRequestCount;
 
   nsString mFilename;
   uint32_t mLineNo;
+  uint32_t mColumn;
 
   ReadyState mReadyState;
   Mode mMode;
 
   bool mCreating;
   bool mRegistered;
   bool mAbortedByScript;
 
@@ -200,17 +201,18 @@ public:
   nsresult
   AbortCode() const
   {
     AssertIsOnOwningThread();
     return mAbortCode;
   }
 
   void
-  GetCallerLocation(nsAString& aFilename, uint32_t* aLineNo) const;
+  GetCallerLocation(nsAString& aFilename, uint32_t* aLineNo,
+                    uint32_t* aColumn) const;
 
   // 'Get' prefix is to avoid name collisions with the enum
   Mode
   GetMode() const
   {
     AssertIsOnOwningThread();
     return mMode;
   }
--- a/dom/indexedDB/IndexedDatabaseManager.cpp
+++ b/dom/indexedDB/IndexedDatabaseManager.cpp
@@ -475,17 +475,17 @@ IndexedDatabaseManager::CommonPostHandle
 
   nsString errorName;
   if (error) {
     error->GetName(errorName);
   }
 
   ThreadsafeAutoJSContext cx;
   RootedDictionary<ErrorEventInit> init(cx);
-  request->GetCallerLocation(init.mFilename, &init.mLineno);
+  request->GetCallerLocation(init.mFilename, &init.mLineno, &init.mColno);
 
   init.mMessage = errorName;
   init.mCancelable = true;
   init.mBubbles = true;
 
   nsEventStatus status = nsEventStatus_eIgnore;
 
   if (NS_IsMainThread()) {
@@ -551,27 +551,27 @@ IndexedDatabaseManager::CommonPostHandle
   MOZ_ASSERT(consoleService);
 
   if (uint64_t innerWindowID = aFactory->InnerWindowID()) {
     MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
       scriptError->InitWithWindowID(errorName,
                                     init.mFilename,
                                     /* aSourceLine */ EmptyString(),
                                     init.mLineno,
-                                    /* aColumnNumber */ 0,
+                                    init.mColno,
                                     nsIScriptError::errorFlag,
                                     category,
                                     innerWindowID)));
   } else {
     MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
       scriptError->Init(errorName,
                         init.mFilename,
                         /* aSourceLine */ EmptyString(),
                         init.mLineno,
-                        /* aColumnNumber */ 0,
+                        init.mColno,
                         nsIScriptError::errorFlag,
                         category.get())));
   }
 
   MOZ_ALWAYS_TRUE(NS_SUCCEEDED(consoleService->LogMessage(scriptError)));
 
   return NS_OK;
 }