Make it harder to leak temp files on devices
This extracts the device temp file creation deletion into a context manager. This context manager will delete the temporary file when leaving the with: scope. Also changes logic for finding a temp file from a linear search from 0 to just using a random number (still checking that the file doesn't exist). Both of these approaches could return the same file in consecutive calls if the earlier files aren't written to (though it is nearly impossible with the random number approach instead of essentially guaranteed). Removed the temp file name patterns and just added a prefix+suffix argument to DeviceTempFile (like tempfile.NamedTemporaryFile). BUG=371054 Review URL: https://codereview.chromium.org/276813002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@270917 0039d316-1c4b-4281-b951-d872f2087c98
Showing
Please register or sign in to comment