Bug 1007034 - Add console warnings for the deprecated BindXXXParameter methods in mozIStorageBaseStatement and replace calls to the deprecated methods in dom/indexedDB/ActorsParent.cpp. r=mak

--HG--
extra : rebase_source : ac32534d36959ff7f3a1c3a382319e6de4225c2f
This commit is contained in:
Sajid Ahmed 2017-04-05 14:08:25 -04:00
parent f604f61de9
commit 591da76059
3 changed files with 30 additions and 3 deletions

View File

@ -1297,17 +1297,17 @@ UpgradeSchemaFrom4To5(mozIStorageConnection* aConnection)
{
mozStorageStatementScoper scoper(stmt);
rv = stmt->BindStringParameter(0, name);
rv = stmt->BindStringByIndex(0, name);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
rv = stmt->BindInt32Parameter(1, intVersion);
rv = stmt->BindInt32ByIndex(1, intVersion);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
rv = stmt->BindInt64Parameter(2, dataVersion);
rv = stmt->BindInt64ByIndex(2, dataVersion);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}

View File

@ -10,6 +10,7 @@
#include "nsISupports.h"
#include "nsCOMPtr.h"
#include "nsAutoPtr.h"
#include "mozStorageHelper.h"
struct sqlite3;
struct sqlite3_stmt;
@ -236,6 +237,7 @@ NS_DEFINE_STATIC_IID_ACCESSOR(StorageBaseStatementInternal,
} \
NS_IMETHODIMP _class::BIND_NAME_CONCAT(_name, Parameter) _declIndex \
{ \
WARN_DEPRECATED(); \
_guard \
mozIStorageBindingParams *params = getParams(); \
NS_ENSURE_TRUE(params, NS_ERROR_OUT_OF_MEMORY); \

View File

@ -9,6 +9,8 @@
#include "nsAutoPtr.h"
#include "nsStringGlue.h"
#include "mozilla/DebugOnly.h"
#include "nsIConsoleService.h"
#include "nsIScriptError.h"
#include "mozIStorageAsyncConnection.h"
#include "mozIStorageConnection.h"
@ -206,4 +208,27 @@ protected:
// queries are stable in the face of source code changes.
#define MOZ_STORAGE_UNIQUIFY_QUERY_STR "/* " __FILE__ " */ "
// Use this to show a console warning when using deprecated methods.
#define WARN_DEPRECATED() \
PR_BEGIN_MACRO \
\
if (NS_IsMainThread()) { \
nsCOMPtr<nsIConsoleService> cs = do_GetService(NS_CONSOLESERVICE_CONTRACTID); \
\
if (cs) { \
nsCString msg(__FUNCTION__); \
msg.AppendLiteral(" is deprecated and will be removed soon."); \
\
nsCOMPtr<nsIScriptError> e = do_CreateInstance(NS_SCRIPTERROR_CONTRACTID); \
if (e && NS_SUCCEEDED(e->Init(NS_ConvertUTF8toUTF16(msg), EmptyString(), \
EmptyString(), 0, 0, \
nsIScriptError::errorFlag, "Storage"))) { \
cs->LogMessage(e); \
} \
} \
} \
MOZ_ASSERT(false, "You are trying to use a deprecated mozStorage method. " \
"Check error message in console to identify the method name.");\
PR_END_MACRO
#endif /* MOZSTORAGEHELPER_H */