Merge m-c to m-i

This commit is contained in:
Justin Wood 2011-11-19 04:33:12 -05:00
commit c3b4abe7a9
11 changed files with 370 additions and 7 deletions

View File

@ -140,6 +140,7 @@ MOZ_UPDATE_PACKAGING = @MOZ_UPDATE_PACKAGING@
MOZ_DISABLE_PARENTAL_CONTROLS = @MOZ_DISABLE_PARENTAL_CONTROLS@
NS_ENABLE_TSF = @NS_ENABLE_TSF@
MOZ_SPELLCHECK = @MOZ_SPELLCHECK@
MOZ_ANDROID_HISTORY = @MOZ_ANDROID_HISTORY@
MOZ_JAVA_COMPOSITOR = @MOZ_JAVA_COMPOSITOR@
MOZ_PROFILELOCKING = @MOZ_PROFILELOCKING@
MOZ_FEEDS = @MOZ_FEEDS@

View File

@ -4681,7 +4681,7 @@ NECKO_PROTOCOLS_DEFAULT="about data file ftp http res viewsource websocket wyciw
USE_ARM_KUSER=
BUILD_CTYPES=1
MOZ_USE_NATIVE_POPUP_WINDOWS=
MOZ_ANDROID_HISTORY=
case "${target}" in
*android*|*darwin*)
@ -8464,6 +8464,7 @@ AC_SUBST(MOZ_D3DCOMPILER_CAB)
AC_SUBST(MOZ_D3DX9_DLL)
AC_SUBST(MOZ_D3DCOMPILER_DLL)
AC_SUBST(MOZ_ANDROID_HISTORY)
AC_SUBST(ENABLE_STRIP)
AC_SUBST(PKG_SKIP_STRIP)
AC_SUBST(USE_ELF_DYNSTR_GC)

View File

@ -54,7 +54,9 @@ DIRS += test
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),android)
ifeq ($(MOZ_BUILD_APP),mobile/xul)
DIRS += android
endif
endif
include $(topsrcdir)/config/rules.mk

View File

@ -297,6 +297,12 @@ Database::~Database()
nsresult
Database::Init()
{
#ifdef MOZ_ANDROID_HISTORY
// Currently places has deeply weaved it way throughout the gecko codebase.
// Here we disable all database creation and loading of places.
return NS_ERROR_NOT_IMPLEMENTED;
#endif
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<mozIStorageService> storage =

View File

@ -101,6 +101,14 @@ CPPSRCS = \
LOCAL_INCLUDES += -I$(srcdir)/../build
ifdef MOZ_ANDROID_HISTORY
CPPSRCS += nsAndroidHistory.cpp
LOCAL_INCLUDES += \
-I$(topsrcdir)/docshell/base \
-I$(topsrcdir)/content/base/src \
$(NULL)
endif
EXTRA_COMPONENTS = \
toolkitplaces.manifest \
nsLivemarkService.js \

View File

@ -0,0 +1,168 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Android code.
*
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Kartikaya Gupta <kgupta@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsAndroidHistory.h"
#include "AndroidBridge.h"
#include "Link.h"
using namespace mozilla;
using mozilla::dom::Link;
NS_IMPL_ISUPPORTS1(nsAndroidHistory, IHistory)
nsAndroidHistory* nsAndroidHistory::sHistory = NULL;
/*static*/
nsAndroidHistory*
nsAndroidHistory::GetSingleton()
{
if (!sHistory) {
sHistory = new nsAndroidHistory();
NS_ENSURE_TRUE(sHistory, nsnull);
}
NS_ADDREF(sHistory);
return sHistory;
}
nsAndroidHistory::nsAndroidHistory()
{
mListeners.Init();
}
NS_IMETHODIMP
nsAndroidHistory::RegisterVisitedCallback(nsIURI *aURI, Link *aContent)
{
if (!aContent || !aURI)
return NS_OK;
nsCAutoString uri;
nsresult rv = aURI->GetSpec(uri);
if (NS_FAILED(rv)) return rv;
nsString uriString = NS_ConvertUTF8toUTF16(uri);
nsTArray<Link*>* list = mListeners.Get(uriString);
if (! list) {
list = new nsTArray<Link*>();
mListeners.Put(uriString, list);
}
list->AppendElement(aContent);
AndroidBridge *bridge = AndroidBridge::Bridge();
if (bridge) {
bridge->CheckURIVisited(uriString);
}
return NS_OK;
}
NS_IMETHODIMP
nsAndroidHistory::UnregisterVisitedCallback(nsIURI *aURI, Link *aContent)
{
if (!aContent || !aURI)
return NS_OK;
nsCAutoString uri;
nsresult rv = aURI->GetSpec(uri);
if (NS_FAILED(rv)) return rv;
nsString uriString = NS_ConvertUTF8toUTF16(uri);
nsTArray<Link*>* list = mListeners.Get(uriString);
if (! list)
return NS_OK;
list->RemoveElement(aContent);
if (list->IsEmpty()) {
mListeners.Remove(uriString);
delete list;
}
return NS_OK;
}
NS_IMETHODIMP
nsAndroidHistory::VisitURI(nsIURI *aURI, nsIURI *aLastVisitedURI, PRUint32 aFlags)
{
if (!aURI)
return NS_OK;
if (!(aFlags & VisitFlags::TOP_LEVEL))
return NS_OK;
AndroidBridge *bridge = AndroidBridge::Bridge();
if (bridge) {
nsCAutoString uri;
nsresult rv = aURI->GetSpec(uri);
if (NS_FAILED(rv)) return rv;
nsString uriString = NS_ConvertUTF8toUTF16(uri);
bridge->MarkURIVisited(uriString);
}
return NS_OK;
}
NS_IMETHODIMP
nsAndroidHistory::SetURITitle(nsIURI *aURI, const nsAString& aTitle)
{
// we don't do anything with this right now
return NS_OK;
}
void /*static*/
nsAndroidHistory::NotifyURIVisited(const nsString& aUriString)
{
if (! sHistory)
return;
sHistory->mPendingURIs.Push(aUriString);
NS_DispatchToMainThread(sHistory);
}
NS_IMETHODIMP
nsAndroidHistory::Run()
{
while (! mPendingURIs.IsEmpty()) {
nsString uriString = mPendingURIs.Pop();
nsTArray<Link*>* list = sHistory->mListeners.Get(uriString);
if (list) {
for (unsigned int i = 0; i < list->Length(); i++) {
list->ElementAt(i)->SetLinkState(eLinkState_Visited);
}
// as per the IHistory interface contract, remove the
// Link pointers once they have been notified
mListeners.Remove(uriString);
delete list;
}
}
return NS_OK;
}

View File

@ -0,0 +1,72 @@
/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Android code.
*
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Kartikaya Gupta <kgupta@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef NS_ANDROIDHISTORY_H
#define NS_ANDROIDHISTORY_H
#include "IHistory.h"
#include "nsDataHashtable.h"
#include "nsTPriorityQueue.h"
#include "nsThreadUtils.h"
#define NS_ANDROIDHISTORY_CID \
{0xCCAA4880, 0x44DD, 0x40A7, {0xA1, 0x3F, 0x61, 0x56, 0xFC, 0x88, 0x2C, 0x0B}}
class nsAndroidHistory : public mozilla::IHistory, public nsIRunnable
{
public:
NS_DECL_ISUPPORTS
NS_DECL_IHISTORY
NS_DECL_NSIRUNNABLE
/**
* Obtains a pointer that has had AddRef called on it. Used by the service
* manager only.
*/
static nsAndroidHistory* GetSingleton();
nsAndroidHistory();
static void NotifyURIVisited(const nsString& str);
private:
static nsAndroidHistory* sHistory;
nsDataHashtable<nsStringHashKey, nsTArray<mozilla::dom::Link *> *> mListeners;
nsTPriorityQueue<nsString> mPendingURIs;
};
#endif

View File

@ -10,6 +10,10 @@
#include "History.h"
#include "nsDocShellCID.h"
#ifdef MOZ_ANDROID_HISTORY
#include "nsAndroidHistory.h"
#endif
using namespace mozilla::places;
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsNavHistory,
@ -20,9 +24,13 @@ NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsNavBookmarks,
nsNavBookmarks::GetSingleton)
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsFaviconService,
nsFaviconService::GetSingleton)
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(History, History::GetSingleton)
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsPlacesImportExportService,
nsPlacesImportExportService::GetSingleton)
#ifdef MOZ_ANDROID_HISTORY
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsAndroidHistory, nsAndroidHistory::GetSingleton)
#else
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(History, History::GetSingleton)
#endif
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAnnoProtocolHandler)
NS_DEFINE_NAMED_CID(NS_NAVHISTORYSERVICE_CID);
@ -30,16 +38,25 @@ NS_DEFINE_NAMED_CID(NS_ANNOTATIONSERVICE_CID);
NS_DEFINE_NAMED_CID(NS_ANNOPROTOCOLHANDLER_CID);
NS_DEFINE_NAMED_CID(NS_NAVBOOKMARKSSERVICE_CID);
NS_DEFINE_NAMED_CID(NS_FAVICONSERVICE_CID);
NS_DEFINE_NAMED_CID(NS_HISTORYSERVICE_CID);
NS_DEFINE_NAMED_CID(NS_PLACESIMPORTEXPORTSERVICE_CID);
#ifdef MOZ_ANDROID_HISTORY
NS_DEFINE_NAMED_CID(NS_ANDROIDHISTORY_CID);
#else
NS_DEFINE_NAMED_CID(NS_HISTORYSERVICE_CID);
#endif
const mozilla::Module::CIDEntry kPlacesCIDs[] = {
{ &kNS_NAVHISTORYSERVICE_CID, false, NULL, nsNavHistoryConstructor },
{ &kNS_ANNOTATIONSERVICE_CID, false, NULL, nsAnnotationServiceConstructor },
{ &kNS_ANNOPROTOCOLHANDLER_CID, false, NULL, nsAnnoProtocolHandlerConstructor },
{ &kNS_NAVBOOKMARKSSERVICE_CID, false, NULL, nsNavBookmarksConstructor },
{ &kNS_FAVICONSERVICE_CID, false, NULL, nsFaviconServiceConstructor },
#ifdef MOZ_ANDROID_HISTORY
{ &kNS_ANDROIDHISTORY_CID, false, NULL, nsAndroidHistoryConstructor },
#else
{ &kNS_HISTORYSERVICE_CID, false, NULL, HistoryConstructor },
#endif
{ &kNS_PLACESIMPORTEXPORTSERVICE_CID, false, NULL, nsPlacesImportExportServiceConstructor },
{ NULL }
};
@ -53,7 +70,11 @@ const mozilla::Module::ContractIDEntry kPlacesContracts[] = {
{ NS_NAVBOOKMARKSSERVICE_CONTRACTID, &kNS_NAVBOOKMARKSSERVICE_CID },
{ NS_FAVICONSERVICE_CONTRACTID, &kNS_FAVICONSERVICE_CID },
{ "@mozilla.org/embeddor.implemented/bookmark-charset-resolver;1", &kNS_NAVHISTORYSERVICE_CID },
#ifdef MOZ_ANDROID_HISTORY
{ NS_IHISTORY_CONTRACTID, &kNS_ANDROIDHISTORY_CID },
#else
{ NS_IHISTORY_CONTRACTID, &kNS_HISTORYSERVICE_CID },
#endif
{ NS_PLACESIMPORTEXPORTSERVICE_CONTRACTID, &kNS_PLACESIMPORTEXPORTSERVICE_CID },
{ NULL }
};

View File

@ -319,10 +319,16 @@ ABI_DIR = armeabi
endif
endif
ifeq ($(MOZ_BUILD_APP),mobile/xul)
GECKO_APP_AP_PATH = ../embedding/android
else
GECKO_APP_AP_PATH = ../mobile/android/base
endif
PKG_SUFFIX = .apk
INNER_MAKE_PACKAGE = \
make -C ../embedding/android gecko.ap_ && \
cp ../embedding/android/gecko.ap_ $(_ABS_DIST) && \
make -C $(GECKO_APP_AP_PATH) gecko.ap_ && \
cp $(GECKO_APP_AP_PATH)/gecko.ap_ $(_ABS_DIST) && \
( cd $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH) && \
mkdir -p lib/$(ABI_DIR) && \
mv libmozutils.so $(MOZ_CHILD_PROCESS_NAME) lib/$(ABI_DIR) && \
@ -661,7 +667,7 @@ ifdef USE_ELF_HACK
@echo === and your environment \(compiler and linker versions\), and use
@echo === --disable-elf-hack until this is fixed.
@echo ===
cd $(DIST)/bin; find . -name "*$(DLL_SUFFIX)" | xargs $(DEPTH)/build/unix/elfhack/elfhack
cd $(DIST)/bin; find . -name "*$(DLL_SUFFIX)" | xargs ../../build/unix/elfhack/elfhack
endif
stage-package: $(MOZ_PKG_MANIFEST) $(MOZ_PKG_REMOVALS_GEN) elfhack

View File

@ -39,6 +39,9 @@
#include <winternl.h>
#include <stdio.h>
#include <string.h>
#include <map>
#ifdef XRE_WANT_DLL_BLOCKLIST
#define XRE_SetupDllBlocklist SetupDllBlocklist
@ -130,6 +133,10 @@ static DllBlockInfo sWindowsDllBlocklist[] = {
// Topcrash in Firefox 4 betas (bug 618899)
{"accelerator.dll", MAKE_VERSION(3,2,1,6)},
// Topcrash with Roboform in Firefox 8 (bug 699134)
{"rf-firefox.dll", MAKE_VERSION(7,6,1,0)},
{"roboform.dll", MAKE_VERSION(7,6,1,0)},
// leave these two in always for tests
{ "mozdllblockingtest.dll", ALL_VERSIONS },
{ "mozdllblockingtest_versioned.dll", 0x0000000400000000ULL },
@ -144,10 +151,68 @@ static DllBlockInfo sWindowsDllBlocklist[] = {
// define this for very verbose dll load debug spew
#undef DEBUG_very_verbose
namespace {
typedef NTSTATUS (NTAPI *LdrLoadDll_func) (PWCHAR filePath, PULONG flags, PUNICODE_STRING moduleFileName, PHANDLE handle);
static LdrLoadDll_func stub_LdrLoadDll = 0;
/**
* Some versions of Windows call LoadLibraryEx to get the version information
* for a DLL, which causes our patched LdrLoadDll implementation to re-enter
* itself and cause infinite recursion and a stack-exhaustion crash. We protect
* against reentrancy by allowing recursive loads of the same DLL.
*
* Note that we don't use __declspec(thread) because that doesn't work in DLLs
* loaded via LoadLibrary and there can be a limited number of TLS slots, so
* we roll our own.
*/
class ReentrancySentinel
{
public:
explicit ReentrancySentinel(const char* dllName)
{
DWORD currentThreadId = GetCurrentThreadId();
EnterCriticalSection(&sLock);
mPreviousDllName = (*sThreadMap)[currentThreadId];
// If there is a DLL currently being loaded and it has the same name
// as the current attempt, we're re-entering.
mReentered = mPreviousDllName && !stricmp(mPreviousDllName, dllName);
(*sThreadMap)[currentThreadId] = dllName;
LeaveCriticalSection(&sLock);
}
~ReentrancySentinel()
{
DWORD currentThreadId = GetCurrentThreadId();
EnterCriticalSection(&sLock);
(*sThreadMap)[currentThreadId] = mPreviousDllName;
LeaveCriticalSection(&sLock);
}
bool BailOut() const
{
return mReentered;
};
static void InitializeStatics()
{
InitializeCriticalSection(&sLock);
sThreadMap = new std::map<DWORD, const char*>;
}
private:
static CRITICAL_SECTION sLock;
static std::map<DWORD, const char*>* sThreadMap;
const char* mPreviousDllName;
bool mReentered;
};
CRITICAL_SECTION ReentrancySentinel::sLock;
std::map<DWORD, const char*>* ReentrancySentinel::sThreadMap;
static NTSTATUS NTAPI
patched_LdrLoadDll (PWCHAR filePath, PULONG flags, PUNICODE_STRING moduleFileName, PHANDLE handle)
{
@ -235,6 +300,11 @@ patched_LdrLoadDll (PWCHAR filePath, PULONG flags, PUNICODE_STRING moduleFileNam
#endif
if (info->maxVersion != ALL_VERSIONS) {
ReentrancySentinel sentinel(dllName);
if (sentinel.BailOut()) {
goto continue_loading;
}
// In Windows 8, the first parameter seems to be used for more than just the
// path name. For example, its numerical value can be 1. Passing a non-valid
// pointer to SearchPathW will cause a crash, so we need to check to see if we
@ -303,11 +373,15 @@ continue_loading:
WindowsDllInterceptor NtDllIntercept;
} // anonymous namespace
void
XRE_SetupDllBlocklist()
{
NtDllIntercept.Init("ntdll.dll");
ReentrancySentinel::InitializeStatics();
bool ok = NtDllIntercept.AddHook("LdrLoadDll", reinterpret_cast<intptr_t>(patched_LdrLoadDll), (void**) &stub_LdrLoadDll);
#ifdef DEBUG

View File

@ -244,6 +244,9 @@ nsAppShell::ProcessNextNativeEvent(bool mayWait)
int curType = curEvent->Type();
int nextType = nextEvent->Type();
// Do not skip draw events if the Java compositor is in use, since the Java compositor
// updates only the rect that changed - thus we will lose updates.
#ifndef MOZ_JAVA_COMPOSITOR
while (nextType == AndroidGeckoEvent::DRAW &&
mNumDraws > 1)
{
@ -263,6 +266,7 @@ nsAppShell::ProcessNextNativeEvent(bool mayWait)
nextEvent = PeekNextEvent();
nextType = nextEvent->Type();
}
#endif
// If the next type of event isn't the same as the current type,
// we don't coalesce.