LCOV - app.info - security/manager/ssl/src/nsNSSCallbacks.h

LCOV - code coverage report
| Current view: | directory - security/manager/ssl/src - nsNSSCallbacks.h (source / functions) |  | Found | Hit | Coverage |
| Test: | app.info | Lines: | 20 | 0 | 0.0 %
| Date: | 2012-04-21 | Functions: | 11 | 0 | 0.0 %

           1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
           2                 :  *
           3                 :  * ***** BEGIN LICENSE BLOCK *****
           4                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
           5                 :  *
           6                 :  * The contents of this file are subject to the Mozilla Public License Version
           7                 :  * 1.1 (the "License"); you may not use this file except in compliance with
           8                 :  * the License. You may obtain a copy of the License at
           9                 :  * http://www.mozilla.org/MPL/
          10                 :  *
          11                 :  * Software distributed under the License is distributed on an "AS IS" basis,
          12                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
          13                 :  * for the specific language governing rights and limitations under the
          14                 :  * License.
          15                 :  *
          16                 :  * The Original Code is mozilla.org code.
          17                 :  *
          18                 :  * The Initial Developer of the Original Code is
          19                 :  * Netscape Communications Corporation.
          20                 :  * Portions created by the Initial Developer are Copyright (C) 1998
          21                 :  * the Initial Developer. All Rights Reserved.
          22                 :  *
          23                 :  * Contributor(s):
          24                 :  *   Brian Ryner <bryner@brianryner.com>
          25                 :  *   Kai Engert <kengert@redhat.com>
          26                 :  *
          27                 :  * Alternatively, the contents of this file may be used under the terms of
          28                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
          29                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
          30                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
          31                 :  * of those above. If you wish to allow use of your version of this file only
          32                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
          33                 :  * use your version of this file under the terms of the MPL, indicate your
          34                 :  * decision by deleting the provisions above and replace them with the notice
          35                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
          36                 :  * the provisions above, a recipient may use your version of this file under
          37                 :  * the terms of any one of the MPL, the GPL or the LGPL.
          38                 :  *
          39                 :  * ***** END LICENSE BLOCK ***** */
          40                 :
          41                 : #ifndef _NSNSSCALLBACKS_H_
          42                 : #define _NSNSSCALLBACKS_H_
          43                 :
          44                 : #include "pk11func.h"
          45                 : #include "nspr.h"
          46                 : #include "ocspt.h"
          47                 : #include "nsIStreamLoader.h"
          48                 : #include "mozilla/CondVar.h"
          49                 : #include "mozilla/Mutex.h"
          50                 :
          51                 : char* PR_CALLBACK
          52                 : PK11PasswordPrompt(PK11SlotInfo *slot, PRBool retry, void* arg);
          53                 :
          54                 : void PR_CALLBACK HandshakeCallback(PRFileDesc *fd, void *client_data);
          55                 :
          56                 : SECStatus RegisterMyOCSPAIAInfoCallback();
          57                 : SECStatus UnregisterMyOCSPAIAInfoCallback();
          58                 :
          59                 : class nsHTTPListener : public nsIStreamLoaderObserver
          60                 : {
          61                 : private:
          62                 :   // For XPCOM implementations that are not a base class for some other
          63                 :   // class, it is good practice to make the destructor non-virtual and
          64                 :   // private.  Then the only way to delete the object is via Release.
          65                 :   ~nsHTTPListener();
          66                 :
          67                 : public:
          68                 :   nsHTTPListener();
          69                 :
          70                 :   NS_DECL_ISUPPORTS
          71                 :   NS_DECL_NSISTREAMLOADEROBSERVER
          72                 :
          73                 :   nsCOMPtr<nsIStreamLoader> mLoader;
          74                 :
          75                 :   nsresult mResultCode;
          76                 :
          77                 :   bool mHttpRequestSucceeded;
          78                 :   PRUint16 mHttpResponseCode;
          79                 :   nsCString mHttpResponseContentType;
          80                 :
          81                 :   const PRUint8* mResultData; // not owned, refers to mLoader
          82                 :   PRUint32 mResultLen;
          83                 :
          84                 :   mozilla::Mutex mLock;
          85                 :   mozilla::CondVar mCondition;
          86                 :   volatile bool mWaitFlag;
          87                 :
          88                 :   bool mResponsibleForDoneSignal;
          89                 :   void send_done_signal();
          90                 :
          91                 :   // no nsCOMPtr. When I use it, I get assertions about
          92                 :   //   loadgroup not being thread safe.
          93                 :   // So, let's use a raw pointer and ensure we only create and destroy
          94                 :   // it on the network thread ourselves.
          95                 :   nsILoadGroup *mLoadGroup;
          96                 :   PRThread *mLoadGroupOwnerThread;
          97                 :   void FreeLoadGroup(bool aCancelLoad);
          98                 : };
          99                 :
         100                 : class nsNSSHttpServerSession
         101               0 : {
         102                 : public:
         103                 :   nsCString mHost;
         104                 :   PRUint16 mPort;
         105                 :
         106                 :   static SECStatus createSessionFcn(const char *host,
         107                 :                                     PRUint16 portnum,
         108                 :                                     SEC_HTTP_SERVER_SESSION *pSession);
         109                 : };
         110                 :
         111                 : class nsNSSHttpRequestSession
         112                 : {
         113                 : protected:
         114                 :   PRInt32 mRefCount;
         115                 :
         116                 : public:
         117                 :   static SECStatus createFcn(SEC_HTTP_SERVER_SESSION session,
         118                 :                              const char *http_protocol_variant,
         119                 :                              const char *path_and_query_string,
         120                 :                              const char *http_request_method,
         121                 :                              const PRIntervalTime timeout,
         122                 :                              SEC_HTTP_REQUEST_SESSION *pRequest);
         123                 :
         124                 :   SECStatus setPostDataFcn(const char *http_data,
         125                 :                            const PRUint32 http_data_len,
         126                 :                            const char *http_content_type);
         127                 :
         128                 :   SECStatus addHeaderFcn(const char *http_header_name,
         129                 :                          const char *http_header_value);
         130                 :
         131                 :   SECStatus trySendAndReceiveFcn(PRPollDesc **pPollDesc,
         132                 :                                  PRUint16 *http_response_code,
         133                 :                                  const char **http_response_content_type,
         134                 :                                  const char **http_response_headers,
         135                 :                                  const char **http_response_data,
         136                 :                                  PRUint32 *http_response_data_len);
         137                 :
         138                 :   SECStatus cancelFcn();
         139                 :   SECStatus freeFcn();
         140                 :
         141                 :   void AddRef();
         142                 :   void Release();
         143                 :
         144                 :   nsCString mURL;
         145                 :   nsCString mRequestMethod;
         146                 :
         147                 :   bool mHasPostData;
         148                 :   nsCString mPostData;
         149                 :   nsCString mPostContentType;
         150                 :
         151                 :   PRIntervalTime mTimeoutInterval;
         152                 :
         153                 :   nsCOMPtr<nsHTTPListener> mListener;
         154                 :
         155                 : protected:
         156                 :   nsNSSHttpRequestSession();
         157                 :   ~nsNSSHttpRequestSession();
         158                 :
         159                 :   SECStatus internal_send_receive_attempt(bool &retryable_error,
         160                 :                                           PRPollDesc **pPollDesc,
         161                 :                                           PRUint16 *http_response_code,
         162                 :                                           const char **http_response_content_type,
         163                 :                                           const char **http_response_headers,
         164                 :                                           const char **http_response_data,
         165                 :                                           PRUint32 *http_response_data_len);
         166                 : };
         167                 :
         168                 : class nsNSSHttpInterface
         169                 : {
         170                 : public:
         171               0 :   static SECStatus createSessionFcn(const char *host,
         172                 :                                     PRUint16 portnum,
         173                 :                                     SEC_HTTP_SERVER_SESSION *pSession)
         174                 :   {
         175               0 :     return nsNSSHttpServerSession::createSessionFcn(host, portnum, pSession);
         176                 :   }
         177                 :
         178               0 :   static SECStatus keepAliveFcn(SEC_HTTP_SERVER_SESSION session,
         179                 :                                 PRPollDesc **pPollDesc)
         180                 :   {
         181                 :     // Not yet implemented, however, Necko does transparent keep-alive
         182                 :     // anyway, when enabled in Necko's prefs.
         183               0 :     return SECSuccess;
         184                 :   }
         185                 :
         186               0 :   static SECStatus freeSessionFcn(SEC_HTTP_SERVER_SESSION session)
         187                 :   {
         188               0 :     delete static_cast<nsNSSHttpServerSession*>(session);
         189               0 :     return SECSuccess;
         190                 :   }
         191                 :
         192               0 :   static SECStatus createFcn(SEC_HTTP_SERVER_SESSION session,
         193                 :                              const char *http_protocol_variant,
         194                 :                              const char *path_and_query_string,
         195                 :                              const char *http_request_method,
         196                 :                              const PRIntervalTime timeout,
         197                 :                              SEC_HTTP_REQUEST_SESSION *pRequest)
         198                 :   {
         199                 :     return nsNSSHttpRequestSession::createFcn(session, http_protocol_variant,
         200                 :                                      path_and_query_string, http_request_method,
         201               0 :                                      timeout, pRequest);
         202                 :   }
         203                 :
         204               0 :   static SECStatus setPostDataFcn(SEC_HTTP_REQUEST_SESSION request,
         205                 :                                   const char *http_data,
         206                 :                                   const PRUint32 http_data_len,
         207                 :                                   const char *http_content_type)
         208                 :   {
         209                 :     return static_cast<nsNSSHttpRequestSession*>(request)
         210               0 :             ->setPostDataFcn(http_data, http_data_len, http_content_type);
         211                 :   }
         212                 :
         213               0 :   static SECStatus addHeaderFcn(SEC_HTTP_REQUEST_SESSION request,
         214                 :                                 const char *http_header_name,
         215                 :                                 const char *http_header_value)
         216                 :   {
         217                 :     return static_cast<nsNSSHttpRequestSession*>(request)
         218               0 :             ->addHeaderFcn(http_header_name, http_header_value);
         219                 :   }
         220                 :
         221               0 :   static SECStatus trySendAndReceiveFcn(SEC_HTTP_REQUEST_SESSION request,
         222                 :                                         PRPollDesc **pPollDesc,
         223                 :                                         PRUint16 *http_response_code,
         224                 :                                         const char **http_response_content_type,
         225                 :                                         const char **http_response_headers,
         226                 :                                         const char **http_response_data,
         227                 :                                         PRUint32 *http_response_data_len)
         228                 :   {
         229                 :     return static_cast<nsNSSHttpRequestSession*>(request)
         230                 :             ->trySendAndReceiveFcn(pPollDesc, http_response_code, http_response_content_type,
         231               0 :                      http_response_headers, http_response_data, http_response_data_len);
         232                 :   }
         233                 :
         234               0 :   static SECStatus cancelFcn(SEC_HTTP_REQUEST_SESSION request)
         235                 :   {
         236                 :     return static_cast<nsNSSHttpRequestSession*>(request)
         237               0 :             ->cancelFcn();
         238                 :   }
         239                 :
         240               0 :   static SECStatus freeFcn(SEC_HTTP_REQUEST_SESSION request)
         241                 :   {
         242                 :     return static_cast<nsNSSHttpRequestSession*>(request)
         243               0 :             ->freeFcn();
         244                 :   }
         245                 :
         246                 :   static void initTable();
         247                 :   static SEC_HttpClientFcn sNSSInterfaceTable;
         248                 :
         249                 :   void registerHttpClient();
         250                 :   void unregisterHttpClient();
         251                 : };
         252                 :
         253                 : #endif // _NSNSSCALLBACKS_H_
         254                 :
         255                 :
         256                 :

Generated by: LCOV version 1.7