2019-01-11 23:55:07 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_net_SocketProcessBridgeChild_h
|
|
|
|
#define mozilla_net_SocketProcessBridgeChild_h
|
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
#include "mozilla/net/PSocketProcessBridgeChild.h"
|
|
|
|
#include "nsIObserver.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace net {
|
|
|
|
|
|
|
|
// The IPC actor implements PSocketProcessBridgeChild in content process.
|
|
|
|
// This is allocated and kept alive by NeckoChild. When "content-child-shutdown"
|
|
|
|
// topic is observed, this actor will be destroyed.
|
|
|
|
class SocketProcessBridgeChild final : public PSocketProcessBridgeChild,
|
|
|
|
public nsIObserver {
|
|
|
|
public:
|
2019-07-15 18:49:30 +03:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2019-01-11 23:55:07 +03:00
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
|
2019-01-11 23:56:39 +03:00
|
|
|
static already_AddRefed<SocketProcessBridgeChild> GetSingleton();
|
2019-02-26 00:50:42 +03:00
|
|
|
typedef MozPromise<RefPtr<SocketProcessBridgeChild>, nsCString, false>
|
|
|
|
GetPromise;
|
|
|
|
static RefPtr<GetPromise> GetSocketProcessBridge();
|
2019-01-11 23:55:07 +03:00
|
|
|
|
2019-02-06 18:58:43 +03:00
|
|
|
mozilla::ipc::IPCResult RecvTest();
|
2019-01-11 23:55:07 +03:00
|
|
|
void ActorDestroy(ActorDestroyReason aWhy) override;
|
|
|
|
void DeferredDestroy();
|
2019-01-11 23:56:39 +03:00
|
|
|
bool IsShuttingDown() const { return mShuttingDown; };
|
2019-01-11 23:55:07 +03:00
|
|
|
bool Inited() const { return mInited; };
|
2019-01-11 23:56:39 +03:00
|
|
|
ProcessId SocketProcessPid() const { return mSocketProcessPid; };
|
2019-01-11 23:55:07 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(SocketProcessBridgeChild);
|
2019-02-26 00:50:42 +03:00
|
|
|
static bool Create(Endpoint<PSocketProcessBridgeChild>&& aEndpoint);
|
2019-01-11 23:55:07 +03:00
|
|
|
explicit SocketProcessBridgeChild(
|
|
|
|
Endpoint<PSocketProcessBridgeChild>&& aEndpoint);
|
|
|
|
virtual ~SocketProcessBridgeChild();
|
|
|
|
|
|
|
|
static StaticRefPtr<SocketProcessBridgeChild> sSocketProcessBridgeChild;
|
2019-01-11 23:56:39 +03:00
|
|
|
bool mShuttingDown;
|
2019-01-11 23:55:07 +03:00
|
|
|
bool mInited = false;
|
2019-01-11 23:56:39 +03:00
|
|
|
ProcessId mSocketProcessPid;
|
2019-01-11 23:55:07 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace net
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_net_SocketProcessBridgeChild_h
|