Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef nsXPCOM_h__ |
michael@0 | 7 | #define nsXPCOM_h__ |
michael@0 | 8 | |
michael@0 | 9 | #include "nscore.h" |
michael@0 | 10 | #include "nsXPCOMCID.h" |
michael@0 | 11 | |
michael@0 | 12 | #ifdef __cplusplus |
michael@0 | 13 | #define DECL_CLASS(c) class c |
michael@0 | 14 | #define DECL_STRUCT(c) struct c |
michael@0 | 15 | #else |
michael@0 | 16 | #define DECL_CLASS(c) typedef struct c c |
michael@0 | 17 | #define DECL_STRUCT(c) typedef struct c c |
michael@0 | 18 | #endif |
michael@0 | 19 | |
michael@0 | 20 | DECL_CLASS(nsAString); |
michael@0 | 21 | DECL_CLASS(nsACString); |
michael@0 | 22 | |
michael@0 | 23 | DECL_CLASS(nsISupports); |
michael@0 | 24 | DECL_CLASS(nsIModule); |
michael@0 | 25 | DECL_CLASS(nsIComponentManager); |
michael@0 | 26 | DECL_CLASS(nsIComponentRegistrar); |
michael@0 | 27 | DECL_CLASS(nsIServiceManager); |
michael@0 | 28 | DECL_CLASS(nsIFile); |
michael@0 | 29 | DECL_CLASS(nsILocalFile); |
michael@0 | 30 | DECL_CLASS(nsIDirectoryServiceProvider); |
michael@0 | 31 | DECL_CLASS(nsIMemory); |
michael@0 | 32 | DECL_CLASS(nsIDebug); |
michael@0 | 33 | |
michael@0 | 34 | #ifdef __cplusplus |
michael@0 | 35 | namespace mozilla { |
michael@0 | 36 | struct Module; |
michael@0 | 37 | } |
michael@0 | 38 | #endif |
michael@0 | 39 | |
michael@0 | 40 | /** |
michael@0 | 41 | * Initialises XPCOM. You must call one of the NS_InitXPCOM methods |
michael@0 | 42 | * before proceeding to use xpcom. The one exception is that you may |
michael@0 | 43 | * call NS_NewLocalFile to create a nsIFile. |
michael@0 | 44 | * |
michael@0 | 45 | * @note Use <CODE>NS_NewLocalFile</CODE> or <CODE>NS_NewNativeLocalFile</CODE> |
michael@0 | 46 | * to create the file object you supply as the bin directory path in this |
michael@0 | 47 | * call. The function may be safely called before the rest of XPCOM or |
michael@0 | 48 | * embedding has been initialised. |
michael@0 | 49 | * |
michael@0 | 50 | * @param result The service manager. You may pass null. |
michael@0 | 51 | * |
michael@0 | 52 | * @param binDirectory The directory containing the component |
michael@0 | 53 | * registry and runtime libraries; |
michael@0 | 54 | * or use <CODE>nullptr</CODE> to use the working |
michael@0 | 55 | * directory. |
michael@0 | 56 | * |
michael@0 | 57 | * @param appFileLocationProvider The object to be used by Gecko that specifies |
michael@0 | 58 | * to Gecko where to find profiles, the component |
michael@0 | 59 | * registry preferences and so on; or use |
michael@0 | 60 | * <CODE>nullptr</CODE> for the default behaviour. |
michael@0 | 61 | * |
michael@0 | 62 | * @see NS_NewLocalFile |
michael@0 | 63 | * @see nsIFile |
michael@0 | 64 | * @see nsIDirectoryServiceProvider |
michael@0 | 65 | * |
michael@0 | 66 | * @return NS_OK for success; |
michael@0 | 67 | * NS_ERROR_NOT_INITIALIZED if static globals were not initialized, |
michael@0 | 68 | * which can happen if XPCOM is reloaded, but did not completly |
michael@0 | 69 | * shutdown. Other error codes indicate a failure during |
michael@0 | 70 | * initialisation. |
michael@0 | 71 | */ |
michael@0 | 72 | XPCOM_API(nsresult) |
michael@0 | 73 | NS_InitXPCOM2(nsIServiceManager* *result, |
michael@0 | 74 | nsIFile* binDirectory, |
michael@0 | 75 | nsIDirectoryServiceProvider* appFileLocationProvider); |
michael@0 | 76 | |
michael@0 | 77 | /** |
michael@0 | 78 | * Shutdown XPCOM. You must call this method after you are finished |
michael@0 | 79 | * using xpcom. |
michael@0 | 80 | * |
michael@0 | 81 | * @param servMgr The service manager which was returned by NS_InitXPCOM. |
michael@0 | 82 | * This will release servMgr. You may pass null. |
michael@0 | 83 | * |
michael@0 | 84 | * @return NS_OK for success; |
michael@0 | 85 | * other error codes indicate a failure during initialisation. |
michael@0 | 86 | * |
michael@0 | 87 | */ |
michael@0 | 88 | XPCOM_API(nsresult) |
michael@0 | 89 | NS_ShutdownXPCOM(nsIServiceManager* servMgr); |
michael@0 | 90 | |
michael@0 | 91 | |
michael@0 | 92 | /** |
michael@0 | 93 | * Public Method to access to the service manager. |
michael@0 | 94 | * |
michael@0 | 95 | * @param result Interface pointer to the service manager |
michael@0 | 96 | * |
michael@0 | 97 | * @return NS_OK for success; |
michael@0 | 98 | * other error codes indicate a failure during initialisation. |
michael@0 | 99 | * |
michael@0 | 100 | */ |
michael@0 | 101 | XPCOM_API(nsresult) |
michael@0 | 102 | NS_GetServiceManager(nsIServiceManager* *result); |
michael@0 | 103 | |
michael@0 | 104 | /** |
michael@0 | 105 | * Public Method to access to the component manager. |
michael@0 | 106 | * |
michael@0 | 107 | * @param result Interface pointer to the service |
michael@0 | 108 | * |
michael@0 | 109 | * @return NS_OK for success; |
michael@0 | 110 | * other error codes indicate a failure during initialisation. |
michael@0 | 111 | * |
michael@0 | 112 | */ |
michael@0 | 113 | XPCOM_API(nsresult) |
michael@0 | 114 | NS_GetComponentManager(nsIComponentManager* *result); |
michael@0 | 115 | |
michael@0 | 116 | |
michael@0 | 117 | /** |
michael@0 | 118 | * Public Method to access to the component registration manager. |
michael@0 | 119 | * |
michael@0 | 120 | * @param result Interface pointer to the service |
michael@0 | 121 | * |
michael@0 | 122 | * @return NS_OK for success; |
michael@0 | 123 | * other error codes indicate a failure during initialisation. |
michael@0 | 124 | * |
michael@0 | 125 | */ |
michael@0 | 126 | XPCOM_API(nsresult) |
michael@0 | 127 | NS_GetComponentRegistrar(nsIComponentRegistrar* *result); |
michael@0 | 128 | |
michael@0 | 129 | /** |
michael@0 | 130 | * Public Method to access to the memory manager. See nsIMemory |
michael@0 | 131 | * |
michael@0 | 132 | * @param result Interface pointer to the memory manager |
michael@0 | 133 | * |
michael@0 | 134 | * @return NS_OK for success; |
michael@0 | 135 | * other error codes indicate a failure during initialisation. |
michael@0 | 136 | * |
michael@0 | 137 | */ |
michael@0 | 138 | XPCOM_API(nsresult) |
michael@0 | 139 | NS_GetMemoryManager(nsIMemory* *result); |
michael@0 | 140 | |
michael@0 | 141 | /** |
michael@0 | 142 | * Public Method to create an instance of a nsIFile. This function |
michael@0 | 143 | * may be called prior to NS_InitXPCOM. |
michael@0 | 144 | * |
michael@0 | 145 | * @param path |
michael@0 | 146 | * A string which specifies a full file path to a |
michael@0 | 147 | * location. Relative paths will be treated as an |
michael@0 | 148 | * error (NS_ERROR_FILE_UNRECOGNIZED_PATH). |
michael@0 | 149 | * |NS_NewNativeLocalFile|'s path must be in the |
michael@0 | 150 | * filesystem charset. |
michael@0 | 151 | * @param followLinks |
michael@0 | 152 | * This attribute will determine if the nsLocalFile will auto |
michael@0 | 153 | * resolve symbolic links. By default, this value will be false |
michael@0 | 154 | * on all non unix systems. On unix, this attribute is effectively |
michael@0 | 155 | * a noop. |
michael@0 | 156 | * @param result Interface pointer to a new instance of an nsIFile |
michael@0 | 157 | * |
michael@0 | 158 | * @return NS_OK for success; |
michael@0 | 159 | * other error codes indicate a failure. |
michael@0 | 160 | */ |
michael@0 | 161 | |
michael@0 | 162 | #ifdef __cplusplus |
michael@0 | 163 | |
michael@0 | 164 | XPCOM_API(nsresult) |
michael@0 | 165 | NS_NewLocalFile(const nsAString &path, |
michael@0 | 166 | bool followLinks, |
michael@0 | 167 | nsIFile* *result); |
michael@0 | 168 | |
michael@0 | 169 | XPCOM_API(nsresult) |
michael@0 | 170 | NS_NewNativeLocalFile(const nsACString &path, |
michael@0 | 171 | bool followLinks, |
michael@0 | 172 | nsIFile* *result); |
michael@0 | 173 | |
michael@0 | 174 | #endif |
michael@0 | 175 | |
michael@0 | 176 | /** |
michael@0 | 177 | * Allocates a block of memory of a particular size. If the memory cannot |
michael@0 | 178 | * be allocated (because of an out-of-memory condition), the process aborts. |
michael@0 | 179 | * |
michael@0 | 180 | * @param size The size of the block to allocate |
michael@0 | 181 | * @result The block of memory |
michael@0 | 182 | * @note This function is thread-safe. |
michael@0 | 183 | */ |
michael@0 | 184 | XPCOM_API(void*) |
michael@0 | 185 | NS_Alloc(size_t size); |
michael@0 | 186 | |
michael@0 | 187 | /** |
michael@0 | 188 | * Reallocates a block of memory to a new size. |
michael@0 | 189 | * |
michael@0 | 190 | * @param ptr The block of memory to reallocate. This block must originally |
michael@0 | 191 | have been allocated by NS_Alloc or NS_Realloc |
michael@0 | 192 | * @param size The new size. If 0, frees the block like NS_Free |
michael@0 | 193 | * @result The reallocated block of memory |
michael@0 | 194 | * @note This function is thread-safe. |
michael@0 | 195 | * |
michael@0 | 196 | * If ptr is null, this function behaves like NS_Alloc. |
michael@0 | 197 | * If s is the size of the block to which ptr points, the first min(s, size) |
michael@0 | 198 | * bytes of ptr's block are copied to the new block. If the allocation |
michael@0 | 199 | * succeeds, ptr is freed and a pointer to the new block is returned. If the |
michael@0 | 200 | * allocation fails, the process aborts. |
michael@0 | 201 | */ |
michael@0 | 202 | XPCOM_API(void*) |
michael@0 | 203 | NS_Realloc(void* ptr, size_t size); |
michael@0 | 204 | |
michael@0 | 205 | /** |
michael@0 | 206 | * Frees a block of memory. Null is a permissible value, in which case no |
michael@0 | 207 | * action is taken. |
michael@0 | 208 | * |
michael@0 | 209 | * @param ptr The block of memory to free. This block must originally have |
michael@0 | 210 | * been allocated by NS_Alloc or NS_Realloc |
michael@0 | 211 | * @note This function is thread-safe. |
michael@0 | 212 | */ |
michael@0 | 213 | XPCOM_API(void) |
michael@0 | 214 | NS_Free(void* ptr); |
michael@0 | 215 | |
michael@0 | 216 | /** |
michael@0 | 217 | * Support for warnings, assertions, and debugging breaks. |
michael@0 | 218 | */ |
michael@0 | 219 | |
michael@0 | 220 | enum { |
michael@0 | 221 | NS_DEBUG_WARNING = 0, |
michael@0 | 222 | NS_DEBUG_ASSERTION = 1, |
michael@0 | 223 | NS_DEBUG_BREAK = 2, |
michael@0 | 224 | NS_DEBUG_ABORT = 3 |
michael@0 | 225 | }; |
michael@0 | 226 | |
michael@0 | 227 | /** |
michael@0 | 228 | * Print a runtime assertion. This function is available in both debug and |
michael@0 | 229 | * release builds. |
michael@0 | 230 | * |
michael@0 | 231 | * @note Based on the value of aSeverity and the XPCOM_DEBUG_BREAK |
michael@0 | 232 | * environment variable, this function may cause the application to |
michael@0 | 233 | * print the warning, print a stacktrace, break into a debugger, or abort |
michael@0 | 234 | * immediately. |
michael@0 | 235 | * |
michael@0 | 236 | * @param aSeverity A NS_DEBUG_* value |
michael@0 | 237 | * @param aStr A readable error message (ASCII, may be null) |
michael@0 | 238 | * @param aExpr The expression evaluated (may be null) |
michael@0 | 239 | * @param aFile The source file containing the assertion (may be null) |
michael@0 | 240 | * @param aLine The source file line number (-1 indicates no line number) |
michael@0 | 241 | */ |
michael@0 | 242 | XPCOM_API(void) |
michael@0 | 243 | NS_DebugBreak(uint32_t aSeverity, |
michael@0 | 244 | const char *aStr, const char *aExpr, |
michael@0 | 245 | const char *aFile, int32_t aLine); |
michael@0 | 246 | |
michael@0 | 247 | /** |
michael@0 | 248 | * Perform a stack-walk to a debugging log under various |
michael@0 | 249 | * circumstances. Used to aid debugging of leaked object graphs. |
michael@0 | 250 | * |
michael@0 | 251 | * The NS_Log* functions are available in both debug and release |
michael@0 | 252 | * builds of XPCOM, but the output will be useless unless binary |
michael@0 | 253 | * debugging symbols for all modules in the stacktrace are available. |
michael@0 | 254 | */ |
michael@0 | 255 | |
michael@0 | 256 | /** |
michael@0 | 257 | * By default, refcount logging is enabled at NS_InitXPCOM and |
michael@0 | 258 | * refcount statistics are printed at NS_ShutdownXPCOM. NS_LogInit and |
michael@0 | 259 | * NS_LogTerm allow applications to enable logging earlier and delay |
michael@0 | 260 | * printing of logging statistics. They should always be used as a |
michael@0 | 261 | * matched pair. |
michael@0 | 262 | */ |
michael@0 | 263 | XPCOM_API(void) |
michael@0 | 264 | NS_LogInit(); |
michael@0 | 265 | |
michael@0 | 266 | XPCOM_API(void) |
michael@0 | 267 | NS_LogTerm(); |
michael@0 | 268 | |
michael@0 | 269 | /** |
michael@0 | 270 | * Log construction and destruction of objects. Processing tools can use the |
michael@0 | 271 | * stacktraces printed by these functions to identify objects that are being |
michael@0 | 272 | * leaked. |
michael@0 | 273 | * |
michael@0 | 274 | * @param aPtr A pointer to the concrete object. |
michael@0 | 275 | * @param aTypeName The class name of the type |
michael@0 | 276 | * @param aInstanceSize The size of the type |
michael@0 | 277 | */ |
michael@0 | 278 | |
michael@0 | 279 | XPCOM_API(void) |
michael@0 | 280 | NS_LogCtor(void *aPtr, const char *aTypeName, uint32_t aInstanceSize); |
michael@0 | 281 | |
michael@0 | 282 | XPCOM_API(void) |
michael@0 | 283 | NS_LogDtor(void *aPtr, const char *aTypeName, uint32_t aInstanceSize); |
michael@0 | 284 | |
michael@0 | 285 | /** |
michael@0 | 286 | * Log a stacktrace when an XPCOM object's refcount is incremented or |
michael@0 | 287 | * decremented. Processing tools can use the stacktraces printed by these |
michael@0 | 288 | * functions to identify objects that were leaked due to XPCOM references. |
michael@0 | 289 | * |
michael@0 | 290 | * @param aPtr A pointer to the concrete object |
michael@0 | 291 | * @param aNewRefCnt The new reference count. |
michael@0 | 292 | * @param aTypeName The class name of the type |
michael@0 | 293 | * @param aInstanceSize The size of the type |
michael@0 | 294 | */ |
michael@0 | 295 | XPCOM_API(void) |
michael@0 | 296 | NS_LogAddRef(void *aPtr, nsrefcnt aNewRefCnt, |
michael@0 | 297 | const char *aTypeName, uint32_t aInstanceSize); |
michael@0 | 298 | |
michael@0 | 299 | XPCOM_API(void) |
michael@0 | 300 | NS_LogRelease(void *aPtr, nsrefcnt aNewRefCnt, const char *aTypeName); |
michael@0 | 301 | |
michael@0 | 302 | /** |
michael@0 | 303 | * Log reference counting performed by COMPtrs. Processing tools can |
michael@0 | 304 | * use the stacktraces printed by these functions to simplify reports |
michael@0 | 305 | * about leaked objects generated from the data printed by |
michael@0 | 306 | * NS_LogAddRef/NS_LogRelease. |
michael@0 | 307 | * |
michael@0 | 308 | * @param aCOMPtr the address of the COMPtr holding a strong reference |
michael@0 | 309 | * @param aObject the object being referenced by the COMPtr |
michael@0 | 310 | */ |
michael@0 | 311 | |
michael@0 | 312 | XPCOM_API(void) |
michael@0 | 313 | NS_LogCOMPtrAddRef(void *aCOMPtr, nsISupports *aObject); |
michael@0 | 314 | |
michael@0 | 315 | XPCOM_API(void) |
michael@0 | 316 | NS_LogCOMPtrRelease(void *aCOMPtr, nsISupports *aObject); |
michael@0 | 317 | |
michael@0 | 318 | /** |
michael@0 | 319 | * The XPCOM cycle collector analyzes and breaks reference cycles between |
michael@0 | 320 | * participating XPCOM objects. All objects in the cycle must implement |
michael@0 | 321 | * nsCycleCollectionParticipant to break cycles correctly. |
michael@0 | 322 | */ |
michael@0 | 323 | |
michael@0 | 324 | #ifdef __cplusplus |
michael@0 | 325 | |
michael@0 | 326 | class nsCycleCollectionParticipant; |
michael@0 | 327 | class nsCycleCollectingAutoRefCnt; |
michael@0 | 328 | |
michael@0 | 329 | XPCOM_API(void) |
michael@0 | 330 | NS_CycleCollectorSuspect3(void *n, nsCycleCollectionParticipant *p, |
michael@0 | 331 | nsCycleCollectingAutoRefCnt *aRefCnt, |
michael@0 | 332 | bool* aShouldDelete); |
michael@0 | 333 | |
michael@0 | 334 | #endif |
michael@0 | 335 | |
michael@0 | 336 | /** |
michael@0 | 337 | * Categories (in the category manager service) used by XPCOM: |
michael@0 | 338 | */ |
michael@0 | 339 | |
michael@0 | 340 | /** |
michael@0 | 341 | * A category which is read after component registration but before |
michael@0 | 342 | * the "xpcom-startup" notifications. Each category entry is treated |
michael@0 | 343 | * as the contract ID of a service which implements |
michael@0 | 344 | * nsIDirectoryServiceProvider. Each directory service provider is |
michael@0 | 345 | * installed in the global directory service. |
michael@0 | 346 | */ |
michael@0 | 347 | #define XPCOM_DIRECTORY_PROVIDER_CATEGORY "xpcom-directory-providers" |
michael@0 | 348 | |
michael@0 | 349 | /** |
michael@0 | 350 | * A category which is read after component registration but before |
michael@0 | 351 | * NS_InitXPCOM returns. Each category entry is treated as the contractID of |
michael@0 | 352 | * a service: each service is instantiated, and if it implements nsIObserver |
michael@0 | 353 | * the nsIObserver.observe method is called with the "xpcom-startup" topic. |
michael@0 | 354 | */ |
michael@0 | 355 | #define NS_XPCOM_STARTUP_CATEGORY "xpcom-startup" |
michael@0 | 356 | |
michael@0 | 357 | |
michael@0 | 358 | /** |
michael@0 | 359 | * Observer topics (in the observer service) used by XPCOM: |
michael@0 | 360 | */ |
michael@0 | 361 | |
michael@0 | 362 | /** |
michael@0 | 363 | * At XPCOM startup after component registration is complete, the |
michael@0 | 364 | * following topic is notified. In order to receive this notification, |
michael@0 | 365 | * component must register their contract ID in the category manager, |
michael@0 | 366 | * |
michael@0 | 367 | * @see NS_XPCOM_STARTUP_CATEGORY |
michael@0 | 368 | */ |
michael@0 | 369 | #define NS_XPCOM_STARTUP_OBSERVER_ID "xpcom-startup" |
michael@0 | 370 | |
michael@0 | 371 | /** |
michael@0 | 372 | * At XPCOM shutdown, this topic is notified just before "xpcom-shutdown". |
michael@0 | 373 | * Components should only use this to mark themselves as 'being destroyed'. |
michael@0 | 374 | * Nothing should be dispatched to any event loop. |
michael@0 | 375 | */ |
michael@0 | 376 | #define NS_XPCOM_WILL_SHUTDOWN_OBSERVER_ID "xpcom-will-shutdown" |
michael@0 | 377 | |
michael@0 | 378 | /** |
michael@0 | 379 | * At XPCOM shutdown, this topic is notified. All components must |
michael@0 | 380 | * release any interface references to objects in other modules when |
michael@0 | 381 | * this topic is notified. |
michael@0 | 382 | */ |
michael@0 | 383 | #define NS_XPCOM_SHUTDOWN_OBSERVER_ID "xpcom-shutdown" |
michael@0 | 384 | |
michael@0 | 385 | /** |
michael@0 | 386 | * This topic is notified when an entry was added to a category in the |
michael@0 | 387 | * category manager. The subject of the notification will be the name of |
michael@0 | 388 | * the added entry as an nsISupportsCString, and the data will be the |
michael@0 | 389 | * name of the category. The notification will occur on the main thread. |
michael@0 | 390 | */ |
michael@0 | 391 | #define NS_XPCOM_CATEGORY_ENTRY_ADDED_OBSERVER_ID \ |
michael@0 | 392 | "xpcom-category-entry-added" |
michael@0 | 393 | |
michael@0 | 394 | /** |
michael@0 | 395 | * This topic is notified when an entry was removed from a category in the |
michael@0 | 396 | * category manager. The subject of the notification will be the name of |
michael@0 | 397 | * the removed entry as an nsISupportsCString, and the data will be the |
michael@0 | 398 | * name of the category. The notification will occur on the main thread. |
michael@0 | 399 | */ |
michael@0 | 400 | #define NS_XPCOM_CATEGORY_ENTRY_REMOVED_OBSERVER_ID \ |
michael@0 | 401 | "xpcom-category-entry-removed" |
michael@0 | 402 | |
michael@0 | 403 | /** |
michael@0 | 404 | * This topic is notified when an a category was cleared in the category |
michael@0 | 405 | * manager. The subject of the notification will be the category manager, |
michael@0 | 406 | * and the data will be the name of the cleared category. |
michael@0 | 407 | * The notification will occur on the main thread. |
michael@0 | 408 | */ |
michael@0 | 409 | #define NS_XPCOM_CATEGORY_CLEARED_OBSERVER_ID "xpcom-category-cleared" |
michael@0 | 410 | |
michael@0 | 411 | XPCOM_API(nsresult) |
michael@0 | 412 | NS_GetDebug(nsIDebug* *result); |
michael@0 | 413 | |
michael@0 | 414 | #endif |