summaryrefslogtreecommitdiffstats
path: root/components/feedback
diff options
context:
space:
mode:
authorcaseq <caseq@chromium.org>2014-09-15 03:50:10 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-15 10:53:18 +0000
commitb85bb8fc41a192f207fa2361a8edcfa42b47076f (patch)
treeb842758c9e5ecea86c2775d2f5d7b976dd146552 /components/feedback
parentad03444a481cf5618dcf40b9449b7ace8fee15e7 (diff)
downloadchromium_src-b85bb8fc41a192f207fa2361a8edcfa42b47076f.zip
chromium_src-b85bb8fc41a192f207fa2361a8edcfa42b47076f.tar.gz
chromium_src-b85bb8fc41a192f207fa2361a8edcfa42b47076f.tar.bz2
tracing: get rid of files in TracingController interface
The only way to get the tracing data used to be by reading the file provided in TracingController::DisableTracing() interface. This does not fit well for most usages, so this introduces a TraceDataSink interface that is backed either by a file, string, or, in case of DevTools, by the protocol client. This resolves the OOM in browser and imporves performance while recording very large traces through DevTools, streamlines TracingController core and reduces coplexity of code for most TracingController clients. BUG=409733,361045 Review URL: https://codereview.chromium.org/541763002 Cr-Commit-Position: refs/heads/master@{#294801}
Diffstat (limited to 'components/feedback')
-rw-r--r--components/feedback/tracing_manager.cc20
-rw-r--r--components/feedback/tracing_manager.h2
2 files changed, 7 insertions, 15 deletions
diff --git a/components/feedback/tracing_manager.cc b/components/feedback/tracing_manager.cc
index e2d77ec..bd7ca79 100644
--- a/components/feedback/tracing_manager.cc
+++ b/components/feedback/tracing_manager.cc
@@ -5,14 +5,13 @@
#include "components/feedback/tracing_manager.h"
#include "base/bind.h"
-#include "base/files/file_util.h"
-#include "base/location.h"
#include "base/memory/ref_counted_memory.h"
#include "base/message_loop/message_loop_proxy.h"
#include "components/feedback/feedback_util.h"
#include "content/public/browser/tracing_controller.h"
namespace {
+
// Only once trace manager can exist at a time.
TracingManager* g_tracing_manager = NULL;
// Trace IDs start at 1 and increase.
@@ -43,9 +42,9 @@ int TracingManager::RequestTrace() {
current_trace_id_ = g_next_trace_id;
++g_next_trace_id;
content::TracingController::GetInstance()->DisableRecording(
- base::FilePath(),
- base::Bind(&TracingManager::OnTraceDataCollected,
- weak_ptr_factory_.GetWeakPtr()));
+ content::TracingController::CreateStringSink(
+ base::Bind(&TracingManager::OnTraceDataCollected,
+ weak_ptr_factory_.GetWeakPtr())));
return current_trace_id_;
}
@@ -96,20 +95,13 @@ void TracingManager::StartTracing() {
content::TracingController::EnableRecordingDoneCallback());
}
-void TracingManager::OnTraceDataCollected(const base::FilePath& path) {
+void TracingManager::OnTraceDataCollected(base::RefCountedString* trace_data) {
if (!current_trace_id_)
return;
- std::string data;
- if (!base::ReadFileToString(path, &data)) {
- LOG(ERROR) << "Failed to read trace data from: " << path.value();
- return;
- }
- base::DeleteFile(path, false);
-
std::string output_val;
feedback_util::ZipString(
- base::FilePath(kTracingFilename), data, &output_val);
+ base::FilePath(kTracingFilename), trace_data->data(), &output_val);
scoped_refptr<base::RefCountedString> output(
base::RefCountedString::TakeString(&output_val));
diff --git a/components/feedback/tracing_manager.h b/components/feedback/tracing_manager.h
index 1148a1c..e846f37 100644
--- a/components/feedback/tracing_manager.h
+++ b/components/feedback/tracing_manager.h
@@ -58,7 +58,7 @@ class TracingManager {
TracingManager();
void StartTracing();
- void OnTraceDataCollected(const base::FilePath& path);
+ void OnTraceDataCollected(base::RefCountedString* data);
// ID of the trace that is being collected.
int current_trace_id_;