PRESUBMIT.py: IPC owners check should not explode on invalid JSON files.

Update the IPC owners checks to skip files that don't parse. This is OK
since invalid JSON already triggers a separate presubmit error. Once the
error is fixed, subsequent presubmit runs will verify that IPC owners
are correctly set.

Bug: 825053
Change-Id: I2295901bf706c1a62ebee3710c5d87e415bd011a
Reviewed-on: https://chromium-review.googlesource.com/978611
Reviewed-by: Emily Stark <[email protected]>
Commit-Queue: Daniel Cheng <[email protected]>
Cr-Commit-Position: refs/heads/master@{#545634}
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 3cf3d7a..c06e0216 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -1771,7 +1771,12 @@
       mostly_json_lines = '\n'.join(f.NewContents())
       # Comments aren't allowed in strict JSON, so filter them out.
       json_lines = json_comment_eater.Nom(mostly_json_lines)
-      json_content = input_api.json.loads(json_lines)
+      try:
+        json_content = input_api.json.loads(json_lines)
+      except:
+        # There's another PRESUBMIT check that already verifies that JSON files
+        # are not invalid, so no need to emit another warning here.
+        continue
       if 'interface_provider_specs' in json_content:
         AddPatternToCheck(f, input_api.os_path.basename(f.LocalPath()))
     for pattern in file_patterns: