mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
Bug 770899 - Prefetch clearing should be repurposed to delete 0 sized read only .pf files only. r=taras
This commit is contained in:
parent
86ed155a34
commit
67fa1f590b
@ -194,8 +194,6 @@ static SETTING gDDESettings[] = {
|
||||
{ MAKE_KEY_NAME1("Software\\Classes\\HTTPS", SOD) }
|
||||
};
|
||||
|
||||
// See Bug 770883
|
||||
#if 0
|
||||
#if defined(MOZ_MAINTENANCE_SERVICE)
|
||||
|
||||
#define ONLY_SERVICE_LAUNCHING
|
||||
@ -206,7 +204,6 @@ static const char *kPrefetchClearedPref =
|
||||
"app.update.service.lastVersionPrefetchCleared";
|
||||
static nsCOMPtr<nsIThread> sThread;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
nsresult
|
||||
GetHelperPath(nsAutoString& aPath)
|
||||
@ -1004,8 +1001,6 @@ nsWindowsShellService::SetDesktopBackgroundColor(PRUint32 aColor)
|
||||
nsWindowsShellService::nsWindowsShellService() :
|
||||
mCheckedThisSession(false)
|
||||
{
|
||||
// See Bug 770883
|
||||
#if 0
|
||||
#if defined(MOZ_MAINTENANCE_SERVICE)
|
||||
|
||||
// Check to make sure the service is installed
|
||||
@ -1050,13 +1045,10 @@ nsWindowsShellService::nsWindowsShellService() :
|
||||
nsnull, CLEAR_PREFETCH_TIMEOUT_MS, nsITimer::TYPE_ONE_SHOT);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
nsWindowsShellService::~nsWindowsShellService()
|
||||
{
|
||||
// See Bug 770883
|
||||
#if 0
|
||||
#if defined(MOZ_MAINTENANCE_SERVICE)
|
||||
if (mTimer) {
|
||||
mTimer->Cancel();
|
||||
@ -1067,11 +1059,8 @@ nsWindowsShellService::~nsWindowsShellService()
|
||||
sThread = nsnull;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
// See Bug 770883
|
||||
#if 0
|
||||
#if defined(MOZ_MAINTENANCE_SERVICE)
|
||||
|
||||
class ClearPrefetchEvent : public nsRunnable {
|
||||
@ -1094,7 +1083,6 @@ public:
|
||||
}
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* For faster startup we attempt to clear the prefetch if the maintenance
|
||||
@ -1105,8 +1093,6 @@ public:
|
||||
* This is done on every update but also there is a one time operation done
|
||||
* from within the program for first time installs.
|
||||
*/
|
||||
// See Bug 770883
|
||||
#if 0
|
||||
#if defined(MOZ_MAINTENANCE_SERVICE)
|
||||
void
|
||||
nsWindowsShellService::LaunchPrefetchClearCommand(nsITimer *aTimer, void*)
|
||||
@ -1131,7 +1117,6 @@ nsWindowsShellService::LaunchPrefetchClearCommand(nsITimer *aTimer, void*)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowsShellService::OpenApplicationWithURI(nsIFile* aApplication,
|
||||
|
@ -37,23 +37,10 @@ WritePrefetchClearedReg()
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL
|
||||
PrefetchFileAlreadyCleared(LPCWSTR prefetchPath)
|
||||
{
|
||||
DWORD attributes = GetFileAttributes(prefetchPath);
|
||||
BOOL alreadyCleared = attributes != INVALID_FILE_ATTRIBUTES &&
|
||||
attributes & FILE_ATTRIBUTE_READONLY;
|
||||
|
||||
nsAutoHandle prefetchFile(CreateFile(prefetchPath, GENERIC_READ, 0, NULL,
|
||||
OPEN_EXISTING, 0, NULL));
|
||||
LARGE_INTEGER fileSize = { 0, 0 };
|
||||
alreadyCleared &= prefetchFile != INVALID_HANDLE_VALUE &&
|
||||
GetFileSizeEx(prefetchFile, &fileSize) &&
|
||||
fileSize.QuadPart == 0;
|
||||
return alreadyCleared;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update: We found that prefetch clearing was a net negative, so this
|
||||
* function has been updated to delete the read only prefetch files.
|
||||
* -----------------------------------------------------------------------
|
||||
* We found that prefetch actually causes large applications like Firefox
|
||||
* to startup slower. This will get rid of the Windows prefetch files for
|
||||
* applications like firefox (FIREFOX-*.pf files) and instead replace them
|
||||
@ -159,40 +146,34 @@ ClearPrefetch(LPCWSTR prefetchProcessName)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (PrefetchFileAlreadyCleared(prefetchPath)) {
|
||||
++deletedCount;
|
||||
LOG(("Prefetch file already cleared: %ls\n", prefetchPath));
|
||||
continue;
|
||||
}
|
||||
|
||||
// Delete the prefetch file and replace it with a blank read only file
|
||||
HANDLE prefetchFile =
|
||||
CreateFile(prefetchPath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
|
||||
if (INVALID_HANDLE_VALUE == prefetchFile) {
|
||||
LOG(("Error replacing prefetch path %ls. (%d)\n", findFileData.cFileName,
|
||||
GetLastError()));
|
||||
deletedAllFFPrefetch = FALSE;
|
||||
continue;
|
||||
}
|
||||
|
||||
CloseHandle(prefetchFile);
|
||||
|
||||
DWORD attributes = GetFileAttributes(prefetchPath);
|
||||
DWORD attributes = GetFileAttributesW(prefetchPath);
|
||||
if (INVALID_FILE_ATTRIBUTES == attributes) {
|
||||
LOG(("Could not get/set attributes on prefetch file: %ls. (%d)\n",
|
||||
findFileData.cFileName, GetLastError()));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!(attributes & FILE_ATTRIBUTE_READONLY)) {
|
||||
LOG(("Prefetch file is not read-only, don't clear: %ls.\n",
|
||||
findFileData.cFileName));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!SetFileAttributes(prefetchPath,
|
||||
attributes | FILE_ATTRIBUTE_READONLY)) {
|
||||
// Remove the read only attribute so a DeleteFile call will work.
|
||||
if (!SetFileAttributesW(prefetchPath,
|
||||
attributes & (~FILE_ATTRIBUTE_READONLY))) {
|
||||
LOG(("Could not set read only on prefetch file: %ls. (%d)\n",
|
||||
findFileData.cFileName, GetLastError()));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!DeleteFileW(prefetchPath)) {
|
||||
LOG(("Could not delete read only prefetch file: %ls. (%d)\n",
|
||||
findFileData.cFileName, GetLastError()));
|
||||
}
|
||||
|
||||
++deletedCount;
|
||||
LOG(("Prefetch file cleared and set to read-only successfully: %ls\n",
|
||||
LOG(("Prefetch file cleared successfully: %ls\n",
|
||||
prefetchPath));
|
||||
} while (FindNextFileW(findHandle, &findFileData));
|
||||
LOG(("Done searching prefetch paths. (%d)\n", GetLastError()));
|
||||
|
@ -504,14 +504,9 @@ ExecuteServiceCommand(int argc, LPWSTR *argv)
|
||||
// because the service self updates itself and the service
|
||||
// installer will stop the service.
|
||||
LOG(("Service command %ls complete.\n", argv[2]));
|
||||
}
|
||||
// See Bug 770883
|
||||
#if 0
|
||||
else if (!lstrcmpi(argv[2], L"clear-prefetch")) {
|
||||
} else if (!lstrcmpi(argv[2], L"clear-prefetch")) {
|
||||
result = ClearKnownPrefetch();
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
} else {
|
||||
LOG(("Service command not recognized: %ls.\n", argv[2]));
|
||||
// result is already set to FALSE
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user