toolkit/crashreporter/google-breakpad/src/common/mac/arch_utilities.cc

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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.

     1 // Copyright (c) 2012, Google Inc.
     2 // All rights reserved.
     3 //
     4 // Redistribution and use in source and binary forms, with or without
     5 // modification, are permitted provided that the following conditions are
     6 // met:
     7 //
     8 //     * Redistributions of source code must retain the above copyright
     9 // notice, this list of conditions and the following disclaimer.
    10 //     * Redistributions in binary form must reproduce the above
    11 // copyright notice, this list of conditions and the following disclaimer
    12 // in the documentation and/or other materials provided with the
    13 // distribution.
    14 //     * Neither the name of Google Inc. nor the names of its
    15 // contributors may be used to endorse or promote products derived from
    16 // this software without specific prior written permission.
    17 //
    18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    30 #include "common/mac/arch_utilities.h"
    32 #include <mach-o/arch.h>
    33 #include <stdio.h>
    34 #include <string.h>
    36 #ifndef CPU_TYPE_ARM
    37 #define CPU_TYPE_ARM (static_cast<cpu_type_t>(12))
    38 #endif  // CPU_TYPE_ARM
    40 #ifndef CPU_SUBTYPE_ARM_V7
    41 #define CPU_SUBTYPE_ARM_V7 (static_cast<cpu_subtype_t>(9))
    42 #endif  // CPU_SUBTYPE_ARM_V7
    44 #ifndef CPU_SUBTYPE_ARM_V7S
    45 #define CPU_SUBTYPE_ARM_V7S (static_cast<cpu_subtype_t>(11))
    46 #endif  // CPU_SUBTYPE_ARM_V7S
    48 namespace {
    50 const NXArchInfo* ArchInfo_armv7s() {
    51   NXArchInfo* armv7s = new NXArchInfo;
    52   *armv7s = *NXGetArchInfoFromCpuType(CPU_TYPE_ARM,
    53                                       CPU_SUBTYPE_ARM_V7);
    54   armv7s->name = "armv7s";
    55   armv7s->cpusubtype = CPU_SUBTYPE_ARM_V7S;
    56   armv7s->description = "arm v7s";
    57   return armv7s;
    58 }
    60 }  // namespace
    62 namespace google_breakpad {
    64 const NXArchInfo* BreakpadGetArchInfoFromName(const char* arch_name) {
    65   // TODO: Remove this when the OS knows about armv7s.
    66   if (!strcmp("armv7s", arch_name))
    67     return BreakpadGetArchInfoFromCpuType(CPU_TYPE_ARM, CPU_SUBTYPE_ARM_V7S);
    68   return NXGetArchInfoFromName(arch_name);
    69 }
    71 const NXArchInfo* BreakpadGetArchInfoFromCpuType(cpu_type_t cpu_type,
    72                                                  cpu_subtype_t cpu_subtype) {
    73   // TODO: Remove this when the OS knows about armv7s.
    74   if (cpu_type == CPU_TYPE_ARM && cpu_subtype == CPU_SUBTYPE_ARM_V7S) {
    75     static const NXArchInfo* armv7s = ArchInfo_armv7s();
    76     return armv7s;
    77   }
    78   return NXGetArchInfoFromCpuType(cpu_type, cpu_subtype);
    79 }
    81 }  // namespace google_breakpad

mercurial