Added NPL and made the implementation threadsafe.
git-svn-id: svn://10.0.0.236/trunk@10535 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
32ede4839b
commit
ca38b8546f
@ -1,8 +1,26 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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/NPL/
|
||||
*
|
||||
* 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 Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsILoadAttribs.h"
|
||||
#include "prtypes.h"
|
||||
|
||||
static NS_DEFINE_IID(kILoadAttribs, NS_ILOAD_ATTRIBS_IDD);
|
||||
|
||||
// nsLoadAttribs definition.
|
||||
class nsLoadAttribs : public nsILoadAttribs {
|
||||
@ -26,29 +44,8 @@ private:
|
||||
|
||||
// nsLoadAttribs Implementation
|
||||
|
||||
NS_IMPL_ADDREF(nsLoadAttribs)
|
||||
NS_IMPL_RELEASE(nsLoadAttribs)
|
||||
|
||||
nsresult
|
||||
nsLoadAttribs::QueryInterface(const nsIID &aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
if (aIID.Equals(kILoadAttribs)) {
|
||||
*aInstancePtr = (void*) ((nsILoadAttribs*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtr = (void*) ((nsISupports *)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
static NS_DEFINE_IID(kILoadAttribsIID, NS_ILOAD_ATTRIBS_IID);
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS(nsLoadAttribs, kILoadAttribsIID);
|
||||
|
||||
nsLoadAttribs::nsLoadAttribs() {
|
||||
mBypass = PR_FALSE;
|
||||
@ -60,26 +57,46 @@ nsLoadAttribs::~nsLoadAttribs() {
|
||||
|
||||
nsresult
|
||||
nsLoadAttribs::SetBypassProxy(PRBool aBypass) {
|
||||
NS_LOCK_INSTANCE();
|
||||
mBypass = aBypass;
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsLoadAttribs::GetBypassProxy(PRBool *aBypass) {
|
||||
*aBypass = mBypass;
|
||||
return NS_OK;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (nsnull == aBypass) {
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
} else {
|
||||
NS_LOCK_INSTANCE();
|
||||
*aBypass = mBypass;
|
||||
NS_UNLOCK_INSTANCE();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsLoadAttribs::SetLocalIP(const PRUint32 aLocalIP) {
|
||||
NS_LOCK_INSTANCE();
|
||||
mLocalIP = aLocalIP;
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsLoadAttribs::GetLocalIP(PRUint32 *aLocalIP) {
|
||||
*aLocalIP = mLocalIP;
|
||||
return NS_OK;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (nsnull == aLocalIP) {
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
} else {
|
||||
NS_LOCK_INSTANCE();
|
||||
*aLocalIP = mLocalIP;
|
||||
NS_UNLOCK_INSTANCE();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Creation routines
|
||||
@ -88,5 +105,5 @@ NS_NET nsresult NS_NewLoadAttribs(nsILoadAttribs** aInstancePtrResult) {
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return it->QueryInterface(kILoadAttribs, (void **) aInstancePtrResult);
|
||||
return it->QueryInterface(kILoadAttribsIID, (void **) aInstancePtrResult);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user