Backed out changesets fd74efe0b44a and eeac5917dda7 (bug 1099414) for bustage.

CLOSED TREE

--HG--
extra : amend_source : b201ff252d00bfdd48aff275e80115797248a2a1
This commit is contained in:
Ryan VanderMeulen 2015-01-24 13:55:02 -05:00
Родитель d8ae8d1c36
Коммит e1bc5a1e60
3 изменённых файлов: 14 добавлений и 110 удалений

Просмотреть файл

@ -693,57 +693,9 @@ abort:
return(_status);
}
NS_IMPL_ISUPPORTS(NrSocketIpcProxy, nsIUDPSocketInternal)
nsresult
NrSocketIpcProxy::Init(const nsRefPtr<NrSocketIpc>& socket)
{
nsresult rv;
sts_thread_ = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv)) {
MOZ_ASSERT(false, "Failed to get STS thread");
return rv;
}
socket_ = socket;
return NS_OK;
}
NrSocketIpcProxy::~NrSocketIpcProxy()
{
// Send our ref to STS to be released
RUN_ON_THREAD(sts_thread_,
mozilla::WrapRelease(socket_.forget()),
NS_DISPATCH_NORMAL);
}
// IUDPSocketInternal interfaces
// callback while error happened in UDP socket operation
NS_IMETHODIMP NrSocketIpcProxy::CallListenerError(const nsACString &message,
const nsACString &filename,
uint32_t line_number) {
return socket_->CallListenerError(message, filename, line_number);
}
// callback while receiving UDP packet
NS_IMETHODIMP NrSocketIpcProxy::CallListenerReceivedData(const nsACString &host,
uint16_t port,
const uint8_t *data,
uint32_t data_length) {
return socket_->CallListenerReceivedData(host, port, data, data_length);
}
// callback while UDP socket is opened
NS_IMETHODIMP NrSocketIpcProxy::CallListenerOpened() {
return socket_->CallListenerOpened();
}
// callback while UDP socket is closed
NS_IMETHODIMP NrSocketIpcProxy::CallListenerClosed() {
return socket_->CallListenerClosed();
}
// NrSocketIpc Implementation
NS_IMPL_ISUPPORTS(NrSocketIpc, nsIUDPSocketInternal)
NrSocketIpc::NrSocketIpc(const nsCOMPtr<nsIEventTarget> &main_thread)
: err_(false),
state_(NR_INIT),
@ -1070,15 +1022,7 @@ void NrSocketIpc::create_m(const nsACString &host, const uint16_t port) {
socket_child_ = new nsMainThreadPtrHolder<nsIUDPSocketChild>(socketChild);
socket_child_->SetFilterName(nsCString("stun"));
nsRefPtr<NrSocketIpcProxy> proxy(new NrSocketIpcProxy);
rv = proxy->Init(this);
if (NS_FAILED(rv)) {
err_ = true;
mon.NotifyAll();
return;
}
if (NS_FAILED(socket_child_->Bind(proxy, host, port,
if (NS_FAILED(socket_child_->Bind(this, host, port,
/* reuse = */ false,
/* loopback = */ false))) {
err_ = true;
@ -1163,7 +1107,7 @@ static nr_socket_vtbl nr_socket_local_vtbl={
};
int nr_socket_local_create(nr_transport_addr *addr, nr_socket **sockp) {
RefPtr<NrSocketBase> sock;
NrSocketBase *sock = nullptr;
// create IPC bridge for content process
if (XRE_GetProcessType() == GeckoProcessType_Default) {
@ -1185,12 +1129,15 @@ int nr_socket_local_create(nr_transport_addr *addr, nr_socket **sockp) {
if (r)
ABORT(r);
// Add a reference so that we can delete it in destroy()
sock->AddRef();
_status = 0;
// We will release this reference in destroy(), not exactly the normal
// ownership model, but it is what it is.
sock.forget().drop();
abort:
if (_status) {
delete sock;
}
return _status;
}

Просмотреть файл

@ -188,7 +188,8 @@ private:
DISALLOW_COPY_ASSIGN(nr_udp_message);
};
class NrSocketIpc : public NrSocketBase {
class NrSocketIpc : public NrSocketBase,
public nsIUDPSocketInternal {
public:
enum NrSocketIpcState {
@ -199,17 +200,8 @@ public:
NR_CLOSED,
};
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(NrSocketIpc)
NS_IMETHODIMP CallListenerError(const nsACString &message,
const nsACString &filename,
uint32_t line_number);
NS_IMETHODIMP CallListenerReceivedData(const nsACString &host,
uint16_t port,
const uint8_t *data,
uint32_t data_length);
NS_IMETHODIMP CallListenerOpened();
NS_IMETHODIMP CallListenerClosed();
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIUDPSOCKETINTERNAL
explicit NrSocketIpc(const nsCOMPtr<nsIEventTarget> &main_thread);
@ -248,22 +240,6 @@ private:
ReentrantMonitor monitor_;
};
// The socket child holds onto one of these, which just passes callbacks
// through and makes sure the ref to the NrSocketIpc is released on STS.
class NrSocketIpcProxy : public nsIUDPSocketInternal {
public:
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIUDPSOCKETINTERNAL
nsresult Init(const nsRefPtr<NrSocketIpc>& socket);
private:
virtual ~NrSocketIpcProxy();
nsRefPtr<NrSocketIpc> socket_;
nsCOMPtr<nsIEventTarget> sts_thread_;
};
int nr_netaddr_to_transport_addr(const net::NetAddr *netaddr,
nr_transport_addr *addr,
int protocol);

Просмотреть файл

@ -96,25 +96,6 @@ RUN_ON_THREAD(nsIEventTarget *thread, detail::runnable_args_base<detail::Returns
#define ASSERT_ON_THREAD(t)
#endif
template <class T>
class DispatchedRelease : public detail::runnable_args_base<detail::NoResult> {
public:
explicit DispatchedRelease(already_AddRefed<T>& ref) : ref_(ref) {}
NS_IMETHOD Run() {
ref_ = nullptr;
return NS_OK;
}
private:
nsRefPtr<T> ref_;
};
template <typename T>
DispatchedRelease<T>* WrapRelease(already_AddRefed<T>&& ref)
{
return new DispatchedRelease<T>(ref);
}
} /* namespace mozilla */
#endif