xpcom/base/nsIMemory.idl

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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: 4; 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 #include "nsISupports.idl"
michael@0 7
michael@0 8 /**
michael@0 9 *
michael@0 10 * nsIMemory: interface to allocate and deallocate memory. Also provides
michael@0 11 * for notifications in low-memory situations.
michael@0 12 *
michael@0 13 * The frozen exported symbols NS_Alloc, NS_Realloc, and NS_Free
michael@0 14 * provide a more efficient way to access XPCOM memory allocation. Using
michael@0 15 * those symbols is preferred to using the methods on this interface.
michael@0 16 *
michael@0 17 * A client that wishes to be notified of low memory situations (for
michael@0 18 * example, because the client maintains a large memory cache that
michael@0 19 * could be released when memory is tight) should register with the
michael@0 20 * observer service (see nsIObserverService) using the topic
michael@0 21 * "memory-pressure". There are three specific types of notications
michael@0 22 * that can occur. These types will be passed as the |aData|
michael@0 23 * parameter of the of the "memory-pressure" notification:
michael@0 24 *
michael@0 25 * "low-memory"
michael@0 26 * This will be passed as the extra data when the pressure
michael@0 27 * observer is being asked to flush for low-memory conditions.
michael@0 28 *
michael@0 29 * "low-memory-ongoing"
michael@0 30 * This will be passed when we continue to be in a low-memory
michael@0 31 * condition and we want to flush caches and do other cheap
michael@0 32 * forms of memory minimization, but heavy handed approaches like
michael@0 33 * a GC are unlikely to succeed.
michael@0 34 *
michael@0 35 * "-no-forward"
michael@0 36 * This is appended to the above two parameters when the resulting
michael@0 37 * notification should not be forwarded to the child processes.
michael@0 38 *
michael@0 39 * "heap-minimize"
michael@0 40 * This will be passed as the extra data when the pressure
michael@0 41 * observer is being asked to flush because of a heap minimize
michael@0 42 * call.
michael@0 43 *
michael@0 44 * "alloc-failure"
michael@0 45 * This will be passed as the extra data when the pressure
michael@0 46 * observer has been asked to flush because a malloc() or
michael@0 47 * realloc() has failed.
michael@0 48 */
michael@0 49
michael@0 50 [scriptable, uuid(6aef11c4-8615-44a6-9711-98f43805693d)]
michael@0 51 interface nsIMemory : nsISupports
michael@0 52 {
michael@0 53 /**
michael@0 54 * Allocates a block of memory of a particular size. If the memory
michael@0 55 * cannot be allocated (because of an out-of-memory condition), the
michael@0 56 * process aborts.
michael@0 57 *
michael@0 58 * @param size - the size of the block to allocate
michael@0 59 * @result the block of memory
michael@0 60 */
michael@0 61 [noscript, notxpcom] voidPtr alloc(in size_t size);
michael@0 62
michael@0 63 /**
michael@0 64 * Reallocates a block of memory to a new size.
michael@0 65 *
michael@0 66 * @param ptr - the block of memory to reallocate
michael@0 67 * @param size - the new size
michael@0 68 * @result the reallocated block of memory
michael@0 69 *
michael@0 70 * If ptr is null, this function behaves like malloc.
michael@0 71 * If s is the size of the block to which ptr points, the first
michael@0 72 * min(s, size) bytes of ptr's block are copied to the new block.
michael@0 73 * If the allocation succeeds, ptr is freed and a pointer to the
michael@0 74 * new block returned. If the allocation fails, the process aborts.
michael@0 75 */
michael@0 76 [noscript, notxpcom] voidPtr realloc(in voidPtr ptr,
michael@0 77 in size_t newSize);
michael@0 78
michael@0 79 /**
michael@0 80 * Frees a block of memory. Null is a permissible value, in which case
michael@0 81 * nothing happens.
michael@0 82 *
michael@0 83 * @param ptr - the block of memory to free
michael@0 84 */
michael@0 85 [noscript, notxpcom] void free(in voidPtr ptr);
michael@0 86
michael@0 87 /**
michael@0 88 * Attempts to shrink the heap.
michael@0 89 * @param immediate - if true, heap minimization will occur
michael@0 90 * immediately if the call was made on the main thread. If
michael@0 91 * false, the flush will be scheduled to happen when the app is
michael@0 92 * idle.
michael@0 93 * @throws NS_ERROR_FAILURE if 'immediate' is set an the call
michael@0 94 * was not on the application's main thread.
michael@0 95 */
michael@0 96 void heapMinimize(in boolean immediate);
michael@0 97
michael@0 98 /**
michael@0 99 * This predicate can be used to determine if we're in a low-memory
michael@0 100 * situation (what constitutes low-memory is platform dependent). This
michael@0 101 * can be used to trigger the memory pressure observers.
michael@0 102 *
michael@0 103 * DEPRECATED - Always returns false. See bug 592308.
michael@0 104 */
michael@0 105 boolean isLowMemory();
michael@0 106
michael@0 107 /**
michael@0 108 * This predicate can be used to determine if the platform is a "low-memory"
michael@0 109 * platform. Callers may use this to dynamically tune their behaviour
michael@0 110 * to favour reduced memory usage at the expense of performance. The value
michael@0 111 * returned by this function will not change over the lifetime of the process.
michael@0 112 */
michael@0 113 boolean isLowMemoryPlatform();
michael@0 114 };
michael@0 115

mercurial