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) 1999 |
michael@0 | 3 | * Silicon Graphics Computer Systems, Inc. |
michael@0 | 4 | * |
michael@0 | 5 | * Copyright (c) 1999 |
michael@0 | 6 | * Boris Fomitchev |
michael@0 | 7 | * |
michael@0 | 8 | * This material is provided "as is", with absolutely no warranty expressed |
michael@0 | 9 | * or implied. Any use is at your own risk. |
michael@0 | 10 | * |
michael@0 | 11 | * Permission to use or copy this software for any purpose is hereby granted |
michael@0 | 12 | * without fee, provided the above notices are retained on all copies. |
michael@0 | 13 | * Permission to modify the code and to distribute modified code is granted, |
michael@0 | 14 | * provided the above notices are retained, and a notice that the code was |
michael@0 | 15 | * modified is included with the above copyright notice. |
michael@0 | 16 | * |
michael@0 | 17 | */ |
michael@0 | 18 | |
michael@0 | 19 | #include "stlport_prefix.h" |
michael@0 | 20 | |
michael@0 | 21 | #ifdef _STLP_USE_UNIX_IO |
michael@0 | 22 | # include "details/fstream_unistd.cpp" |
michael@0 | 23 | #elif defined(_STLP_USE_STDIO_IO) |
michael@0 | 24 | # include "details/fstream_stdio.cpp" |
michael@0 | 25 | #elif defined(_STLP_USE_WIN32_IO) |
michael@0 | 26 | # include "details/fstream_win32io.cpp" |
michael@0 | 27 | #else |
michael@0 | 28 | # error "Can't recognize IO scheme to use" |
michael@0 | 29 | #endif |
michael@0 | 30 | |
michael@0 | 31 | _STLP_BEGIN_NAMESPACE |
michael@0 | 32 | |
michael@0 | 33 | // fbp : let us map 1 MB maximum, just be sure not to trash VM |
michael@0 | 34 | #define MMAP_CHUNK 0x100000L |
michael@0 | 35 | |
michael@0 | 36 | _Underflow< char, char_traits<char> >::int_type _STLP_CALL |
michael@0 | 37 | _Underflow< char, char_traits<char> >::_M_doit(basic_filebuf<char, char_traits<char> >* __this) |
michael@0 | 38 | { |
michael@0 | 39 | typedef char_traits<char> traits_type; |
michael@0 | 40 | typedef traits_type::int_type int_type; |
michael@0 | 41 | |
michael@0 | 42 | if (!__this->_M_in_input_mode) { |
michael@0 | 43 | if (!__this->_M_switch_to_input_mode()) |
michael@0 | 44 | return traits_type::eof(); |
michael@0 | 45 | } |
michael@0 | 46 | else if (__this->_M_in_putback_mode) { |
michael@0 | 47 | __this->_M_exit_putback_mode(); |
michael@0 | 48 | if (__this->gptr() != __this->egptr()) { |
michael@0 | 49 | int_type __c = traits_type::to_int_type(*__this->gptr()); |
michael@0 | 50 | return __c; |
michael@0 | 51 | } |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | // If it's a disk file, and if the internal and external character |
michael@0 | 55 | // sequences are guaranteed to be identical, then try to use memory |
michael@0 | 56 | // mapped I/O. Otherwise, revert to ordinary read. |
michael@0 | 57 | if (__this->_M_base.__regular_file() |
michael@0 | 58 | && __this->_M_always_noconv |
michael@0 | 59 | && __this->_M_base._M_in_binary_mode()) { |
michael@0 | 60 | // If we've mmapped part of the file already, then unmap it. |
michael@0 | 61 | if (__this->_M_mmap_base) |
michael@0 | 62 | __this->_M_base._M_unmap(__this->_M_mmap_base, __this->_M_mmap_len); |
michael@0 | 63 | |
michael@0 | 64 | // Determine the position where we start mapping. It has to be |
michael@0 | 65 | // a multiple of the page size. |
michael@0 | 66 | streamoff __cur = __this->_M_base._M_seek(0, ios_base::cur); |
michael@0 | 67 | streamoff __size = __this->_M_base._M_file_size(); |
michael@0 | 68 | if (__size > 0 && __cur >= 0 && __cur < __size) { |
michael@0 | 69 | streamoff __offset = (__cur / __this->_M_base.__page_size()) * __this->_M_base.__page_size(); |
michael@0 | 70 | streamoff __remainder = __cur - __offset; |
michael@0 | 71 | |
michael@0 | 72 | __this->_M_mmap_len = __size - __offset; |
michael@0 | 73 | |
michael@0 | 74 | if (__this->_M_mmap_len > MMAP_CHUNK) |
michael@0 | 75 | __this->_M_mmap_len = MMAP_CHUNK; |
michael@0 | 76 | |
michael@0 | 77 | if ((__this->_M_mmap_base = __this->_M_base._M_mmap(__offset, __this->_M_mmap_len)) != 0) { |
michael@0 | 78 | __this->setg(__STATIC_CAST(char*, __this->_M_mmap_base), |
michael@0 | 79 | __STATIC_CAST(char*, __this->_M_mmap_base) + __STATIC_CAST(ptrdiff_t, __remainder), |
michael@0 | 80 | __STATIC_CAST(char*, __this->_M_mmap_base) + __STATIC_CAST(ptrdiff_t, __this->_M_mmap_len)); |
michael@0 | 81 | return traits_type::to_int_type(*__this->gptr()); |
michael@0 | 82 | } |
michael@0 | 83 | else |
michael@0 | 84 | __this->_M_mmap_len = 0; |
michael@0 | 85 | } |
michael@0 | 86 | else { |
michael@0 | 87 | __this->_M_mmap_base = 0; |
michael@0 | 88 | __this->_M_mmap_len = 0; |
michael@0 | 89 | } |
michael@0 | 90 | } |
michael@0 | 91 | |
michael@0 | 92 | return __this->_M_underflow_aux(); |
michael@0 | 93 | } |
michael@0 | 94 | |
michael@0 | 95 | //---------------------------------------------------------------------- |
michael@0 | 96 | // Force instantiation of filebuf and fstream classes. |
michael@0 | 97 | #if !defined(_STLP_NO_FORCE_INSTANTIATE) |
michael@0 | 98 | |
michael@0 | 99 | template class basic_filebuf<char, char_traits<char> >; |
michael@0 | 100 | template class basic_ifstream<char, char_traits<char> >; |
michael@0 | 101 | template class basic_ofstream<char, char_traits<char> >; |
michael@0 | 102 | template class basic_fstream<char, char_traits<char> >; |
michael@0 | 103 | |
michael@0 | 104 | # if !defined (_STLP_NO_WCHAR_T) |
michael@0 | 105 | template class _Underflow<wchar_t, char_traits<wchar_t> >; |
michael@0 | 106 | template class basic_filebuf<wchar_t, char_traits<wchar_t> >; |
michael@0 | 107 | template class basic_ifstream<wchar_t, char_traits<wchar_t> >; |
michael@0 | 108 | template class basic_ofstream<wchar_t, char_traits<wchar_t> >; |
michael@0 | 109 | template class basic_fstream<wchar_t, char_traits<wchar_t> >; |
michael@0 | 110 | # endif /* _STLP_NO_WCHAR_T */ |
michael@0 | 111 | |
michael@0 | 112 | #endif |
michael@0 | 113 | |
michael@0 | 114 | _STLP_END_NAMESPACE |