Index: chrome/test/automation/automation_proxy.cc |
diff --git a/chrome/test/automation/automation_proxy.cc b/chrome/test/automation/automation_proxy.cc |
index aae6691b5b025ce5337948d3fd430b9b25243a94..1c8cdb233b4af2e63c5ca2b927200d4ecc45305f 100644 |
--- a/chrome/test/automation/automation_proxy.cc |
+++ b/chrome/test/automation/automation_proxy.cc |
@@ -7,7 +7,7 @@ |
#include <sstream> |
#include "base/basictypes.h" |
-#include "base/file_util.h" |
+#include "base/debug/trace_event.h" |
#include "base/logging.h" |
#include "base/memory/ref_counted.h" |
#include "base/synchronization/waitable_event.h" |
@@ -410,13 +410,31 @@ |
bool AutomationProxy::EndTracing(std::string* json_trace_output) { |
bool success = false; |
- base::FilePath path; |
- if (!Send(new AutomationMsg_EndTracing(&path, &success)) || !success) |
- return false; |
- |
- bool ok = base::ReadFileToString(path, json_trace_output); |
- DCHECK(ok); |
- base::DeleteFile(path, false); |
+ size_t num_trace_chunks = 0; |
+ if (!Send(new AutomationMsg_EndTracing(&num_trace_chunks, &success)) || |
+ !success) |
+ return false; |
+ |
+ std::string chunk; |
+ base::debug::TraceResultBuffer buffer; |
+ base::debug::TraceResultBuffer::SimpleOutput output; |
+ buffer.SetOutputCallback(output.GetCallback()); |
+ |
+ // TODO(jbates): See bug 100255, IPC send fails if message is too big. This |
+ // code can be simplified if that limitation is fixed. |
+ // Workaround IPC payload size limitation by getting chunks. |
+ buffer.Start(); |
+ for (size_t i = 0; i < num_trace_chunks; ++i) { |
+ // The broswer side AutomationProvider resets state at BeginTracing, |
+ // so it can recover even after this fails mid-way. |
+ if (!Send(new AutomationMsg_GetTracingOutput(&chunk, &success)) || |
+ !success) |
+ return false; |
+ buffer.AddFragment(chunk); |
+ } |
+ buffer.Finish(); |
+ |
+ *json_trace_output = output.json_output; |
return true; |
} |