Skip to content

Commit

Permalink
Bug 1648141 - IPCBlobInputStream to RemoteLazyInputStream - part 8 - …
Browse files Browse the repository at this point in the history
…mozilla namespace, r=smaug,necko-reviewers,dragana

Differential Revision: https://phabricator.services.mozilla.com/D80931
  • Loading branch information
bakulf committed Jun 29, 2020
1 parent 7e63b7b commit c333ede
Show file tree
Hide file tree
Showing 29 changed files with 103 additions and 125 deletions.
2 changes: 1 addition & 1 deletion dom/fetch/InternalRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
#include "mozilla/ErrorResult.h"
#include "mozilla/dom/Document.h"
#include "mozilla/dom/FetchTypes.h"
#include "mozilla/dom/RemoteLazyInputStreamChild.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/WorkerCommon.h"
#include "mozilla/dom/WorkerPrivate.h"
#include "mozilla/ipc/IPCStreamUtils.h"
#include "mozilla/ipc/PBackgroundChild.h"
#include "mozilla/RemoteLazyInputStreamChild.h"
#include "nsIContentPolicy.h"
#include "nsStreamUtils.h"

Expand Down
2 changes: 1 addition & 1 deletion dom/fetch/InternalResponse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
#include "mozilla/dom/FetchTypes.h"
#include "mozilla/dom/InternalHeaders.h"
#include "mozilla/dom/cache/CacheTypes.h"
#include "mozilla/dom/RemoteLazyInputStreamStorage.h"
#include "mozilla/ipc/PBackgroundSharedTypes.h"
#include "mozilla/ipc/IPCStreamUtils.h"
#include "mozilla/RandomNum.h"
#include "mozilla/RemoteLazyInputStreamStorage.h"
#include "nsIRandomGenerator.h"
#include "nsStreamUtils.h"

Expand Down
21 changes: 11 additions & 10 deletions dom/file/ipc/IPCBlob.ipdlh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ using struct mozilla::void_t
from "ipc/IPCMessageUtils.h";

namespace mozilla {

union RemoteLazyStream
{
// Parent to Child: The child will receive a RemoteLazyInputStream. Nothing
// can be done with it except retrieving the size.
PRemoteLazyInputStream;

// Child to Parent: Normal serialization.
IPCStream;
};

namespace dom {

// This contains any extra bit for making a File out of a Blob.
Expand All @@ -30,16 +41,6 @@ struct IPCFile
bool isDirectory;
};

union RemoteLazyStream
{
// Parent to Child: The child will receive a RemoteLazyInputStream. Nothing
// can be done with it except retrieving the size.
PRemoteLazyInputStream;

// Child to Parent: Normal serialization.
IPCStream;
};

struct IPCBlob
{
nsString type;
Expand Down
3 changes: 0 additions & 3 deletions dom/file/ipc/PRemoteLazyInputStream.ipdl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ include protocol PSocketProcess;
include IPCStream;

namespace mozilla {
namespace dom {

refcounted protocol PRemoteLazyInputStream
{
Expand Down Expand Up @@ -44,6 +43,4 @@ both:
async __delete__();
};

} // namespace dom
} // namespace mozilla

4 changes: 1 addition & 3 deletions dom/file/ipc/RemoteLazyInputStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@

namespace mozilla {

using namespace dom;
using net::SocketProcessParent;

namespace dom {

class RemoteLazyInputStream;

namespace {
Expand Down Expand Up @@ -955,5 +954,4 @@ void RemoteLazyInputStream::LengthReady(int64_t aLength) {
}
}

} // namespace dom
} // namespace mozilla
8 changes: 3 additions & 5 deletions dom/file/ipc/RemoteLazyInputStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* 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 mozilla_dom_RemoteLazyInputStream_h
#define mozilla_dom_RemoteLazyInputStream_h
#ifndef mozilla_RemoteLazyInputStream_h
#define mozilla_RemoteLazyInputStream_h

#include "mozilla/Mutex.h"
#include "mozIRemoteLazyInputStream.h"
Expand All @@ -17,7 +17,6 @@
#include "nsCOMPtr.h"

namespace mozilla {
namespace dom {

class RemoteLazyInputStreamChild;

Expand Down Expand Up @@ -126,7 +125,6 @@ class RemoteLazyInputStream final : public nsIAsyncInputStream,
Mutex mMutex;
};

} // namespace dom
} // namespace mozilla

#endif // mozilla_dom_RemoteLazyInputStream_h
#endif // mozilla_RemoteLazyInputStream_h
4 changes: 2 additions & 2 deletions dom/file/ipc/RemoteLazyInputStreamChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
#include "mozilla/dom/WorkerRef.h"

namespace mozilla {
namespace dom {

using namespace dom;

namespace {

Expand Down Expand Up @@ -436,5 +437,4 @@ void RemoteLazyInputStreamChild::Migrated() {
}
}

} // namespace dom
} // namespace mozilla
17 changes: 9 additions & 8 deletions dom/file/ipc/RemoteLazyInputStreamChild.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@
* 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 mozilla_dom_RemoteLazyInputStreamChild_h
#define mozilla_dom_RemoteLazyInputStreamChild_h
#ifndef mozilla_RemoteLazyInputStreamChild_h
#define mozilla_RemoteLazyInputStreamChild_h

#include "mozilla/dom/PRemoteLazyInputStreamChild.h"
#include "mozilla/dom/RemoteLazyInputStream.h"
#include "mozilla/PRemoteLazyInputStreamChild.h"
#include "mozilla/RemoteLazyInputStream.h"
#include "mozilla/Mutex.h"
#include "mozilla/UniquePtr.h"
#include "nsTArray.h"

namespace mozilla {
namespace dom {

class RemoteLazyInputStream;

namespace dom {
class ThreadSafeWorkerRef;
}

class RemoteLazyInputStreamChild final : public PRemoteLazyInputStreamChild {
public:
Expand Down Expand Up @@ -96,10 +98,9 @@ class RemoteLazyInputStreamChild final : public PRemoteLazyInputStreamChild {

nsCOMPtr<nsISerialEventTarget> mOwningEventTarget;

RefPtr<ThreadSafeWorkerRef> mWorkerRef;
RefPtr<dom::ThreadSafeWorkerRef> mWorkerRef;
};

} // namespace dom
} // namespace mozilla

#endif // mozilla_dom_RemoteLazyInputStreamChild_h
#endif // mozilla_RemoteLazyInputStreamChild_h
2 changes: 0 additions & 2 deletions dom/file/ipc/RemoteLazyInputStreamParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "RemoteLazyInputStreamStorage.h"

namespace mozilla {
namespace dom {

template <typename M>
/* static */
Expand Down Expand Up @@ -227,5 +226,4 @@ bool RemoteLazyInputStreamParent::HasValidStream() const {
return RemoteLazyInputStreamStorage::Get()->HasStream(mID);
}

} // namespace dom
} // namespace mozilla
19 changes: 10 additions & 9 deletions dom/file/ipc/RemoteLazyInputStreamParent.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,23 @@
* 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 mozilla_dom_RemoteLazyInputStreamParent_h
#define mozilla_dom_RemoteLazyInputStreamParent_h
#ifndef mozilla_RemoteLazyInputStreamParent_h
#define mozilla_RemoteLazyInputStreamParent_h

#include "mozilla/dom/PRemoteLazyInputStreamParent.h"
#include "mozilla/PRemoteLazyInputStreamParent.h"

class nsIInputStream;

namespace mozilla {

namespace dom {
class ContentParent;
}

namespace net {
class SocketProcessParent;
}

namespace dom {

class NS_NO_VTABLE RemoteLazyInputStreamParentCallback {
public:
virtual void ActorDestroyed(const nsID& aID) = 0;
Expand Down Expand Up @@ -69,7 +71,7 @@ class RemoteLazyInputStreamParent final : public PRemoteLazyInputStreamParent {

private:
RemoteLazyInputStreamParent(const nsID& aID, uint64_t aSize,
ContentParent* aManager);
mozilla::dom::ContentParent* aManager);

RemoteLazyInputStreamParent(const nsID& aID, uint64_t aSize,
mozilla::ipc::PBackgroundParent* aManager);
Expand All @@ -84,7 +86,7 @@ class RemoteLazyInputStreamParent final : public PRemoteLazyInputStreamParent {

// Only 1 of these is set. Raw pointer because these managers are keeping
// the parent actor alive. The pointers will be nullified in ActorDestroyed.
ContentParent* mContentManager;
mozilla::dom::ContentParent* mContentManager;
mozilla::ipc::PBackgroundParent* mPBackgroundManager;
mozilla::net::SocketProcessParent* mSocketProcessManager;

Expand All @@ -93,7 +95,6 @@ class RemoteLazyInputStreamParent final : public PRemoteLazyInputStreamParent {
bool mMigrating;
};

} // namespace dom
} // namespace mozilla

#endif // mozilla_dom_RemoteLazyInputStreamParent_h
#endif // mozilla_RemoteLazyInputStreamParent_h
3 changes: 0 additions & 3 deletions dom/file/ipc/RemoteLazyInputStreamStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ namespace mozilla {

using namespace hal;

namespace dom {

namespace {
StaticMutex gMutex;
StaticRefPtr<RemoteLazyInputStreamStorage> gStorage;
Expand Down Expand Up @@ -202,5 +200,4 @@ RemoteLazyInputStreamStorage::TakeCallback(const nsID& aID) {
return callback.forget();
}

} // namespace dom
} // namespace mozilla
8 changes: 3 additions & 5 deletions dom/file/ipc/RemoteLazyInputStreamStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* 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 mozilla_dom_RemoteLazyInputStreamStorage_h
#define mozilla_dom_RemoteLazyInputStreamStorage_h
#ifndef mozilla_RemoteLazyInputStreamStorage_h
#define mozilla_RemoteLazyInputStreamStorage_h

#include "mozilla/RefPtr.h"
#include "nsClassHashtable.h"
Expand All @@ -15,7 +15,6 @@ class nsIInputStream;
struct nsID;

namespace mozilla {
namespace dom {

class RemoteLazyInputStreamParentCallback;

Expand Down Expand Up @@ -65,7 +64,6 @@ class RemoteLazyInputStreamStorage final : public nsIObserver {
nsClassHashtable<nsIDHashKey, StreamData> mStorage;
};

} // namespace dom
} // namespace mozilla

#endif // mozilla_dom_RemoteLazyInputStreamStorage_h
#endif // mozilla_RemoteLazyInputStreamStorage_h
21 changes: 8 additions & 13 deletions dom/file/ipc/RemoteLazyInputStreamThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@

namespace mozilla {

using namespace ipc;

namespace dom {

namespace {

StaticMutex gRemoteLazyThreadMutex;
Expand All @@ -31,7 +27,7 @@ class ThreadInitializeRunnable final : public Runnable {

NS_IMETHOD
Run() override {
mozilla::StaticMutexAutoLock lock(gRemoteLazyThreadMutex);
StaticMutexAutoLock lock(gRemoteLazyThreadMutex);
MOZ_ASSERT(gRemoteLazyThread);
gRemoteLazyThread->InitializeOnMainThread();
return NS_OK;
Expand Down Expand Up @@ -86,13 +82,13 @@ bool RemoteLazyInputStreamThread::IsOnFileEventTarget(
return true;
}

mozilla::StaticMutexAutoLock lock(gRemoteLazyThreadMutex);
StaticMutexAutoLock lock(gRemoteLazyThreadMutex);
return gRemoteLazyThread && aEventTarget == gRemoteLazyThread->mThread;
}

/* static */
RemoteLazyInputStreamThread* RemoteLazyInputStreamThread::Get() {
mozilla::StaticMutexAutoLock lock(gRemoteLazyThreadMutex);
StaticMutexAutoLock lock(gRemoteLazyThreadMutex);

if (gShutdownHasStarted) {
return nullptr;
Expand All @@ -103,7 +99,7 @@ RemoteLazyInputStreamThread* RemoteLazyInputStreamThread::Get() {

/* static */
RemoteLazyInputStreamThread* RemoteLazyInputStreamThread::GetOrCreate() {
mozilla::StaticMutexAutoLock lock(gRemoteLazyThreadMutex);
StaticMutexAutoLock lock(gRemoteLazyThreadMutex);

if (gShutdownHasStarted) {
return nullptr;
Expand Down Expand Up @@ -166,7 +162,7 @@ RemoteLazyInputStreamThread::Observe(nsISupports* aSubject, const char* aTopic,
const char16_t* aData) {
MOZ_ASSERT(!strcmp(aTopic, NS_XPCOM_SHUTDOWN_THREADS_OBSERVER_ID));

mozilla::StaticMutexAutoLock lock(gRemoteLazyThreadMutex);
StaticMutexAutoLock lock(gRemoteLazyThreadMutex);

if (mThread) {
mThread->Shutdown();
Expand All @@ -183,7 +179,7 @@ void RemoteLazyInputStreamThread::MigrateActor(
RemoteLazyInputStreamChild* aActor) {
MOZ_ASSERT(aActor->State() == RemoteLazyInputStreamChild::eInactiveMigrating);

mozilla::StaticMutexAutoLock lock(gRemoteLazyThreadMutex);
StaticMutexAutoLock lock(gRemoteLazyThreadMutex);

if (gShutdownHasStarted) {
return;
Expand Down Expand Up @@ -221,7 +217,7 @@ RemoteLazyInputStreamThread::Dispatch(already_AddRefed<nsIRunnable> aRunnable,
uint32_t aFlags) {
nsCOMPtr<nsIRunnable> runnable(aRunnable);

mozilla::StaticMutexAutoLock lock(gRemoteLazyThreadMutex);
StaticMutexAutoLock lock(gRemoteLazyThreadMutex);

if (gShutdownHasStarted) {
return NS_ERROR_NOT_INITIALIZED;
Expand All @@ -244,7 +240,7 @@ RemoteLazyInputStreamThread::DelayedDispatch(already_AddRefed<nsIRunnable>,
}

bool IsOnDOMFileThread() {
mozilla::StaticMutexAutoLock lock(gRemoteLazyThreadMutex);
StaticMutexAutoLock lock(gRemoteLazyThreadMutex);

MOZ_ASSERT(!gShutdownHasStarted);
MOZ_ASSERT(gRemoteLazyThread);
Expand All @@ -254,5 +250,4 @@ bool IsOnDOMFileThread() {

void AssertIsOnDOMFileThread() { MOZ_ASSERT(IsOnDOMFileThread()); }

} // namespace dom
} // namespace mozilla
Loading

0 comments on commit c333ede

Please sign in to comment.