Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4044)

Unified Diff: build/android/pylib/android_commands.py

Issue 97133002: Add instance-level in-memory cache for PushIfNeeded(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/android_commands.py
diff --git a/build/android/pylib/android_commands.py b/build/android/pylib/android_commands.py
index 95b193bbc231131f3c8b389cabfadfe429f06f21..6bb9933655187f8bf13a05781687904f0aadd75a 100644
--- a/build/android/pylib/android_commands.py
+++ b/build/android/pylib/android_commands.py
@@ -260,6 +260,7 @@ class AndroidCommands(object):
self._util_wrapper = ''
self._api_strict_mode = api_strict_mode
self._system_properties = system_properties.SystemProperties(self.Adb())
+ self._push_if_needed_cache = {}
if not self._api_strict_mode:
logging.warning(
@@ -965,6 +966,15 @@ class AndroidCommands(object):
MAX_INDIVIDUAL_PUSHES = 50
assert os.path.exists(host_path), 'Local path not found %s' % host_path
+ # See if the file on the host changed since the last push (if any) and
+ # return early if it didn't. Note that this shortcut assumes that the tests
+ # on the device don't modify the files.
+ if not os.path.isdir(host_path):
+ if host_path in self._push_if_needed_cache:
+ host_path_mtime = self._push_if_needed_cache[host_path]
+ if host_path_mtime == os.stat(host_path).st_mtime:
+ return
+
def GetHostSize(path):
return int(cmd_helper.GetCmdOutput(['du', '-sb', path]).split()[0])
@@ -989,6 +999,8 @@ class AndroidCommands(object):
while True:
output = self._adb.SendCommand(push_command, timeout_time=30 * 60)
if _HasAdbPushSucceeded(output):
+ if not os.path.isdir(host_path):
+ self._push_if_needed_cache[host] = os.stat(host).st_mtime
return
if retry < 3:
retry += 1
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698