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 | /* |
michael@0 | 3 | * Copyright 2011 Google Inc. |
michael@0 | 4 | * |
michael@0 | 5 | * Use of this source code is governed by a BSD-style license that can be |
michael@0 | 6 | * found in the LICENSE file. |
michael@0 | 7 | */ |
michael@0 | 8 | #include "SkTypes.h" |
michael@0 | 9 | #include <stdio.h> |
michael@0 | 10 | #include <stdlib.h> |
michael@0 | 11 | |
michael@0 | 12 | static inline void* throw_on_failure(size_t size, void* p) { |
michael@0 | 13 | if (size > 0 && p == NULL) { |
michael@0 | 14 | // If we've got a NULL here, the only reason we should have failed is running out of RAM. |
michael@0 | 15 | sk_out_of_memory(); |
michael@0 | 16 | } |
michael@0 | 17 | return p; |
michael@0 | 18 | } |
michael@0 | 19 | |
michael@0 | 20 | void sk_throw() { |
michael@0 | 21 | SkDEBUGFAIL("sk_throw"); |
michael@0 | 22 | abort(); |
michael@0 | 23 | } |
michael@0 | 24 | |
michael@0 | 25 | void sk_out_of_memory(void) { |
michael@0 | 26 | SkDEBUGFAIL("sk_out_of_memory"); |
michael@0 | 27 | abort(); |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | void* sk_malloc_throw(size_t size) { |
michael@0 | 31 | return sk_malloc_flags(size, SK_MALLOC_THROW); |
michael@0 | 32 | } |
michael@0 | 33 | |
michael@0 | 34 | void* sk_realloc_throw(void* addr, size_t size) { |
michael@0 | 35 | return throw_on_failure(size, realloc(addr, size)); |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | void sk_free(void* p) { |
michael@0 | 39 | if (p) { |
michael@0 | 40 | free(p); |
michael@0 | 41 | } |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | void* sk_malloc_flags(size_t size, unsigned flags) { |
michael@0 | 45 | void* p = malloc(size); |
michael@0 | 46 | if (flags & SK_MALLOC_THROW) { |
michael@0 | 47 | return throw_on_failure(size, p); |
michael@0 | 48 | } else { |
michael@0 | 49 | return p; |
michael@0 | 50 | } |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | void* sk_calloc(size_t size) { |
michael@0 | 54 | return calloc(size, 1); |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | void* sk_calloc_throw(size_t size) { |
michael@0 | 58 | return throw_on_failure(size, sk_calloc(size)); |
michael@0 | 59 | } |