Commit e7d94b1a authored by Adrian Elder's avatar Adrian Elder Committed by Commit Bot

Grant delete on Entry from webrtcLoggingPrivate.getLogsDirectory

This API is intended for use by an app to read "WebRTC Logs" files
generated for debug purposes on devices within Google. I initially
proposed making it purely read-only to prevent contention with
the creation and writing to audio debug files; however, the app
can restrict itself to acting on files that the aec dump process
has finished with (as indicated by getting a callback from
startAudioDebugRecordings/stopAudioDebugRecordings).

While a low volume of debug recordings would eventually be cleaned up
after 5 days and a reboot (per
WebRtcLogUtil::DeleteOldWebRtcLogFilesForAllProfiles), the needed
frequency and volume of recordings would be more flexible if the
app could clean up files it generated.

Bug: 775961
Change-Id: I8492b0619ee1c98737f0248190d68a1e3bee5bca
Reviewed-on: https://chromium-review.googlesource.com/795671Reviewed-by: default avatarMustafa Emre Acer <meacer@chromium.org>
Reviewed-by: default avatarTommi <tommi@chromium.org>
Commit-Queue: Adrian Elder <aelder@chromium.org>
Cr-Commit-Position: refs/heads/master@{#520176}
parent f2679b39
...@@ -303,11 +303,13 @@ void WebRtcLoggingHandlerHost::GrantLogsDirectoryAccess( ...@@ -303,11 +303,13 @@ void WebRtcLoggingHandlerHost::GrantLogsDirectoryAccess(
storage::kFileSystemTypeNativeLocal, std::string(), logs_path, storage::kFileSystemTypeNativeLocal, std::string(), logs_path,
&registered_name); &registered_name);
// Only granting read-only access to reduce contention with webrtcLogging APIs // Only granting read and delete access to reduce contention with
// that modify files in that folder. // webrtcLogging APIs that modify files in that folder.
content::ChildProcessSecurityPolicy* policy = content::ChildProcessSecurityPolicy* policy =
content::ChildProcessSecurityPolicy::GetInstance(); content::ChildProcessSecurityPolicy::GetInstance();
policy->GrantReadFileSystem(render_process_id_, filesystem_id); policy->GrantReadFileSystem(render_process_id_, filesystem_id);
// Delete is needed to prevent accumulation of files.
policy->GrantDeleteFromFileSystem(render_process_id_, filesystem_id);
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE, BrowserThread::UI, FROM_HERE,
base::BindOnce(callback, filesystem_id, registered_name)); base::BindOnce(callback, filesystem_id, registered_name));
......
...@@ -71,6 +71,22 @@ function testCanReadFile() { ...@@ -71,6 +71,22 @@ function testCanReadFile() {
}); });
} }
function testCanRemoveFile() {
chrome.webrtcLoggingPrivate.getLogsDirectory(function(directoryEntry) {
readFileEntries(directoryEntry, function(entries) {
chrome.test.assertEq(1, entries.length);
var fileEntry = entries[0];
chrome.test.assertTrue(fileEntry.isFile);
fileEntry.remove(function() {
readFileEntries(directoryEntry, function(entries) {
chrome.test.assertEq(0, entries.length);
chrome.test.succeed();
});
});
});
});
}
function testCannotWriteToFile() { function testCannotWriteToFile() {
chrome.webrtcLoggingPrivate.getLogsDirectory(function(directoryEntry) { chrome.webrtcLoggingPrivate.getLogsDirectory(function(directoryEntry) {
readFileEntries(directoryEntry, function(entries) { readFileEntries(directoryEntry, function(entries) {
...@@ -93,10 +109,15 @@ function testCannotWriteToFile() { ...@@ -93,10 +109,15 @@ function testCannotWriteToFile() {
var testGroups = { var testGroups = {
'test_without_directory': [ 'test_without_directory': [
testGetsReadOnlyDirectoryEntry, testEmptyDirectory, testGetsReadOnlyDirectoryEntry,
testEmptyDirectory,
], ],
'test_with_file_in_directory': [ 'test_with_file_in_directory': [
testGetsReadOnlyDirectoryEntry, testCanReadFile, testCannotWriteToFile, testGetsReadOnlyDirectoryEntry,
testCanReadFile,
testCannotWriteToFile,
// Must be run last, since it deletes the test file.
testCanRemoveFile,
], ],
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment