1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/tools/profiler/SaveProfileTask.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,45 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "SaveProfileTask.h" 1.10 +#include "GeckoProfiler.h" 1.11 + 1.12 +nsresult 1.13 +SaveProfileTask::Run() { 1.14 + // Get file path 1.15 +#if defined(SPS_PLAT_arm_android) && !defined(MOZ_WIDGET_GONK) 1.16 + nsCString tmpPath; 1.17 + tmpPath.AppendPrintf("/sdcard/profile_%i_%i.txt", XRE_GetProcessType(), getpid()); 1.18 +#else 1.19 + nsCOMPtr<nsIFile> tmpFile; 1.20 + nsAutoCString tmpPath; 1.21 + if (NS_FAILED(NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(tmpFile)))) { 1.22 + LOG("Failed to find temporary directory."); 1.23 + return NS_ERROR_FAILURE; 1.24 + } 1.25 + tmpPath.AppendPrintf("profile_%i_%i.txt", XRE_GetProcessType(), getpid()); 1.26 + 1.27 + nsresult rv = tmpFile->AppendNative(tmpPath); 1.28 + if (NS_FAILED(rv)) 1.29 + return rv; 1.30 + 1.31 + rv = tmpFile->GetNativePath(tmpPath); 1.32 + if (NS_FAILED(rv)) 1.33 + return rv; 1.34 +#endif 1.35 + 1.36 + profiler_save_profile_to_file(tmpPath.get()); 1.37 + 1.38 + return NS_OK; 1.39 +} 1.40 + 1.41 +NS_IMPL_ISUPPORTS(ProfileSaveEvent, nsIProfileSaveEvent) 1.42 + 1.43 +nsresult 1.44 +ProfileSaveEvent::AddSubProfile(const char* aProfile) { 1.45 + mFunc(aProfile, mClosure); 1.46 + return NS_OK; 1.47 +} 1.48 +