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 | // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. |
michael@0 | 3 | // Use of this source code is governed by a BSD-style license that can be |
michael@0 | 4 | // found in the LICENSE file. |
michael@0 | 5 | // |
michael@0 | 6 | |
michael@0 | 7 | #ifndef _COMMON_INCLUDED_ |
michael@0 | 8 | #define _COMMON_INCLUDED_ |
michael@0 | 9 | |
michael@0 | 10 | #include <map> |
michael@0 | 11 | #include <sstream> |
michael@0 | 12 | #include <string> |
michael@0 | 13 | #include <vector> |
michael@0 | 14 | |
michael@0 | 15 | #include "compiler/PoolAlloc.h" |
michael@0 | 16 | |
michael@0 | 17 | struct TSourceLoc { |
michael@0 | 18 | int first_file; |
michael@0 | 19 | int first_line; |
michael@0 | 20 | int last_file; |
michael@0 | 21 | int last_line; |
michael@0 | 22 | }; |
michael@0 | 23 | |
michael@0 | 24 | // |
michael@0 | 25 | // Put POOL_ALLOCATOR_NEW_DELETE in base classes to make them use this scheme. |
michael@0 | 26 | // |
michael@0 | 27 | #define POOL_ALLOCATOR_NEW_DELETE() \ |
michael@0 | 28 | void* operator new(size_t s) { return GetGlobalPoolAllocator()->allocate(s); } \ |
michael@0 | 29 | void* operator new(size_t, void *_Where) { return (_Where); } \ |
michael@0 | 30 | void operator delete(void*) { } \ |
michael@0 | 31 | void operator delete(void *, void *) { } \ |
michael@0 | 32 | void* operator new[](size_t s) { return GetGlobalPoolAllocator()->allocate(s); } \ |
michael@0 | 33 | void* operator new[](size_t, void *_Where) { return (_Where); } \ |
michael@0 | 34 | void operator delete[](void*) { } \ |
michael@0 | 35 | void operator delete[](void *, void *) { } |
michael@0 | 36 | |
michael@0 | 37 | // |
michael@0 | 38 | // Pool version of string. |
michael@0 | 39 | // |
michael@0 | 40 | typedef pool_allocator<char> TStringAllocator; |
michael@0 | 41 | typedef std::basic_string <char, std::char_traits<char>, TStringAllocator> TString; |
michael@0 | 42 | typedef std::basic_ostringstream<char, std::char_traits<char>, TStringAllocator> TStringStream; |
michael@0 | 43 | inline TString* NewPoolTString(const char* s) |
michael@0 | 44 | { |
michael@0 | 45 | void* memory = GetGlobalPoolAllocator()->allocate(sizeof(TString)); |
michael@0 | 46 | return new(memory) TString(s); |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | // |
michael@0 | 50 | // Persistent string memory. Should only be used for strings that survive |
michael@0 | 51 | // across compiles. |
michael@0 | 52 | // |
michael@0 | 53 | #define TPersistString std::string |
michael@0 | 54 | #define TPersistStringStream std::ostringstream |
michael@0 | 55 | |
michael@0 | 56 | // |
michael@0 | 57 | // Pool allocator versions of vectors, lists, and maps |
michael@0 | 58 | // |
michael@0 | 59 | template <class T> class TVector : public std::vector<T, pool_allocator<T> > { |
michael@0 | 60 | public: |
michael@0 | 61 | typedef typename std::vector<T, pool_allocator<T> >::size_type size_type; |
michael@0 | 62 | TVector() : std::vector<T, pool_allocator<T> >() {} |
michael@0 | 63 | TVector(const pool_allocator<T>& a) : std::vector<T, pool_allocator<T> >(a) {} |
michael@0 | 64 | TVector(size_type i): std::vector<T, pool_allocator<T> >(i) {} |
michael@0 | 65 | }; |
michael@0 | 66 | |
michael@0 | 67 | template <class K, class D, class CMP = std::less<K> > |
michael@0 | 68 | class TMap : public std::map<K, D, CMP, pool_allocator<std::pair<const K, D> > > { |
michael@0 | 69 | public: |
michael@0 | 70 | typedef pool_allocator<std::pair<const K, D> > tAllocator; |
michael@0 | 71 | |
michael@0 | 72 | TMap() : std::map<K, D, CMP, tAllocator>() {} |
michael@0 | 73 | // use correct two-stage name lookup supported in gcc 3.4 and above |
michael@0 | 74 | TMap(const tAllocator& a) : std::map<K, D, CMP, tAllocator>(std::map<K, D, CMP, tAllocator>::key_compare(), a) {} |
michael@0 | 75 | }; |
michael@0 | 76 | |
michael@0 | 77 | #endif // _COMMON_INCLUDED_ |