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 | // Copyright (c) 2008, Google Inc. |
michael@0 | 2 | // All rights reserved. |
michael@0 | 3 | // |
michael@0 | 4 | // Redistribution and use in source and binary forms, with or without |
michael@0 | 5 | // modification, are permitted provided that the following conditions are |
michael@0 | 6 | // met: |
michael@0 | 7 | // |
michael@0 | 8 | // * Redistributions of source code must retain the above copyright |
michael@0 | 9 | // notice, this list of conditions and the following disclaimer. |
michael@0 | 10 | // * Redistributions in binary form must reproduce the above |
michael@0 | 11 | // copyright notice, this list of conditions and the following disclaimer |
michael@0 | 12 | // in the documentation and/or other materials provided with the |
michael@0 | 13 | // distribution. |
michael@0 | 14 | // * Neither the name of Google Inc. nor the names of its |
michael@0 | 15 | // contributors may be used to endorse or promote products derived from |
michael@0 | 16 | // this software without specific prior written permission. |
michael@0 | 17 | // |
michael@0 | 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
michael@0 | 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
michael@0 | 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
michael@0 | 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
michael@0 | 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
michael@0 | 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
michael@0 | 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
michael@0 | 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
michael@0 | 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
michael@0 | 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
michael@0 | 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
michael@0 | 29 | |
michael@0 | 30 | #ifndef CLIENT_WINDOWS_COMMON_IPC_PROTOCOL_H__ |
michael@0 | 31 | #define CLIENT_WINDOWS_COMMON_IPC_PROTOCOL_H__ |
michael@0 | 32 | |
michael@0 | 33 | #include <Windows.h> |
michael@0 | 34 | #include <DbgHelp.h> |
michael@0 | 35 | #include <string> |
michael@0 | 36 | #include <utility> |
michael@0 | 37 | #include "common/windows/string_utils-inl.h" |
michael@0 | 38 | #include "google_breakpad/common/minidump_format.h" |
michael@0 | 39 | |
michael@0 | 40 | namespace google_breakpad { |
michael@0 | 41 | |
michael@0 | 42 | // Name/value pair for custom client information. |
michael@0 | 43 | struct CustomInfoEntry { |
michael@0 | 44 | // Maximum length for name and value for client custom info. |
michael@0 | 45 | static const int kNameMaxLength = 64; |
michael@0 | 46 | static const int kValueMaxLength = 64; |
michael@0 | 47 | |
michael@0 | 48 | CustomInfoEntry() { |
michael@0 | 49 | // Putting name and value in initializer list makes VC++ show warning 4351. |
michael@0 | 50 | set_name(NULL); |
michael@0 | 51 | set_value(NULL); |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | CustomInfoEntry(const wchar_t* name_arg, const wchar_t* value_arg) { |
michael@0 | 55 | set_name(name_arg); |
michael@0 | 56 | set_value(value_arg); |
michael@0 | 57 | } |
michael@0 | 58 | |
michael@0 | 59 | void set_name(const wchar_t* name_arg) { |
michael@0 | 60 | if (!name_arg) { |
michael@0 | 61 | name[0] = L'\0'; |
michael@0 | 62 | return; |
michael@0 | 63 | } |
michael@0 | 64 | WindowsStringUtils::safe_wcscpy(name, kNameMaxLength, name_arg); |
michael@0 | 65 | } |
michael@0 | 66 | |
michael@0 | 67 | void set_value(const wchar_t* value_arg) { |
michael@0 | 68 | if (!value_arg) { |
michael@0 | 69 | value[0] = L'\0'; |
michael@0 | 70 | return; |
michael@0 | 71 | } |
michael@0 | 72 | |
michael@0 | 73 | WindowsStringUtils::safe_wcscpy(value, kValueMaxLength, value_arg); |
michael@0 | 74 | } |
michael@0 | 75 | |
michael@0 | 76 | void set(const wchar_t* name_arg, const wchar_t* value_arg) { |
michael@0 | 77 | set_name(name_arg); |
michael@0 | 78 | set_value(value_arg); |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | wchar_t name[kNameMaxLength]; |
michael@0 | 82 | wchar_t value[kValueMaxLength]; |
michael@0 | 83 | }; |
michael@0 | 84 | |
michael@0 | 85 | // Constants for the protocol between client and the server. |
michael@0 | 86 | |
michael@0 | 87 | // Tags sent with each message indicating the purpose of |
michael@0 | 88 | // the message. |
michael@0 | 89 | enum MessageTag { |
michael@0 | 90 | MESSAGE_TAG_NONE = 0, |
michael@0 | 91 | MESSAGE_TAG_REGISTRATION_REQUEST = 1, |
michael@0 | 92 | MESSAGE_TAG_REGISTRATION_RESPONSE = 2, |
michael@0 | 93 | MESSAGE_TAG_REGISTRATION_ACK = 3, |
michael@0 | 94 | MESSAGE_TAG_UPLOAD_REQUEST = 4 |
michael@0 | 95 | }; |
michael@0 | 96 | |
michael@0 | 97 | struct CustomClientInfo { |
michael@0 | 98 | const CustomInfoEntry* entries; |
michael@0 | 99 | size_t count; |
michael@0 | 100 | }; |
michael@0 | 101 | |
michael@0 | 102 | // Message structure for IPC between crash client and crash server. |
michael@0 | 103 | struct ProtocolMessage { |
michael@0 | 104 | ProtocolMessage() |
michael@0 | 105 | : tag(MESSAGE_TAG_NONE), |
michael@0 | 106 | id(0), |
michael@0 | 107 | dump_type(MiniDumpNormal), |
michael@0 | 108 | thread_id(0), |
michael@0 | 109 | exception_pointers(NULL), |
michael@0 | 110 | assert_info(NULL), |
michael@0 | 111 | custom_client_info(), |
michael@0 | 112 | dump_request_handle(NULL), |
michael@0 | 113 | dump_generated_handle(NULL), |
michael@0 | 114 | server_alive_handle(NULL) { |
michael@0 | 115 | } |
michael@0 | 116 | |
michael@0 | 117 | // Creates an instance with the given parameters. |
michael@0 | 118 | ProtocolMessage(MessageTag arg_tag, |
michael@0 | 119 | DWORD arg_id, |
michael@0 | 120 | MINIDUMP_TYPE arg_dump_type, |
michael@0 | 121 | DWORD* arg_thread_id, |
michael@0 | 122 | EXCEPTION_POINTERS** arg_exception_pointers, |
michael@0 | 123 | MDRawAssertionInfo* arg_assert_info, |
michael@0 | 124 | const CustomClientInfo& custom_info, |
michael@0 | 125 | HANDLE arg_dump_request_handle, |
michael@0 | 126 | HANDLE arg_dump_generated_handle, |
michael@0 | 127 | HANDLE arg_server_alive) |
michael@0 | 128 | : tag(arg_tag), |
michael@0 | 129 | id(arg_id), |
michael@0 | 130 | dump_type(arg_dump_type), |
michael@0 | 131 | thread_id(arg_thread_id), |
michael@0 | 132 | exception_pointers(arg_exception_pointers), |
michael@0 | 133 | assert_info(arg_assert_info), |
michael@0 | 134 | custom_client_info(custom_info), |
michael@0 | 135 | dump_request_handle(arg_dump_request_handle), |
michael@0 | 136 | dump_generated_handle(arg_dump_generated_handle), |
michael@0 | 137 | server_alive_handle(arg_server_alive) { |
michael@0 | 138 | } |
michael@0 | 139 | |
michael@0 | 140 | // Tag in the message. |
michael@0 | 141 | MessageTag tag; |
michael@0 | 142 | |
michael@0 | 143 | // The id for this message. This may be either a process id or a crash id |
michael@0 | 144 | // depending on the type of message. |
michael@0 | 145 | DWORD id; |
michael@0 | 146 | |
michael@0 | 147 | // Dump type requested. |
michael@0 | 148 | MINIDUMP_TYPE dump_type; |
michael@0 | 149 | |
michael@0 | 150 | // Client thread id pointer. |
michael@0 | 151 | DWORD* thread_id; |
michael@0 | 152 | |
michael@0 | 153 | // Exception information. |
michael@0 | 154 | EXCEPTION_POINTERS** exception_pointers; |
michael@0 | 155 | |
michael@0 | 156 | // Assert information in case of an invalid parameter or |
michael@0 | 157 | // pure call failure. |
michael@0 | 158 | MDRawAssertionInfo* assert_info; |
michael@0 | 159 | |
michael@0 | 160 | // Custom client information. |
michael@0 | 161 | CustomClientInfo custom_client_info; |
michael@0 | 162 | |
michael@0 | 163 | // Handle to signal the crash event. |
michael@0 | 164 | HANDLE dump_request_handle; |
michael@0 | 165 | |
michael@0 | 166 | // Handle to check if server is done generating crash. |
michael@0 | 167 | HANDLE dump_generated_handle; |
michael@0 | 168 | |
michael@0 | 169 | // Handle to a mutex that becomes signaled (WAIT_ABANDONED) |
michael@0 | 170 | // if server process goes down. |
michael@0 | 171 | HANDLE server_alive_handle; |
michael@0 | 172 | |
michael@0 | 173 | private: |
michael@0 | 174 | // Disable copy ctor and operator=. |
michael@0 | 175 | ProtocolMessage(const ProtocolMessage& msg); |
michael@0 | 176 | ProtocolMessage& operator=(const ProtocolMessage& msg); |
michael@0 | 177 | }; |
michael@0 | 178 | |
michael@0 | 179 | } // namespace google_breakpad |
michael@0 | 180 | |
michael@0 | 181 | #endif // CLIENT_WINDOWS_COMMON_IPC_PROTOCOL_H__ |