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 2006 The Android Open Source Project |
michael@0 | 3 | * |
michael@0 | 4 | * Use of this source code is governed by a BSD-style license that can be |
michael@0 | 5 | * found in the LICENSE file. |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | #include "SkTime.h" |
michael@0 | 9 | |
michael@0 | 10 | #ifdef SK_BUILD_FOR_WIN |
michael@0 | 11 | |
michael@0 | 12 | #ifdef SK_DEBUG |
michael@0 | 13 | SkMSec gForceTickCount = (SkMSec) -1; |
michael@0 | 14 | #endif |
michael@0 | 15 | |
michael@0 | 16 | void SkTime::GetDateTime(DateTime* t) { |
michael@0 | 17 | if (t) { |
michael@0 | 18 | SYSTEMTIME syst; |
michael@0 | 19 | |
michael@0 | 20 | ::GetLocalTime(&syst); |
michael@0 | 21 | t->fYear = SkToU16(syst.wYear); |
michael@0 | 22 | t->fMonth = SkToU8(syst.wMonth); |
michael@0 | 23 | t->fDayOfWeek = SkToU8(syst.wDayOfWeek); |
michael@0 | 24 | t->fDay = SkToU8(syst.wDay); |
michael@0 | 25 | t->fHour = SkToU8(syst.wHour); |
michael@0 | 26 | t->fMinute = SkToU8(syst.wMinute); |
michael@0 | 27 | t->fSecond = SkToU8(syst.wSecond); |
michael@0 | 28 | } |
michael@0 | 29 | } |
michael@0 | 30 | |
michael@0 | 31 | SkMSec SkTime::GetMSecs() { |
michael@0 | 32 | #ifdef SK_DEBUG |
michael@0 | 33 | if (gForceTickCount != (SkMSec) -1) { |
michael@0 | 34 | return gForceTickCount; |
michael@0 | 35 | } |
michael@0 | 36 | #endif |
michael@0 | 37 | return ::GetTickCount(); |
michael@0 | 38 | } |
michael@0 | 39 | |
michael@0 | 40 | #elif defined(xSK_BUILD_FOR_MAC) |
michael@0 | 41 | |
michael@0 | 42 | #include <time.h> |
michael@0 | 43 | |
michael@0 | 44 | void SkTime::GetDateTime(DateTime* t) { |
michael@0 | 45 | if (t) { |
michael@0 | 46 | tm syst; |
michael@0 | 47 | time_t tm; |
michael@0 | 48 | |
michael@0 | 49 | time(&tm); |
michael@0 | 50 | localtime_r(&tm, &syst); |
michael@0 | 51 | t->fYear = SkToU16(syst.tm_year); |
michael@0 | 52 | t->fMonth = SkToU8(syst.tm_mon + 1); |
michael@0 | 53 | t->fDayOfWeek = SkToU8(syst.tm_wday); |
michael@0 | 54 | t->fDay = SkToU8(syst.tm_mday); |
michael@0 | 55 | t->fHour = SkToU8(syst.tm_hour); |
michael@0 | 56 | t->fMinute = SkToU8(syst.tm_min); |
michael@0 | 57 | t->fSecond = SkToU8(syst.tm_sec); |
michael@0 | 58 | } |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | SkMSec SkTime::GetMSecs() { |
michael@0 | 62 | UnsignedWide wide; |
michael@0 | 63 | ::Microseconds(&wide); |
michael@0 | 64 | |
michael@0 | 65 | int64_t s = ((int64_t)wide.hi << 32) | wide.lo; |
michael@0 | 66 | s = (s + 500) / 1000; // rounded divide |
michael@0 | 67 | return (SkMSec)s; |
michael@0 | 68 | } |
michael@0 | 69 | |
michael@0 | 70 | #endif |