tools/profiler/SaveProfileTask.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial