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.
1 /*
2 * Copyright 2008 The Android Open Source Project
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
8 /*
9 * Implementation of the user-space ashmem API for devices, which have our
10 * ashmem-enabled kernel. See ashmem-sim.c for the "fake" tmp-based version,
11 * used by the simulator.
12 */
14 #include <android/ashmem.h>
16 #include <unistd.h>
17 #include <string.h>
18 #include <sys/types.h>
19 #include <sys/stat.h>
20 #include <sys/ioctl.h>
21 #include <fcntl.h>
23 #include <linux/ashmem.h>
25 #define ASHMEM_DEVICE "/dev/ashmem"
27 /*
28 * ashmem_create_region - creates a new ashmem region and returns the file
29 * descriptor, or <0 on error
30 *
31 * `name' is an optional label to give the region (visible in /proc/pid/maps)
32 * `size' is the size of the region, in page-aligned bytes
33 */
34 int ashmem_create_region(const char *name, size_t size)
35 {
36 int fd, ret;
38 fd = open(ASHMEM_DEVICE, O_RDWR);
39 if (fd < 0)
40 return fd;
42 if (name) {
43 char buf[ASHMEM_NAME_LEN];
45 strlcpy(buf, name, sizeof(buf));
46 ret = ioctl(fd, ASHMEM_SET_NAME, buf);
47 if (ret < 0)
48 goto error;
49 }
51 ret = ioctl(fd, ASHMEM_SET_SIZE, size);
52 if (ret < 0)
53 goto error;
55 return fd;
57 error:
58 close(fd);
59 return ret;
60 }
62 int ashmem_set_prot_region(int fd, int prot)
63 {
64 return ioctl(fd, ASHMEM_SET_PROT_MASK, prot);
65 }
67 int ashmem_pin_region(int fd, size_t offset, size_t len)
68 {
69 struct ashmem_pin pin = { offset, len };
70 return ioctl(fd, ASHMEM_PIN, &pin);
71 }
73 int ashmem_unpin_region(int fd, size_t offset, size_t len)
74 {
75 struct ashmem_pin pin = { offset, len };
76 return ioctl(fd, ASHMEM_UNPIN, &pin);
77 }
79 int ashmem_get_size_region(int fd)
80 {
81 return ioctl(fd, ASHMEM_GET_SIZE, NULL);
82 }
84 int ashmem_purge_all_caches(int fd)
85 {
86 return ioctl(fd, ASHMEM_PURGE_ALL_CACHES, NULL);
87 }