tools/profiler/SaveProfileTask.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++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef PROFILER_SAVETASK_H_
     7 #define PROFILER_SAVETASK_H_
     9 #include "platform.h"
    10 #include "nsThreadUtils.h"
    11 #include "nsIXULRuntime.h"
    12 #include "nsDirectoryServiceUtils.h"
    13 #include "nsDirectoryServiceDefs.h"
    14 #include "nsXULAppAPI.h"
    15 #include "nsIJSRuntimeService.h"
    16 #include "nsIProfileSaveEvent.h"
    18 #ifdef XP_WIN
    19  #include <windows.h>
    20  #define getpid GetCurrentProcessId
    21 #else
    22  #include <unistd.h>
    23 #endif
    25 /**
    26  * This is an event used to save the profile on the main thread
    27  * to be sure that it is not being modified while saving.
    28  */
    29 class SaveProfileTask : public nsRunnable {
    30 public:
    31   SaveProfileTask() {}
    33   NS_IMETHOD Run();
    34 };
    36 class ProfileSaveEvent MOZ_FINAL : public nsIProfileSaveEvent {
    37 public:
    38   typedef void (*AddSubProfileFunc)(const char* aProfile, void* aClosure);
    39   NS_DECL_ISUPPORTS
    41   ProfileSaveEvent(AddSubProfileFunc aFunc, void* aClosure)
    42     : mFunc(aFunc)
    43     , mClosure(aClosure)
    44   {}
    46   ~ProfileSaveEvent() {}
    48   NS_IMETHOD AddSubProfile(const char* aProfile);
    49 private:
    50   AddSubProfileFunc mFunc;
    51   void* mClosure;
    52 };
    54 #endif

mercurial