Stack sampling profiler: set process and thread information

Adds process and thread state to CallStackProfileParams, and sets it at
the the profiler call sites. Propagates this information to the
associated UMA protobuf. This state is required to distinguish different
process/thread profiling scenarios in the resulting data.

BUG=517958

Review-Url: https://codereview.chromium.org/2362493002
Cr-Commit-Position: refs/heads/master@{#420439}
diff --git a/components/metrics/call_stack_profile_collector.h b/components/metrics/call_stack_profile_collector.h
index cfae8c8f..f6a2ca1 100644
--- a/components/metrics/call_stack_profile_collector.h
+++ b/components/metrics/call_stack_profile_collector.h
@@ -14,10 +14,13 @@
  public:
   using CallStackProfile = base::StackSamplingProfiler::CallStackProfile;
 
-  CallStackProfileCollector();
+  explicit CallStackProfileCollector(
+      CallStackProfileParams::Process expected_process);
   ~CallStackProfileCollector() override;
 
-  static void Create(mojom::CallStackProfileCollectorRequest request);
+  // Create a collector to receive profiles from |expected_process|.
+  static void Create(CallStackProfileParams::Process expected_process,
+                     mojom::CallStackProfileCollectorRequest request);
 
   // mojom::CallStackProfileCollector:
   void Collect(const CallStackProfileParams& params,
@@ -25,6 +28,11 @@
                const std::vector<CallStackProfile>& profiles) override;
 
  private:
+  // Profile params are validated to come from this process. Profiles with a
+  // different process declared in the params are considered untrustworthy and
+  // ignored.
+  const CallStackProfileParams::Process expected_process_;
+
   DISALLOW_COPY_AND_ASSIGN(CallStackProfileCollector);
 };