security/sandbox/chromium/base/sequence_checker.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 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
     2 // Use of this source code is governed by a BSD-style license that can be
     3 // found in the LICENSE file.
     5 #ifndef BASE_SEQUENCE_CHECKER_H_
     6 #define BASE_SEQUENCE_CHECKER_H_
     8 #include "base/memory/ref_counted.h"
    10 // See comments for the similar block in thread_checker.h.
    11 #if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON))
    12 #define ENABLE_SEQUENCE_CHECKER 1
    13 #else
    14 #define ENABLE_SEQUENCE_CHECKER 0
    15 #endif
    17 #if ENABLE_SEQUENCE_CHECKER
    18 #include "base/sequence_checker_impl.h"
    19 #endif
    21 namespace base {
    23 class SequencedTaskRunner;
    25 // Do nothing implementation, for use in release mode.
    26 //
    27 // Note: You should almost always use the SequenceChecker class to get
    28 // the right version for your build configuration.
    29 class SequenceCheckerDoNothing {
    30  public:
    31   bool CalledOnValidSequencedThread() const {
    32     return true;
    33   }
    35   void DetachFromSequence() {}
    36 };
    38 // SequenceChecker is a helper class used to help verify that some
    39 // methods of a class are called in sequence -- that is, called from
    40 // the same SequencedTaskRunner. It is a generalization of
    41 // ThreadChecker; see comments in sequence_checker_impl.h for details.
    42 //
    43 // Example:
    44 // class MyClass {
    45 //  public:
    46 //   void Foo() {
    47 //     DCHECK(sequence_checker_.CalledOnValidSequence());
    48 //     ... (do stuff) ...
    49 //   }
    50 //
    51 //  private:
    52 //   SequenceChecker sequence_checker_;
    53 // }
    54 //
    55 // In Release mode, CalledOnValidSequence will always return true.
    56 #if ENABLE_SEQUENCE_CHECKER
    57 class SequenceChecker : public SequenceCheckerImpl {
    58 };
    59 #else
    60 class SequenceChecker : public SequenceCheckerDoNothing {
    61 };
    62 #endif  // ENABLE_SEQUENCE_CHECKER
    64 #undef ENABLE_SEQUENCE_CHECKER
    66 }  // namespace base
    68 #endif  // BASE_SEQUENCE_CHECKER_H_

mercurial