Moved sufficient_chrome_processes from gesture_jank to sufficient_chrome_processes.sql
to avoid including the entire gesture_jank file in google3 dependencies

Bug:197841224
Change-Id: I9fe0e309f66385a7fafb169688da2ebedf79fa47
diff --git a/Android.bp b/Android.bp
index 42c037f..8e1e126 100644
--- a/Android.bp
+++ b/Android.bp
@@ -8143,6 +8143,7 @@
         "src/trace_processor/metrics/sql/chrome/scroll_jank_cause_blocking_touch_move.sql",
         "src/trace_processor/metrics/sql/chrome/scroll_jank_cause_get_bitmap.sql",
         "src/trace_processor/metrics/sql/chrome/scroll_jank_cause_queuing_delay.sql",
+        "src/trace_processor/metrics/sql/chrome/sufficient_chrome_processes.sql",
         "src/trace_processor/metrics/sql/chrome/test_chrome_metric.sql",
         "src/trace_processor/metrics/sql/chrome/touch_flow_event.sql",
         "src/trace_processor/metrics/sql/chrome/touch_flow_event_queuing_delay.sql",
diff --git a/BUILD b/BUILD
index 0fbed3c..31ba472 100644
--- a/BUILD
+++ b/BUILD
@@ -1114,6 +1114,7 @@
         "src/trace_processor/metrics/sql/chrome/scroll_jank_cause_blocking_touch_move.sql",
         "src/trace_processor/metrics/sql/chrome/scroll_jank_cause_get_bitmap.sql",
         "src/trace_processor/metrics/sql/chrome/scroll_jank_cause_queuing_delay.sql",
+        "src/trace_processor/metrics/sql/chrome/sufficient_chrome_processes.sql",
         "src/trace_processor/metrics/sql/chrome/test_chrome_metric.sql",
         "src/trace_processor/metrics/sql/chrome/touch_flow_event.sql",
         "src/trace_processor/metrics/sql/chrome/touch_flow_event_queuing_delay.sql",
diff --git a/src/trace_processor/metrics/sql/BUILD.gn b/src/trace_processor/metrics/sql/BUILD.gn
index 8be8f90..c2b3592 100644
--- a/src/trace_processor/metrics/sql/BUILD.gn
+++ b/src/trace_processor/metrics/sql/BUILD.gn
@@ -85,6 +85,7 @@
   "chrome/cpu_time_by_rail_mode.sql",
   "chrome/estimated_power_by_category.sql",
   "chrome/estimated_power_by_rail_mode.sql",
+  "chrome/sufficient_chrome_processes.sql",
   "chrome/gesture_jank.sql",
   "chrome/gesture_flow_event.sql",
   "chrome/gesture_flow_event_queuing_delay.sql",
diff --git a/src/trace_processor/metrics/sql/chrome/gesture_jank.sql b/src/trace_processor/metrics/sql/chrome/gesture_jank.sql
index c13a051..8756d27 100644
--- a/src/trace_processor/metrics/sql/chrome/gesture_jank.sql
+++ b/src/trace_processor/metrics/sql/chrome/gesture_jank.sql
@@ -24,40 +24,9 @@
 --          active development and the values & meaning might change without
 --          notice.
 
--- Get all chrome processes and threads tables set up.
-SELECT RUN_METRIC('chrome/chrome_processes.sql');
-
--- When working on InputLatency events we need to ensure we have all the events
--- from the browser, renderer, and GPU processes. This query isn't quite
--- perfect. In system tracing we could have 3 browser processes all in the
--- background and this would match, but for now its the best we can do (renderer
--- and GPU names on android are quite complicated, but this should filter 99%
--- (citation needed) of what we want.
---
--- See b/151077536 for historical context.
--- TODO(b/197841224): Refactor or remove this table.
-DROP VIEW IF EXISTS sufficient_chrome_processes;
-CREATE VIEW sufficient_chrome_processes AS
-  SELECT
-    CASE WHEN (
-      SELECT COUNT(*) FROM chrome_process) = 0
-    THEN
-      FALSE
-    ELSE (
-      SELECT COUNT(*) >= 3 FROM (
-        SELECT name FROM chrome_process
-        WHERE
-          name GLOB "Browser" OR
-          name GLOB "Renderer" OR
-          name GLOB "Gpu" OR
-          name GLOB 'com.android.chrome*' OR
-          name GLOB 'com.chrome.beta*' OR
-          name GLOB 'com.chrome.dev*' OR
-          name GLOB 'com.chrome.canary*' OR
-          name GLOB 'com.google.android.apps.chrome*' OR
-          name GLOB 'org.chromium.chrome*'
-        GROUP BY name
-    )) END AS have_enough_chrome_processes;
+-- Temporarily get the sufficient_chrome_processes view until dependency
+-- is removed
+SELECT RUN_METRIC('chrome/sufficient_chrome_processes.sql');
 
 -- A simple table that checks the time between VSync (this can be used to
 -- determine if we're refreshing at 90 FPS or 60 FPS.
diff --git a/src/trace_processor/metrics/sql/chrome/sufficient_chrome_processes.sql b/src/trace_processor/metrics/sql/chrome/sufficient_chrome_processes.sql
new file mode 100644
index 0000000..c44270e
--- /dev/null
+++ b/src/trace_processor/metrics/sql/chrome/sufficient_chrome_processes.sql
@@ -0,0 +1,48 @@
+--
+-- Copyright 2021 The Android Open Source Project
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+--     https://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Get all chrome processes and threads tables set up.
+SELECT RUN_METRIC('chrome/chrome_processes.sql');
+
+-- When working on InputLatency events we need to ensure we have all the events
+-- from the browser, renderer, and GPU processes. This query isn't quite
+-- perfect. In system tracing we could have 3 browser processes all in the
+-- background and this would match, but for now its the best we can do (renderer
+-- and GPU names on android are quite complicated, but this should filter 99%
+-- (citation needed) of what we want.
+--
+-- See b/151077536 for historical context.
+DROP VIEW IF EXISTS sufficient_chrome_processes;
+CREATE VIEW sufficient_chrome_processes AS
+  SELECT
+    CASE WHEN (
+      SELECT COUNT(*) FROM chrome_process) = 0
+    THEN
+      FALSE
+    ELSE (
+      SELECT COUNT(*) >= 3 FROM (
+        SELECT name FROM chrome_process
+        WHERE
+          name GLOB "Browser" OR
+          name GLOB "Renderer" OR
+          name GLOB "Gpu" OR
+          name GLOB 'com.android.chrome*' OR
+          name GLOB 'com.chrome.beta*' OR
+          name GLOB 'com.chrome.dev*' OR
+          name GLOB 'com.chrome.canary*' OR
+          name GLOB 'com.google.android.apps.chrome*' OR
+          name GLOB 'org.chromium.chrome*'
+        GROUP BY name
+    )) END AS have_enough_chrome_processes;
\ No newline at end of file