summaryrefslogtreecommitdiffstats
path: root/mojo/common
diff options
context:
space:
mode:
authorerg <erg@chromium.org>2015-10-20 17:18:51 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-21 00:19:42 +0000
commit83e47b933a49ee7ba011a862eb706a0d25ec1624 (patch)
tree13d8668c7c50cecb3c21972238409d1dd53cfa51 /mojo/common
parent59647ecac9524d954010d3d10b539ee4a340bf94 (diff)
downloadchromium_src-83e47b933a49ee7ba011a862eb706a0d25ec1624.zip
chromium_src-83e47b933a49ee7ba011a862eb706a0d25ec1624.tar.gz
chromium_src-83e47b933a49ee7ba011a862eb706a0d25ec1624.tar.bz2
Port over the mojo tracing service from the mojo repo.
When we unforked from the mojo repo, we got the tracing service in a state where it didn't reliably collect reports from different processes. This ports all the startup time tracking changes we added to the tracing application onto the mojo repo's tracing service. With this change, mandoline traces go from totally useless to merely missing most of the data. BUG=534895 R=msw@chromium.org TBR=ben@chromium.org Review URL: https://codereview.chromium.org/1415843003 Cr-Commit-Position: refs/heads/master@{#355197}
Diffstat (limited to 'mojo/common')
-rw-r--r--mojo/common/BUILD.gn18
-rw-r--r--mojo/common/data_pipe_utils.cc2
-rw-r--r--mojo/common/trace_controller_impl.cc49
-rw-r--r--mojo/common/trace_controller_impl.h39
-rw-r--r--mojo/common/tracing_impl.cc32
-rw-r--r--mojo/common/tracing_impl.h38
6 files changed, 2 insertions, 176 deletions
diff --git a/mojo/common/BUILD.gn b/mojo/common/BUILD.gn
index 5186bc2..0d8f355 100644
--- a/mojo/common/BUILD.gn
+++ b/mojo/common/BUILD.gn
@@ -95,21 +95,3 @@ test("mojo_common_unittests") {
"common_type_converters_unittest.cc",
]
}
-
-if (!is_component_build) {
- source_set("tracing_impl") {
- sources = [
- "trace_controller_impl.cc",
- "trace_controller_impl.h",
- "tracing_impl.cc",
- "tracing_impl.h",
- ]
-
- deps = [
- "//base",
- "//mojo/application/public/cpp",
- "//mojo/services/tracing/public/interfaces",
- "//third_party/mojo/src/mojo/public/cpp/bindings",
- ]
- }
-}
diff --git a/mojo/common/data_pipe_utils.cc b/mojo/common/data_pipe_utils.cc
index a280dad..100453d 100644
--- a/mojo/common/data_pipe_utils.cc
+++ b/mojo/common/data_pipe_utils.cc
@@ -88,6 +88,8 @@ bool MOJO_COMMON_EXPORT BlockingCopyFromString(
char_buffer[byte_index++] = *it++;
}
EndWriteDataRaw(destination.get(), byte_index);
+ if (it == source.end())
+ return true;
} else if (result == MOJO_RESULT_SHOULD_WAIT) {
result = Wait(destination.get(), MOJO_HANDLE_SIGNAL_WRITABLE,
MOJO_DEADLINE_INDEFINITE, nullptr);
diff --git a/mojo/common/trace_controller_impl.cc b/mojo/common/trace_controller_impl.cc
deleted file mode 100644
index ae40100..0000000
--- a/mojo/common/trace_controller_impl.cc
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "mojo/common/trace_controller_impl.h"
-
-#include "base/trace_event/trace_event.h"
-#include "mojo/application/public/cpp/application_connection.h"
-#include "mojo/application/public/cpp/application_impl.h"
-
-namespace mojo {
-
-TraceControllerImpl::TraceControllerImpl(
- InterfaceRequest<tracing::TraceController> request)
- : binding_(this, request.Pass()) {
-}
-
-TraceControllerImpl::~TraceControllerImpl() {
-}
-
-void TraceControllerImpl::StartTracing(
- const String& categories,
- tracing::TraceDataCollectorPtr collector) {
- DCHECK(!collector_.get());
- collector_ = collector.Pass();
- std::string categories_str = categories.To<std::string>();
- base::trace_event::TraceLog::GetInstance()->SetEnabled(
- base::trace_event::TraceConfig(categories_str,
- base::trace_event::RECORD_UNTIL_FULL),
- base::trace_event::TraceLog::RECORDING_MODE);
-}
-
-void TraceControllerImpl::StopTracing() {
- base::trace_event::TraceLog::GetInstance()->SetDisabled();
-
- base::trace_event::TraceLog::GetInstance()->Flush(
- base::Bind(&TraceControllerImpl::SendChunk, base::Unretained(this)));
-}
-
-void TraceControllerImpl::SendChunk(
- const scoped_refptr<base::RefCountedString>& events_str,
- bool has_more_events) {
- collector_->DataCollected(mojo::String(events_str->data()));
- if (!has_more_events) {
- collector_.reset();
- }
-}
-
-} // namespace mojo
diff --git a/mojo/common/trace_controller_impl.h b/mojo/common/trace_controller_impl.h
deleted file mode 100644
index 57918bf..0000000
--- a/mojo/common/trace_controller_impl.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef MOJO_COMMON_TRACING_CONTROLLER_IMPL_H_
-#define MOJO_COMMON_TRACING_CONTROLLER_IMPL_H_
-
-#include "base/memory/ref_counted_memory.h"
-#include "mojo/services/tracing/public/interfaces/tracing.mojom.h"
-#include "third_party/mojo/src/mojo/public/cpp/bindings/interface_request.h"
-#include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h"
-
-namespace mojo {
-
-class TraceControllerImpl : public tracing::TraceController {
- public:
- explicit TraceControllerImpl(
- InterfaceRequest<tracing::TraceController> request);
-
- ~TraceControllerImpl() override;
-
- private:
- // tracing::TraceController implementation:
- void StartTracing(const String& categories,
- tracing::TraceDataCollectorPtr collector) override;
- void StopTracing() override;
-
- void SendChunk(const scoped_refptr<base::RefCountedString>& events_str,
- bool has_more_events);
-
- tracing::TraceDataCollectorPtr collector_;
- StrongBinding<tracing::TraceController> binding_;
-
- DISALLOW_COPY_AND_ASSIGN(TraceControllerImpl);
-};
-
-} // namespace mojo
-
-#endif // MOJO_COMMON_TRACING_CONTROLLER_IMPL_H_
diff --git a/mojo/common/tracing_impl.cc b/mojo/common/tracing_impl.cc
deleted file mode 100644
index 46329300..0000000
--- a/mojo/common/tracing_impl.cc
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "mojo/common/tracing_impl.h"
-
-#include "base/trace_event/trace_event.h"
-#include "mojo/application/public/cpp/application_connection.h"
-#include "mojo/application/public/cpp/application_impl.h"
-#include "mojo/common/trace_controller_impl.h"
-
-namespace mojo {
-
-TracingImpl::TracingImpl() {
-}
-
-TracingImpl::~TracingImpl() {
-}
-
-void TracingImpl::Initialize(ApplicationImpl* app) {
- mojo::URLRequestPtr request(mojo::URLRequest::New());
- request->url = mojo::String::From("mojo:tracing");
- connection_ = app->ConnectToApplication(request.Pass());
- connection_->AddService(this);
-}
-
-void TracingImpl::Create(ApplicationConnection* connection,
- InterfaceRequest<tracing::TraceController> request) {
- new TraceControllerImpl(request.Pass());
-}
-
-} // namespace mojo
diff --git a/mojo/common/tracing_impl.h b/mojo/common/tracing_impl.h
deleted file mode 100644
index 9b9cf47..0000000
--- a/mojo/common/tracing_impl.h
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef MOJO_COMMON_TRACING_IMPL_H_
-#define MOJO_COMMON_TRACING_IMPL_H_
-
-#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
-#include "mojo/application/public/cpp/interface_factory.h"
-#include "mojo/services/tracing/public/interfaces/tracing.mojom.h"
-
-namespace mojo {
-
-class ApplicationImpl;
-
-class TracingImpl : public InterfaceFactory<tracing::TraceController> {
- public:
- TracingImpl();
- ~TracingImpl() override;
-
- // This connects to the tracing service and registers ourselves to provide
- // tracing data on demand.
- void Initialize(ApplicationImpl* app);
-
- private:
- // InterfaceFactory<tracing::TraceController> implementation.
- void Create(ApplicationConnection* connection,
- InterfaceRequest<tracing::TraceController> request) override;
-
- scoped_ptr<ApplicationConnection> connection_;
-
- DISALLOW_COPY_AND_ASSIGN(TracingImpl);
-};
-
-} // namespace mojo
-
-#endif // MOJO_COMMON_TRACING_IMPL_H_