dom/camera/CameraCommon.h

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 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
     2 /* vim: set ts=2 et sw=2 tw=40: */
     3 /* This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     5  * You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 #ifndef DOM_CAMERA_CAMERACOMMON_H
     8 #define DOM_CAMERA_CAMERACOMMON_H
    10 #ifndef __func__
    11 #ifdef __FUNCTION__
    12 #define __func__ __FUNCTION__
    13 #else
    14 #define __func__ __FILE__
    15 #endif
    16 #endif
    18 #ifndef NAN
    19 #define NAN std::numeric_limits<double>::quiet_NaN()
    20 #endif
    22 #include "prlog.h"
    24 #ifdef PR_LOGGING
    25 extern PRLogModuleInfo* GetCameraLog();
    26 #define DOM_CAMERA_LOG( type, ... ) PR_LOG(GetCameraLog(), (PRLogModuleLevel)type, ( __VA_ARGS__ ))
    27 #else
    28 #define DOM_CAMERA_LOG( type, ... )
    29 #endif
    31 #define DOM_CAMERA_LOGA( ... )      DOM_CAMERA_LOG( 0, __VA_ARGS__ )
    33 /**
    34  * From the least to the most output.
    35  */
    36 enum {
    37   DOM_CAMERA_LOG_NOTHING,
    38   DOM_CAMERA_LOG_ERROR,
    39   DOM_CAMERA_LOG_WARNING,
    40   DOM_CAMERA_LOG_INFO,
    41   DOM_CAMERA_LOG_TRACE,
    42   DOM_CAMERA_LOG_REFERENCES
    43 };
    45 /**
    46  * DOM_CAMERA_LOGR() can be called before 'gCameraLog' is set, so
    47  * we need to handle this one a little differently.
    48  */
    49 #ifdef PR_LOGGING
    50 #define DOM_CAMERA_LOGR( ... )                                  \
    51   do {                                                          \
    52     if (GetCameraLog()) {                                       \
    53       DOM_CAMERA_LOG( DOM_CAMERA_LOG_REFERENCES, __VA_ARGS__ ); \
    54     }                                                           \
    55   } while (0)
    56 #else
    57 #define DOM_CAMERA_LOGR( ... )
    58 #endif
    59 #define DOM_CAMERA_LOGT( ... )      DOM_CAMERA_LOG( DOM_CAMERA_LOG_TRACE, __VA_ARGS__ )
    60 #define DOM_CAMERA_LOGI( ... )      DOM_CAMERA_LOG( DOM_CAMERA_LOG_INFO, __VA_ARGS__ )
    61 #define DOM_CAMERA_LOGW( ... )      DOM_CAMERA_LOG( DOM_CAMERA_LOG_WARNING, __VA_ARGS__ )
    62 #define DOM_CAMERA_LOGE( ... )      DOM_CAMERA_LOG( DOM_CAMERA_LOG_ERROR, __VA_ARGS__ )
    64 #endif // DOM_CAMERA_CAMERACOMMON_H

mercurial