Commit 88a7e52f authored by jar@chromium.org's avatar jar@chromium.org

Propogate status setting for profiler to track parents

This allows child processes to track ancestry, and report
it to the browser process.

Parent tracking is only turned on based on an 
environment variable.

r=rtenneti
Review URL: https://chromiumcodereview.appspot.com/9181002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@120789 0039d316-1c4b-4281-b951-d872f2087c98
parent 7defb4f0
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -76,7 +76,7 @@ TEST(TrackedTimeTest, TrackedTimerVsTimeTicks) { ...@@ -76,7 +76,7 @@ TEST(TrackedTimeTest, TrackedTimerVsTimeTicks) {
TEST(TrackedTimeTest, TrackedTimerDisabled) { TEST(TrackedTimeTest, TrackedTimerDisabled) {
// Check to be sure disabling the collection of data induces a null time // Check to be sure disabling the collection of data induces a null time
// (which we know will return much faster). // (which we know will return much faster).
if (!ThreadData::InitializeAndSetTrackingStatus(false)) if (!ThreadData::InitializeAndSetTrackingStatus(ThreadData::DEACTIVATED))
return; return;
// Since we disabled tracking, we should get a null response. // Since we disabled tracking, we should get a null response.
TrackedTime track_now = ThreadData::Now(); TrackedTime track_now = ThreadData::Now();
...@@ -88,7 +88,8 @@ TEST(TrackedTimeTest, TrackedTimerDisabled) { ...@@ -88,7 +88,8 @@ TEST(TrackedTimeTest, TrackedTimerDisabled) {
} }
TEST(TrackedTimeTest, TrackedTimerEnabled) { TEST(TrackedTimeTest, TrackedTimerEnabled) {
if (!ThreadData::InitializeAndSetTrackingStatus(true)) if (!ThreadData::InitializeAndSetTrackingStatus(
ThreadData::PROFILING_CHILDREN_ACTIVE))
return; return;
// Make sure that when we enable tracking, we get a real timer result. // Make sure that when we enable tracking, we get a real timer result.
......
...@@ -393,7 +393,7 @@ Births* ThreadData::TallyABirthIfActive(const Location& location) { ...@@ -393,7 +393,7 @@ Births* ThreadData::TallyABirthIfActive(const Location& location) {
if (!kTrackAllTaskObjects) if (!kTrackAllTaskObjects)
return NULL; // Not compiled in. return NULL; // Not compiled in.
if (!tracking_status()) if (!TrackingStatus())
return NULL; return NULL;
ThreadData* current_thread_data = Get(); ThreadData* current_thread_data = Get();
if (!current_thread_data) if (!current_thread_data)
...@@ -622,28 +622,31 @@ bool ThreadData::Initialize() { ...@@ -622,28 +622,31 @@ bool ThreadData::Initialize() {
} }
// static // static
bool ThreadData::InitializeAndSetTrackingStatus(bool status) { bool ThreadData::InitializeAndSetTrackingStatus(Status status) {
DCHECK_GE(status, DEACTIVATED);
DCHECK_LE(status, PROFILING_CHILDREN_ACTIVE);
if (!Initialize()) // No-op if already initialized. if (!Initialize()) // No-op if already initialized.
return false; // Not compiled in. return false; // Not compiled in.
if (!status) { if (!kTrackParentChildLinks && status > DEACTIVATED)
status_ = DEACTIVATED; status = PROFILING_ACTIVE;
} else { status_ = status;
if (kTrackParentChildLinks)
status_ = PROFILING_CHILDREN_ACTIVE;
else
status_ = PROFILING_ACTIVE;
}
return true; return true;
} }
// static // static
bool ThreadData::tracking_status() { ThreadData::Status ThreadData::status() {
return status_;
}
// static
bool ThreadData::TrackingStatus() {
return status_ > DEACTIVATED; return status_ > DEACTIVATED;
} }
// static // static
bool ThreadData::tracking_parent_child_status() { bool ThreadData::TrackingParentChildStatus() {
return status_ >= PROFILING_CHILDREN_ACTIVE; return status_ >= PROFILING_CHILDREN_ACTIVE;
} }
...@@ -664,7 +667,7 @@ TrackedTime ThreadData::NowForEndOfRun() { ...@@ -664,7 +667,7 @@ TrackedTime ThreadData::NowForEndOfRun() {
// static // static
TrackedTime ThreadData::Now() { TrackedTime ThreadData::Now() {
if (kTrackAllTaskObjects && tracking_status()) if (kTrackAllTaskObjects && TrackingStatus())
return TrackedTime::Now(); return TrackedTime::Now();
return TrackedTime(); // Super fast when disabled, or not compiled. return TrackedTime(); // Super fast when disabled, or not compiled.
} }
...@@ -686,7 +689,7 @@ void ThreadData::ShutdownSingleThreadedCleanup(bool leak) { ...@@ -686,7 +689,7 @@ void ThreadData::ShutdownSingleThreadedCleanup(bool leak) {
// This is only called from test code, where we need to cleanup so that // This is only called from test code, where we need to cleanup so that
// additional tests can be run. // additional tests can be run.
// We must be single threaded... but be careful anyway. // We must be single threaded... but be careful anyway.
if (!InitializeAndSetTrackingStatus(false)) if (!InitializeAndSetTrackingStatus(DEACTIVATED))
return; return;
ThreadData* thread_data_list; ThreadData* thread_data_list;
{ {
......
...@@ -442,15 +442,17 @@ class BASE_EXPORT ThreadData { ...@@ -442,15 +442,17 @@ class BASE_EXPORT ThreadData {
// PROFILING_ACTIVE (i.e., it can't be set to a higher level than what is // PROFILING_ACTIVE (i.e., it can't be set to a higher level than what is
// compiled into the binary, and parent-child tracking at the // compiled into the binary, and parent-child tracking at the
// PROFILING_CHILDREN_ACTIVE level might not be compiled in). // PROFILING_CHILDREN_ACTIVE level might not be compiled in).
static bool InitializeAndSetTrackingStatus(bool status); static bool InitializeAndSetTrackingStatus(Status status);
static Status status();
// Indicate if any sort of profiling is being done (i.e., we are more than // Indicate if any sort of profiling is being done (i.e., we are more than
// DEACTIVATED). // DEACTIVATED).
static bool tracking_status(); static bool TrackingStatus();
// For testing only, indicate if the status of parent-child tracking is turned // For testing only, indicate if the status of parent-child tracking is turned
// on. This is currently a compiled option, atop tracking_status(). // on. This is currently a compiled option, atop TrackingStatus().
static bool tracking_parent_child_status(); static bool TrackingParentChildStatus();
// Special versions of Now() for getting times at start and end of a tracked // Special versions of Now() for getting times at start and end of a tracked
// run. They are super fast when tracking is disabled, and have some internal // run. They are super fast when tracking is disabled, and have some internal
......
...@@ -35,7 +35,8 @@ class TrackedObjectsTest : public testing::Test { ...@@ -35,7 +35,8 @@ class TrackedObjectsTest : public testing::Test {
TEST_F(TrackedObjectsTest, MinimalStartupShutdown) { TEST_F(TrackedObjectsTest, MinimalStartupShutdown) {
// Minimal test doesn't even create any tasks. // Minimal test doesn't even create any tasks.
if (!ThreadData::InitializeAndSetTrackingStatus(true)) if (!ThreadData::InitializeAndSetTrackingStatus(
ThreadData::PROFILING_CHILDREN_ACTIVE))
return; return;
EXPECT_FALSE(ThreadData::first()); // No activity even on this thread. EXPECT_FALSE(ThreadData::first()); // No activity even on this thread.
...@@ -55,7 +56,8 @@ TEST_F(TrackedObjectsTest, MinimalStartupShutdown) { ...@@ -55,7 +56,8 @@ TEST_F(TrackedObjectsTest, MinimalStartupShutdown) {
ShutdownSingleThreadedCleanup(false); ShutdownSingleThreadedCleanup(false);
// Do it again, just to be sure we reset state completely. // Do it again, just to be sure we reset state completely.
ThreadData::InitializeAndSetTrackingStatus(true); ThreadData::InitializeAndSetTrackingStatus(
ThreadData::PROFILING_CHILDREN_ACTIVE);
EXPECT_FALSE(ThreadData::first()); // No activity even on this thread. EXPECT_FALSE(ThreadData::first()); // No activity even on this thread.
data = ThreadData::Get(); data = ThreadData::Get();
EXPECT_TRUE(ThreadData::first()); // Now class was constructed. EXPECT_TRUE(ThreadData::first()); // Now class was constructed.
...@@ -71,7 +73,8 @@ TEST_F(TrackedObjectsTest, MinimalStartupShutdown) { ...@@ -71,7 +73,8 @@ TEST_F(TrackedObjectsTest, MinimalStartupShutdown) {
} }
TEST_F(TrackedObjectsTest, TinyStartupShutdown) { TEST_F(TrackedObjectsTest, TinyStartupShutdown) {
if (!ThreadData::InitializeAndSetTrackingStatus(true)) if (!ThreadData::InitializeAndSetTrackingStatus(
ThreadData::PROFILING_CHILDREN_ACTIVE))
return; return;
// Instigate tracking on a single tracked object, on our thread. // Instigate tracking on a single tracked object, on our thread.
...@@ -113,7 +116,7 @@ TEST_F(TrackedObjectsTest, TinyStartupShutdown) { ...@@ -113,7 +116,7 @@ TEST_F(TrackedObjectsTest, TinyStartupShutdown) {
EXPECT_EQ(2, birth_map.begin()->second->birth_count()); // 2 births. EXPECT_EQ(2, birth_map.begin()->second->birth_count()); // 2 births.
EXPECT_EQ(1u, death_map.size()); // 1 location. EXPECT_EQ(1u, death_map.size()); // 1 location.
EXPECT_EQ(1, death_map.begin()->second.count()); // 1 death. EXPECT_EQ(1, death_map.begin()->second.count()); // 1 death.
if (ThreadData::tracking_parent_child_status()) { if (ThreadData::TrackingParentChildStatus()) {
EXPECT_EQ(1u, parent_child_set.size()); // 1 child. EXPECT_EQ(1u, parent_child_set.size()); // 1 child.
EXPECT_EQ(parent_child_set.begin()->first, EXPECT_EQ(parent_child_set.begin()->first,
parent_child_set.begin()->second); parent_child_set.begin()->second);
...@@ -126,9 +129,10 @@ TEST_F(TrackedObjectsTest, TinyStartupShutdown) { ...@@ -126,9 +129,10 @@ TEST_F(TrackedObjectsTest, TinyStartupShutdown) {
} }
TEST_F(TrackedObjectsTest, ParentChildTest) { TEST_F(TrackedObjectsTest, ParentChildTest) {
if (!ThreadData::InitializeAndSetTrackingStatus(true)) if (!ThreadData::InitializeAndSetTrackingStatus(
ThreadData::PROFILING_CHILDREN_ACTIVE))
return; return;
if (!ThreadData::tracking_parent_child_status()) if (!ThreadData::TrackingParentChildStatus())
return; // Feature not compiled in. return; // Feature not compiled in.
// Instigate tracking on a single tracked object, on our thread. // Instigate tracking on a single tracked object, on our thread.
...@@ -211,7 +215,8 @@ TEST_F(TrackedObjectsTest, ParentChildTest) { ...@@ -211,7 +215,8 @@ TEST_F(TrackedObjectsTest, ParentChildTest) {
} }
TEST_F(TrackedObjectsTest, DeathDataTest) { TEST_F(TrackedObjectsTest, DeathDataTest) {
if (!ThreadData::InitializeAndSetTrackingStatus(true)) if (!ThreadData::InitializeAndSetTrackingStatus(
ThreadData::PROFILING_CHILDREN_ACTIVE))
return; return;
scoped_ptr<DeathData> data(new DeathData()); scoped_ptr<DeathData> data(new DeathData());
...@@ -270,7 +275,7 @@ TEST_F(TrackedObjectsTest, DeathDataTest) { ...@@ -270,7 +275,7 @@ TEST_F(TrackedObjectsTest, DeathDataTest) {
TEST_F(TrackedObjectsTest, DeactivatedBirthOnlyToValueWorkerThread) { TEST_F(TrackedObjectsTest, DeactivatedBirthOnlyToValueWorkerThread) {
// Transition to Deactivated state before doing anything. // Transition to Deactivated state before doing anything.
if (!ThreadData::InitializeAndSetTrackingStatus(false)) if (!ThreadData::InitializeAndSetTrackingStatus(ThreadData::DEACTIVATED))
return; return;
// We don't initialize system with a thread name, so we're viewed as a worker // We don't initialize system with a thread name, so we're viewed as a worker
// thread. // thread.
...@@ -296,7 +301,7 @@ TEST_F(TrackedObjectsTest, DeactivatedBirthOnlyToValueWorkerThread) { ...@@ -296,7 +301,7 @@ TEST_F(TrackedObjectsTest, DeactivatedBirthOnlyToValueWorkerThread) {
TEST_F(TrackedObjectsTest, DeactivatedBirthOnlyToValueMainThread) { TEST_F(TrackedObjectsTest, DeactivatedBirthOnlyToValueMainThread) {
// Start in the deactivated state. // Start in the deactivated state.
if (!ThreadData::InitializeAndSetTrackingStatus(false)) if (!ThreadData::InitializeAndSetTrackingStatus(ThreadData::DEACTIVATED))
return; return;
// Use a well named thread. // Use a well named thread.
...@@ -323,7 +328,8 @@ TEST_F(TrackedObjectsTest, DeactivatedBirthOnlyToValueMainThread) { ...@@ -323,7 +328,8 @@ TEST_F(TrackedObjectsTest, DeactivatedBirthOnlyToValueMainThread) {
} }
TEST_F(TrackedObjectsTest, BirthOnlyToValueWorkerThread) { TEST_F(TrackedObjectsTest, BirthOnlyToValueWorkerThread) {
if (!ThreadData::InitializeAndSetTrackingStatus(true)) if (!ThreadData::InitializeAndSetTrackingStatus(
ThreadData::PROFILING_CHILDREN_ACTIVE))
return; return;
// We don't initialize system with a thread name, so we're viewed as a worker // We don't initialize system with a thread name, so we're viewed as a worker
// thread. // thread.
...@@ -365,7 +371,8 @@ TEST_F(TrackedObjectsTest, BirthOnlyToValueWorkerThread) { ...@@ -365,7 +371,8 @@ TEST_F(TrackedObjectsTest, BirthOnlyToValueWorkerThread) {
} }
TEST_F(TrackedObjectsTest, BirthOnlyToValueMainThread) { TEST_F(TrackedObjectsTest, BirthOnlyToValueMainThread) {
if (!ThreadData::InitializeAndSetTrackingStatus(true)) if (!ThreadData::InitializeAndSetTrackingStatus(
ThreadData::PROFILING_CHILDREN_ACTIVE))
return; return;
// Use a well named thread. // Use a well named thread.
...@@ -409,7 +416,8 @@ TEST_F(TrackedObjectsTest, BirthOnlyToValueMainThread) { ...@@ -409,7 +416,8 @@ TEST_F(TrackedObjectsTest, BirthOnlyToValueMainThread) {
} }
TEST_F(TrackedObjectsTest, LifeCycleToValueMainThread) { TEST_F(TrackedObjectsTest, LifeCycleToValueMainThread) {
if (!ThreadData::InitializeAndSetTrackingStatus(true)) if (!ThreadData::InitializeAndSetTrackingStatus(
ThreadData::PROFILING_CHILDREN_ACTIVE))
return; return;
// Use a well named thread. // Use a well named thread.
...@@ -470,7 +478,8 @@ TEST_F(TrackedObjectsTest, LifeCycleToValueMainThread) { ...@@ -470,7 +478,8 @@ TEST_F(TrackedObjectsTest, LifeCycleToValueMainThread) {
// our tallied births are matched by tallied deaths (except for when the // our tallied births are matched by tallied deaths (except for when the
// task is still running, or is queued). // task is still running, or is queued).
TEST_F(TrackedObjectsTest, LifeCycleMidDeactivatedToValueMainThread) { TEST_F(TrackedObjectsTest, LifeCycleMidDeactivatedToValueMainThread) {
if (!ThreadData::InitializeAndSetTrackingStatus(true)) if (!ThreadData::InitializeAndSetTrackingStatus(
ThreadData::PROFILING_CHILDREN_ACTIVE))
return; return;
// Use a well named thread. // Use a well named thread.
...@@ -491,7 +500,8 @@ TEST_F(TrackedObjectsTest, LifeCycleMidDeactivatedToValueMainThread) { ...@@ -491,7 +500,8 @@ TEST_F(TrackedObjectsTest, LifeCycleMidDeactivatedToValueMainThread) {
pending_task.time_posted = kTimePosted; // Overwrite implied Now(). pending_task.time_posted = kTimePosted; // Overwrite implied Now().
// Turn off tracking now that we have births. // Turn off tracking now that we have births.
EXPECT_TRUE(ThreadData::InitializeAndSetTrackingStatus(false)); EXPECT_TRUE(ThreadData::InitializeAndSetTrackingStatus(
ThreadData::DEACTIVATED));
const TrackedTime kStartOfRun = TrackedTime() + const TrackedTime kStartOfRun = TrackedTime() +
Duration::FromMilliseconds(5); Duration::FromMilliseconds(5);
...@@ -532,7 +542,7 @@ TEST_F(TrackedObjectsTest, LifeCycleMidDeactivatedToValueMainThread) { ...@@ -532,7 +542,7 @@ TEST_F(TrackedObjectsTest, LifeCycleMidDeactivatedToValueMainThread) {
// We will deactivate tracking before starting a life cycle, and neither // We will deactivate tracking before starting a life cycle, and neither
// the birth nor the death will be recorded. // the birth nor the death will be recorded.
TEST_F(TrackedObjectsTest, LifeCyclePreDeactivatedToValueMainThread) { TEST_F(TrackedObjectsTest, LifeCyclePreDeactivatedToValueMainThread) {
if (!ThreadData::InitializeAndSetTrackingStatus(false)) if (!ThreadData::InitializeAndSetTrackingStatus(ThreadData::DEACTIVATED))
return; return;
// Use a well named thread. // Use a well named thread.
...@@ -571,7 +581,8 @@ TEST_F(TrackedObjectsTest, LifeCyclePreDeactivatedToValueMainThread) { ...@@ -571,7 +581,8 @@ TEST_F(TrackedObjectsTest, LifeCyclePreDeactivatedToValueMainThread) {
} }
TEST_F(TrackedObjectsTest, LifeCycleToValueWorkerThread) { TEST_F(TrackedObjectsTest, LifeCycleToValueWorkerThread) {
if (!ThreadData::InitializeAndSetTrackingStatus(true)) if (!ThreadData::InitializeAndSetTrackingStatus(
ThreadData::PROFILING_CHILDREN_ACTIVE))
return; return;
// Don't initialize thread, so that we appear as a worker thread. // Don't initialize thread, so that we appear as a worker thread.
...@@ -662,7 +673,8 @@ TEST_F(TrackedObjectsTest, LifeCycleToValueWorkerThread) { ...@@ -662,7 +673,8 @@ TEST_F(TrackedObjectsTest, LifeCycleToValueWorkerThread) {
} }
TEST_F(TrackedObjectsTest, TwoLives) { TEST_F(TrackedObjectsTest, TwoLives) {
if (!ThreadData::InitializeAndSetTrackingStatus(true)) if (!ThreadData::InitializeAndSetTrackingStatus(
ThreadData::PROFILING_CHILDREN_ACTIVE))
return; return;
// Use a well named thread. // Use a well named thread.
...@@ -727,7 +739,8 @@ TEST_F(TrackedObjectsTest, TwoLives) { ...@@ -727,7 +739,8 @@ TEST_F(TrackedObjectsTest, TwoLives) {
} }
TEST_F(TrackedObjectsTest, DifferentLives) { TEST_F(TrackedObjectsTest, DifferentLives) {
if (!ThreadData::InitializeAndSetTrackingStatus(true)) if (!ThreadData::InitializeAndSetTrackingStatus(
ThreadData::PROFILING_CHILDREN_ACTIVE))
return; return;
// Use a well named thread. // Use a well named thread.
......
...@@ -1147,13 +1147,19 @@ int ChromeBrowserMainParts::PreCreateThreadsImpl() { ...@@ -1147,13 +1147,19 @@ int ChromeBrowserMainParts::PreCreateThreadsImpl() {
browser_process_.reset(new BrowserProcessImpl(parsed_command_line())); browser_process_.reset(new BrowserProcessImpl(parsed_command_line()));
} }
// Default to basic profiling (no parent child support).
tracked_objects::ThreadData::Status status =
tracked_objects::ThreadData::PROFILING_ACTIVE;
if (parsed_command_line().HasSwitch(switches::kEnableProfiling)) { if (parsed_command_line().HasSwitch(switches::kEnableProfiling)) {
// User wants to override default tracking status. // User wants to override default tracking status.
std::string flag = std::string flag =
parsed_command_line().GetSwitchValueASCII(switches::kEnableProfiling); parsed_command_line().GetSwitchValueASCII(switches::kEnableProfiling);
bool enabled = flag.compare("0") != 0; if (flag.compare("0") != 0)
tracked_objects::ThreadData::InitializeAndSetTrackingStatus(enabled); status = tracked_objects::ThreadData::DEACTIVATED;
else if (flag.compare("child") != 0)
status = tracked_objects::ThreadData::PROFILING_CHILDREN_ACTIVE;
} }
tracked_objects::ThreadData::InitializeAndSetTrackingStatus(status);
// This forces the TabCloseableStateWatcher to be created and, on chromeos, // This forces the TabCloseableStateWatcher to be created and, on chromeos,
// register for the notifications it needs to track the closeable state of // register for the notifications it needs to track the closeable state of
......
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -121,14 +121,16 @@ void ProfilerControllerImpl::GetProfilerData(int sequence_number) { ...@@ -121,14 +121,16 @@ void ProfilerControllerImpl::GetProfilerData(int sequence_number) {
sequence_number)); sequence_number));
} }
void ProfilerControllerImpl::SetProfilerStatusInChildProcesses(bool enable) { void ProfilerControllerImpl::SetProfilerStatusInChildProcesses(
tracked_objects::ThreadData::Status status) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
for (BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) for (BrowserChildProcessHostIterator iter; !iter.Done(); ++iter)
iter.Send(new ChildProcessMsg_SetProfilerStatus(enable)); iter.Send(new ChildProcessMsg_SetProfilerStatus(status));
} }
void ProfilerControllerImpl::SetProfilerStatus(bool enable) { void ProfilerControllerImpl::SetProfilerStatus(
tracked_objects::ThreadData::Status status) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
BrowserThread::PostTask( BrowserThread::PostTask(
...@@ -136,12 +138,12 @@ void ProfilerControllerImpl::SetProfilerStatus(bool enable) { ...@@ -136,12 +138,12 @@ void ProfilerControllerImpl::SetProfilerStatus(bool enable) {
FROM_HERE, FROM_HERE,
base::Bind(&ProfilerControllerImpl::SetProfilerStatusInChildProcesses, base::Bind(&ProfilerControllerImpl::SetProfilerStatusInChildProcesses,
base::Unretained(this), base::Unretained(this),
enable)); status));
for (content::RenderProcessHost::iterator it( for (content::RenderProcessHost::iterator it(
content::RenderProcessHost::AllHostsIterator()); content::RenderProcessHost::AllHostsIterator());
!it.IsAtEnd(); it.Advance()) { !it.IsAtEnd(); it.Advance()) {
it.GetCurrentValue()->Send(new ChildProcessMsg_SetProfilerStatus(enable)); it.GetCurrentValue()->Send(new ChildProcessMsg_SetProfilerStatus(status));
} }
} }
} // namespace content } // namespace content
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define CONTENT_BROWSER_PROFILER_CONTROLLER_IMPL_H_ #define CONTENT_BROWSER_PROFILER_CONTROLLER_IMPL_H_
#include "base/memory/singleton.h" #include "base/memory/singleton.h"
#include "base/tracked_objects.h"
#include "content/common/content_export.h" #include "content/common/content_export.h"
#include "content/public/browser/profiler_controller.h" #include "content/public/browser/profiler_controller.h"
...@@ -34,7 +35,8 @@ class CONTENT_EXPORT ProfilerControllerImpl : public ProfilerController { ...@@ -34,7 +35,8 @@ class CONTENT_EXPORT ProfilerControllerImpl : public ProfilerController {
virtual void Register(ProfilerSubscriber* subscriber) OVERRIDE; virtual void Register(ProfilerSubscriber* subscriber) OVERRIDE;
virtual void Unregister(ProfilerSubscriber* subscriber) OVERRIDE; virtual void Unregister(ProfilerSubscriber* subscriber) OVERRIDE;
virtual void GetProfilerData(int sequence_number) OVERRIDE; virtual void GetProfilerData(int sequence_number) OVERRIDE;
virtual void SetProfilerStatus(bool enable) OVERRIDE; virtual void SetProfilerStatus(
tracked_objects::ThreadData::Status status) OVERRIDE;
private: private:
friend struct DefaultSingletonTraits<ProfilerControllerImpl>; friend struct DefaultSingletonTraits<ProfilerControllerImpl>;
...@@ -43,7 +45,8 @@ class CONTENT_EXPORT ProfilerControllerImpl : public ProfilerController { ...@@ -43,7 +45,8 @@ class CONTENT_EXPORT ProfilerControllerImpl : public ProfilerController {
void GetProfilerDataFromChildProcesses(int sequence_number); void GetProfilerDataFromChildProcesses(int sequence_number);
// Contact child processes and set profiler status to |enable|. // Contact child processes and set profiler status to |enable|.
void SetProfilerStatusInChildProcesses(bool enable); void SetProfilerStatusInChildProcesses(
tracked_objects::ThreadData::Status status);
ProfilerSubscriber* subscriber_; ProfilerSubscriber* subscriber_;
......
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -21,8 +21,9 @@ ProfilerMessageFilter::~ProfilerMessageFilter() { ...@@ -21,8 +21,9 @@ ProfilerMessageFilter::~ProfilerMessageFilter() {
void ProfilerMessageFilter::OnChannelConnected(int32 peer_pid) { void ProfilerMessageFilter::OnChannelConnected(int32 peer_pid) {
BrowserMessageFilter::OnChannelConnected(peer_pid); BrowserMessageFilter::OnChannelConnected(peer_pid);
bool enable = tracked_objects::ThreadData::tracking_status(); tracked_objects::ThreadData::Status status =
Send(new ChildProcessMsg_SetProfilerStatus(enable)); tracked_objects::ThreadData::status();
Send(new ChildProcessMsg_SetProfilerStatus(status));
} }
bool ProfilerMessageFilter::OnMessageReceived(const IPC::Message& message, bool ProfilerMessageFilter::OnMessageReceived(const IPC::Message& message,
......
...@@ -909,8 +909,9 @@ void RenderProcessHostImpl::OnChannelConnected(int32 peer_pid) { ...@@ -909,8 +909,9 @@ void RenderProcessHostImpl::OnChannelConnected(int32 peer_pid) {
IPC::Logging::GetInstance()->Enabled())); IPC::Logging::GetInstance()->Enabled()));
#endif #endif
bool enable = tracked_objects::ThreadData::tracking_status(); tracked_objects::ThreadData::Status status =
Send(new ChildProcessMsg_SetProfilerStatus(enable)); tracked_objects::ThreadData::status();
Send(new ChildProcessMsg_SetProfilerStatus(status));
} }
void RenderProcessHostImpl::OnChannelError() { void RenderProcessHostImpl::OnChannelError() {
......
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -6,11 +6,14 @@ ...@@ -6,11 +6,14 @@
// Multiply-included message file, hence no include guard. // Multiply-included message file, hence no include guard.
#include "base/shared_memory.h" #include "base/shared_memory.h"
#include "base/tracked_objects.h"
#include "base/values.h" #include "base/values.h"
#include "content/common/content_export.h" #include "content/common/content_export.h"
#include "googleurl/src/gurl.h" #include "googleurl/src/gurl.h"
#include "ipc/ipc_message_macros.h" #include "ipc/ipc_message_macros.h"
IPC_ENUM_TRAITS(tracked_objects::ThreadData::Status)
#undef IPC_MESSAGE_EXPORT #undef IPC_MESSAGE_EXPORT
#define IPC_MESSAGE_EXPORT CONTENT_EXPORT #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
...@@ -41,7 +44,7 @@ IPC_MESSAGE_CONTROL0(ChildProcessMsg_GetTraceBufferPercentFull) ...@@ -41,7 +44,7 @@ IPC_MESSAGE_CONTROL0(ChildProcessMsg_GetTraceBufferPercentFull)
// Tell the child process to enable or disable the profiler status. // Tell the child process to enable or disable the profiler status.
IPC_MESSAGE_CONTROL1(ChildProcessMsg_SetProfilerStatus, IPC_MESSAGE_CONTROL1(ChildProcessMsg_SetProfilerStatus,
bool /* profiler status */) tracked_objects::ThreadData::Status /* profiler status */)
// Send to all the child processes to send back profiler data (ThreadData in // Send to all the child processes to send back profiler data (ThreadData in
// tracked_objects). // tracked_objects).
......
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -218,8 +218,9 @@ void ChildThread::OnSetIPCLoggingEnabled(bool enable) { ...@@ -218,8 +218,9 @@ void ChildThread::OnSetIPCLoggingEnabled(bool enable) {
} }
#endif // IPC_MESSAGE_LOG_ENABLED #endif // IPC_MESSAGE_LOG_ENABLED
void ChildThread::OnSetProfilerStatus(bool enable) { void ChildThread::OnSetProfilerStatus(
tracked_objects::ThreadData::InitializeAndSetTrackingStatus(enable); tracked_objects::ThreadData::Status status) {
tracked_objects::ThreadData::InitializeAndSetTrackingStatus(status);
} }
void ChildThread::OnGetChildProfilerData( void ChildThread::OnGetChildProfilerData(
......
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/shared_memory.h" #include "base/shared_memory.h"
#include "base/tracked_objects.h"
#include "content/common/content_export.h" #include "content/common/content_export.h"
#include "content/common/message_router.h" #include "content/common/message_router.h"
#include "webkit/glue/resource_loader_bridge.h" #include "webkit/glue/resource_loader_bridge.h"
...@@ -92,7 +93,7 @@ class CONTENT_EXPORT ChildThread : public IPC::Channel::Listener, ...@@ -92,7 +93,7 @@ class CONTENT_EXPORT ChildThread : public IPC::Channel::Listener,
virtual void OnSetIPCLoggingEnabled(bool enable); virtual void OnSetIPCLoggingEnabled(bool enable);
#endif #endif
virtual void OnSetProfilerStatus(bool enable); virtual void OnSetProfilerStatus(tracked_objects::ThreadData::Status status);
virtual void OnGetChildProfilerData(int sequence_number, virtual void OnGetChildProfilerData(int sequence_number,
const std::string& process_type); const std::string& process_type);
......
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
#include "content/common/content_export.h" #include "content/common/content_export.h"
#include "base/tracked_objects.h"
namespace base { namespace base {
class DictionaryValue; class DictionaryValue;
} }
...@@ -43,7 +45,8 @@ class CONTENT_EXPORT ProfilerController { ...@@ -43,7 +45,8 @@ class CONTENT_EXPORT ProfilerController {
virtual void GetProfilerData(int sequence_number) = 0; virtual void GetProfilerData(int sequence_number) = 0;
// Contact all processes and set profiler status to |enable|. // Contact all processes and set profiler status to |enable|.
virtual void SetProfilerStatus(bool enable) = 0; virtual void SetProfilerStatus(
tracked_objects::ThreadData::Status status) = 0;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment