Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes | Private Member Functions
nsCookie Class Reference

The nsCookie class is the main cookie storage medium for use within cookie code. More...

#include <nsCookie.h>

Inheritance diagram for nsCookie:
Inheritance graph
[legend]
Collaboration diagram for nsCookie:
Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual ~nsCookie ()
const nsDependentCString Name () const
const nsDependentCString Value () const
const nsDependentCString Host () const
const nsDependentCString RawHost () const
const nsDependentCString Path () const
nsInt64 Expiry () const
nsInt64 LastAccessed () const
PRUint32 CreationTime () const
PRBool IsSession () const
PRBool IsDomain () const
PRBool IsSecure () const
PRBool IsHttpOnly () const
nsCookieStatus Status () const
nsCookiePolicy Policy () const
void SetLastAccessed (nsInt64 aLastAccessed)
void SetExpiry (PRInt64 aExpiry)
void SetIsSession (PRBool aIsSession)
void SetCreationTime (PRUint32 aCT)
nsCookie *& Next ()

Static Public Member Functions

static nsCookieCreate (const nsACString &aName, const nsACString &aValue, const nsACString &aHost, const nsACString &aPath, nsInt64 aExpiry, nsInt64 aLastAccessed, PRBool aIsSession, PRBool aIsSecure, PRBool aIsHttpOnly, nsCookieStatus aStatus, nsCookiePolicy aPolicy)

Public Attributes

readonly attribute boolean isHttpOnly
 true if the cookie is an http only cookie
readonly attribute AUTF8String rawHost
 the host (possibly fully qualified) of the cookie, without a leading dot to represent if it is a domain cookie.
readonly attribute boolean isSession
 true if the cookie is a session cookie (note: if true, the expiry time is undefined).
readonly attribute PRInt64 expiry
 the actual expiry time of the cookie (where 0 does not represent a session cookie).
readonly attribute ACString name
 the name of the cookie
readonly attribute ACString value
 the cookie value
readonly attribute boolean isDomain
 true if the cookie is a domain cookie, false otherwise
readonly attribute AUTF8String host
 the host (possibly fully qualified) of the cookie
readonly attribute AUTF8String path
 the path pertaining to the cookie
readonly attribute boolean isSecure
 true if the cookie was transmitted over ssl, false otherwise
readonly attribute PRUint64 expires
 expiration time (local timezone) expressed as number of seconds since Jan 1, 1970
const nsCookieStatus STATUS_UNKNOWN = 0
 P3P status of cookie.
const nsCookieStatus STATUS_ACCEPTED = 1
const nsCookieStatus STATUS_DOWNGRADED = 2
const nsCookieStatus STATUS_FLAGGED = 3
const nsCookieStatus STATUS_REJECTED = 4
readonly attribute nsCookieStatus status
const nsCookiePolicy POLICY_UNKNOWN = 0
 Site's compact policy.
const nsCookiePolicy POLICY_NONE = 1
const nsCookiePolicy POLICY_NO_CONSENT = 2
const nsCookiePolicy POLICY_IMPLICIT_CONSENT = 3
const nsCookiePolicy POLICY_EXPLICIT_CONSENT = 4
const nsCookiePolicy POLICY_NO_II = 5
readonly attribute nsCookiePolicy policy

Protected Attributes

nsCookiemNext
const char * mName
const char * mValue
const char * mHost
const char * mPath
const char * mEnd
nsInt64 mExpiry
nsInt64 mLastAccessed
PRUint32 mCreationTime
PRUint32 mRefCnt: 16
PRUint32 mIsSession: 1
PRUint32 mIsSecure: 1
PRUint32 mIsHttpOnly: 1
PRUint32 mStatus: 3
PRUint32 mPolicy: 3

Private Member Functions

 nsCookie (const char *aName, const char *aValue, const char *aHost, const char *aPath, const char *aEnd, nsInt64 aExpiry, nsInt64 aLastAccessed, PRUint32 aCreationTime, PRBool aIsSession, PRBool aIsSecure, PRBool aIsHttpOnly, nsCookieStatus aStatus, nsCookiePolicy aPolicy)

Detailed Description

The nsCookie class is the main cookie storage medium for use within cookie code.

It implements nsICookie2, which extends nsICookie, a frozen interface for xpcom access of cookie objects.

Definition at line 58 of file nsCookie.h.


Constructor & Destructor Documentation

nsCookie::nsCookie ( const char *  aName,
const char *  aValue,
const char *  aHost,
const char *  aPath,
const char *  aEnd,
nsInt64  aExpiry,
nsInt64  aLastAccessed,
PRUint32  aCreationTime,
PRBool  aIsSession,
PRBool  aIsSecure,
PRBool  aIsHttpOnly,
nsCookieStatus  aStatus,
nsCookiePolicy  aPolicy 
) [inline, private]

Definition at line 74 of file nsCookie.h.

     : mNext(nsnull)
     , mName(aName)
     , mValue(aValue)
     , mHost(aHost)
     , mPath(aPath)
     , mEnd(aEnd)
     , mExpiry(aExpiry)
     , mLastAccessed(aLastAccessed)
     , mCreationTime(aCreationTime)
     , mRefCnt(0)
     , mIsSession(aIsSession != PR_FALSE)
     , mIsSecure(aIsSecure != PR_FALSE)
     , mIsHttpOnly(aIsHttpOnly != PR_FALSE)
     , mStatus(aStatus)
     , mPolicy(aPolicy)
    {
    }

Here is the caller graph for this function:

virtual nsCookie::~nsCookie ( ) [inline, virtual]

Definition at line 120 of file nsCookie.h.

{};

Member Function Documentation

nsCookie * nsCookie::Create ( const nsACString &  aName,
const nsACString &  aValue,
const nsACString &  aHost,
const nsACString &  aPath,
nsInt64  aExpiry,
nsInt64  aLastAccessed,
PRBool  aIsSession,
PRBool  aIsSecure,
PRBool  aIsHttpOnly,
nsCookieStatus  aStatus,
nsCookiePolicy  aPolicy 
) [static]

Definition at line 84 of file nsCookie.cpp.

{
  // find the required string buffer size, adding 4 for the terminating nulls
  const PRUint32 stringLength = aName.Length() + aValue.Length() +
                                aHost.Length() + aPath.Length() + 4;

  // allocate contiguous space for the nsCookie and its strings -
  // we store the strings in-line with the nsCookie to save allocations
  void *place = ::operator new(sizeof(nsCookie) + stringLength);
  if (!place)
    return nsnull;

  // assign string members
  char *name, *value, *host, *path, *end;
  name = NS_STATIC_CAST(char *, place) + sizeof(nsCookie);
  StrBlockCopy(aName, aValue, aHost, aPath,
               name, value, host, path, end);

  // construct the cookie. placement new, oh yeah!
  return new (place) nsCookie(name, value, host, path, end,
                              aExpiry, aLastAccessed, ++gLastCreationTime,
                              aIsSession, aIsSecure, aIsHttpOnly,
                              aStatus, aPolicy);
}

Here is the call graph for this function:

PRUint32 nsCookie::CreationTime ( ) const [inline]

Definition at line 130 of file nsCookie.h.

{ return mCreationTime; }

Here is the caller graph for this function:

nsInt64 nsCookie::Expiry ( ) const [inline]

Definition at line 128 of file nsCookie.h.

{ return mExpiry; }

Here is the caller graph for this function:

Definition at line 125 of file nsCookie.h.

{ return nsDependentCString(mHost, mPath - 1); }

Here is the caller graph for this function:

PRBool nsCookie::IsDomain ( ) const [inline]

Definition at line 132 of file nsCookie.h.

{ return *mHost == '.'; }

Here is the caller graph for this function:

PRBool nsCookie::IsHttpOnly ( ) const [inline]

Definition at line 134 of file nsCookie.h.

{ return mIsHttpOnly; }

Here is the caller graph for this function:

PRBool nsCookie::IsSecure ( ) const [inline]

Definition at line 133 of file nsCookie.h.

{ return mIsSecure; }

Here is the caller graph for this function:

PRBool nsCookie::IsSession ( ) const [inline]

Definition at line 131 of file nsCookie.h.

{ return mIsSession; }

Here is the caller graph for this function:

nsInt64 nsCookie::LastAccessed ( ) const [inline]

Definition at line 129 of file nsCookie.h.

{ return mLastAccessed; }

Here is the caller graph for this function:

Definition at line 123 of file nsCookie.h.

{ return nsDependentCString(mName, mValue - 1); }

Here is the caller graph for this function:

nsCookie*& nsCookie::Next ( ) [inline]

Definition at line 145 of file nsCookie.h.

{ return mNext; }

Here is the caller graph for this function:

Definition at line 127 of file nsCookie.h.

Here is the caller graph for this function:

nsCookiePolicy nsCookie::Policy ( ) const [inline]

Definition at line 136 of file nsCookie.h.

{ return mPolicy; }

Definition at line 126 of file nsCookie.h.

{ return nsDependentCString(IsDomain() ? mHost + 1 : mHost, mPath - 1); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 142 of file nsCookie.h.

{ mCreationTime = aCT; }

Here is the caller graph for this function:

void nsCookie::SetExpiry ( PRInt64  aExpiry) [inline]

Definition at line 140 of file nsCookie.h.

{ mExpiry = aExpiry; }
void nsCookie::SetIsSession ( PRBool  aIsSession) [inline]

Definition at line 141 of file nsCookie.h.

{ mIsSession = aIsSession; }
void nsCookie::SetLastAccessed ( nsInt64  aLastAccessed) [inline]

Definition at line 139 of file nsCookie.h.

{ mLastAccessed = aLastAccessed; }

Here is the caller graph for this function:

nsCookieStatus nsCookie::Status ( ) const [inline]

Definition at line 135 of file nsCookie.h.

{ return mStatus; }

Definition at line 124 of file nsCookie.h.

{ return nsDependentCString(mValue, mHost - 1); }

Here is the caller graph for this function:


Member Data Documentation

readonly attribute PRUint64 nsICookie::expires [inherited]

expiration time (local timezone) expressed as number of seconds since Jan 1, 1970

Definition at line 88 of file nsICookie.idl.

readonly attribute PRInt64 nsICookie2::expiry [inherited]

the actual expiry time of the cookie (where 0 does not represent a session cookie).

not to be confused with |expires|, an attribute on nsICookie.

Definition at line 72 of file nsICookie2.idl.

readonly attribute AUTF8String nsICookie::host [inherited]

the host (possibly fully qualified) of the cookie

Definition at line 73 of file nsICookie.idl.

readonly attribute boolean nsICookie::isDomain [inherited]

true if the cookie is a domain cookie, false otherwise

Definition at line 68 of file nsICookie.idl.

true if the cookie is an http only cookie

Definition at line 82 of file nsICookie2.idl.

readonly attribute boolean nsICookie::isSecure [inherited]

true if the cookie was transmitted over ssl, false otherwise

Definition at line 83 of file nsICookie.idl.

readonly attribute boolean nsICookie2::isSession [inherited]

true if the cookie is a session cookie (note: if true, the expiry time is undefined).

Definition at line 63 of file nsICookie2.idl.

Definition at line 162 of file nsCookie.h.

const char* nsCookie::mEnd [protected]

Definition at line 159 of file nsCookie.h.

Definition at line 160 of file nsCookie.h.

const char* nsCookie::mHost [protected]

Definition at line 157 of file nsCookie.h.

Definition at line 166 of file nsCookie.h.

Definition at line 165 of file nsCookie.h.

Definition at line 164 of file nsCookie.h.

Definition at line 161 of file nsCookie.h.

const char* nsCookie::mName [protected]

Definition at line 155 of file nsCookie.h.

nsCookie* nsCookie::mNext [protected]

Definition at line 154 of file nsCookie.h.

const char* nsCookie::mPath [protected]

Definition at line 158 of file nsCookie.h.

Definition at line 168 of file nsCookie.h.

Definition at line 163 of file nsCookie.h.

Definition at line 167 of file nsCookie.h.

const char* nsCookie::mValue [protected]

Definition at line 156 of file nsCookie.h.

readonly attribute ACString nsICookie::name [inherited]

the name of the cookie

Definition at line 58 of file nsICookie.idl.

readonly attribute AUTF8String nsICookie::path [inherited]

the path pertaining to the cookie

Definition at line 78 of file nsICookie.idl.

Definition at line 123 of file nsICookie.idl.

Definition at line 121 of file nsICookie.idl.

Definition at line 120 of file nsICookie.idl.

Definition at line 119 of file nsICookie.idl.

Definition at line 122 of file nsICookie.idl.

Definition at line 118 of file nsICookie.idl.

Site's compact policy.

Values are

POLICY_UNKNOWN -- cookie collected in a previous session and this info no longer available POLICY_NONE -- site did not send a compact policy along with the cookie POLICY_NO_CONSENT -- site collects identfiable information without user involvement POLICY_IMPLICIT_CONSENT -- site collects identifiable information unless user opts out POLICY_EXPLICIT_CONSENT -- site does not collect identifiable information unless user opts in POLICY_NO_II -- site does not collect identifiable information

Definition at line 117 of file nsICookie.idl.

readonly attribute AUTF8String nsICookie2::rawHost [inherited]

the host (possibly fully qualified) of the cookie, without a leading dot to represent if it is a domain cookie.

Definition at line 57 of file nsICookie2.idl.

Definition at line 105 of file nsICookie.idl.

Definition at line 100 of file nsICookie.idl.

Definition at line 101 of file nsICookie.idl.

Definition at line 102 of file nsICookie.idl.

Definition at line 103 of file nsICookie.idl.

P3P status of cookie.

Values are

STATUS_UNKNOWN -- cookie collected in a previous session and this info no longer available STATUS_ACCEPTED -- cookie was accepted as it STATUS_DOWNGRADED -- cookie was accepted but downgraded to a session cookie STATUS_FLAGGED -- cookie was accepted with a warning being issued to the user STATUS_REJECTED -- cookie was not accepted

Definition at line 99 of file nsICookie.idl.

readonly attribute ACString nsICookie::value [inherited]

the cookie value

Definition at line 63 of file nsICookie.idl.


The documentation for this class was generated from the following files: