forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdelete_with_retry.h
27 lines (21 loc) · 1.21 KB
/
delete_with_retry.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_INSTALLER_MINI_INSTALLER_DELETE_WITH_RETRY_H_
#define CHROME_INSTALLER_MINI_INSTALLER_DELETE_WITH_RETRY_H_
namespace mini_installer {
// Deletes the file or directory at |path|, retrying for up to ten seconds.
// Returns false if |path| indicates a directory that is not empty or if the
// item could not be deleted after ten seconds of effort. Otherwise, returns
// true once the item has been deleted. |attempts| is populated with the number
// of attempts needed to reach the result (e.g., a value of 1 means that the
// item was deleted on the first attempt and no sleeping was required).
bool DeleteWithRetry(const wchar_t* path, int& attempts);
// Sets a function with accompanying context that will be called by
// DeleteWithRetry when it sleeps before a retry. Returns the previous sleep
// function.
using SleepFunction = void (*)(void*);
SleepFunction SetRetrySleepHookForTesting(SleepFunction hook_fn,
void* hook_context);
} // namespace mini_installer
#endif // CHROME_INSTALLER_MINI_INSTALLER_DELETE_WITH_RETRY_H_