зеркало из https://github.com/mozilla/pjs.git
Added a Clone(...) method.
This commit is contained in:
Родитель
77deb1b5d8
Коммит
88b0709451
|
@ -32,6 +32,9 @@
|
|||
// Defining attributes of a url's load behavior.
|
||||
class nsILoadAttribs : public nsISupports {
|
||||
public:
|
||||
// Copy the state of another nsILoadAttribs instance.
|
||||
NS_IMETHOD Clone(nsILoadAttribs* aLoadAttribs) = 0;
|
||||
|
||||
// Bypass Proxy.
|
||||
NS_IMETHOD SetBypassProxy(PRBool aBypass) = 0;
|
||||
NS_IMETHOD GetBypassProxy(PRBool *aBypass) = 0;
|
||||
|
|
|
@ -26,17 +26,20 @@
|
|||
class nsLoadAttribs : public nsILoadAttribs {
|
||||
public:
|
||||
nsLoadAttribs();
|
||||
virtual ~nsLoadAttribs();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsILoadAttribs
|
||||
NS_IMETHOD Clone(nsILoadAttribs* aLoadAttribs);
|
||||
NS_IMETHOD SetBypassProxy(PRBool aBypass);
|
||||
NS_IMETHOD GetBypassProxy(PRBool *aBypass);
|
||||
NS_IMETHOD SetLocalIP(const PRUint32 aIP);
|
||||
NS_IMETHOD GetLocalIP(PRUint32 *aIP);
|
||||
|
||||
protected:
|
||||
virtual ~nsLoadAttribs();
|
||||
|
||||
private:
|
||||
PRBool mBypass;
|
||||
PRUint32 mLocalIP;
|
||||
|
@ -48,14 +51,38 @@ static NS_DEFINE_IID(kILoadAttribsIID, NS_ILOAD_ATTRIBS_IID);
|
|||
NS_IMPL_THREADSAFE_ISUPPORTS(nsLoadAttribs, kILoadAttribsIID);
|
||||
|
||||
nsLoadAttribs::nsLoadAttribs() {
|
||||
mBypass = PR_FALSE;
|
||||
mLocalIP = 0;
|
||||
NS_INIT_REFCNT();
|
||||
mBypass = PR_FALSE;
|
||||
mLocalIP = 0;
|
||||
}
|
||||
|
||||
nsLoadAttribs::~nsLoadAttribs() {
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_IMETHODIMP
|
||||
nsLoadAttribs::Clone(nsILoadAttribs* aLoadAttribs)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (nsnull == aLoadAttribs) {
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
} else {
|
||||
PRBool bypass;
|
||||
PRUint32 ip;
|
||||
|
||||
NS_LOCK_INSTANCE();
|
||||
aLoadAttribs->GetBypassProxy(&bypass);
|
||||
SetBypassProxy(bypass);
|
||||
|
||||
aLoadAttribs->GetLocalIP(&ip);
|
||||
SetLocalIP(ip);
|
||||
NS_UNLOCK_INSTANCE();
|
||||
}
|
||||
return rv;
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLoadAttribs::SetBypassProxy(PRBool aBypass) {
|
||||
NS_LOCK_INSTANCE();
|
||||
mBypass = aBypass;
|
||||
|
@ -63,7 +90,7 @@ nsLoadAttribs::SetBypassProxy(PRBool aBypass) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_IMETHODIMP
|
||||
nsLoadAttribs::GetBypassProxy(PRBool *aBypass) {
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
|
@ -77,7 +104,7 @@ nsLoadAttribs::GetBypassProxy(PRBool *aBypass) {
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_IMETHODIMP
|
||||
nsLoadAttribs::SetLocalIP(const PRUint32 aLocalIP) {
|
||||
NS_LOCK_INSTANCE();
|
||||
mLocalIP = aLocalIP;
|
||||
|
@ -85,7 +112,7 @@ nsLoadAttribs::SetLocalIP(const PRUint32 aLocalIP) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_IMETHODIMP
|
||||
nsLoadAttribs::GetLocalIP(PRUint32 *aLocalIP) {
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
|
@ -101,7 +128,9 @@ nsLoadAttribs::GetLocalIP(PRUint32 *aLocalIP) {
|
|||
|
||||
// Creation routines
|
||||
NS_NET nsresult NS_NewLoadAttribs(nsILoadAttribs** aInstancePtrResult) {
|
||||
nsILoadAttribs* it = new nsLoadAttribs();
|
||||
nsILoadAttribs* it;
|
||||
|
||||
NS_NEWXPCOM(it, nsLoadAttribs);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче