gfx/skia/trunk/src/animator/SkTime.cpp

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 /*
     2  * Copyright 2006 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 #include "SkTime.h"
    10 #ifdef SK_BUILD_FOR_WIN
    12 #ifdef SK_DEBUG
    13 SkMSec gForceTickCount = (SkMSec) -1;
    14 #endif
    16 void SkTime::GetDateTime(DateTime* t) {
    17     if (t) {
    18         SYSTEMTIME  syst;
    20         ::GetLocalTime(&syst);
    21         t->fYear        = SkToU16(syst.wYear);
    22         t->fMonth       = SkToU8(syst.wMonth);
    23         t->fDayOfWeek   = SkToU8(syst.wDayOfWeek);
    24         t->fDay         = SkToU8(syst.wDay);
    25         t->fHour        = SkToU8(syst.wHour);
    26         t->fMinute      = SkToU8(syst.wMinute);
    27         t->fSecond      = SkToU8(syst.wSecond);
    28     }
    29 }
    31 SkMSec SkTime::GetMSecs() {
    32 #ifdef SK_DEBUG
    33     if (gForceTickCount != (SkMSec) -1) {
    34         return gForceTickCount;
    35     }
    36 #endif
    37     return ::GetTickCount();
    38 }
    40 #elif defined(xSK_BUILD_FOR_MAC)
    42 #include <time.h>
    44 void SkTime::GetDateTime(DateTime* t) {
    45     if (t) {
    46         tm      syst;
    47         time_t  tm;
    49         time(&tm);
    50         localtime_r(&tm, &syst);
    51         t->fYear        = SkToU16(syst.tm_year);
    52         t->fMonth       = SkToU8(syst.tm_mon + 1);
    53         t->fDayOfWeek   = SkToU8(syst.tm_wday);
    54         t->fDay         = SkToU8(syst.tm_mday);
    55         t->fHour        = SkToU8(syst.tm_hour);
    56         t->fMinute      = SkToU8(syst.tm_min);
    57         t->fSecond      = SkToU8(syst.tm_sec);
    58     }
    59 }
    61 SkMSec SkTime::GetMSecs() {
    62     UnsignedWide    wide;
    63     ::Microseconds(&wide);
    65     int64_t s = ((int64_t)wide.hi << 32) | wide.lo;
    66     s = (s + 500) / 1000;   // rounded divide
    67     return (SkMSec)s;
    68 }
    70 #endif

mercurial