Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions base/trace_event/trace_log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,13 @@ TraceEventHandle TraceLog::AddTraceEventWithThreadIdAndTimestamp(
id = MangleEventId(id);
}

#if defined(CASTANETS)
// Some timestamps bring the timeticks of the other process,
// it causes a problem.
TimeTicks offset_event_timestamp = OffsetNow();
#else
TimeTicks offset_event_timestamp = OffsetTimestamp(timestamp);
#endif
ThreadTicks thread_now = ThreadNow();

ThreadLocalEventBuffer* thread_local_event_buffer = nullptr;
Expand Down
7 changes: 7 additions & 0 deletions mojo/core/broker_castanets.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include "base/memory/shared_memory_helper.h"
#include "base/memory/shared_memory_tracker.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/trace_event/trace_event.h"
#include "base/trace_event/trace_event_argument.h"
#include "build/build_config.h"
#include "mojo/core/broker_messages.h"
#include "mojo/core/channel.h"
Expand Down Expand Up @@ -205,6 +207,9 @@ void BrokerCastanets::SyncSharedBufferImpl(const base::UnguessableToken& guid,
BeginSync(guid);

CHECK_GE(mapped_size, offset + sync_size);

TRACE_EVENT2("SyncSharedMemory", "BrokerCastanets::SyncSharedBufferImpl",
"GUID", guid.ToString(), "sync_bytes", sync_size);
BufferSyncData* buffer_sync = nullptr;
void* extra_data = nullptr;
Channel::MessagePtr out_message =
Expand Down Expand Up @@ -234,6 +239,8 @@ void BrokerCastanets::OnBufferSync(uint64_t guid_high, uint64_t guid_low,
base::UnguessableToken guid =
base::UnguessableToken::Deserialize(guid_high, guid_low);

TRACE_EVENT2("SyncSharedMemory", "BrokerCastanets::OnBufferSync", "GUID",
guid.ToString(), "sync_bytes", sync_bytes);
VLOG(2) << "Recv sync" << guid << " offset: " << offset
<< ", sync_size: " << sync_bytes
<< ", buffer_size: " << buffer_bytes;
Expand Down
11 changes: 11 additions & 0 deletions services/tracing/public/cpp/trace_event_agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
#include "services/tracing/public/cpp/tracing_features.h"
#include "services/tracing/public/mojom/constants.mojom.h"

#if defined(CASTANETS)
#include "base/command_line.h"
#endif

#if defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_MACOSX) || \
defined(OS_WIN)
#define PERFETTO_AVAILABLE
Expand Down Expand Up @@ -146,6 +150,13 @@ void LegacyTraceEventAgent::StartTracing(const std::string& config,
// latency.
base::TimeDelta time_offset = TRACE_TIME_TICKS_NOW() - coordinator_time;
TraceLog::GetInstance()->SetTimeOffset(time_offset);
#endif
#if defined(CASTANETS)
if (std::string("renderer") ==
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII("type")) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about defining like this ? for more easy modifications in future.
constexpr const char kProcessTypeSwitch[] = "type";

base::TimeDelta time_offset = TRACE_TIME_TICKS_NOW() - coordinator_time;
base::trace_event::TraceLog::GetInstance()->SetTimeOffset(time_offset);
}
#endif
enabled_tracing_modes_ = base::trace_event::TraceLog::RECORDING_MODE;
const base::trace_event::TraceConfig trace_config(config);
Expand Down