Tue, 06 Jan 2015 21:39:09 +0100
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.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "SaveProfileTask.h" |
michael@0 | 7 | #include "GeckoProfiler.h" |
michael@0 | 8 | |
michael@0 | 9 | nsresult |
michael@0 | 10 | SaveProfileTask::Run() { |
michael@0 | 11 | // Get file path |
michael@0 | 12 | #if defined(SPS_PLAT_arm_android) && !defined(MOZ_WIDGET_GONK) |
michael@0 | 13 | nsCString tmpPath; |
michael@0 | 14 | tmpPath.AppendPrintf("/sdcard/profile_%i_%i.txt", XRE_GetProcessType(), getpid()); |
michael@0 | 15 | #else |
michael@0 | 16 | nsCOMPtr<nsIFile> tmpFile; |
michael@0 | 17 | nsAutoCString tmpPath; |
michael@0 | 18 | if (NS_FAILED(NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(tmpFile)))) { |
michael@0 | 19 | LOG("Failed to find temporary directory."); |
michael@0 | 20 | return NS_ERROR_FAILURE; |
michael@0 | 21 | } |
michael@0 | 22 | tmpPath.AppendPrintf("profile_%i_%i.txt", XRE_GetProcessType(), getpid()); |
michael@0 | 23 | |
michael@0 | 24 | nsresult rv = tmpFile->AppendNative(tmpPath); |
michael@0 | 25 | if (NS_FAILED(rv)) |
michael@0 | 26 | return rv; |
michael@0 | 27 | |
michael@0 | 28 | rv = tmpFile->GetNativePath(tmpPath); |
michael@0 | 29 | if (NS_FAILED(rv)) |
michael@0 | 30 | return rv; |
michael@0 | 31 | #endif |
michael@0 | 32 | |
michael@0 | 33 | profiler_save_profile_to_file(tmpPath.get()); |
michael@0 | 34 | |
michael@0 | 35 | return NS_OK; |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | NS_IMPL_ISUPPORTS(ProfileSaveEvent, nsIProfileSaveEvent) |
michael@0 | 39 | |
michael@0 | 40 | nsresult |
michael@0 | 41 | ProfileSaveEvent::AddSubProfile(const char* aProfile) { |
michael@0 | 42 | mFunc(aProfile, mClosure); |
michael@0 | 43 | return NS_OK; |
michael@0 | 44 | } |
michael@0 | 45 |