Bug 664860. Rename nsIWebSocketHandler -> nsIWebSocketChannel. r=biesi

--HG--
rename : netwerk/protocol/websocket/nsIWebSocketProtocol.idl => netwerk/protocol/websocket/nsIWebSocketChannel.idl
rename : netwerk/protocol/websocket/nsIWebSocketProtocol.idl => netwerk/protocol/websocket/nsIWebSocketListener.idl
This commit is contained in:
Jason Duell 2011-07-04 21:18:32 -07:00
parent ebaf20a075
commit 45ea24eb5d
12 changed files with 142 additions and 96 deletions

View File

@ -72,7 +72,8 @@
#include "nsJSUtils.h"
#include "nsIScriptError.h"
#include "nsNetUtil.h"
#include "nsIWebSocketProtocol.h"
#include "nsIWebSocketChannel.h"
#include "nsIWebSocketListener.h"
#include "nsILoadGroup.h"
#include "nsIRequest.h"
#include "mozilla/Preferences.h"
@ -147,7 +148,7 @@ private:
PRUint32 mOutgoingBufferedAmount;
nsWebSocket* mOwner; // weak reference
nsCOMPtr<nsIWebSocketProtocol> mWebSocketProtocol;
nsCOMPtr<nsIWebSocketChannel> mWebSocketChannel;
PRPackedBool mClosedCleanly;
@ -187,7 +188,7 @@ nsWebSocketEstablishedConnection::~nsWebSocketEstablishedConnection()
{
NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");
NS_ABORT_IF_FALSE(!mOwner, "Disconnect wasn't called!");
NS_ABORT_IF_FALSE(!mWebSocketProtocol, "Disconnect wasn't called!");
NS_ABORT_IF_FALSE(!mWebSocketChannel, "Disconnect wasn't called!");
}
nsresult
@ -251,7 +252,7 @@ nsWebSocketEstablishedConnection::PostMessage(const nsString& aMessage)
rv = NS_BASE_STREAM_CLOSED;
} else {
mOutgoingBufferedAmount += buf.Length();
mWebSocketProtocol->SendMsg(buf);
mWebSocketChannel->SendMsg(buf);
rv = NS_OK;
}
@ -271,16 +272,16 @@ nsWebSocketEstablishedConnection::Init(nsWebSocket *aOwner)
mOwner = aOwner;
if (mOwner->mSecure) {
mWebSocketProtocol =
mWebSocketChannel =
do_CreateInstance("@mozilla.org/network/protocol;1?name=wss", &rv);
}
else {
mWebSocketProtocol =
mWebSocketChannel =
do_CreateInstance("@mozilla.org/network/protocol;1?name=ws", &rv);
}
NS_ENSURE_SUCCESS(rv, rv);
rv = mWebSocketProtocol->SetNotificationCallbacks(this);
rv = mWebSocketChannel->SetNotificationCallbacks(this);
NS_ENSURE_SUCCESS(rv, rv);
// add ourselves to the document's load group and
@ -288,19 +289,19 @@ nsWebSocketEstablishedConnection::Init(nsWebSocket *aOwner)
nsCOMPtr<nsILoadGroup> loadGroup;
rv = GetLoadGroup(getter_AddRefs(loadGroup));
if (loadGroup) {
rv = mWebSocketProtocol->SetLoadGroup(loadGroup);
rv = mWebSocketChannel->SetLoadGroup(loadGroup);
NS_ENSURE_SUCCESS(rv, rv);
rv = loadGroup->AddRequest(this, nsnull);
NS_ENSURE_SUCCESS(rv, rv);
}
if (!mOwner->mProtocol.IsEmpty())
rv = mWebSocketProtocol->SetProtocol(mOwner->mProtocol);
rv = mWebSocketChannel->SetProtocol(mOwner->mProtocol);
NS_ENSURE_SUCCESS(rv, rv);
nsCString utf8Origin;
CopyUTF16toUTF8(mOwner->mUTF16Origin, utf8Origin);
rv = mWebSocketProtocol->AsyncOpen(mOwner->mURI,
rv = mWebSocketChannel->AsyncOpen(mOwner->mURI,
utf8Origin, this, nsnull);
NS_ENSURE_SUCCESS(rv, rv);
@ -388,7 +389,7 @@ nsWebSocketEstablishedConnection::Close()
return NS_OK;
}
return mWebSocketProtocol->Close();
return mWebSocketChannel->Close();
}
nsresult
@ -451,7 +452,7 @@ nsWebSocketEstablishedConnection::Disconnect()
mOwner->DontKeepAliveAnyMore();
mStatus = CONN_CLOSED;
mOwner = nsnull;
mWebSocketProtocol = nsnull;
mWebSocketChannel = nsnull;
nsLayoutStatics::Release();
return NS_OK;
@ -504,7 +505,7 @@ nsWebSocketEstablishedConnection::OnStart(nsISupports *aContext)
return NS_OK;
if (!mOwner->mProtocol.IsEmpty())
mWebSocketProtocol->GetProtocol(mOwner->mProtocol);
mWebSocketChannel->GetProtocol(mOwner->mProtocol);
mStatus = CONN_CONNECTED_AND_READY;
mOwner->SetReadyState(nsIWebSocket::OPEN);

View File

@ -63,7 +63,7 @@ BaseWebSocketChannel::BaseWebSocketChannel()
}
//-----------------------------------------------------------------------------
// BaseWebSocketChannel::nsIWebSocketProtocol
// BaseWebSocketChannel::nsIWebSocketChannel
//-----------------------------------------------------------------------------
NS_IMETHODIMP

View File

@ -40,7 +40,8 @@
#ifndef mozilla_net_BaseWebSocketChannel_h
#define mozilla_net_BaseWebSocketChannel_h
#include "nsIWebSocketProtocol.h"
#include "nsIWebSocketChannel.h"
#include "nsIWebSocketListener.h"
#include "nsIProtocolHandler.h"
#include "nsCOMPtr.h"
#include "nsString.h"
@ -51,7 +52,7 @@ namespace net {
const static PRInt32 kDefaultWSPort = 80;
const static PRInt32 kDefaultWSSPort = 443;
class BaseWebSocketChannel : public nsIWebSocketProtocol,
class BaseWebSocketChannel : public nsIWebSocketChannel,
public nsIProtocolHandler
{
public:
@ -63,7 +64,7 @@ class BaseWebSocketChannel : public nsIWebSocketProtocol,
NS_IMETHOD_(nsrefcnt ) AddRef(void) = 0;
NS_IMETHOD_(nsrefcnt ) Release(void) = 0;
// Partial implementation of nsIWebSocketProtocol
// Partial implementation of nsIWebSocketChannel
//
NS_IMETHOD GetOriginalURI(nsIURI **aOriginalURI);
NS_IMETHOD GetURI(nsIURI **aURI);

View File

@ -52,7 +52,8 @@ FORCE_STATIC_LIB = 1
EXPORTS_NAMESPACES = mozilla/net
XPIDLSRCS = \
nsIWebSocketProtocol.idl \
nsIWebSocketChannel.idl \
nsIWebSocketListener.idl \
$(NULL)
CPPSRCS = \

View File

@ -53,7 +53,7 @@ async protocol PWebSocket
manager PNecko;
parent:
// Forwarded methods corresponding to methods on nsIWebSocketProtocolHandler
// Forwarded methods corresponding to methods on nsIWebSocketChannelHandler
AsyncOpen(URI aURI, nsCString aOrigin, nsCString aProtocol, bool aSecure);
Close();
SendMsg(nsCString aMsg);

View File

@ -69,13 +69,13 @@ NS_IMETHODIMP_(nsrefcnt) WebSocketChannelChild::Release()
}
NS_INTERFACE_MAP_BEGIN(WebSocketChannelChild)
NS_INTERFACE_MAP_ENTRY(nsIWebSocketProtocol)
NS_INTERFACE_MAP_ENTRY(nsIWebSocketChannel)
NS_INTERFACE_MAP_ENTRY(nsIProtocolHandler)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIWebSocketProtocol)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIWebSocketChannel)
NS_INTERFACE_MAP_END
WebSocketChannelChild::WebSocketChannelChild(bool aSecure)
: mEventQ(static_cast<nsIWebSocketProtocol*>(this))
: mEventQ(static_cast<nsIWebSocketChannel*>(this))
, mIPCOpen(false)
, mCancelled(false)
{

View File

@ -58,7 +58,7 @@ class WebSocketChannelChild : public BaseWebSocketChannel,
NS_DECL_ISUPPORTS
// nsIWebSocketProtocol methods BaseWebSocketChannel didn't implement for us
// nsIWebSocketChannel methods BaseWebSocketChannel didn't implement for us
//
NS_SCRIPTABLE NS_IMETHOD AsyncOpen(nsIURI *aURI,
const nsACString &aOrigin,

View File

@ -75,7 +75,7 @@ class WebSocketChannelParent : public PWebSocketParent,
void ActorDestroy(ActorDestroyReason why);
nsCOMPtr<nsIAuthPromptProvider> mAuthProvider;
nsCOMPtr<nsIWebSocketProtocol> mChannel;
nsCOMPtr<nsIWebSocketChannel> mChannel;
bool mIPCOpen;
};

View File

@ -1,4 +1,5 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim: set sw=4 ts=4 et tw=80 : */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -38,79 +39,13 @@
interface nsIURI;
interface nsIInterfaceRequestor;
interface nsIRunnable;
interface nsILoadGroup;
interface nsIWebSocketListener;
#include "nsISupports.idl"
/**
* nsIWebSocketListener
*/
[scriptable, uuid(b0c27050-31e9-42e5-bc59-499d54b52f99)]
interface nsIWebSocketListener : nsISupports
{
/**
* Called to signify the establishment of the message stream.
* Any listener that receives onStart will also receive OnStop.
*
* @param aContext user defined context
*/
void onStart(in nsISupports aContext);
/**
* Called to signify the completion of the message stream.
* OnStop is the final notification the listener will receive and it
* completes the WebSocket connection. This event can be received in error
* cases even if nsIWebSocketProtocol::Close() has not been called.
*
* @param aContext user defined context
* @param aStatusCode reason for stopping (NS_OK if completed successfully)
*/
void onStop(in nsISupports aContext,
in nsresult aStatusCode);
/**
* Called to deliver text message.
*
* @param aContext user defined context
* @param aMsg the message data
*/
void onMessageAvailable(in nsISupports aContext,
in AUTF8String aMsg);
/**
* Called to deliver binary message.
*
* @param aContext user defined context
* @param aMsg the message data
*/
void onBinaryMessageAvailable(in nsISupports aContext,
in ACString aMsg);
/**
* Called to acknowledge message sent via sendMsg() or sendBinaryMsg.
*
* @param aContext user defined context
* @param aSize number of bytes placed in OS send buffer
*/
void onAcknowledge(in nsISupports aContext, in PRUint32 aSize);
/**
* Called to inform receipt of WebSocket Close message from server.
* In the case of errors onStop() can be called without ever
* receiving server close.
*
* No additional messages through onMessageAvailable(),
* onBinaryMessageAvailable() or onAcknowledge() will be delievered
* to the listener after onServerClose(), though outgoing messages can still
* be sent through the nsIWebSocketProtocol connection.
*/
void onServerClose(in nsISupports aContext);
};
[scriptable, uuid(dc01db59-a513-4c90-824b-085cce06c0aa)]
interface nsIWebSocketProtocol : nsISupports
[scriptable, uuid(398a2460-a46d-11e0-8264-0800200c9a66)]
interface nsIWebSocketChannel : nsISupports
{
/**
* The original URI used to construct the protocol connection. This is used

View File

@ -0,0 +1,109 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim: set sw=4 ts=4 et tw=80 : */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Patrick McManus <mcmanus@ducksong.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
/**
* nsIWebSocketListener: passed to nsIWebSocketChannel::AsyncOpen. Receives
* websocket traffic events as they arrive.
*/
[scriptable, uuid(b0c27050-31e9-42e5-bc59-499d54b52f99)]
interface nsIWebSocketListener : nsISupports
{
/**
* Called to signify the establishment of the message stream.
* Any listener that receives onStart will also receive OnStop.
*
* @param aContext user defined context
*/
void onStart(in nsISupports aContext);
/**
* Called to signify the completion of the message stream.
* OnStop is the final notification the listener will receive and it
* completes the WebSocket connection. This event can be received in error
* cases even if nsIWebSocketChannel::Close() has not been called.
*
* @param aContext user defined context
* @param aStatusCode reason for stopping (NS_OK if completed successfully)
*/
void onStop(in nsISupports aContext,
in nsresult aStatusCode);
/**
* Called to deliver text message.
*
* @param aContext user defined context
* @param aMsg the message data
*/
void onMessageAvailable(in nsISupports aContext,
in AUTF8String aMsg);
/**
* Called to deliver binary message.
*
* @param aContext user defined context
* @param aMsg the message data
*/
void onBinaryMessageAvailable(in nsISupports aContext,
in ACString aMsg);
/**
* Called to acknowledge message sent via sendMsg() or sendBinaryMsg.
*
* @param aContext user defined context
* @param aSize number of bytes placed in OS send buffer
*/
void onAcknowledge(in nsISupports aContext, in PRUint32 aSize);
/**
* Called to inform receipt of WebSocket Close message from server.
* In the case of errors onStop() can be called without ever
* receiving server close.
*
* No additional messages through onMessageAvailable(),
* onBinaryMessageAvailable() or onAcknowledge() will be delievered
* to the listener after onServerClose(), though outgoing messages can still
* be sent through the nsIWebSocketChannel connection.
*/
void onServerClose(in nsISupports aContext);
};

View File

@ -78,7 +78,7 @@ namespace mozilla {
namespace net {
NS_IMPL_THREADSAFE_ISUPPORTS11(nsWebSocketHandler,
nsIWebSocketProtocol,
nsIWebSocketChannel,
nsIHttpUpgradeListener,
nsIRequestObserver,
nsIStreamListener,

View File

@ -40,7 +40,6 @@
#ifndef mozilla_net_nsWebSocketHandler_h
#define mozilla_net_nsWebSocketHandler_h
#include "nsIWebSocketProtocol.h"
#include "nsIURI.h"
#include "nsISupports.h"
#include "nsIInterfaceRequestor.h"
@ -93,7 +92,7 @@ public:
NS_DECL_NSIINTERFACEREQUESTOR
NS_DECL_NSICHANNELEVENTSINK
// nsIWebSocketProtocol methods BaseWebSocketChannel didn't implement for us
// nsIWebSocketChannel methods BaseWebSocketChannel didn't implement for us
//
NS_IMETHOD AsyncOpen(nsIURI *aURI,
const nsACString &aOrigin,