gecko/dom/network/TCPServerSocketParent.h
Andrew Sutherland 546c79ec45 Bug 1087145 - Move mozTCPSocket/TCPSocket unit tests from xpcshell tests to mochitest-plain tests. r=jdm
Most of the TCPSocket and TCPServerSocket coverage was implemented exclusively
in Chrome-privileged xpcshell tests.  This failed to provide coverage for the
key use case of content-privileged code using TCPSocket.

This cleans up the test implementation and migrates them to mochitests.
Coverage is improved as evidenced by two tested TCPServerSocket issues that were
addressed in this patch:
- ArrayBuffers weren't being created in the content page's context, so
  exceptions would be thrown when accessed.
- 'drain' notifications were not being hooked up.

The following fix that lacks coverage that notices the fix was implemented:
- TCPServerSocket now properly propagates the appId for network usage tracking.
2014-10-29 22:03:54 -04:00

52 lines
1.4 KiB
C++

/* 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/. */
#include "mozilla/net/PNeckoParent.h"
#include "mozilla/net/PTCPServerSocketParent.h"
#include "nsITCPSocketParent.h"
#include "nsITCPServerSocketParent.h"
#include "nsCycleCollectionParticipant.h"
#include "nsCOMPtr.h"
#include "nsIDOMTCPSocket.h"
namespace mozilla {
namespace dom {
class PBrowserParent;
class TCPServerSocketParent : public mozilla::net::PTCPServerSocketParent
, public nsITCPServerSocketParent
{
public:
NS_DECL_CYCLE_COLLECTION_CLASS(TCPServerSocketParent)
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_NSITCPSERVERSOCKETPARENT
TCPServerSocketParent() : mNeckoParent(nullptr), mIPCOpen(false) {}
bool Init(PNeckoParent* neckoParent, const uint16_t& aLocalPort, const uint16_t& aBacklog,
const nsString& aBinaryType);
virtual bool RecvClose() MOZ_OVERRIDE;
virtual bool RecvRequestDelete() MOZ_OVERRIDE;
uint32_t GetAppId();
void AddIPDLReference();
void ReleaseIPDLReference();
private:
~TCPServerSocketParent() {}
virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
PNeckoParent* mNeckoParent;
nsCOMPtr<nsITCPSocketIntermediary> mIntermediary;
nsCOMPtr<nsIDOMTCPServerSocket> mServerSocket;
bool mIPCOpen;
};
} // namespace dom
} // namespace mozilla