Skip to content

Commit

Permalink
Bug 1093934 - Create a XPCOM library that can be used to support stan…
Browse files Browse the repository at this point in the history
…dalone WebRTC. r=nfroyd

--HG--
extra : rebase_source : 93f11457b16b344e148a6fcb924b286ef8a48051
  • Loading branch information
Randall Barker committed Apr 3, 2015
1 parent 662dbd9 commit c236b48
Show file tree
Hide file tree
Showing 31 changed files with 639 additions and 31 deletions.
4 changes: 2 additions & 2 deletions mfbt/Assertions.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ MOZ_ReportAssertionFailure(const char* aStr, const char* aFilename, int aLine)
aStr, aFilename, aLine);
#else
fprintf(stderr, "Assertion failure: %s, at %s:%d\n", aStr, aFilename, aLine);
#ifdef MOZ_DUMP_ASSERTION_STACK
#if defined (MOZ_DUMP_ASSERTION_STACK) && !defined(MOZILLA_XPCOMRT_API)
nsTraceRefcnt::WalkTheStack(stderr);
#endif
fflush(stderr);
Expand All @@ -157,7 +157,7 @@ MOZ_ReportCrash(const char* aStr, const char* aFilename, int aLine)
"Hit MOZ_CRASH(%s) at %s:%d\n", aStr, aFilename, aLine);
#else
fprintf(stderr, "Hit MOZ_CRASH(%s) at %s:%d\n", aStr, aFilename, aLine);
#ifdef MOZ_DUMP_ASSERTION_STACK
#if defined(MOZ_DUMP_ASSERTION_STACK) && !defined(MOZILLA_XPCOMRT_API)
nsTraceRefcnt::WalkTheStack(stderr);
#endif
fflush(stderr);
Expand Down
1 change: 1 addition & 0 deletions mfbt/RefPtr.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#endif

#if defined(MOZILLA_INTERNAL_API) && \
!defined(MOZILLA_XPCOMRT_API) && \
(defined(DEBUG) || defined(FORCE_BUILD_REFCNT_LOGGING))
#define MOZ_REFCOUNTED_LEAK_CHECKING
#endif
Expand Down
2 changes: 1 addition & 1 deletion mfbt/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
* symbols. We add the weak attribute to the import version of the MFBT API
* macros to exploit this.
*/
# if defined(MOZ_GLUE_IN_PROGRAM)
# if defined(MOZ_GLUE_IN_PROGRAM) && !defined(MOZILLA_XPCOMRT_API)
# define MFBT_API __attribute__((weak)) MOZ_IMPORT_API
# define MFBT_DATA __attribute__((weak)) MOZ_IMPORT_DATA
# else
Expand Down
2 changes: 1 addition & 1 deletion toolkit/components/telemetry/Telemetry.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class ProcessedStack;
* @param aFirefoxUptime - Firefox uptime at the time of the hang, in minutes
* @param aAnnotations - Any annotations to be added to the report
*/
#if defined(MOZ_ENABLE_PROFILER_SPS)
#if defined(MOZ_ENABLE_PROFILER_SPS) && !defined(MOZILLA_XPCOMRT_API)
void RecordChromeHang(uint32_t aDuration,
ProcessedStack &aStack,
int32_t aSystemUptime,
Expand Down
4 changes: 3 additions & 1 deletion tools/profiler/GeckoProfiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
#include "js/TypeDecls.h"
#include "mozilla/GuardObjects.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/GuardObjects.h"
#include "ProfilerBacktrace.h"

namespace mozilla {
class TimeStamp;
Expand All @@ -65,7 +67,7 @@ enum TracingMetadata {
TRACING_EVENT_BACKTRACE
};

#ifndef MOZ_ENABLE_PROFILER_SPS
#if !defined(MOZ_ENABLE_PROFILER_SPS) || defined(MOZILLA_XPCOMRT_API)

#include <stdint.h>
#include <stdarg.h>
Expand Down
12 changes: 9 additions & 3 deletions xpcom/base/nsDebugImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,9 @@ NS_DebugBreak(uint32_t aSeverity, const char* aStr, const char* aExpr,
if (sMultiprocessDescription) {
PrintToBuffer("%s ", sMultiprocessDescription);
}
#if !defined(MOZILLA_XPCOMRT_API)
PrintToBuffer("%d] ", base::GetCurrentProcId());
#endif // !defined(MOZILLA_XPCOMRT_API)

PrintToBuffer("%s: ", sevString);

Expand Down Expand Up @@ -403,7 +405,7 @@ NS_DebugBreak(uint32_t aSeverity, const char* aStr, const char* aExpr,
return;

case NS_DEBUG_ABORT: {
#if defined(MOZ_CRASHREPORTER)
#if defined(MOZ_CRASHREPORTER) && !defined(MOZILLA_XPCOMRT_API)
// Updating crash annotations in the child causes us to do IPC. This can
// really cause trouble if we're asserting from within IPC code. So we
// have to do without the annotations in that case.
Expand All @@ -420,7 +422,7 @@ NS_DebugBreak(uint32_t aSeverity, const char* aStr, const char* aExpr,
#if defined(DEBUG) && defined(_WIN32)
RealBreak();
#endif
#ifdef DEBUG
#if defined(DEBUG) && !defined(MOZILLA_XPCOMRT_API)
nsTraceRefcnt::WalkTheStack(stderr);
#endif
Abort(buf.buffer);
Expand All @@ -445,11 +447,15 @@ NS_DebugBreak(uint32_t aSeverity, const char* aStr, const char* aExpr,
return;

case NS_ASSERT_STACK:
#if !defined(MOZILLA_XPCOMRT_API)
nsTraceRefcnt::WalkTheStack(stderr);
#endif // !defined(MOZILLA_XPCOMRT_API)
return;

case NS_ASSERT_STACK_AND_ABORT:
#if !defined(MOZILLA_XPCOMRT_API)
nsTraceRefcnt::WalkTheStack(stderr);
#endif // !defined(MOZILLA_XPCOMRT_API)
// Fall through to abort

case NS_ASSERT_ABORT:
Expand Down Expand Up @@ -616,7 +622,7 @@ NS_ErrorAccordingToNSPR()
void
NS_ABORT_OOM(size_t aSize)
{
#ifdef MOZ_CRASHREPORTER
#if defined(MOZ_CRASHREPORTER) && !defined(MOZILLA_XPCOMRT_API)
CrashReporter::AnnotateOOMAllocationSize(aSize);
#endif
MOZ_CRASH();
Expand Down
2 changes: 1 addition & 1 deletion xpcom/base/nsIMemoryReporter.idl
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ nsresult RegisterNonJSSizeOfTab(NonJSSizeOfTabFn aSizeOfTabFn);

}

#if defined(MOZ_DMD)
#if defined(MOZ_DMD) && !defined(MOZILLA_XPCOMRT_API)
namespace mozilla {
namespace dmd {
// This runs all the memory reporters in the current process but does nothing
Expand Down
32 changes: 29 additions & 3 deletions xpcom/build/FileLocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "FileLocation.h"
#if !defined(MOZILLA_XPCOMRT_API)
#include "nsZipArchive.h"
#include "nsURLHelper.h"
#endif // !defined(MOZILLA_XPCOMRT_API)

namespace mozilla {

Expand All @@ -31,9 +33,12 @@ FileLocation::FileLocation(const FileLocation& aFile, const char* aPath)
if (aFile.IsZip()) {
if (aFile.mBaseFile) {
Init(aFile.mBaseFile, aFile.mPath.get());
} else {
}
#if !defined(MOZILLA_XPCOMRT_API)
else {
Init(aFile.mBaseZip, aFile.mPath.get());
}
#endif
if (aPath) {
int32_t i = mPath.RFindChar('/');
if (kNotFound == i) {
Expand Down Expand Up @@ -71,30 +76,37 @@ FileLocation::FileLocation(const FileLocation& aFile, const char* aPath)
void
FileLocation::Init(nsIFile* aFile)
{
#if !defined(MOZILLA_XPCOMRT_API)
mBaseZip = nullptr;
#endif //!defined(MOZILLA_XPCOMRT_API)
mBaseFile = aFile;
mPath.Truncate();
}

void
FileLocation::Init(nsIFile* aFile, const char* aPath)
{
#if !defined(MOZILLA_XPCOMRT_API)
mBaseZip = nullptr;
#endif // !defined(MOZILLA_XPCOMRT_API)
mBaseFile = aFile;
mPath = aPath;
}

void
FileLocation::Init(nsZipArchive* aZip, const char* aPath)
{
#if !defined(MOZILLA_XPCOMRT_API)
mBaseZip = aZip;
#endif // !defined(MOZILLA_XPCOMRT_API)
mBaseFile = nullptr;
mPath = aPath;
}

void
FileLocation::GetURIString(nsACString& aResult) const
{
#if !defined(MOZILLA_XPCOMRT_API)
if (mBaseFile) {
net_GetURLSpecFromActualFile(mBaseFile, aResult);
} else if (mBaseZip) {
Expand All @@ -106,18 +118,21 @@ FileLocation::GetURIString(nsACString& aResult) const
aResult += "!/";
aResult += mPath;
}
#endif // !defined(MOZILLA_XPCOMRT_API)
}

already_AddRefed<nsIFile>
FileLocation::GetBaseFile()
{
#if !defined(MOZILLA_XPCOMRT_API)
if (IsZip() && mBaseZip) {
nsRefPtr<nsZipHandle> handler = mBaseZip->GetFD();
if (handler) {
return handler->mFile.GetBaseFile();
}
return nullptr;
}
#endif // !defined(MOZILLA_XPCOMRT_API)

nsCOMPtr<nsIFile> file = mBaseFile;
return file.forget();
Expand All @@ -137,6 +152,7 @@ FileLocation::Equals(const FileLocation& aFile) const

const FileLocation* a = this;
const FileLocation* b = &aFile;
#if !defined(MOZILLA_XPCOMRT_API)
if (a->mBaseZip) {
nsRefPtr<nsZipHandle> handler = a->mBaseZip->GetFD();
a = &handler->mFile;
Expand All @@ -145,12 +161,15 @@ FileLocation::Equals(const FileLocation& aFile) const
nsRefPtr<nsZipHandle> handler = b->mBaseZip->GetFD();
b = &handler->mFile;
}
#endif // !defined(MOZILLA_XPCOMRT_API)

return a->Equals(*b);
}

nsresult
FileLocation::GetData(Data& aData)
{
#if !defined(MOZILLA_XPCOMRT_API)
if (!IsZip()) {
return mBaseFile->OpenNSPRFileDesc(PR_RDONLY, 0444, &aData.mFd.rwget());
}
Expand All @@ -163,6 +182,7 @@ FileLocation::GetData(Data& aData)
if (aData.mItem) {
return NS_OK;
}
#endif // !defined(MOZILLA_XPCOMRT_API)
return NS_ERROR_FILE_UNRECOGNIZED_PATH;
}

Expand All @@ -181,10 +201,13 @@ FileLocation::Data::GetSize(uint32_t* aResult)

*aResult = fileInfo.size;
return NS_OK;
} else if (mItem) {
}
#if !defined(MOZILLA_XPCOMRT_API)
else if (mItem) {
*aResult = mItem->RealSize();
return NS_OK;
}
#endif // !defined(MOZILLA_XPCOMRT_API)
return NS_ERROR_NOT_INITIALIZED;
}

Expand All @@ -201,13 +224,16 @@ FileLocation::Data::Copy(char* aBuf, uint32_t aLen)
totalRead += read;
}
return NS_OK;
} else if (mItem) {
}
#if !defined(MOZILLA_XPCOMRT_API)
else if (mItem) {
nsZipCursor cursor(mItem, mZip, reinterpret_cast<uint8_t*>(aBuf),
aLen, true);
uint32_t readLen;
cursor.Copy(&readLen);
return (readLen == aLen) ? NS_OK : NS_ERROR_FILE_CORRUPTED;
}
#endif // !defined(MOZILLA_XPCOMRT_API)
return NS_ERROR_NOT_INITIALIZED;
}

Expand Down
8 changes: 8 additions & 0 deletions xpcom/build/FileLocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ class FileLocation
* Boolean value corresponding to whether the file location is initialized
* or not.
*/
#if defined(MOZILLA_XPCOMRT_API)
operator bool() const { return mBaseFile; }
#else
operator bool() const { return mBaseFile || mBaseZip; }
#endif // defined(MOZILLA_XPCOMRT_API)

/**
* Returns whether another FileLocation points to the same resource
Expand All @@ -111,7 +115,9 @@ class FileLocation
nsresult Copy(char* aBuf, uint32_t aLen);
protected:
friend class FileLocation;
#if !defined(MOZILLA_XPCOMRT_API)
nsZipItem* mItem;
#endif // !defined(MOZILLA_XPCOMRT_API)
nsRefPtr<nsZipArchive> mZip;
mozilla::AutoFDClose mFd;
};
Expand All @@ -123,7 +129,9 @@ class FileLocation
nsresult GetData(Data& aData);
private:
nsCOMPtr<nsIFile> mBaseFile;
#if !defined(MOZILLA_XPCOMRT_API)
nsRefPtr<nsZipArchive> mBaseZip;
#endif // !defined(MOZILLA_XPCOMRT_API)
nsCString mPath;
}; /* class FileLocation */

Expand Down
4 changes: 4 additions & 0 deletions xpcom/build/ServiceList.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// IWYU pragma: private, include "mozilla/Services.h"

#if !defined(MOZILLA_XPCOMRT_API)
#ifdef ACCESSIBILITY
MOZ_SERVICE(AccessibilityService, nsIAccessibilityService,
"@mozilla.org/accessibilityService;1")
Expand All @@ -17,8 +18,10 @@ MOZ_SERVICE(XULOverlayProviderService, nsIXULOverlayProvider,
"@mozilla.org/chrome/chrome-registry;1")
MOZ_SERVICE(IOService, nsIIOService,
"@mozilla.org/network/io-service;1")
#endif // !defined(MOZILLA_XPCOMRT_API)
MOZ_SERVICE(ObserverService, nsIObserverService,
"@mozilla.org/observer-service;1")
#if !defined(MOZILLA_XPCOMRT_API)
MOZ_SERVICE(StringBundleService, nsIStringBundleService,
"@mozilla.org/intl/stringbundle;1")
MOZ_SERVICE(XPConnect, nsIXPConnect,
Expand All @@ -44,3 +47,4 @@ MOZ_SERVICE(HistoryService, IHistory,
#ifdef MOZ_USE_NAMESPACE
}
#endif
#endif // !defined(MOZILLA_XPCOMRT_API)
10 changes: 6 additions & 4 deletions xpcom/build/Services.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@
#include "mozilla/Likely.h"
#include "mozilla/Services.h"
#include "nsComponentManager.h"
#include "nsIObserverService.h"
#include "nsNetCID.h"
#include "nsObserverService.h"
#include "nsXPCOMPrivate.h"
#if !defined(MOZILLA_XPCOMRT_API)
#include "nsIIOService.h"
#include "nsIDirectoryService.h"
#ifdef ACCESSIBILITY
#include "nsIAccessibilityService.h"
#endif
#include "nsIChromeRegistry.h"
#include "nsIObserverService.h"
#include "nsNetCID.h"
#include "nsObserverService.h"
#include "nsXPCOMPrivate.h"
#include "nsIStringBundle.h"
#include "nsIToolkitChromeRegistry.h"
#include "nsIXULOverlayProvider.h"
Expand All @@ -26,6 +27,7 @@
#include "nsIServiceWorkerManager.h"
#include "nsIAsyncShutdown.h"
#include "nsIUUIDGenerator.h"
#endif // !defined(MOZILLA_XPCOMRT_API)

using namespace mozilla;
using namespace mozilla::services;
Expand Down
2 changes: 2 additions & 0 deletions xpcom/components/ManifestParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
#define ManifestParser_h

#include "nsComponentManager.h"
#if !defined(MOZILLA_XPCOMRT_API)
#include "nsChromeRegistry.h"
#endif // !defined(MOZILLA_XPCOMRT_API)
#include "mozilla/FileLocation.h"

class nsIFile;
Expand Down
Loading

0 comments on commit c236b48

Please sign in to comment.