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

Unified Diff: content/browser/browser_shutdown_profile_dumper.cc

Issue 359473006: Store unsaved trace data on exit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build. Created 6 years, 6 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
« no previous file with comments | « content/browser/browser_shutdown_profile_dumper.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/browser_shutdown_profile_dumper.cc
diff --git a/content/browser/browser_shutdown_profile_dumper.cc b/content/browser/browser_shutdown_profile_dumper.cc
index 3e74e063b0c0b60aadd9d47783d0c248c2d12687..a8b9e952e13044a73ba0a9ecec4267be58343bf8 100644
--- a/content/browser/browser_shutdown_profile_dumper.cc
+++ b/content/browser/browser_shutdown_profile_dumper.cc
@@ -18,17 +18,18 @@
namespace content {
-BrowserShutdownProfileDumper::BrowserShutdownProfileDumper()
- : blocks_(0),
+BrowserShutdownProfileDumper::BrowserShutdownProfileDumper(
+ const base::FilePath& dump_file_name)
+ : dump_file_name_(dump_file_name),
+ blocks_(0),
dump_file_(NULL) {
}
BrowserShutdownProfileDumper::~BrowserShutdownProfileDumper() {
- WriteTracesToDisc(GetFileName());
+ WriteTracesToDisc();
}
-void BrowserShutdownProfileDumper::WriteTracesToDisc(
- const base::FilePath& file_name) {
+void BrowserShutdownProfileDumper::WriteTracesToDisc() {
// Note: I have seen a usage of 0.000xx% when dumping - which fits easily.
// Since the tracer stops when the trace buffer is filled, we'd rather save
// what we have than nothing since we might see from the amount of events
@@ -37,10 +38,10 @@ void BrowserShutdownProfileDumper::WriteTracesToDisc(
base::debug::TraceLog::GetInstance()->GetBufferPercentFull() <<
" full.";
DCHECK(!dump_file_);
- dump_file_ = base::OpenFile(file_name, "w+");
+ dump_file_ = base::OpenFile(dump_file_name_, "w+");
if (!IsFileValid()) {
- LOG(ERROR) << "Failed to open performance trace file: " <<
- file_name.value();
+ LOG(ERROR) << "Failed to open performance trace file: "
+ << dump_file_name_.value();
return;
}
WriteString("{\"traceEvents\":");
@@ -72,7 +73,8 @@ void BrowserShutdownProfileDumper::EndTraceAndFlush(
base::Unretained(flush_complete_event)));
}
-base::FilePath BrowserShutdownProfileDumper::GetFileName() {
+// static
+base::FilePath BrowserShutdownProfileDumper::GetShutdownProfileFileName() {
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
base::FilePath trace_file =
command_line.GetSwitchValuePath(switches::kTraceShutdownFile);
@@ -122,8 +124,9 @@ void BrowserShutdownProfileDumper::WriteChars(const char* chars, size_t size) {
size_t written = fwrite(chars, 1, size, dump_file_);
if (written != size) {
- LOG(ERROR) << "Error " << ferror(dump_file_) <<
- " in fwrite() to trace file";
+ LOG(ERROR) << "Error " << ferror(dump_file_)
+ << " in fwrite() to trace file '" << dump_file_name_.value()
+ << "'";
CloseFile();
}
}
« no previous file with comments | « content/browser/browser_shutdown_profile_dumper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698