From e6fc137e6aaacd4038b30d89767b13406f7f3340 Mon Sep 17 00:00:00 2001 From: Eric Chou Date: Mon, 9 Dec 2013 17:43:15 +0800 Subject: [PATCH 01/19] Bug 947060 - Don't go through bonding procedure while transferring files via OPP, r=gyeh --- dom/bluetooth/bluedroid/BluetoothOppManager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dom/bluetooth/bluedroid/BluetoothOppManager.cpp b/dom/bluetooth/bluedroid/BluetoothOppManager.cpp index 3323ecbe54ba..f83479754f26 100644 --- a/dom/bluetooth/bluedroid/BluetoothOppManager.cpp +++ b/dom/bluetooth/bluedroid/BluetoothOppManager.cpp @@ -261,7 +261,7 @@ BluetoothOppManager::ConnectInternal(const nsAString& aDeviceAddress) } mSocket = - new BluetoothSocket(this, BluetoothSocketType::RFCOMM, true, true); + new BluetoothSocket(this, BluetoothSocketType::RFCOMM, false, true); mSocket->Connect(aDeviceAddress, -1); } @@ -295,7 +295,7 @@ BluetoothOppManager::Listen() } mServerSocket = - new BluetoothSocket(this, BluetoothSocketType::RFCOMM, true, true); + new BluetoothSocket(this, BluetoothSocketType::RFCOMM, false, true); if (!mServerSocket->Listen(BluetoothReservedChannels::CHANNEL_OPUSH)) { BT_WARNING("[OPP] Can't listen on RFCOMM socket!"); From 9a1043aef4477fd11970ddbe3a87d2dc754bc58a Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Mon, 9 Dec 2013 03:20:23 -0800 Subject: [PATCH 02/19] Bumping gaia.json for 1 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/f8d3d0e31a20 Author: Malini Das Desc: Bug 945284 - Bump gaiatest version to 0.20. r=dhunt --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 16ad7d351f09..263f214b6c10 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "7343851c97c278a338434d2632098a263e19bbb6", + "revision": "f8d3d0e31a201137e53f447d2518f93529bd7b4c", "repo_path": "/integration/gaia-central" } From b20f384194da544c77d7570d08bc45f6d34a6c2c Mon Sep 17 00:00:00 2001 From: Gene Lian Date: Mon, 9 Dec 2013 20:24:59 +0800 Subject: [PATCH 03/19] Bug 945711 - [Messages] We lose the 'body' information when migrating. r=vicamo a=v1.3+ --- dom/mobilemessage/src/gonk/MobileMessageDatabaseService.js | 1 + 1 file changed, 1 insertion(+) diff --git a/dom/mobilemessage/src/gonk/MobileMessageDatabaseService.js b/dom/mobilemessage/src/gonk/MobileMessageDatabaseService.js index 726749ef3d8b..d56b18381d9b 100644 --- a/dom/mobilemessage/src/gonk/MobileMessageDatabaseService.js +++ b/dom/mobilemessage/src/gonk/MobileMessageDatabaseService.js @@ -924,6 +924,7 @@ MobileMessageDatabaseService.prototype = { // Participant store cursor iteration done. if (!invalidParticipantIds.length) { next(); + return; } // Find affected thread. From 00ea22f38854390f99ae5537a758a4b536e2bb8f Mon Sep 17 00:00:00 2001 From: Vicamo Yang Date: Mon, 9 Dec 2013 21:02:54 +0800 Subject: [PATCH 04/19] Bug 944625 - B2G Emulator-x86: fix undeclared __NR_socketpair, __NR_sendmsg. r=kang,jld --- security/sandbox/linux/seccomp_filter.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/security/sandbox/linux/seccomp_filter.h b/security/sandbox/linux/seccomp_filter.h index b69f6cb03123..0dc610b4a881 100644 --- a/security/sandbox/linux/seccomp_filter.h +++ b/security/sandbox/linux/seccomp_filter.h @@ -81,6 +81,8 @@ ALLOW_SYSCALL(fstat64), \ ALLOW_SYSCALL(stat64), \ ALLOW_SYSCALL(lstat64), \ + ALLOW_SYSCALL(socketpair), \ + ALLOW_SYSCALL(sendmsg), \ ALLOW_SYSCALL(sigprocmask), #elif defined(__i386__) #define SECCOMP_WHITELIST_ARCH_TOREMOVE \ @@ -89,7 +91,9 @@ ALLOW_SYSCALL(lstat64), \ ALLOW_SYSCALL(sigprocmask), #else -#define SECCOMP_WHITELIST_ARCH_TOREMOVE +#define SECCOMP_WHITELIST_ARCH_TOREMOVE \ + ALLOW_SYSCALL(socketpair), \ + ALLOW_SYSCALL(sendmsg), #endif /* Architecture-specific syscalls for desktop linux */ @@ -252,8 +256,6 @@ ALLOW_SYSCALL(access), \ ALLOW_SYSCALL(unlink), \ ALLOW_SYSCALL(fsync), \ - ALLOW_SYSCALL(socketpair), \ - ALLOW_SYSCALL(sendmsg), \ /* Should remove all of the following in the future, if possible */ \ ALLOW_SYSCALL(getpriority), \ ALLOW_SYSCALL(setpriority), \ From 2a3d1cd8b9dc37817352c8e913a41a590da725ba Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Mon, 9 Dec 2013 14:21:18 +0100 Subject: [PATCH 05/19] Bug 936402: Duplicate connection status in UnixSocketImpl, r=bent UnixSocketImpl, which mostly runs on the I/O thread, doesn't control its reference to UnixSocketConsumer. If the connection status is stored in UnixSocketConsumer, the I/O thread can't read it safely. This patch duplicates the connection status in UnixSocketImpl, where reading from the I/O thread is safe. Methods of UnixSocketImpl don't need to access mConsumer any longer to obtain the connection status. --- ipc/unixsocket/UnixSocket.cpp | 39 ++++++++++++++++++++++++----------- ipc/unixsocket/UnixSocket.h | 2 ++ 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/ipc/unixsocket/UnixSocket.cpp b/ipc/unixsocket/UnixSocket.cpp index f352c18a1102..7db20ebb73bf 100644 --- a/ipc/unixsocket/UnixSocket.cpp +++ b/ipc/unixsocket/UnixSocket.cpp @@ -20,7 +20,6 @@ #include "mozilla/Util.h" #include "mozilla/FileUtils.h" #include "nsString.h" -#include "nsThreadUtils.h" #include "nsTArray.h" #include "nsXULAppAPI.h" @@ -44,13 +43,15 @@ class UnixSocketImpl : public MessageLoopForIO::Watcher { public: UnixSocketImpl(UnixSocketConsumer* aConsumer, UnixSocketConnector* aConnector, - const nsACString& aAddress) + const nsACString& aAddress, + SocketConnectionStatus aConnectionStatus) : mConsumer(aConsumer) , mIOLoop(nullptr) , mConnector(aConnector) , mShuttingDownOnIOThread(false) , mAddress(aAddress) , mDelayedConnectTask(nullptr) + , mConnectionStatus(aConnectionStatus) { } @@ -246,6 +247,12 @@ private: * Task member for delayed connect task. Should only be access on main thread. */ CancelableTask* mDelayedConnectTask; + + /** + * Socket connection status. Duplicate from UnixSocketConsumer. Should only + * be accessed on I/O thread. + */ + SocketConnectionStatus mConnectionStatus; }; template @@ -526,6 +533,7 @@ UnixSocketImpl::Accept() nsRefPtr t = new OnSocketEventTask(this, OnSocketEventTask::CONNECT_ERROR); NS_DispatchToMainThread(t); + mConnectionStatus = SOCKET_DISCONNECTED; return; } @@ -563,6 +571,7 @@ UnixSocketImpl::Connect() nsRefPtr t = new OnSocketEventTask(this, OnSocketEventTask::CONNECT_ERROR); NS_DispatchToMainThread(t); + mConnectionStatus = SOCKET_DISCONNECTED; return; } @@ -579,6 +588,7 @@ UnixSocketImpl::Connect() nsRefPtr t = new OnSocketEventTask(this, OnSocketEventTask::CONNECT_ERROR); NS_DispatchToMainThread(t); + mConnectionStatus = SOCKET_DISCONNECTED; return; } if (-1 == fcntl(mFd.get(), F_SETFL, current_opts & ~O_NONBLOCK)) { @@ -587,6 +597,7 @@ UnixSocketImpl::Connect() nsRefPtr t = new OnSocketEventTask(this, OnSocketEventTask::CONNECT_ERROR); NS_DispatchToMainThread(t); + mConnectionStatus = SOCKET_DISCONNECTED; return; } @@ -610,6 +621,7 @@ UnixSocketImpl::Connect() nsRefPtr t = new OnSocketEventTask(this, OnSocketEventTask::CONNECT_ERROR); NS_DispatchToMainThread(t); + mConnectionStatus = SOCKET_DISCONNECTED; return; } @@ -625,6 +637,7 @@ UnixSocketImpl::Connect() nsRefPtr t = new OnSocketEventTask(this, OnSocketEventTask::CONNECT_SUCCESS); NS_DispatchToMainThread(t); + mConnectionStatus = SOCKET_CONNECTED; SetUpIO(); } @@ -721,8 +734,7 @@ UnixSocketImpl::OnFileCanReadWithoutBlocking(int aFd) MOZ_ASSERT(!NS_IsMainThread()); MOZ_ASSERT(!mShuttingDownOnIOThread); - SocketConnectionStatus status = mConsumer->GetConnectionStatus(); - if (status == SOCKET_CONNECTED) { + if (mConnectionStatus == SOCKET_CONNECTED) { // Read all of the incoming data. while (true) { nsAutoPtr incoming(new UnixSocketRawData(MAX_READ_SIZE)); @@ -765,9 +777,7 @@ UnixSocketImpl::OnFileCanReadWithoutBlocking(int aFd) } MOZ_CRASH("We returned early"); - } - - if (status == SOCKET_LISTENING) { + } else if (mConnectionStatus == SOCKET_LISTENING) { int client_fd = accept(mFd.get(), (struct sockaddr*)&mAddr, &mAddrSize); if (client_fd < 0) { @@ -792,6 +802,7 @@ UnixSocketImpl::OnFileCanReadWithoutBlocking(int aFd) nsRefPtr t = new OnSocketEventTask(this, OnSocketEventTask::CONNECT_SUCCESS); NS_DispatchToMainThread(t); + mConnectionStatus = SOCKET_CONNECTED; SetUpIO(); } @@ -804,8 +815,7 @@ UnixSocketImpl::OnFileCanWriteWithoutBlocking(int aFd) MOZ_ASSERT(!mShuttingDownOnIOThread); MOZ_ASSERT(aFd >= 0); - SocketConnectionStatus status = mConsumer->GetConnectionStatus(); - if (status == SOCKET_CONNECTED) { + if (mConnectionStatus == SOCKET_CONNECTED) { // Try to write the bytes of mCurrentRilRawData. If all were written, continue. // // Otherwise, save the byte position of the next byte to write @@ -846,7 +856,7 @@ UnixSocketImpl::OnFileCanWriteWithoutBlocking(int aFd) mOutgoingQ.RemoveElementAt(0); delete data; } - } else if (status == SOCKET_CONNECTING) { + } else if (mConnectionStatus == SOCKET_CONNECTING) { int error, ret; socklen_t len = sizeof(error); ret = getsockopt(mFd.get(), SOL_SOCKET, SO_ERROR, &error, &len); @@ -857,6 +867,7 @@ UnixSocketImpl::OnFileCanWriteWithoutBlocking(int aFd) nsRefPtr t = new OnSocketEventTask(this, OnSocketEventTask::CONNECT_ERROR); NS_DispatchToMainThread(t); + mConnectionStatus = SOCKET_DISCONNECTED; return; } @@ -865,6 +876,7 @@ UnixSocketImpl::OnFileCanWriteWithoutBlocking(int aFd) nsRefPtr t = new OnSocketEventTask(this, OnSocketEventTask::CONNECT_ERROR); NS_DispatchToMainThread(t); + mConnectionStatus = SOCKET_DISCONNECTED; return; } @@ -874,12 +886,14 @@ UnixSocketImpl::OnFileCanWriteWithoutBlocking(int aFd) nsRefPtr t = new OnSocketEventTask(this, OnSocketEventTask::CONNECT_ERROR); NS_DispatchToMainThread(t); + mConnectionStatus = SOCKET_DISCONNECTED; return; } nsRefPtr t = new OnSocketEventTask(this, OnSocketEventTask::CONNECT_SUCCESS); NS_DispatchToMainThread(t); + mConnectionStatus = SOCKET_CONNECTED; SetUpIO(); } @@ -936,7 +950,7 @@ UnixSocketConsumer::ConnectSocket(UnixSocketConnector* aConnector, } nsCString addr(aAddress); - mImpl = new UnixSocketImpl(this, connector.forget(), addr); + mImpl = new UnixSocketImpl(this, connector.forget(), addr, SOCKET_CONNECTING); MessageLoop* ioLoop = XRE_GetIOMessageLoop(); mConnectionStatus = SOCKET_CONNECTING; if (aDelayMs > 0) { @@ -962,7 +976,8 @@ UnixSocketConsumer::ListenSocket(UnixSocketConnector* aConnector) return false; } - mImpl = new UnixSocketImpl(this, connector.forget(), EmptyCString()); + mImpl = new UnixSocketImpl(this, connector.forget(), EmptyCString(), + SOCKET_LISTENING); mConnectionStatus = SOCKET_LISTENING; XRE_GetIOMessageLoop()->PostTask(FROM_HERE, new SocketAcceptTask(mImpl)); diff --git a/ipc/unixsocket/UnixSocket.h b/ipc/unixsocket/UnixSocket.h index 3cbb552b6b8b..70452f493b98 100644 --- a/ipc/unixsocket/UnixSocket.h +++ b/ipc/unixsocket/UnixSocket.h @@ -22,6 +22,7 @@ #include "nsString.h" #include "nsAutoPtr.h" #include "mozilla/RefPtr.h" +#include "nsThreadUtils.h" namespace mozilla { namespace ipc { @@ -165,6 +166,7 @@ public: SocketConnectionStatus GetConnectionStatus() const { + MOZ_ASSERT(NS_IsMainThread()); return mConnectionStatus; } From fef6cb033d8e07b7260ed03cb248a84a8bcaf678 Mon Sep 17 00:00:00 2001 From: Vincent Chang Date: Mon, 25 Nov 2013 19:40:22 +0800 Subject: [PATCH 06/19] Bug 895753 - Rtsp: Support suspend and resume to media stream server. r=sworkman --- netwerk/protocol/rtsp/rtsp/RTSPSource.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/netwerk/protocol/rtsp/rtsp/RTSPSource.cpp b/netwerk/protocol/rtsp/rtsp/RTSPSource.cpp index c646532502d1..f9b895af4131 100644 --- a/netwerk/protocol/rtsp/rtsp/RTSPSource.cpp +++ b/netwerk/protocol/rtsp/rtsp/RTSPSource.cpp @@ -207,7 +207,16 @@ void RTSPSource::performPlay(int64_t playTimeUs) { if (mState == PAUSING) { playTimeUs = mLatestPausedUnit; } - LOGI("performPlay : %lld", playTimeUs); + + int64_t duration = 0; + getDuration(&duration); + MOZ_ASSERT(playTimeUs < duration, + "Should never receive an out of bounds play time!"); + if (playTimeUs >= duration) { + return; + } + + LOGI("performPlay : duration=%lld playTimeUs=%lld", duration, playTimeUs); mState = PLAYING; mHandler->play(playTimeUs); } @@ -238,13 +247,22 @@ void RTSPSource::performSeek(int64_t seekTimeUs) { if (mState != PLAYING && mState != PAUSING) { return; } - LOGI("performSeek: %llu", seekTimeUs); + + int64_t duration = 0; + getDuration(&duration); + MOZ_ASSERT(seekTimeUs < duration, + "Should never receive an out of bounds seek time!"); + if (seekTimeUs >= duration) { + return; + } + for (size_t i = 0; i < mTracks.size(); ++i) { TrackInfo *info = &mTracks.editItemAt(i); info->mLatestPausedUnit = 0; mLatestPausedUnit = 0; } + LOGI("performSeek: %llu", seekTimeUs); mState = SEEKING; mHandler->seek(seekTimeUs); } From 18e1783c39e85c9db14bfbb5498f72923319c162 Mon Sep 17 00:00:00 2001 From: Ben Tian Date: Fri, 6 Dec 2013 12:20:07 +0800 Subject: [PATCH 07/19] Bug 946555 - Remove unused functions in BluetoothService classes and some warnings, r=echou --- dom/bluetooth/BluetoothHidManager.h | 2 +- dom/bluetooth/BluetoothProfileController.cpp | 4 +- dom/bluetooth/BluetoothRilListener.h | 3 + dom/bluetooth/BluetoothService.h | 20 ------- dom/bluetooth/BluetoothUtils.cpp | 2 +- .../bluedroid/BluetoothA2dpManager.h | 2 +- dom/bluetooth/bluedroid/BluetoothHfpManager.h | 2 +- .../bluedroid/BluetoothOppManager.cpp | 2 +- dom/bluetooth/bluedroid/BluetoothOppManager.h | 2 +- .../gonk/BluetoothServiceBluedroid.cpp | 57 ------------------- .../gonk/BluetoothServiceBluedroid.h | 33 ----------- dom/bluetooth/bluez/BluetoothA2dpManager.h | 2 +- dom/bluetooth/bluez/BluetoothHfpManager.cpp | 25 +++----- dom/bluetooth/bluez/BluetoothOppManager.cpp | 2 +- dom/bluetooth/bluez/BluetoothOppManager.h | 2 +- .../bluez/linux/BluetoothDBusService.cpp | 39 +------------ .../bluez/linux/BluetoothDBusService.h | 15 ----- .../ipc/BluetoothServiceChildProcess.cpp | 29 ---------- .../ipc/BluetoothServiceChildProcess.h | 11 ---- 19 files changed, 24 insertions(+), 230 deletions(-) diff --git a/dom/bluetooth/BluetoothHidManager.h b/dom/bluetooth/BluetoothHidManager.h index 41fccf563591..068acf2d8b19 100644 --- a/dom/bluetooth/BluetoothHidManager.h +++ b/dom/bluetooth/BluetoothHidManager.h @@ -25,7 +25,7 @@ public: } static BluetoothHidManager* Get(); - ~BluetoothHidManager(); + virtual ~BluetoothHidManager(); // HID-specific functions void HandleInputPropertyChanged(const BluetoothSignal& aSignal); diff --git a/dom/bluetooth/BluetoothProfileController.cpp b/dom/bluetooth/BluetoothProfileController.cpp index ed02a728daa1..a6fd33648a96 100644 --- a/dom/bluetooth/BluetoothProfileController.cpp +++ b/dom/bluetooth/BluetoothProfileController.cpp @@ -187,9 +187,9 @@ BluetoothProfileController::Next() { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(!mDeviceAddress.IsEmpty()); - MOZ_ASSERT(mProfilesIndex < mProfiles.Length()); + MOZ_ASSERT(mProfilesIndex < (int)mProfiles.Length()); - if (++mProfilesIndex < mProfiles.Length()) { + if (++mProfilesIndex < (int)mProfiles.Length()) { BT_LOGR_PROFILE(mProfiles[mProfilesIndex], ""); if (mConnect) { diff --git a/dom/bluetooth/BluetoothRilListener.h b/dom/bluetooth/BluetoothRilListener.h index 44ca1a80c233..462280ef3b51 100644 --- a/dom/bluetooth/BluetoothRilListener.h +++ b/dom/bluetooth/BluetoothRilListener.h @@ -26,6 +26,7 @@ public: NS_DECL_NSIICCLISTENER IccListener() { } + virtual ~IccListener() { } bool Listen(bool aStart); void SetOwner(BluetoothRilListener *aOwner); @@ -42,6 +43,7 @@ public: MobileConnectionListener(uint32_t aClientId) : mClientId(aClientId) { } + virtual ~MobileConnectionListener() { } bool Listen(bool aStart); @@ -56,6 +58,7 @@ public: NS_DECL_NSITELEPHONYLISTENER TelephonyListener() { } + virtual ~TelephonyListener() { } bool Listen(bool aStart); }; diff --git a/dom/bluetooth/BluetoothService.h b/dom/bluetooth/BluetoothService.h index 2c525e90869e..7adf497f97a0 100644 --- a/dom/bluetooth/BluetoothService.h +++ b/dom/bluetooth/BluetoothService.h @@ -172,20 +172,6 @@ public: const BluetoothNamedValue& aValue, BluetoothReplyRunnable* aRunnable) = 0; - /** - * Get the path of a device - * - * @param aAdapterPath Path to the Adapter that's communicating with the device - * @param aDeviceAddress Device address (XX:XX:XX:XX:XX:XX format) - * @param aDevicePath Return value of path - * - * @return True if path set correctly, false otherwise - */ - virtual bool - GetDevicePath(const nsAString& aAdapterPath, - const nsAString& aDeviceAddress, - nsAString& aDevicePath) = 0; - virtual nsresult CreatePairedDeviceInternal(const nsAString& aAddress, int aTimeout, @@ -195,12 +181,6 @@ public: RemoveDeviceInternal(const nsAString& aObjectPath, BluetoothReplyRunnable* aRunnable) = 0; - virtual nsresult - GetScoSocket(const nsAString& aObjectPath, - bool aAuth, - bool aEncrypt, - mozilla::ipc::UnixSocketConsumer* aConsumer) = 0; - /** * Get corresponding service channel of specific service on remote device. * It's usually the very first step of establishing an outbound connection. diff --git a/dom/bluetooth/BluetoothUtils.cpp b/dom/bluetooth/BluetoothUtils.cpp index fb03577d766c..55571587ae6c 100644 --- a/dom/bluetooth/BluetoothUtils.cpp +++ b/dom/bluetooth/BluetoothUtils.cpp @@ -95,7 +95,7 @@ GetAddressFromObjectPath(const nsAString& aObjectPath) nsString address(aObjectPath); int addressHead = address.RFind("/") + 5; - MOZ_ASSERT(addressHead + BLUETOOTH_ADDRESS_LENGTH == address.Length()); + MOZ_ASSERT(addressHead + BLUETOOTH_ADDRESS_LENGTH == (int)address.Length()); address.Cut(0, addressHead); address.ReplaceChar('_', ':'); diff --git a/dom/bluetooth/bluedroid/BluetoothA2dpManager.h b/dom/bluetooth/bluedroid/BluetoothA2dpManager.h index c690e7965cce..e373b26cc46c 100644 --- a/dom/bluetooth/bluedroid/BluetoothA2dpManager.h +++ b/dom/bluetooth/bluedroid/BluetoothA2dpManager.h @@ -32,7 +32,7 @@ public: }; static BluetoothA2dpManager* Get(); - ~BluetoothA2dpManager(); + virtual ~BluetoothA2dpManager(); void ResetA2dp(); void ResetAvrcp(); diff --git a/dom/bluetooth/bluedroid/BluetoothHfpManager.h b/dom/bluetooth/bluedroid/BluetoothHfpManager.h index 632ed667780c..a0178559b286 100644 --- a/dom/bluetooth/bluedroid/BluetoothHfpManager.h +++ b/dom/bluetooth/bluedroid/BluetoothHfpManager.h @@ -84,7 +84,7 @@ public: } static BluetoothHfpManager* Get(); - ~BluetoothHfpManager(); + virtual ~BluetoothHfpManager(); bool ConnectSco(); bool DisconnectSco(); diff --git a/dom/bluetooth/bluedroid/BluetoothOppManager.cpp b/dom/bluetooth/bluedroid/BluetoothOppManager.cpp index f83479754f26..3856ebb18242 100644 --- a/dom/bluetooth/bluedroid/BluetoothOppManager.cpp +++ b/dom/bluetooth/bluedroid/BluetoothOppManager.cpp @@ -315,7 +315,7 @@ BluetoothOppManager::StartSendingNextFile() MOZ_ASSERT(!IsConnected()); MOZ_ASSERT(!mBatches.IsEmpty()); - MOZ_ASSERT(mBatches[0].mBlobs.Length() > mCurrentBlobIndex + 1); + MOZ_ASSERT((int)mBatches[0].mBlobs.Length() > mCurrentBlobIndex + 1); mBlob = mBatches[0].mBlobs[++mCurrentBlobIndex]; diff --git a/dom/bluetooth/bluedroid/BluetoothOppManager.h b/dom/bluetooth/bluedroid/BluetoothOppManager.h index 0642c2457cee..878224eef6f0 100644 --- a/dom/bluetooth/bluedroid/BluetoothOppManager.h +++ b/dom/bluetooth/bluedroid/BluetoothOppManager.h @@ -45,7 +45,7 @@ public: static const int DEFAULT_OPP_CHANNEL = 10; static const int MAX_PACKET_LENGTH = 0xFFFE; - ~BluetoothOppManager(); + virtual ~BluetoothOppManager(); static BluetoothOppManager* Get(); void ClientDataHandler(mozilla::ipc::UnixSocketRawData* aMessage); void ServerDataHandler(mozilla::ipc::UnixSocketRawData* aMessage); diff --git a/dom/bluetooth/bluedroid/gonk/BluetoothServiceBluedroid.cpp b/dom/bluetooth/bluedroid/gonk/BluetoothServiceBluedroid.cpp index 29e94906dae4..9de307338b2c 100644 --- a/dom/bluetooth/bluedroid/gonk/BluetoothServiceBluedroid.cpp +++ b/dom/bluetooth/bluedroid/gonk/BluetoothServiceBluedroid.cpp @@ -965,13 +965,6 @@ BluetoothServiceBluedroid::StopDiscoveryInternal( return NS_OK; } -nsresult -BluetoothServiceBluedroid::GetDevicePropertiesInternal( - const BluetoothSignal& aSignal) -{ - return NS_OK; -} - nsresult BluetoothServiceBluedroid::SetProperty(BluetoothObjectType aType, const BluetoothNamedValue& aValue, @@ -1033,56 +1026,6 @@ BluetoothServiceBluedroid::SetProperty(BluetoothObjectType aType, return NS_OK; } -bool -BluetoothServiceBluedroid::GetDevicePath(const nsAString& aAdapterPath, - const nsAString& aDeviceAddress, - nsAString& aDevicePath) -{ - return true; -} - -bool -BluetoothServiceBluedroid::AddServiceRecords(const char* serviceName, - unsigned long long uuidMsb, - unsigned long long uuidLsb, - int channel) -{ - return true; -} - -bool -BluetoothServiceBluedroid::RemoveServiceRecords(const char* serviceName, - unsigned long long uuidMsb, - unsigned long long uuidLsb, - int channel) -{ - return true; -} - -bool -BluetoothServiceBluedroid::AddReservedServicesInternal( - const nsTArray& aServices, - nsTArray& aServiceHandlesContainer) -{ - return true; - -} - -bool -BluetoothServiceBluedroid::RemoveReservedServicesInternal( - const nsTArray& aServiceHandles) -{ - return true; -} - -nsresult -BluetoothServiceBluedroid::GetScoSocket( - const nsAString& aObjectPath, bool aAuth, bool aEncrypt, - mozilla::ipc::UnixSocketConsumer* aConsumer) -{ - return NS_OK; -} - nsresult BluetoothServiceBluedroid::GetServiceChannel( const nsAString& aDeviceAddress, diff --git a/dom/bluetooth/bluedroid/gonk/BluetoothServiceBluedroid.h b/dom/bluetooth/bluedroid/gonk/BluetoothServiceBluedroid.h index 9a3f228f9583..c362e4bef124 100644 --- a/dom/bluetooth/bluedroid/gonk/BluetoothServiceBluedroid.h +++ b/dom/bluetooth/bluedroid/gonk/BluetoothServiceBluedroid.h @@ -49,44 +49,11 @@ public: virtual nsresult StartDiscoveryInternal(BluetoothReplyRunnable* aRunnable); virtual nsresult StopDiscoveryInternal(BluetoothReplyRunnable* aRunnable); - virtual nsresult - GetDevicePropertiesInternal(const BluetoothSignal& aSignal); - virtual nsresult SetProperty(BluetoothObjectType aType, const BluetoothNamedValue& aValue, BluetoothReplyRunnable* aRunnable); - virtual bool - GetDevicePath(const nsAString& aAdapterPath, - const nsAString& aDeviceAddress, - nsAString& aDevicePath); - - static bool - AddServiceRecords(const char* serviceName, - unsigned long long uuidMsb, - unsigned long long uuidLsb, - int channel); - - static bool - RemoveServiceRecords(const char* serviceName, - unsigned long long uuidMsb, - unsigned long long uuidLsb, - int channel); - - static bool - AddReservedServicesInternal(const nsTArray& aServices, - nsTArray& aServiceHandlesContainer); - - static bool - RemoveReservedServicesInternal(const nsTArray& aServiceHandles); - - virtual nsresult - GetScoSocket(const nsAString& aObjectPath, - bool aAuth, - bool aEncrypt, - mozilla::ipc::UnixSocketConsumer* aConsumer); - virtual nsresult GetServiceChannel(const nsAString& aDeviceAddress, const nsAString& aServiceUuid, diff --git a/dom/bluetooth/bluez/BluetoothA2dpManager.h b/dom/bluetooth/bluez/BluetoothA2dpManager.h index 70d88f345571..2c7d6bb83559 100644 --- a/dom/bluetooth/bluez/BluetoothA2dpManager.h +++ b/dom/bluetooth/bluez/BluetoothA2dpManager.h @@ -33,7 +33,7 @@ public: }; static BluetoothA2dpManager* Get(); - ~BluetoothA2dpManager(); + virtual ~BluetoothA2dpManager(); void ResetA2dp(); void ResetAvrcp(); diff --git a/dom/bluetooth/bluez/BluetoothHfpManager.cpp b/dom/bluetooth/bluez/BluetoothHfpManager.cpp index b223c13b5346..26a979738d8c 100644 --- a/dom/bluetooth/bluez/BluetoothHfpManager.cpp +++ b/dom/bluetooth/bluez/BluetoothHfpManager.cpp @@ -1018,7 +1018,7 @@ BluetoothHfpManager::ReceiveSocketData(BluetoothSocket* aSocket, for (uint8_t i = 0; i < atCommandValues.Length(); i++) { CINDType indicatorType = (CINDType) (i + 1); - if (indicatorType >= ArrayLength(sCINDItems)) { + if (indicatorType >= (int)ArrayLength(sCINDItems)) { // Ignore excess parameters at the end break; } @@ -1802,15 +1802,8 @@ BluetoothHfpManager::ConnectSco(BluetoothReplyRunnable* aRunnable) { MOZ_ASSERT(NS_IsMainThread()); - if (sInShutdown) { - BT_WARNING("ConnecteSco called while in shutdown!"); - return false; - } - - if (!IsConnected()) { - BT_WARNING("BluetoothHfpManager is not connected"); - return false; - } + NS_ENSURE_TRUE(!sInShutdown, false); + NS_ENSURE_TRUE(IsConnected(), false); SocketConnectionStatus status = mScoSocket->GetConnectionStatus(); if (status == SocketConnectionStatus::SOCKET_CONNECTED || @@ -1828,16 +1821,14 @@ BluetoothHfpManager::ConnectSco(BluetoothReplyRunnable* aRunnable) return false; } + // Stop listening mScoSocket->Disconnect(); - mScoRunnable = aRunnable; - - BluetoothService* bs = BluetoothService::Get(); - NS_ENSURE_TRUE(bs, false); - nsresult rv = bs->GetScoSocket(mDeviceAddress, true, false, mScoSocket); - + mScoSocket->Connect(NS_ConvertUTF16toUTF8(mDeviceAddress), -1); mScoSocketStatus = mScoSocket->GetConnectionStatus(); - return NS_SUCCEEDED(rv); + + mScoRunnable = aRunnable; + return true; } bool diff --git a/dom/bluetooth/bluez/BluetoothOppManager.cpp b/dom/bluetooth/bluez/BluetoothOppManager.cpp index a6e2f1fee101..c327925ae969 100644 --- a/dom/bluetooth/bluez/BluetoothOppManager.cpp +++ b/dom/bluetooth/bluez/BluetoothOppManager.cpp @@ -331,7 +331,7 @@ BluetoothOppManager::StartSendingNextFile() MOZ_ASSERT(!IsConnected()); MOZ_ASSERT(!mBatches.IsEmpty()); - MOZ_ASSERT(mBatches[0].mBlobs.Length() > mCurrentBlobIndex + 1); + MOZ_ASSERT((int)mBatches[0].mBlobs.Length() > mCurrentBlobIndex + 1); mBlob = mBatches[0].mBlobs[++mCurrentBlobIndex]; diff --git a/dom/bluetooth/bluez/BluetoothOppManager.h b/dom/bluetooth/bluez/BluetoothOppManager.h index 062032ac69d6..c8c884c9953f 100644 --- a/dom/bluetooth/bluez/BluetoothOppManager.h +++ b/dom/bluetooth/bluez/BluetoothOppManager.h @@ -45,7 +45,7 @@ public: static const int DEFAULT_OPP_CHANNEL = 10; static const int MAX_PACKET_LENGTH = 0xFFFE; - ~BluetoothOppManager(); + virtual ~BluetoothOppManager(); static BluetoothOppManager* Get(); void ClientDataHandler(mozilla::ipc::UnixSocketRawData* aMessage); void ServerDataHandler(mozilla::ipc::UnixSocketRawData* aMessage); diff --git a/dom/bluetooth/bluez/linux/BluetoothDBusService.cpp b/dom/bluetooth/bluez/linux/BluetoothDBusService.cpp index 18c614c78a7d..46021841c102 100644 --- a/dom/bluetooth/bluez/linux/BluetoothDBusService.cpp +++ b/dom/bluetooth/bluez/linux/BluetoothDBusService.cpp @@ -174,7 +174,7 @@ static const char* sBluetoothDBusSignals[] = static nsRefPtr gThreadConnection; // Only A2DP and HID are authorized. -static nsTArray sAuthorizedServiceClass; +static nsTArray sAuthorizedServiceClass; // The object path of adpater which should be updated after switching Bluetooth. static nsString sAdapterPath; @@ -2366,7 +2366,7 @@ BluetoothDBusService::SetProperty(BluetoothObjectType aType, return NS_OK; } - MOZ_ASSERT(aType < ArrayLength(sBluetoothDBusIfaces)); + MOZ_ASSERT(aType < (int)ArrayLength(sBluetoothDBusIfaces)); MOZ_ASSERT(!sAdapterPath.IsEmpty()); const char* interface = sBluetoothDBusIfaces[aType]; @@ -2439,15 +2439,6 @@ BluetoothDBusService::SetProperty(BluetoothObjectType aType, return NS_OK; } -bool -BluetoothDBusService::GetDevicePath(const nsAString& aAdapterPath, - const nsAString& aDeviceAddress, - nsAString& aDevicePath) -{ - aDevicePath = GetObjectPathFromAddress(aAdapterPath, aDeviceAddress); - return true; -} - nsresult BluetoothDBusService::CreatePairedDeviceInternal( const nsAString& aDeviceAddress, @@ -2979,32 +2970,6 @@ BluetoothDBusService::UpdateSdpRecords(const nsAString& aDeviceAddress, DBUS_TYPE_INVALID); } -nsresult -BluetoothDBusService::GetScoSocket(const nsAString& aAddress, - bool aAuth, - bool aEncrypt, - mozilla::ipc::UnixSocketConsumer* aConsumer) -{ - MOZ_ASSERT(NS_IsMainThread()); - - if (!mConnection || !gThreadConnection) { - NS_ERROR("Bluetooth service not started yet!"); - return NS_ERROR_FAILURE; - } - - BluetoothUnixSocketConnector* c = - new BluetoothUnixSocketConnector(BluetoothSocketType::SCO, -1, - aAuth, aEncrypt); - - if (!aConsumer->ConnectSocket(c, NS_ConvertUTF16toUTF8(aAddress).get())) { - nsAutoString replyError; - replyError.AssignLiteral("SocketConnectionError"); - return NS_ERROR_FAILURE; - } - - return NS_OK; -} - void BluetoothDBusService::SendFile(const nsAString& aDeviceAddress, BlobParent* aBlobParent, diff --git a/dom/bluetooth/bluez/linux/BluetoothDBusService.h b/dom/bluetooth/bluez/linux/BluetoothDBusService.h index 341205a3496d..251efd2982f0 100644 --- a/dom/bluetooth/bluez/linux/BluetoothDBusService.h +++ b/dom/bluetooth/bluez/linux/BluetoothDBusService.h @@ -54,21 +54,6 @@ public: const BluetoothNamedValue& aValue, BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; - virtual bool - GetDevicePath(const nsAString& aAdapterPath, - const nsAString& aDeviceAddress, - nsAString& aDevicePath) MOZ_OVERRIDE; - - static bool - AddReservedServicesInternal(const nsTArray& aServices, - nsTArray& aServiceHandlesContainer); - - virtual nsresult - GetScoSocket(const nsAString& aObjectPath, - bool aAuth, - bool aEncrypt, - mozilla::ipc::UnixSocketConsumer* aConsumer) MOZ_OVERRIDE; - virtual nsresult GetServiceChannel(const nsAString& aDeviceAddress, const nsAString& aServiceUuid, diff --git a/dom/bluetooth/ipc/BluetoothServiceChildProcess.cpp b/dom/bluetooth/ipc/BluetoothServiceChildProcess.cpp index de9b8f164637..2ad030201c84 100644 --- a/dom/bluetooth/ipc/BluetoothServiceChildProcess.cpp +++ b/dom/bluetooth/ipc/BluetoothServiceChildProcess.cpp @@ -148,25 +148,6 @@ BluetoothServiceChildProcess::SetProperty(BluetoothObjectType aType, return NS_OK; } -bool -BluetoothServiceChildProcess::GetDevicePath(const nsAString& aAdapterPath, - const nsAString& aDeviceAddress, - nsAString& aDevicePath) -{ - // XXXbent Right now this is adapted from BluetoothDBusService's - // GetObjectPathFromAddress. This is basically a sync call that cannot - // be forwarded to the parent process without blocking. Hopefully this - // can be reworked. - nsAutoString path(aAdapterPath); - path.AppendLiteral("/dev_"); - path.Append(aDeviceAddress); - path.ReplaceChar(':', '_'); - - aDevicePath = path; - - return true; -} - nsresult BluetoothServiceChildProcess::CreatePairedDeviceInternal( const nsAString& aAddress, @@ -188,16 +169,6 @@ BluetoothServiceChildProcess::RemoveDeviceInternal( return NS_OK; } -nsresult -BluetoothServiceChildProcess::GetScoSocket( - const nsAString& aObjectPath, - bool aAuth, - bool aEncrypt, - mozilla::ipc::UnixSocketConsumer* aConsumer) -{ - MOZ_CRASH("This should never be called!"); -} - nsresult BluetoothServiceChildProcess::GetServiceChannel(const nsAString& aDeviceAddress, const nsAString& aServiceUuid, diff --git a/dom/bluetooth/ipc/BluetoothServiceChildProcess.h b/dom/bluetooth/ipc/BluetoothServiceChildProcess.h index ac8298fe6bd3..b97384348e13 100644 --- a/dom/bluetooth/ipc/BluetoothServiceChildProcess.h +++ b/dom/bluetooth/ipc/BluetoothServiceChildProcess.h @@ -66,11 +66,6 @@ public: const BluetoothNamedValue& aValue, BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; - virtual bool - GetDevicePath(const nsAString& aAdapterPath, - const nsAString& aDeviceAddress, - nsAString& aDevicePath) MOZ_OVERRIDE; - virtual nsresult CreatePairedDeviceInternal(const nsAString& aAddress, int aTimeout, @@ -80,12 +75,6 @@ public: RemoveDeviceInternal(const nsAString& aObjectPath, BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; - virtual nsresult - GetScoSocket(const nsAString& aObjectPath, - bool aAuth, - bool aEncrypt, - mozilla::ipc::UnixSocketConsumer* aConsumer) MOZ_OVERRIDE; - virtual nsresult GetServiceChannel(const nsAString& aDeviceAddress, const nsAString& aServiceUuid, From ec662907d1d617dce9ea993ee0808c80389d60d7 Mon Sep 17 00:00:00 2001 From: Alfredo Yang Date: Mon, 9 Dec 2013 09:35:03 -0500 Subject: [PATCH 08/19] Bug 853356 - Test: Check mediastream track according to request type. r=jsmith --- dom/media/tests/mochitest/Makefile.in | 6 ++ .../test_getUserMedia_permission.html | 75 +++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 dom/media/tests/mochitest/test_getUserMedia_permission.html diff --git a/dom/media/tests/mochitest/Makefile.in b/dom/media/tests/mochitest/Makefile.in index f0beca99b9af..b2406a195626 100644 --- a/dom/media/tests/mochitest/Makefile.in +++ b/dom/media/tests/mochitest/Makefile.in @@ -7,3 +7,9 @@ ifdef MOZ_WEBRTC_LEAKING_TESTS MOCHITEST_FILES += \ $(NULL) endif + +ifdef MOZ_B2G_CAMERA +MOCHITEST_FILES += \ + test_getUserMedia_permission.html \ + $(NULL) +endif diff --git a/dom/media/tests/mochitest/test_getUserMedia_permission.html b/dom/media/tests/mochitest/test_getUserMedia_permission.html new file mode 100644 index 000000000000..82c312446bbf --- /dev/null +++ b/dom/media/tests/mochitest/test_getUserMedia_permission.html @@ -0,0 +1,75 @@ + + + + + + mozGetUserMedia Permission Test + + + + + + +Display camera/microphone permission acquisition prompt + + + + From 9081dfe90e7dcce6d1c1e5f9c6e0d457ff7dd8b1 Mon Sep 17 00:00:00 2001 From: Douglas Crosher Date: Sun, 8 Dec 2013 17:39:21 +1100 Subject: [PATCH 09/19] Bug 947687 - Fix jit-tests remote harness push of tests/* to remote device. r=dminor --- js/src/tests/lib/jittests.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/js/src/tests/lib/jittests.py b/js/src/tests/lib/jittests.py index 650707f9b630..7998437b7166 100755 --- a/js/src/tests/lib/jittests.py +++ b/js/src/tests/lib/jittests.py @@ -661,8 +661,7 @@ def run_tests_remote(tests, prefix, options): Test.CacheDir = posixpath.join(options.remote_test_root, '.js-cache') dm.mkDir(Test.CacheDir) - for path in os.listdir(JS_TESTS_DIR): - dm.pushDir(os.path.join(JS_TESTS_DIR, path), posixpath.join(jit_tests_dir, 'tests', path)) + dm.pushDir(JS_TESTS_DIR, posixpath.join(jit_tests_dir, 'tests'), timeout=600) dm.pushDir(os.path.dirname(TEST_DIR), options.remote_test_root, timeout=600) prefix[0] = os.path.join(options.remote_test_root, 'js') From 7f5769b8857a596ee21bdcacd26e3fae27934837 Mon Sep 17 00:00:00 2001 From: Patrick Wang Date: Fri, 29 Nov 2013 17:28:54 +0800 Subject: [PATCH 10/19] Bug 944665: Part 1: Move common initialization routine into a function. r=khuey --- dom/ipc/ContentParent.cpp | 188 +++++++++++++++++++++----------------- dom/ipc/ContentParent.h | 5 + 2 files changed, 107 insertions(+), 86 deletions(-) diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 8e21165c8157..3530938b25b1 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -1249,93 +1249,13 @@ ContentParent::ContentParent(mozIApplication* aApp, Open(mSubprocess->GetChannel(), mSubprocess->GetOwnedChildProcessHandle()); - // Set the subprocess's priority. We do this early on because we're likely - // /lowering/ the process's CPU and memory priority, which it has inherited - // from this process. - // - // This call can cause us to send IPC messages to the child process, so it - // must come after the Open() call above. - ProcessPriorityManager::SetProcessPriority(this, aInitialPriority); - - // NB: internally, this will send an IPC message to the child - // process to get it to create the CompositorChild. This - // message goes through the regular IPC queue for this - // channel, so delivery will happen-before any other messages - // we send. The CompositorChild must be created before any - // PBrowsers are created, because they rely on the Compositor - // already being around. (Creation is async, so can't happen - // on demand.) - bool useOffMainThreadCompositing = !!CompositorParent::CompositorLoop(); - if (useOffMainThreadCompositing) { - DebugOnly opened = PCompositor::Open(this); - MOZ_ASSERT(opened); - - if (Preferences::GetBool("layers.async-video.enabled",false)) { - opened = PImageBridge::Open(this); - MOZ_ASSERT(opened); - } - } - - nsCOMPtr registrySvc = nsChromeRegistry::GetService(); - nsChromeRegistryChrome* chromeRegistry = - static_cast(registrySvc.get()); - chromeRegistry->SendRegisteredChrome(this); - mMessageManager = nsFrameMessageManager::NewProcessMessageManager(this); - - if (gAppData) { - nsCString version(gAppData->version); - nsCString buildID(gAppData->buildID); - nsCString name(gAppData->name); - nsCString UAName(gAppData->UAName); - - // Sending all information to content process. - unused << SendAppInfo(version, buildID, name, UAName); - } - - nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance(); - if (sheetService) { - // This looks like a lot of work, but in a normal browser session we just - // send two loads. - - nsCOMArray& agentSheets = *sheetService->AgentStyleSheets(); - for (uint32_t i = 0; i < agentSheets.Length(); i++) { - URIParams uri; - SerializeURI(agentSheets[i]->GetSheetURI(), uri); - unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::AGENT_SHEET); - } - - nsCOMArray& userSheets = *sheetService->UserStyleSheets(); - for (uint32_t i = 0; i < userSheets.Length(); i++) { - URIParams uri; - SerializeURI(userSheets[i]->GetSheetURI(), uri); - unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::USER_SHEET); - } - - nsCOMArray& authorSheets = *sheetService->AuthorStyleSheets(); - for (uint32_t i = 0; i < authorSheets.Length(); i++) { - URIParams uri; - SerializeURI(authorSheets[i]->GetSheetURI(), uri); - unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::AUTHOR_SHEET); - } - } - -#ifdef MOZ_CONTENT_SANDBOX - // Bug 921817. We enable the sandbox in RecvSetProcessPrivileges, - // which is where a preallocated process drops unnecessary privileges, - // but a non-preallocated process will already have changed its - // uid/gid/etc immediately after forking. Thus, we send this message, - // which is otherwise a no-op, to sandbox it at an appropriate point - // during startup. - if (aOSPrivileges != base::PRIVILEGES_INHERIT) { - if (!SendSetProcessPrivileges(base::PRIVILEGES_INHERIT)) { - KillHard(); - } - } -#endif + InitInternal(aInitialPriority, + true, /* Setup off-main thread compositing */ + true /* Send registered chrome */); } #ifdef MOZ_NUWA_PROCESS -static const FileDescriptor* +static const mozilla::ipc::FileDescriptor* FindFdProtocolFdMapping(const nsTArray& aFds, ProtocolId aProtoId) { @@ -1401,8 +1321,9 @@ ContentParent::ContentParent(ContentParent* aTemplate, priority = PROCESS_PRIORITY_FOREGROUND; } - ProcessPriorityManager::SetProcessPriority(this, priority); - mMessageManager = nsFrameMessageManager::NewProcessMessageManager(this); + InitInternal(priority, + false, /* Setup Off-main thread compositing */ + false /* Send registered chrome */); } #endif // MOZ_NUWA_PROCESS @@ -1432,6 +1353,101 @@ ContentParent::~ContentParent() } } +void +ContentParent::InitInternal(ProcessPriority aInitialPriority, + bool aSetupOffMainThreadCompositing, + bool aSendRegisteredChrome) +{ + // Set the subprocess's priority. We do this early on because we're likely + // /lowering/ the process's CPU and memory priority, which it has inherited + // from this process. + // + // This call can cause us to send IPC messages to the child process, so it + // must come after the Open() call above. + ProcessPriorityManager::SetProcessPriority(this, aInitialPriority); + + if (aSetupOffMainThreadCompositing) { + // NB: internally, this will send an IPC message to the child + // process to get it to create the CompositorChild. This + // message goes through the regular IPC queue for this + // channel, so delivery will happen-before any other messages + // we send. The CompositorChild must be created before any + // PBrowsers are created, because they rely on the Compositor + // already being around. (Creation is async, so can't happen + // on demand.) + bool useOffMainThreadCompositing = !!CompositorParent::CompositorLoop(); + if (useOffMainThreadCompositing) { + DebugOnly opened = PCompositor::Open(this); + MOZ_ASSERT(opened); + + if (Preferences::GetBool("layers.async-video.enabled",false)) { + opened = PImageBridge::Open(this); + MOZ_ASSERT(opened); + } + } + } + + if (aSendRegisteredChrome) { + nsCOMPtr registrySvc = nsChromeRegistry::GetService(); + nsChromeRegistryChrome* chromeRegistry = + static_cast(registrySvc.get()); + chromeRegistry->SendRegisteredChrome(this); + } + + mMessageManager = nsFrameMessageManager::NewProcessMessageManager(this); + + if (gAppData) { + nsCString version(gAppData->version); + nsCString buildID(gAppData->buildID); + nsCString name(gAppData->name); + nsCString UAName(gAppData->UAName); + + // Sending all information to content process. + unused << SendAppInfo(version, buildID, name, UAName); + } + + nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance(); + if (sheetService) { + // This looks like a lot of work, but in a normal browser session we just + // send two loads. + + nsCOMArray& agentSheets = *sheetService->AgentStyleSheets(); + for (uint32_t i = 0; i < agentSheets.Length(); i++) { + URIParams uri; + SerializeURI(agentSheets[i]->GetSheetURI(), uri); + unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::AGENT_SHEET); + } + + nsCOMArray& userSheets = *sheetService->UserStyleSheets(); + for (uint32_t i = 0; i < userSheets.Length(); i++) { + URIParams uri; + SerializeURI(userSheets[i]->GetSheetURI(), uri); + unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::USER_SHEET); + } + + nsCOMArray& authorSheets = *sheetService->AuthorStyleSheets(); + for (uint32_t i = 0; i < authorSheets.Length(); i++) { + URIParams uri; + SerializeURI(authorSheets[i]->GetSheetURI(), uri); + unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::AUTHOR_SHEET); + } + } + +#ifdef MOZ_CONTENT_SANDBOX + // Bug 921817. We enable the sandbox in RecvSetProcessPrivileges, + // which is where a preallocated process drops unnecessary privileges, + // but a non-preallocated process will already have changed its + // uid/gid/etc immediately after forking. Thus, we send this message, + // which is otherwise a no-op, to sandbox it at an appropriate point + // during startup. + if (mOSPrivileges != base::PRIVILEGES_INHERIT) { + if (!SendSetProcessPrivileges(base::PRIVILEGES_INHERIT)) { + KillHard(); + } + } +#endif +} + bool ContentParent::IsAlive() { diff --git a/dom/ipc/ContentParent.h b/dom/ipc/ContentParent.h index b70b5616165e..5e64ed2b5561 100644 --- a/dom/ipc/ContentParent.h +++ b/dom/ipc/ContentParent.h @@ -265,6 +265,11 @@ private: // The common initialization for the constructors. void InitializeMembers(); + // The common initialization logic shared by all constuctors. + void InitInternal(ProcessPriority aPriority, + bool aSetupOffMainThreadCompositing, + bool aSendRegisteredChrome); + virtual ~ContentParent(); void Init(); From b8a63f9739d67520f9d7c39d50e13122e7215b32 Mon Sep 17 00:00:00 2001 From: Patrick Wang Date: Fri, 29 Nov 2013 17:28:54 +0800 Subject: [PATCH 11/19] Bug 944665: Part 2: Call PreloadSlowThings after Nuwa fork. r=khuey --- dom/ipc/ContentChild.cpp | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index 082d23670939..5e9bc6b1defb 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -1348,17 +1348,6 @@ PreloadSlowThings() TabChild::PreloadSlowThings(); -#ifdef MOZ_NUWA_PROCESS - // After preload of slow things, start freezing threads. - if (IsNuwaProcess()) { - // Perform GC before freezing the Nuwa process to reduce memory usage. - ContentChild::GetSingleton()->RecvGarbageCollect(); - - MessageLoop::current()-> - PostTask(FROM_HERE, - NewRunnableFunction(OnFinishNuwaPreparation)); - } -#endif } bool @@ -1369,15 +1358,32 @@ ContentChild::RecvAppInfo(const nsCString& version, const nsCString& buildID, mAppInfo.buildID.Assign(buildID); mAppInfo.name.Assign(name); mAppInfo.UAName.Assign(UAName); + + if (!Preferences::GetBool("dom.ipc.processPrelaunch.enabled", false)) { + return true; + } + // If we're part of the mozbrowser machinery, go ahead and start // preloading things. We can only do this for mozbrowser because // PreloadSlowThings() may set the docshell of the first TabChild // inactive, and we can only safely restore it to active from // BrowserElementChild.js. - if ((mIsForApp || mIsForBrowser) && - Preferences::GetBool("dom.ipc.processPrelaunch.enabled", false)) { + if ((mIsForApp || mIsForBrowser) +#ifdef MOZ_NUWA_PROCESS + && !IsNuwaProcess() +#endif + ) { PreloadSlowThings(); } + +#ifdef MOZ_NUWA_PROCESS + if (IsNuwaProcess()) { + ContentChild::GetSingleton()->RecvGarbageCollect(); + MessageLoop::current()->PostTask( + FROM_HERE, NewRunnableFunction(OnFinishNuwaPreparation)); + } +#endif + return true; } From b2f15c3309e6828cc94eb3269e16a921b66b6d72 Mon Sep 17 00:00:00 2001 From: Patrick Wang Date: Thu, 24 Oct 2013 21:49:49 +0800 Subject: [PATCH 12/19] Bug 922465: Automated test for nuwa process. r=khuey --- dom/ipc/PreallocatedProcessManager.cpp | 17 ++++ dom/ipc/tests/mochitest.ini | 2 + dom/ipc/tests/moz.build | 1 + dom/ipc/tests/test_NuwaProcessCreation.html | 99 +++++++++++++++++++++ 4 files changed, 119 insertions(+) create mode 100644 dom/ipc/tests/mochitest.ini create mode 100644 dom/ipc/tests/test_NuwaProcessCreation.html diff --git a/dom/ipc/PreallocatedProcessManager.cpp b/dom/ipc/PreallocatedProcessManager.cpp index 6322a7342d7e..404a8d703d86 100644 --- a/dom/ipc/PreallocatedProcessManager.cpp +++ b/dom/ipc/PreallocatedProcessManager.cpp @@ -281,6 +281,15 @@ PreallocatedProcessManagerImpl::PublishSpareProcess(ContentParent* aContent) { MOZ_ASSERT(NS_IsMainThread()); + if (Preferences::GetBool("dom.ipc.processPriorityManager.testMode")) { + AutoJSContext cx; + nsCOMPtr ppmm = + do_GetService("@mozilla.org/parentprocessmessagemanager;1"); + nsresult rv = ppmm->BroadcastAsyncMessage( + NS_LITERAL_STRING("TEST-ONLY:nuwa-add-new-process"), + JSVAL_NULL, JSVAL_NULL, cx, 1); + } + if (!mNuwaForkWaitTasks.IsEmpty()) { mNuwaForkWaitTasks.ElementAt(0)->Cancel(); mNuwaForkWaitTasks.RemoveElementAt(0); @@ -312,6 +321,14 @@ PreallocatedProcessManagerImpl::OnNuwaReady() ProcessPriorityManager::SetProcessPriority(mPreallocatedAppProcess, hal::PROCESS_PRIORITY_FOREGROUND); mIsNuwaReady = true; + if (Preferences::GetBool("dom.ipc.processPriorityManager.testMode")) { + AutoJSContext cx; + nsCOMPtr ppmm = + do_GetService("@mozilla.org/parentprocessmessagemanager;1"); + nsresult rv = ppmm->BroadcastAsyncMessage( + NS_LITERAL_STRING("TEST-ONLY:nuwa-ready"), + JSVAL_NULL, JSVAL_NULL, cx, 1); + } NuwaFork(); } diff --git a/dom/ipc/tests/mochitest.ini b/dom/ipc/tests/mochitest.ini new file mode 100644 index 000000000000..2f594dd8c012 --- /dev/null +++ b/dom/ipc/tests/mochitest.ini @@ -0,0 +1,2 @@ +[test_NuwaProcessCreation.html] +run-if = toolkit == 'gonk' diff --git a/dom/ipc/tests/moz.build b/dom/ipc/tests/moz.build index 87c88dfddbc5..5244ac16b12d 100644 --- a/dom/ipc/tests/moz.build +++ b/dom/ipc/tests/moz.build @@ -5,4 +5,5 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. MOCHITEST_CHROME_MANIFESTS += ['chrome.ini'] +MOCHITEST_MANIFESTS += ['mochitest.ini'] diff --git a/dom/ipc/tests/test_NuwaProcessCreation.html b/dom/ipc/tests/test_NuwaProcessCreation.html new file mode 100644 index 000000000000..55c7e1636a05 --- /dev/null +++ b/dom/ipc/tests/test_NuwaProcessCreation.html @@ -0,0 +1,99 @@ + + + + + + + + + + + + From df57fe71d054479589acbaf1081d10e0d2423826 Mon Sep 17 00:00:00 2001 From: Patrick Wang Date: Tue, 15 Oct 2013 17:43:08 +0800 Subject: [PATCH 13/19] Bug 930282: Part 1: Enable Nuwa by default. r=khuey --- b2g/confvars.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/b2g/confvars.sh b/b2g/confvars.sh index 0f9e63d0402c..c5cf779db8eb 100644 --- a/b2g/confvars.sh +++ b/b2g/confvars.sh @@ -56,7 +56,9 @@ MOZ_TOOLKIT_SEARCH= MOZ_PLACES= MOZ_B2G=1 -#MOZ_NUWA_PROCESS=1 +if test "$OS_TARGET" = "Android"; then +MOZ_NUWA_PROCESS=1 +fi MOZ_FOLD_LIBS=1 MOZ_JSDOWNLOADS=1 From 7ce480d3542252f6fc0558d43805aa94aecd380c Mon Sep 17 00:00:00 2001 From: Cervantes Yu Date: Tue, 15 Oct 2013 17:43:08 +0800 Subject: [PATCH 14/19] Bug 930282: Part 2: Mark PACMan thread and BackgroundHangMonitor thread. r=khuey --- netwerk/base/src/nsPACMan.cpp | 10 ++++++++++ xpcom/threads/BackgroundHangMonitor.cpp | 12 ++++++++++++ 2 files changed, 22 insertions(+) diff --git a/netwerk/base/src/nsPACMan.cpp b/netwerk/base/src/nsPACMan.cpp index 3b739701b0e8..98431e7373e1 100644 --- a/netwerk/base/src/nsPACMan.cpp +++ b/netwerk/base/src/nsPACMan.cpp @@ -14,6 +14,9 @@ #include "nsNetUtil.h" #include "nsIAsyncVerifyRedirectCallback.h" #include "nsISystemProxySettings.h" +#ifdef MOZ_NUWA_PROCESS +#include "ipc/Nuwa.h" +#endif //----------------------------------------------------------------------------- using namespace mozilla; @@ -674,6 +677,13 @@ nsPACMan::NamePACThread() { NS_ABORT_IF_FALSE(!NS_IsMainThread(), "wrong thread"); PR_SetCurrentThreadName("Proxy Resolution"); +#ifdef MOZ_NUWA_PROCESS + if (IsNuwaProcess()) { + NS_ASSERTION(NuwaMarkCurrentThread != nullptr, + "NuwaMarkCurrentThread is undefined!"); + NuwaMarkCurrentThread(nullptr, nullptr); + } +#endif } nsresult diff --git a/xpcom/threads/BackgroundHangMonitor.cpp b/xpcom/threads/BackgroundHangMonitor.cpp index a56b34bea873..723c481640a7 100644 --- a/xpcom/threads/BackgroundHangMonitor.cpp +++ b/xpcom/threads/BackgroundHangMonitor.cpp @@ -11,6 +11,9 @@ #include "mozilla/Telemetry.h" #include "mozilla/ThreadHangStats.h" #include "mozilla/ThreadLocal.h" +#ifdef MOZ_NUWA_PROCESS +#include "ipc/Nuwa.h" +#endif #include "prinrval.h" #include "prthread.h" @@ -31,6 +34,15 @@ private: static void MonitorThread(void* aData) { PR_SetCurrentThreadName("BgHangManager"); + +#ifdef MOZ_NUWA_PROCESS + if (IsNuwaProcess()) { + NS_ASSERTION(NuwaMarkCurrentThread != nullptr, + "NuwaMarkCurrentThread is undefined!"); + NuwaMarkCurrentThread(nullptr, nullptr); + } +#endif + /* We do not hold a reference to BackgroundHangManager here because the monitor thread only exists as long as the BackgroundHangManager instance exists. We stop the monitor From 7069e9193ccff4c60c7c2973a21c7a4204bd7f8a Mon Sep 17 00:00:00 2001 From: Patrick Wang Date: Mon, 9 Dec 2013 22:42:48 +0800 Subject: [PATCH 15/19] Bug 930282: Part 3: Don't fork after xpcom shutdown. r=khuey --- dom/ipc/PreallocatedProcessManager.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dom/ipc/PreallocatedProcessManager.cpp b/dom/ipc/PreallocatedProcessManager.cpp index 404a8d703d86..898663c004f8 100644 --- a/dom/ipc/PreallocatedProcessManager.cpp +++ b/dom/ipc/PreallocatedProcessManager.cpp @@ -88,6 +88,7 @@ private: void ObserveProcessShutdown(nsISupports* aSubject); bool mEnabled; + bool mShutdown; nsRefPtr mPreallocatedAppProcess; }; @@ -114,6 +115,7 @@ PreallocatedProcessManagerImpl::PreallocatedProcessManagerImpl() , mPreallocateAppProcessTask(nullptr) , mIsNuwaReady(false) #endif + , mShutdown(false) {} void @@ -124,6 +126,8 @@ PreallocatedProcessManagerImpl::Init() if (os) { os->AddObserver(this, "ipc:content-shutdown", /* weakRef = */ false); + os->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, + /* weakRef = */ false); } RereadPrefs(); } @@ -138,6 +142,8 @@ PreallocatedProcessManagerImpl::Observe(nsISupports* aSubject, } else if (!strcmp("nsPref:changed", aTopic)) { // The only other observer we registered was for our prefs. RereadPrefs(); + } else if (!strcmp(NS_XPCOM_SHUTDOWN_OBSERVER_ID, aTopic)) { + mShutdown = true; } else { MOZ_ASSERT(false); } @@ -240,7 +246,7 @@ PreallocatedProcessManagerImpl::DelayedNuwaFork() mPreallocateAppProcessTask = nullptr; if (!mIsNuwaReady) { - if (!mPreallocatedAppProcess) { + if (!mPreallocatedAppProcess && !mShutdown) { mPreallocatedAppProcess = ContentParent::RunNuwaProcess(); } // else mPreallocatedAppProcess is starting. It will NuwaFork() when ready. From fbf71b8c7cd9a7ae292f23df851465bdf97154ff Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Mon, 9 Dec 2013 11:50:23 -0800 Subject: [PATCH 16/19] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/0f6e26b5cac9 Author: Gregor Wagner Desc: Merge pull request #14509 from etiennesegonzac/bug-946769-edge-gesture-intermittent Bug 946769 - Trying to fix the egde gesture marionette test intermittent ======== https://hg.mozilla.org/integration/gaia-central/rev/81b96ac56ca3 Author: Etienne Segonzac Desc: Bug 946769 - Trying to fix the egde gesture marionette test intermittent by properly waiting for the end of the last app-opening transition. --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 263f214b6c10..21605a60169e 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "f8d3d0e31a201137e53f447d2518f93529bd7b4c", + "revision": "0f6e26b5cac949ece61366265c2f9988bae827c6", "repo_path": "/integration/gaia-central" } From c9298d6745a1f9bee9e142cbe2f3e90308ad7190 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Mon, 9 Dec 2013 12:25:30 -0800 Subject: [PATCH 17/19] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/accec2f4e2c8 Author: Gregor Wagner Desc: Merge pull request #14479 from gregorwagner/disable No Bug - Disable intermittent failures ======== https://hg.mozilla.org/integration/gaia-central/rev/108ef7a4ce0d Author: Gregor Wagner Desc: Disable failing tests --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 21605a60169e..9d8006eed245 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "0f6e26b5cac949ece61366265c2f9988bae827c6", + "revision": "accec2f4e2c8cc463f3f255aa6e21e5669578fc2", "repo_path": "/integration/gaia-central" } From fa1d8e0a48712644255cd8c28de0e135b2727bd7 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Mon, 9 Dec 2013 13:00:39 -0800 Subject: [PATCH 18/19] Bumping gaia.json for 1 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/d5f4a104c0b7 Author: John Ford Desc: Revert "Bug 944718 - [Cost Control] Broken access to usage widget from utility tray" This reverts commit 31bbe151e0d92da77a86a3ae5edb6ca2643968e1. This is the second time this patch has been backed out. https://bugzilla.mozilla.org/show_bug.cgi?id=944718 --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 9d8006eed245..08e70b618f41 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "accec2f4e2c8cc463f3f255aa6e21e5669578fc2", + "revision": "d5f4a104c0b79b8fe13b7883dd531249ed251146", "repo_path": "/integration/gaia-central" } From 842741608ddc2d2128bec54de1c96699ada059bc Mon Sep 17 00:00:00 2001 From: Reuben Morais Date: Mon, 9 Dec 2013 19:01:42 -0200 Subject: [PATCH 19/19] Bug 697343 - Create the results array in the content scope. r=bz --HG-- extra : rebase_source : ae7ae1873dc1f074942858c4d37e3d5916e42223 --- dom/contacts/ContactManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dom/contacts/ContactManager.js b/dom/contacts/ContactManager.js index 8042325cfde4..81232a3a6d97 100644 --- a/dom/contacts/ContactManager.js +++ b/dom/contacts/ContactManager.js @@ -400,7 +400,7 @@ ContactManager.prototype = { }, _convertContacts: function(aContacts) { - let contacts = []; + let contacts = new this._window.Array(); for (let i in aContacts) { contacts.push(this._convertContact(aContacts[i])); }