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 | // |
michael@0 | 2 | // GTMGarbageCollection.h |
michael@0 | 3 | // |
michael@0 | 4 | // Copyright 2007-2008 Google Inc. |
michael@0 | 5 | // |
michael@0 | 6 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not |
michael@0 | 7 | // use this file except in compliance with the License. You may obtain a copy |
michael@0 | 8 | // of the License at |
michael@0 | 9 | // |
michael@0 | 10 | // http://www.apache.org/licenses/LICENSE-2.0 |
michael@0 | 11 | // |
michael@0 | 12 | // Unless required by applicable law or agreed to in writing, software |
michael@0 | 13 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
michael@0 | 14 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
michael@0 | 15 | // License for the specific language governing permissions and limitations under |
michael@0 | 16 | // the License. |
michael@0 | 17 | // |
michael@0 | 18 | |
michael@0 | 19 | #import <Foundation/Foundation.h> |
michael@0 | 20 | |
michael@0 | 21 | #import "GTMDefines.h" |
michael@0 | 22 | |
michael@0 | 23 | // This allows us to easily move our code from GC to non GC. |
michael@0 | 24 | // They are no-ops unless we are require Leopard or above. |
michael@0 | 25 | // See |
michael@0 | 26 | // http://developer.apple.com/documentation/Cocoa/Conceptual/GarbageCollection/index.html |
michael@0 | 27 | // and |
michael@0 | 28 | // http://developer.apple.com/documentation/Cocoa/Conceptual/GarbageCollection/Articles/gcCoreFoundation.html#//apple_ref/doc/uid/TP40006687-SW1 |
michael@0 | 29 | // for details. |
michael@0 | 30 | |
michael@0 | 31 | #if (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5) && !GTM_IPHONE_SDK |
michael@0 | 32 | // General use would be to call this through GTMCFAutorelease |
michael@0 | 33 | // but there may be a reason the you want to make something collectable |
michael@0 | 34 | // but not autoreleased, especially in pure GC code where you don't |
michael@0 | 35 | // want to bother with the nop autorelease. Done as a define instead of an |
michael@0 | 36 | // inline so that tools like Clang's scan-build don't report code as leaking. |
michael@0 | 37 | #define GTMNSMakeCollectable(cf) ((id)NSMakeCollectable(cf)) |
michael@0 | 38 | |
michael@0 | 39 | // GTMNSMakeUncollectable is for global maps, etc. that we don't |
michael@0 | 40 | // want released ever. You should still retain these in non-gc code. |
michael@0 | 41 | GTM_INLINE void GTMNSMakeUncollectable(id object) { |
michael@0 | 42 | [[NSGarbageCollector defaultCollector] disableCollectorForPointer:object]; |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | // Hopefully no code really needs this, but GTMIsGarbageCollectionEnabled is |
michael@0 | 46 | // a common way to check at runtime if GC is on. |
michael@0 | 47 | // There are some places where GC doesn't work w/ things w/in Apple's |
michael@0 | 48 | // frameworks, so this is here so GTM unittests and detect it, and not run |
michael@0 | 49 | // individual tests to work around bugs in Apple's frameworks. |
michael@0 | 50 | GTM_INLINE BOOL GTMIsGarbageCollectionEnabled(void) { |
michael@0 | 51 | return ([NSGarbageCollector defaultCollector] != nil); |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | #else |
michael@0 | 55 | |
michael@0 | 56 | #define GTMNSMakeCollectable(cf) ((id)(cf)) |
michael@0 | 57 | |
michael@0 | 58 | GTM_INLINE void GTMNSMakeUncollectable(id object) { |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | GTM_INLINE BOOL GTMIsGarbageCollectionEnabled(void) { |
michael@0 | 62 | return NO; |
michael@0 | 63 | } |
michael@0 | 64 | |
michael@0 | 65 | #endif |
michael@0 | 66 | |
michael@0 | 67 | // GTMCFAutorelease makes a CF object collectable in GC mode, or adds it |
michael@0 | 68 | // to the autorelease pool in non-GC mode. Either way it is taken care |
michael@0 | 69 | // of. Done as a define instead of an inline so that tools like Clang's |
michael@0 | 70 | // scan-build don't report code as leaking. |
michael@0 | 71 | #define GTMCFAutorelease(cf) ([GTMNSMakeCollectable(cf) autorelease]) |
michael@0 | 72 |