Upload WebRTC CLs from Chromium.

This CL removes some assumptions that were making it difficult to
upload a patch from the directory //third_party/webrtc in a
Chromium checkout.

Bug: webrtc:9705
Change-Id: I227ca492d5cf03875474ffd4d31abf387f947e5e
Reviewed-on: https://webrtc-review.googlesource.com/97600
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24549}
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 1b435a7..ae5303d 100755
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -110,6 +110,14 @@
 FILE_PATH_RE = re.compile(r'"(?P<file_path>(\w|\/)+)(?P<extension>\.\w+)"')
 
 
+def FindSrcDirPath(starting_dir):
+  """Returns the abs path to the src/ dir of the project."""
+  src_dir = starting_dir
+  while os.path.basename(src_dir) != 'src':
+    src_dir = os.path.normpath(os.path.join(src_dir, os.pardir))
+  return src_dir
+
+
 @contextmanager
 def _AddToPath(*paths):
   original_sys_path = sys.path
@@ -554,7 +562,7 @@
   with _AddToPath(input_api.os_path.join(
       input_api.PresubmitLocalPath(), 'tools_webrtc', 'presubmit_checks_lib')):
     from gn_check import RunGnCheck
-  errors = RunGnCheck(input_api.PresubmitLocalPath())[:5]
+  errors = RunGnCheck(FindSrcDirPath(input_api.PresubmitLocalPath()))[:5]
   if errors:
     return [output_api.PresubmitPromptWarning(
         'Some #includes do not match the build dependency graph. Please run:\n'
@@ -573,8 +581,8 @@
   # We need to wait until we have an input_api object and use this
   # roundabout construct to import checkdeps because this file is
   # eval-ed and thus doesn't have __file__.
-  checkdeps_path = input_api.os_path.join(input_api.PresubmitLocalPath(),
-                                          'buildtools', 'checkdeps')
+  src_path = FindSrcDirPath(input_api.PresubmitLocalPath())
+  checkdeps_path = input_api.os_path.join(src_path, 'buildtools', 'checkdeps')
   if not os.path.exists(checkdeps_path):
     return [output_api.PresubmitError(
         'Cannot find checkdeps at %s\nHave you run "gclient sync" to '