Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(280)

Unified Diff: chrome/browser/chromeos/system_logs/debug_log_writer.cc

Issue 2081153002: No dbus::FileDescriptor in DebugDaemonClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/system_logs/debug_log_writer.cc
diff --git a/chrome/browser/chromeos/system_logs/debug_log_writer.cc b/chrome/browser/chromeos/system_logs/debug_log_writer.cc
index 3aad0adcb13e505ea5eebccaf2123e15f92ddc0d..6e9b57fdbd97dba427718dc0f7ccf337de85718e 100644
--- a/chrome/browser/chromeos/system_logs/debug_log_writer.cc
+++ b/chrome/browser/chromeos/system_logs/debug_log_writer.cc
@@ -62,7 +62,7 @@ void WriteDebugLogToFileCompleted(
// Stores into |file_path| debug logs in the .tgz format. Calls
// |callback| upon completion.
-void WriteDebugLogToFile(base::File* file,
+void WriteDebugLogToFile(std::unique_ptr<base::File> file,
const std::string& sequence_token_name,
const base::FilePath& file_path,
bool should_compress,
@@ -74,12 +74,15 @@ void WriteDebugLogToFile(base::File* file,
<< "error: " << file->error_details();
return;
}
- scoped_refptr<base::TaskRunner> task_runner =
- GetSequencedTaskRunner(sequence_token_name);
chromeos::DBusThreadManager::Get()->GetDebugDaemonClient()->DumpDebugLogs(
- should_compress, std::move(*file), task_runner,
+ should_compress, file->GetPlatformFile(),
base::Bind(&WriteDebugLogToFileCompleted, file_path, sequence_token_name,
callback));
+
+ // Close the file on an IO-allowed thread.
+ GetSequencedTaskRunner(sequence_token_name)
+ ->PostTask(FROM_HERE,
+ base::Bind(&base::DeletePointer<base::File>, file.release()));
}
// Runs command with its parameters as defined in |argv|.
@@ -224,16 +227,15 @@ void StartLogRetrieval(const base::FilePath& file_name_template,
logging::GenerateTimestampedName(file_name_template, base::Time::Now());
int flags = base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE;
- base::File* file = new base::File;
- GetSequencedTaskRunner(sequence_token_name)->PostTaskAndReply(
- FROM_HERE,
- base::Bind(&IntializeLogFile, base::Unretained(file), file_path, flags),
- base::Bind(&WriteDebugLogToFile,
- base::Owned(file),
- sequence_token_name,
- file_path,
- should_compress,
- callback));
+ std::unique_ptr<base::File> file(new base::File);
+ auto* file_ptr = file.get();
stevenjb 2016/08/22 16:04:38 nit: base::File* is slightly more clear here.
hashimoto 2016/08/23 06:38:50 Done.
+ GetSequencedTaskRunner(sequence_token_name)
+ ->PostTaskAndReply(
+ FROM_HERE, base::Bind(&IntializeLogFile, base::Unretained(file_ptr),
+ file_path, flags),
+ base::Bind(&WriteDebugLogToFile, base::Passed(&file),
+ sequence_token_name, file_path, should_compress,
+ callback));
}
const char kDefaultSequenceName[] = "DebugLogWriter";

Powered by Google App Engine
This is Rietveld 408576698