Fix crash when passing NULL |callback| to CefEndTracing.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1948 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2014-12-02 16:42:34 +00:00
parent b12e172af0
commit 405dd1824b
1 changed files with 10 additions and 6 deletions

View File

@ -71,6 +71,13 @@ bool CefTraceSubscriber::EndTracing(
if (!collecting_trace_data_) if (!collecting_trace_data_)
return false; return false;
if (!callback.get()) {
// Discard the trace data.
collecting_trace_data_ = false;
TracingController::GetInstance()->DisableRecording(NULL);
return true;
}
if (tracing_file.empty()) { if (tracing_file.empty()) {
// Create a new temporary file path on the FILE thread, then continue. // Create a new temporary file path on the FILE thread, then continue.
CEF_POST_TASK(CEF_FILET, CEF_POST_TASK(CEF_FILET,
@ -81,12 +88,9 @@ bool CefTraceSubscriber::EndTracing(
return true; return true;
} }
base::Closure result_callback; base::Closure result_callback =
if (callback.get()) { base::Bind(&CefTraceSubscriber::OnTracingFileResult,
result_callback = weak_factory_.GetWeakPtr(), callback, tracing_file);
base::Bind(&CefTraceSubscriber::OnTracingFileResult,
weak_factory_.GetWeakPtr(), callback, tracing_file);
}
TracingController::GetInstance()->DisableRecording( TracingController::GetInstance()->DisableRecording(
TracingController::CreateFileSink(tracing_file, result_callback)); TracingController::CreateFileSink(tracing_file, result_callback));