michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "SaveProfileTask.h" michael@0: #include "GeckoProfiler.h" michael@0: michael@0: nsresult michael@0: SaveProfileTask::Run() { michael@0: // Get file path michael@0: #if defined(SPS_PLAT_arm_android) && !defined(MOZ_WIDGET_GONK) michael@0: nsCString tmpPath; michael@0: tmpPath.AppendPrintf("/sdcard/profile_%i_%i.txt", XRE_GetProcessType(), getpid()); michael@0: #else michael@0: nsCOMPtr tmpFile; michael@0: nsAutoCString tmpPath; michael@0: if (NS_FAILED(NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(tmpFile)))) { michael@0: LOG("Failed to find temporary directory."); michael@0: return NS_ERROR_FAILURE; michael@0: } michael@0: tmpPath.AppendPrintf("profile_%i_%i.txt", XRE_GetProcessType(), getpid()); michael@0: michael@0: nsresult rv = tmpFile->AppendNative(tmpPath); michael@0: if (NS_FAILED(rv)) michael@0: return rv; michael@0: michael@0: rv = tmpFile->GetNativePath(tmpPath); michael@0: if (NS_FAILED(rv)) michael@0: return rv; michael@0: #endif michael@0: michael@0: profiler_save_profile_to_file(tmpPath.get()); michael@0: michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMPL_ISUPPORTS(ProfileSaveEvent, nsIProfileSaveEvent) michael@0: michael@0: nsresult michael@0: ProfileSaveEvent::AddSubProfile(const char* aProfile) { michael@0: mFunc(aProfile, mClosure); michael@0: return NS_OK; michael@0: } michael@0: