netwerk/protocol/websocket/BaseWebSocketChannel.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/protocol/websocket/BaseWebSocketChannel.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,80 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim: set sw=2 ts=8 et tw=80 : */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef mozilla_net_BaseWebSocketChannel_h
    1.11 +#define mozilla_net_BaseWebSocketChannel_h
    1.12 +
    1.13 +#include "nsIWebSocketChannel.h"
    1.14 +#include "nsIWebSocketListener.h"
    1.15 +#include "nsIProtocolHandler.h"
    1.16 +#include "nsIThread.h"
    1.17 +#include "nsIThreadRetargetableRequest.h"
    1.18 +#include "nsCOMPtr.h"
    1.19 +#include "nsString.h"
    1.20 +
    1.21 +namespace mozilla {
    1.22 +namespace net {
    1.23 +
    1.24 +const static int32_t kDefaultWSPort     = 80;
    1.25 +const static int32_t kDefaultWSSPort    = 443;
    1.26 +
    1.27 +class BaseWebSocketChannel : public nsIWebSocketChannel,
    1.28 +                             public nsIProtocolHandler,
    1.29 +                             public nsIThreadRetargetableRequest
    1.30 +{
    1.31 + public:
    1.32 +  BaseWebSocketChannel();
    1.33 +
    1.34 +  NS_DECL_NSIPROTOCOLHANDLER
    1.35 +  NS_DECL_NSITHREADRETARGETABLEREQUEST
    1.36 +
    1.37 +  NS_IMETHOD QueryInterface(const nsIID & uuid, void **result) = 0;
    1.38 +  NS_IMETHOD_(MozExternalRefCountType ) AddRef(void) = 0;
    1.39 +  NS_IMETHOD_(MozExternalRefCountType ) Release(void) = 0;
    1.40 +
    1.41 +  // Partial implementation of nsIWebSocketChannel
    1.42 +  //
    1.43 +  NS_IMETHOD GetOriginalURI(nsIURI **aOriginalURI);
    1.44 +  NS_IMETHOD GetURI(nsIURI **aURI);
    1.45 +  NS_IMETHOD GetNotificationCallbacks(nsIInterfaceRequestor **aNotificationCallbacks);
    1.46 +  NS_IMETHOD SetNotificationCallbacks(nsIInterfaceRequestor *aNotificationCallbacks);
    1.47 +  NS_IMETHOD GetLoadGroup(nsILoadGroup **aLoadGroup);
    1.48 +  NS_IMETHOD SetLoadGroup(nsILoadGroup *aLoadGroup);
    1.49 +  NS_IMETHOD GetExtensions(nsACString &aExtensions);
    1.50 +  NS_IMETHOD GetProtocol(nsACString &aProtocol);
    1.51 +  NS_IMETHOD SetProtocol(const nsACString &aProtocol);
    1.52 +  NS_IMETHOD GetPingInterval(uint32_t *aSeconds);
    1.53 +  NS_IMETHOD SetPingInterval(uint32_t aSeconds);
    1.54 +  NS_IMETHOD GetPingTimeout(uint32_t *aSeconds);
    1.55 +  NS_IMETHOD SetPingTimeout(uint32_t aSeconds);
    1.56 +
    1.57 + protected:
    1.58 +  nsCOMPtr<nsIURI>                mOriginalURI;
    1.59 +  nsCOMPtr<nsIURI>                mURI;
    1.60 +  nsCOMPtr<nsIWebSocketListener>  mListener;
    1.61 +  nsCOMPtr<nsISupports>           mContext;
    1.62 +  nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
    1.63 +  nsCOMPtr<nsILoadGroup>          mLoadGroup;
    1.64 +  nsCOMPtr<nsIThread>             mTargetThread;
    1.65 +
    1.66 +  nsCString                       mProtocol;
    1.67 +  nsCString                       mOrigin;
    1.68 +
    1.69 +  nsCString                       mNegotiatedExtensions;
    1.70 +
    1.71 +  uint32_t                        mEncrypted                 : 1;
    1.72 +  uint32_t                        mWasOpened                 : 1;
    1.73 +  uint32_t                        mClientSetPingInterval     : 1;
    1.74 +  uint32_t                        mClientSetPingTimeout      : 1;
    1.75 +
    1.76 +  uint32_t                        mPingInterval;         /* milliseconds */
    1.77 +  uint32_t                        mPingResponseTimeout;  /* milliseconds */
    1.78 +};
    1.79 +
    1.80 +} // namespace net
    1.81 +} // namespace mozilla
    1.82 +
    1.83 +#endif // mozilla_net_BaseWebSocketChannel_h

mercurial