Backed out changeset ef82210d0bf3 (bug 1193387) for various WinXP test failures.

CLOSED TREE
This commit is contained in:
Ryan VanderMeulen 2015-08-28 21:01:27 -04:00
parent fa4e814804
commit f8d82fe3a5
13 changed files with 547 additions and 913 deletions

View File

@ -24,7 +24,6 @@ LOCAL_INCLUDES += [
if CONFIG['OS_ARCH'] == 'WINNT':
OS_LIBS += [
'esent',
'ole32',
'shell32',
'shlwapi',

View File

@ -10,12 +10,6 @@
#define NS_IEHISTORYENUMERATOR_CONTRACTID \
"@mozilla.org/profile/migrator/iehistoryenumerator;1"
#define NS_EDGEREADINGLISTEXTRACTOR_CID \
{ 0xeeff77b1, 0xdb98, 0x4241, { 0x94, 0x36, 0x14, 0xf7, 0xa2, 0x28, 0x84, 0xc1 } }
#define NS_EDGEREADINGLISTEXTRACTOR_CONTRACTID \
"@mozilla.org/profile/migrator/edgereadinglistextractor;1"
#endif
#define NS_SHELLSERVICE_CID \

View File

@ -18,7 +18,6 @@
#if defined(XP_WIN)
#include "nsIEHistoryEnumerator.h"
#include "nsEdgeReadingListExtractor.h"
#endif
#include "rdf.h"
@ -43,7 +42,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsGNOMEShellService, Init)
#if defined(XP_WIN)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsIEHistoryEnumerator)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsEdgeReadingListExtractor)
#endif
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFeedSniffer)
@ -58,7 +56,6 @@ NS_DEFINE_NAMED_CID(NS_FEEDSNIFFER_CID);
NS_DEFINE_NAMED_CID(NS_BROWSER_ABOUT_REDIRECTOR_CID);
#if defined(XP_WIN)
NS_DEFINE_NAMED_CID(NS_WINIEHISTORYENUMERATOR_CID);
NS_DEFINE_NAMED_CID(NS_EDGEREADINGLISTEXTRACTOR_CID);
#elif defined(XP_MACOSX)
NS_DEFINE_NAMED_CID(NS_SHELLSERVICE_CID);
#endif
@ -74,7 +71,6 @@ static const mozilla::Module::CIDEntry kBrowserCIDs[] = {
{ &kNS_BROWSER_ABOUT_REDIRECTOR_CID, false, nullptr, AboutRedirector::Create },
#if defined(XP_WIN)
{ &kNS_WINIEHISTORYENUMERATOR_CID, false, nullptr, nsIEHistoryEnumeratorConstructor },
{ &kNS_EDGEREADINGLISTEXTRACTOR_CID, false, nullptr, nsEdgeReadingListExtractorConstructor },
#elif defined(XP_MACOSX)
{ &kNS_SHELLSERVICE_CID, false, nullptr, nsMacShellServiceConstructor },
#endif
@ -123,7 +119,6 @@ static const mozilla::Module::ContractIDEntry kBrowserContracts[] = {
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "pocket-signup", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
#if defined(XP_WIN)
{ NS_IEHISTORYENUMERATOR_CONTRACTID, &kNS_WINIEHISTORYENUMERATOR_CID },
{ NS_EDGEREADINGLISTEXTRACTOR_CONTRACTID, &kNS_EDGEREADINGLISTEXTRACTOR_CID },
#elif defined(XP_MACOSX)
{ NS_SHELLSERVICE_CONTRACTID, &kNS_SHELLSERVICE_CID },
#endif

View File

@ -1,30 +1,30 @@
/* 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/. */
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/Task.jsm");
Cu.import("resource:///modules/MigrationUtils.jsm");
Cu.import("resource:///modules/MSMigrationUtils.jsm");
function EdgeProfileMigrator() {
}
EdgeProfileMigrator.prototype = Object.create(MigratorPrototype);
EdgeProfileMigrator.prototype.getResources = function() {
let resources = [
MSMigrationUtils.getBookmarksMigrator(MSMigrationUtils.MIGRATION_TYPE_EDGE),
MSMigrationUtils.getCookiesMigrator(MSMigrationUtils.MIGRATION_TYPE_EDGE),
];
return resources.filter(r => r.exists);
};
EdgeProfileMigrator.prototype.classDescription = "Edge Profile Migrator";
EdgeProfileMigrator.prototype.contractID = "@mozilla.org/profile/migrator;1?app=browser&type=edge";
EdgeProfileMigrator.prototype.classID = Components.ID("{62e8834b-2d17-49f5-96ff-56344903a2ae}");
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([EdgeProfileMigrator]);
/* 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/. */
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/Task.jsm");
Cu.import("resource:///modules/MigrationUtils.jsm");
Cu.import("resource:///modules/MSMigrationUtils.jsm");
function EdgeProfileMigrator() {
}
EdgeProfileMigrator.prototype = Object.create(MigratorPrototype);
EdgeProfileMigrator.prototype.getResources = function() {
let resources = [
MSMigrationUtils.getBookmarksMigrator(MSMigrationUtils.MIGRATION_TYPE_EDGE),
MSMigrationUtils.getCookiesMigrator(MSMigrationUtils.MIGRATION_TYPE_EDGE),
];
return resources.filter(r => r.exists);
};
EdgeProfileMigrator.prototype.classDescription = "Edge Profile Migrator";
EdgeProfileMigrator.prototype.contractID = "@mozilla.org/profile/migrator;1?app=browser&type=edge";
EdgeProfileMigrator.prototype.classID = Components.ID("{62e8834b-2d17-49f5-96ff-56344903a2ae}");
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([EdgeProfileMigrator]);

View File

@ -84,8 +84,7 @@ History.prototype = {
let transitionType = this._typedURLs[uri.spec] ?
Ci.nsINavHistoryService.TRANSITION_TYPED :
Ci.nsINavHistoryService.TRANSITION_LINK;
// use the current date if we have no visits for this entry
let lastVisitTime = entry.get("time") || Date.now();
let lastVisitTime = entry.get("time");
places.push(
{ uri: uri,

File diff suppressed because it is too large Load Diff

View File

@ -10,14 +10,12 @@ JAR_MANIFESTS += ['jar.mn']
XPIDL_SOURCES += [
'nsIBrowserProfileMigrator.idl',
'nsIEdgeReadingListExtractor.idl',
]
XPIDL_MODULE = 'migration'
if CONFIG['OS_ARCH'] == 'WINNT':
SOURCES += [
'nsEdgeReadingListExtractor.cpp',
'nsIEHistoryEnumerator.cpp',
]

View File

@ -1,203 +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/. */
#include "nsEdgeReadingListExtractor.h"
#include <windows.h>
#include "nsCOMPtr.h"
#include "nsIConsoleService.h"
#include "nsIMutableArray.h"
#include "nsIWritablePropertyBag2.h"
#include "nsNetUtil.h"
#include "nsServiceManagerUtils.h"
#include "nsWindowsMigrationUtils.h"
#define NS_HANDLE_JET_ERROR(err) { \
if (err < JET_errSuccess) { \
rv = ConvertJETError(err); \
goto CloseDB; \
} \
}
#define MAX_URL_LENGTH 4168
#define MAX_TITLE_LENGTH 1024
NS_IMPL_ISUPPORTS(nsEdgeReadingListExtractor, nsIEdgeReadingListExtractor)
NS_IMETHODIMP
nsEdgeReadingListExtractor::Extract(const nsAString& aDBPath, nsIArray** aItems)
{
nsresult rv = NS_OK;
*aItems = nullptr;
JET_ERR err;
JET_INSTANCE instance;
JET_SESID sesid;
JET_DBID dbid;
JET_TABLEID tableid;
JET_COLUMNDEF urlColumnInfo = { 0 };
JET_COLUMNDEF titleColumnInfo = { 0 };
JET_COLUMNDEF addedDateColumnInfo = { 0 };
// Need to ensure this happens before we skip ahead to CloseDB,
// otherwise the compiler complains.
nsCOMPtr<nsIMutableArray> items = do_CreateInstance(NS_ARRAY_CONTRACTID);
// JET does not throw exceptions, and so error handling and ensuring we close
// the DB is a bit finnicky. Keep track of how far we got so we guarantee closing
// the right things
bool instanceCreated, sessionCreated, dbOpened, tableOpened;
char16_t* dbPath = ToNewUnicode(aDBPath);
// Check for the right page size and initialize with that
unsigned long pageSize;
err = JetGetDatabaseFileInfoW(dbPath, &pageSize, sizeof(pageSize), JET_DbInfoPageSize);
NS_HANDLE_JET_ERROR(err)
err = JetSetSystemParameter(&instance, NULL, JET_paramDatabasePageSize, pageSize, NULL);
NS_HANDLE_JET_ERROR(err)
// Turn off recovery, because otherwise we will create log files in either the cwd or
// overwrite Edge's own logfiles, which is useless at best and at worst might mess with
// Edge actually using the DB
err = JetSetSystemParameter(&instance, NULL, JET_paramRecovery, NULL, "Off");
NS_HANDLE_JET_ERROR(err)
// Start our session:
err = JetCreateInstance(&instance, "edge_readinglist_migration");
NS_HANDLE_JET_ERROR(err)
instanceCreated = true;
err = JetInit(&instance);
NS_HANDLE_JET_ERROR(err)
err = JetBeginSession(instance, &sesid, 0, 0);
NS_HANDLE_JET_ERROR(err)
sessionCreated = true;
// Actually open the DB, and make sure to do so readonly:
err = JetAttachDatabaseW(sesid, dbPath, JET_bitDbReadOnly);
NS_HANDLE_JET_ERROR(err)
dbOpened = true;
err = JetOpenDatabaseW(sesid, dbPath, NULL, &dbid, JET_bitDbReadOnly);
NS_HANDLE_JET_ERROR(err)
// Open the readinglist table and get information on the columns we are interested in:
err = JetOpenTable(sesid, dbid, "ReadingList", NULL, 0, JET_bitTableReadOnly, &tableid);
NS_HANDLE_JET_ERROR(err)
tableOpened = true;
err = JetGetColumnInfo(sesid, dbid, "ReadingList", "URL", &urlColumnInfo,
sizeof(urlColumnInfo), JET_ColInfo);
NS_HANDLE_JET_ERROR(err)
if (urlColumnInfo.cbMax > MAX_URL_LENGTH) {
nsCOMPtr<nsIConsoleService> consoleService = do_GetService(NS_CONSOLESERVICE_CONTRACTID);
if (consoleService) {
consoleService->LogStringMessage(NS_LITERAL_STRING("Edge migration: URL column size increased").get());
}
}
err = JetGetColumnInfo(sesid, dbid, "ReadingList", "Title", &titleColumnInfo,
sizeof(titleColumnInfo), JET_ColInfo);
NS_HANDLE_JET_ERROR(err)
if (titleColumnInfo.cbMax > MAX_TITLE_LENGTH) {
nsCOMPtr<nsIConsoleService> consoleService = do_GetService(NS_CONSOLESERVICE_CONTRACTID);
if (consoleService) {
consoleService->LogStringMessage(NS_LITERAL_STRING("Edge migration: Title column size increased").get());
}
}
err = JetGetColumnInfo(sesid, dbid, "ReadingList", "AddedDate", &addedDateColumnInfo,
sizeof(addedDateColumnInfo), JET_ColInfo);
NS_HANDLE_JET_ERROR(err)
// verify the column types are what we expect:
if (urlColumnInfo.coltyp != JET_coltypLongText ||
titleColumnInfo.coltyp != JET_coltypLongText ||
addedDateColumnInfo.coltyp != JET_coltypLongLong) {
rv = NS_ERROR_NOT_IMPLEMENTED;
goto CloseDB;
}
JET_COLUMNID urlColumnId = urlColumnInfo.columnid;
JET_COLUMNID titleColumnId = titleColumnInfo.columnid;
JET_COLUMNID addedDateColumnId = addedDateColumnInfo.columnid;
// If we got here, we've found our table and column information
err = JetMove(sesid, tableid, JET_MoveFirst, 0);
// It's possible there are 0 items in this table, in which case we want to
// not fail:
if (err == JET_errNoCurrentRecord) {
items.forget(aItems);
goto CloseDB;
}
// Check for any other errors
NS_HANDLE_JET_ERROR(err)
FILETIME addedDate;
wchar_t urlBuffer[MAX_URL_LENGTH] = { 0 };
wchar_t titleBuffer[MAX_TITLE_LENGTH] = { 0 };
do {
err = JetRetrieveColumn(sesid, tableid, urlColumnId, &urlBuffer,
sizeof(urlBuffer), NULL, 0, NULL);
NS_HANDLE_JET_ERROR(err)
err = JetRetrieveColumn(sesid, tableid, titleColumnId, &titleBuffer,
sizeof(titleBuffer), NULL, 0, NULL);
NS_HANDLE_JET_ERROR(err)
err = JetRetrieveColumn(sesid, tableid, addedDateColumnId, &addedDate,
sizeof(addedDate), NULL, 0, NULL);
NS_HANDLE_JET_ERROR(err)
nsCOMPtr<nsIWritablePropertyBag2> pbag = do_CreateInstance("@mozilla.org/hash-property-bag;1");
bool dateIsValid;
PRTime prAddedDate = WinMigrationFileTimeToPRTime(&addedDate, &dateIsValid);
nsDependentString url(urlBuffer);
nsDependentString title(titleBuffer);
pbag->SetPropertyAsAString(NS_LITERAL_STRING("uri"), url);
pbag->SetPropertyAsAString(NS_LITERAL_STRING("title"), title);
if (dateIsValid) {
pbag->SetPropertyAsInt64(NS_LITERAL_STRING("time"), prAddedDate);
}
items->AppendElement(pbag, false);
memset(urlBuffer, 0, sizeof(urlBuffer));
memset(titleBuffer, 0, sizeof(titleBuffer));
} while (JET_errSuccess == JetMove(sesid, tableid, JET_MoveNext, 0));
items.forget(aItems);
CloseDB:
// Terminate ESENT. This performs a clean shutdown.
// Ignore errors while closing:
if (tableOpened)
JetCloseTable(sesid, tableid);
if (dbOpened)
JetCloseDatabase(sesid, dbid, 0);
if (sessionCreated)
JetEndSession(sesid, 0);
if (instanceCreated)
JetTerm(instance);
return rv;
}
nsresult
nsEdgeReadingListExtractor::ConvertJETError(const JET_ERR &aError)
{
switch (aError) {
case JET_errPageSizeMismatch:
case JET_errInvalidName:
case JET_errColumnNotFound:
// The DB format has changed and we haven't updated this migration code:
return NS_ERROR_NOT_IMPLEMENTED;
case JET_errDatabaseLocked:
return NS_ERROR_FILE_IS_LOCKED;
case JET_errPermissionDenied:
case JET_errAccessDenied:
return NS_ERROR_FILE_ACCESS_DENIED;
case JET_errInvalidFilename:
return NS_ERROR_FILE_INVALID_PATH;
case JET_errFileNotFound:
return NS_ERROR_FILE_NOT_FOUND;
default:
return NS_ERROR_FAILURE;
}
}

View File

@ -1,31 +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/. */
#ifndef edgereadinglistextractor__h__
#define edgereadinglistextractor__h__
#include "nsIArray.h"
#include "nsIEdgeReadingListExtractor.h"
// To get access to the long data types, we need to use at least the Vista version of the JET APIs
#undef JET_VERSION
#define JET_VERSION 0x0600
#include <esent.h>
class nsEdgeReadingListExtractor final : public nsIEdgeReadingListExtractor
{
public:
nsEdgeReadingListExtractor() {}
NS_DECL_ISUPPORTS
NS_DECL_NSIEDGEREADINGLISTEXTRACTOR
private:
~nsEdgeReadingListExtractor() {}
nsresult ConvertJETError(const JET_ERR &err);
};
#endif

View File

@ -7,13 +7,37 @@
#include <urlhist.h>
#include <shlguid.h>
#include "nsArrayEnumerator.h"
#include "nsCOMArray.h"
#include "nsIVariant.h"
#include "nsNetUtil.h"
#include "nsStringAPI.h"
#include "nsWindowsMigrationUtils.h"
#include "nsNetUtil.h"
#include "prtime.h"
#include "nsIVariant.h"
#include "nsCOMArray.h"
#include "nsArrayEnumerator.h"
namespace {
PRTime FileTimeToPRTime(FILETIME* filetime)
{
SYSTEMTIME st;
::FileTimeToSystemTime(filetime, &st);
PRExplodedTime prt;
prt.tm_year = st.wYear;
// SYSTEMTIME's day-of-month parameter is 1-based,
// PRExplodedTime's is 0-based.
prt.tm_month = st.wMonth - 1;
prt.tm_mday = st.wDay;
prt.tm_hour = st.wHour;
prt.tm_min = st.wMinute;
prt.tm_sec = st.wSecond;
prt.tm_usec = st.wMilliseconds * 1000;
prt.tm_wday = 0;
prt.tm_yday = 0;
prt.tm_params.tp_gmt_offset = 0;
prt.tm_params.tp_dst_offset = 0;
return PR_ImplodeTime(&prt);
}
} // namespace
////////////////////////////////////////////////////////////////////////////////
//// nsIEHistoryEnumerator
@ -82,17 +106,14 @@ nsIEHistoryEnumerator::HasMoreElements(bool* _retval)
nsDependentString title(statURL.pwcsTitle);
bool lastVisitTimeIsValid;
PRTime lastVisited = WinMigrationFileTimeToPRTime(&(statURL.ftLastVisited), &lastVisitTimeIsValid);
PRTime lastVisited = FileTimeToPRTime(&(statURL.ftLastVisited));
mCachedNextEntry = do_CreateInstance("@mozilla.org/hash-property-bag;1");
MOZ_ASSERT(mCachedNextEntry, "Should have instanced a new property bag");
if (mCachedNextEntry) {
mCachedNextEntry->SetPropertyAsInterface(NS_LITERAL_STRING("uri"), uri);
mCachedNextEntry->SetPropertyAsAString(NS_LITERAL_STRING("title"), title);
if (lastVisitTimeIsValid) {
mCachedNextEntry->SetPropertyAsInt64(NS_LITERAL_STRING("time"), lastVisited);
}
mCachedNextEntry->SetPropertyAsInt64(NS_LITERAL_STRING("time"), lastVisited);
*_retval = true;
}

View File

@ -1,23 +0,0 @@
/* -*- Mode: C++; 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 "nsISupports.idl"
interface nsIArray;
[scriptable, uuid(bfdef4aa-dcd1-4d31-b5d9-188fe8d98623)]
interface nsIEdgeReadingListExtractor : nsISupports
{
/**
* Import data from the database indicated by the databasePath
* May fail if the path is invalid, unreadable, the database is corrupt,
* or the data in the database is not in the format we expect.
*
* @param databasePath the absolute path to the database we'd like to import
* @return an enumerator of nsIPropertyBag2 items that each have a URL, title, and
* creation dates.
*/
nsIArray extract(in DOMString databasePath);
};

View File

@ -1,36 +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/. */
#ifndef windowsmigrationutils__h__
#define windowsmigrationutils__h__
#include "prtime.h"
static
PRTime WinMigrationFileTimeToPRTime(FILETIME* filetime, bool* isValid)
{
SYSTEMTIME st;
*isValid = ::FileTimeToSystemTime(filetime, &st);
if (!*isValid) {
return 0;
}
PRExplodedTime prt;
prt.tm_year = st.wYear;
// SYSTEMTIME's day-of-month parameter is 1-based,
// PRExplodedTime's is 0-based.
prt.tm_month = st.wMonth - 1;
prt.tm_mday = st.wDay;
prt.tm_hour = st.wHour;
prt.tm_min = st.wMinute;
prt.tm_sec = st.wSecond;
prt.tm_usec = st.wMilliseconds * 1000;
prt.tm_wday = 0;
prt.tm_yday = 0;
prt.tm_params.tp_gmt_offset = 0;
prt.tm_params.tp_dst_offset = 0;
return PR_ImplodeTime(&prt);
}
#endif

View File

@ -17,7 +17,6 @@ sourceName360se=360 Secure Browser
importedBookmarksFolder=From %S
importedSafariReadingList=Reading List (From Safari)
importedEdgeReadingList=Reading List (From Edge)
# Import Sources
# Note: When adding an import source for profile reset, add the string name to