Don't fetch histograms from the same process.

This change makes HistogramController not fetch any
histograms from a "child" process when that process
is the same as the current process. In reality, this
could be the case on Android where the browser
process is actually also the GPU process.

See associated bug for the specific issue this is
actually fixing.

Also updates the profiler child process code to
use the same logic (it was not affected by the
bug, though).

BUG=370208

Review URL: https://codereview.chromium.org/328823002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276900 0039d316-1c4b-4281-b951-d872f2087c98
parent 05c9065b
......@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "base/metrics/histogram.h"
#include "base/process/process_handle.h"
#include "content/browser/histogram_subscriber.h"
#include "content/common/child_process_messages.h"
#include "content/public/browser/browser_child_process_host_iterator.h"
......@@ -72,7 +73,8 @@ void HistogramController::GetHistogramDataFromChildProcesses(
int pending_processes = 0;
for (BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) {
int type = iter.GetData().process_type;
const ChildProcessData& data = iter.GetData();
int type = data.process_type;
if (type != PROCESS_TYPE_PLUGIN &&
type != PROCESS_TYPE_GPU &&
type != PROCESS_TYPE_PPAPI_PLUGIN &&
......@@ -80,6 +82,13 @@ void HistogramController::GetHistogramDataFromChildProcesses(
continue;
}
// In some cases, there may be no child process of the given type (for
// example, the GPU process may not exist and there may instead just be a
// GPU thread in the browser process). If that's the case, then the process
// handle will be base::kNullProcessHandle and we shouldn't ask it for data.
if (data.handle == base::kNullProcessHandle)
continue;
++pending_processes;
if (!iter.Send(new ChildProcessMsg_GetChildHistogramData(sequence_number)))
--pending_processes;
......
......@@ -5,7 +5,7 @@
#include "content/browser/profiler_controller_impl.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/process/process_handle.h"
#include "base/tracked_objects.h"
#include "content/common/child_process_messages.h"
#include "content/public/browser/browser_child_process_host_iterator.h"
......@@ -13,7 +13,6 @@
#include "content/public/browser/child_process_data.h"
#include "content/public/browser/profiler_subscriber.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/common/content_switches.h"
namespace content {
......@@ -78,12 +77,12 @@ void ProfilerControllerImpl::GetProfilerDataFromChildProcesses(
int pending_processes = 0;
for (BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) {
// Skips requesting profiler data from the "GPU Process" if we are using in
// process GPU. Those stats should be in the Browser-process's GPU thread.
if (iter.GetData().process_type == PROCESS_TYPE_GPU &&
CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessGPU)) {
// In some cases, there may be no child process of the given type (for
// example, the GPU process may not exist and there may instead just be a
// GPU thread in the browser process). If that's the case, then the process
// handle will be base::kNullProcessHandle and we shouldn't ask it for data.
if (iter.GetData().handle == base::kNullProcessHandle)
continue;
}
++pending_processes;
if (!iter.Send(new ChildProcessMsg_GetChildProfilerData(sequence_number)))
......
......@@ -25,7 +25,9 @@ struct ChildProcessData {
// one run of the browser.
int id;
// The handle to the process.
// The handle to the process. May have value kNullProcessHandle if no process
// exists - either because it hasn't been started yet or it's running in the
// current process.
base::ProcessHandle handle;
explicit ChildProcessData(int process_type)
......
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