1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/tools/profiler/SaveProfileTask.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,55 @@ 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 +#ifndef PROFILER_SAVETASK_H_ 1.10 +#define PROFILER_SAVETASK_H_ 1.11 + 1.12 +#include "platform.h" 1.13 +#include "nsThreadUtils.h" 1.14 +#include "nsIXULRuntime.h" 1.15 +#include "nsDirectoryServiceUtils.h" 1.16 +#include "nsDirectoryServiceDefs.h" 1.17 +#include "nsXULAppAPI.h" 1.18 +#include "nsIJSRuntimeService.h" 1.19 +#include "nsIProfileSaveEvent.h" 1.20 + 1.21 +#ifdef XP_WIN 1.22 + #include <windows.h> 1.23 + #define getpid GetCurrentProcessId 1.24 +#else 1.25 + #include <unistd.h> 1.26 +#endif 1.27 + 1.28 +/** 1.29 + * This is an event used to save the profile on the main thread 1.30 + * to be sure that it is not being modified while saving. 1.31 + */ 1.32 +class SaveProfileTask : public nsRunnable { 1.33 +public: 1.34 + SaveProfileTask() {} 1.35 + 1.36 + NS_IMETHOD Run(); 1.37 +}; 1.38 + 1.39 +class ProfileSaveEvent MOZ_FINAL : public nsIProfileSaveEvent { 1.40 +public: 1.41 + typedef void (*AddSubProfileFunc)(const char* aProfile, void* aClosure); 1.42 + NS_DECL_ISUPPORTS 1.43 + 1.44 + ProfileSaveEvent(AddSubProfileFunc aFunc, void* aClosure) 1.45 + : mFunc(aFunc) 1.46 + , mClosure(aClosure) 1.47 + {} 1.48 + 1.49 + ~ProfileSaveEvent() {} 1.50 + 1.51 + NS_IMETHOD AddSubProfile(const char* aProfile); 1.52 +private: 1.53 + AddSubProfileFunc mFunc; 1.54 + void* mClosure; 1.55 +}; 1.56 + 1.57 +#endif 1.58 +