| 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..58ce88972e11a53e4b7b382302364d129c74bdde 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,18 +73,6 @@ void BrowserShutdownProfileDumper::EndTraceAndFlush(
|
| base::Unretained(flush_complete_event)));
|
| }
|
|
|
| -base::FilePath BrowserShutdownProfileDumper::GetFileName() {
|
| - const CommandLine& command_line = *CommandLine::ForCurrentProcess();
|
| - base::FilePath trace_file =
|
| - command_line.GetSwitchValuePath(switches::kTraceShutdownFile);
|
| -
|
| - if (!trace_file.empty())
|
| - return trace_file;
|
| -
|
| - // Default to saving the startup trace into the current dir.
|
| - return base::FilePath().AppendASCII("chrometrace.log");
|
| -}
|
| -
|
| void BrowserShutdownProfileDumper::WriteTraceDataCollected(
|
| base::WaitableEvent* flush_complete_event,
|
| const scoped_refptr<base::RefCountedString>& events_str,
|
| @@ -122,8 +111,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();
|
| }
|
| }
|
|
|