Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | |
|
mikecase (-- gone --)
2016/06/16 17:55:08
Making this CL Android only which means this file
| |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 class Url(object): | |
|
jbudorick
2016/05/04 18:10:43
Not sure I see a strong argument for namespacing t
| |
| 6 GS_CHROMIUM_CONTINUOUS_URL = 'gs://chromium-browser-continuous' | |
| 7 GS_CHROMIUM_SNAPSHOT_URL = 'gs://chromium-browser-snapshots' | |
| 8 GS_CHROMIUM_BLINK_SNAPSHOT_URL = 'gs://chromium-webkit-snapshots' | |
| 9 | |
| 10 | |
| 11 class Archive(object): | |
| 12 """Downloads items from the Chromium continuous archive.""" | |
| 13 | |
| 14 CHROME_45_REVISION = '338390' | |
|
jbudorick
2016/05/04 18:10:43
Why are we hard-coding these? Can we do this anoth
| |
| 15 CHROME_46_REVISION = '344997' | |
| 16 CHROME_47_REVISION = '352825' | |
| 17 | |
| 18 def __init__(self, m): | |
|
jbudorick
2016/05/04 18:10:43
Passing the modules object here seems weird but re
| |
| 19 self.m = m | |
| 20 | |
| 21 def get_download_platform(self): | |
| 22 """Returns the name for this platform on the archive site.""" | |
| 23 if self.m.platform.is_win: | |
| 24 return 'Win' | |
| 25 elif self.m.platform.is_mac: | |
| 26 return 'Mac' | |
| 27 elif self.m.platform.is_linux: | |
| 28 if self.m.platform.bits == 64: | |
| 29 return 'Linux_x64' | |
| 30 else: | |
| 31 return 'Linux' | |
| 32 | |
| 33 def get_latest_revision(self, site=Url.GS_CHROMIUM_CONTINUOUS_URL): | |
| 34 """Returns the latest revision (as a string) available for this platform. | |
| 35 | |
| 36 Args: | |
| 37 site: the archive site to check against, default to the continuous one. | |
| 38 """ | |
| 39 url = site + '/%s/LAST_CHANGE' | |
|
jbudorick
2016/05/04 18:10:43
Are you leaving the %s in here intentionally? Does
| |
| 40 step_result = self.m.gsutil.cat( | |
| 41 name='get latest revision', | |
| 42 url=url, | |
| 43 stdout=self.m.raw_io.output(), | |
| 44 step_test_data=lambda: self.m.raw_io.test_api.stream_output( | |
| 45 '123_LATEST_CHROME_REV_456', stream='stdout')) | |
| 46 return step_result.stdout | |
| 47 | |
| 48 def download_chrome(self, revision, dest_dir, | |
| 49 site=Url.GS_CHROMIUM_CONTINUOUS_URL): | |
| 50 """Downloads the packaged Chrome from the archive to the given directory. | |
| 51 | |
| 52 Args: | |
| 53 revision: the revision of Chrome to download. | |
| 54 dest_dir: the directory to download Chrome to. | |
| 55 site: the archive site to download from, default to the continuous one. | |
| 56 | |
| 57 Returns: | |
| 58 The path to the unzipped Chrome binary. | |
| 59 """ | |
| 60 def get_zip_name(): | |
| 61 if self.m.platform.is_win: | |
| 62 return 'chrome-win32' | |
| 63 elif self.m.platform.is_mac: | |
| 64 return 'chrome-mac' | |
| 65 elif self.m.platform.is_linux: | |
| 66 return 'chrome-linux' | |
| 67 | |
| 68 def get_chrome_path_from_package(): | |
| 69 if self.m.platform.is_win: | |
| 70 return 'chrome.exe' | |
| 71 elif self.m.platform.is_mac: | |
| 72 return 'Chromium.app/Contents/MacOS/Chromium' | |
| 73 elif self.m.platform.is_linux: | |
| 74 return 'chrome-wrapper' | |
| 75 | |
| 76 zip_path = self.m.path.join(dest_dir, 'chrome-%s.zip' % revision) | |
| 77 if not self.m.path.exists(zip_path): | |
| 78 url = site + '/%s/%s/%s.zip' % (self.get_download_platform(), revision, | |
|
jbudorick
2016/05/04 18:10:43
Why isn't this just
'%s/%s/%s/%s.zip' % (site,
| |
| 79 get_zip_name()) | |
| 80 temp_zip_path = self.m.path.mkdtemp('chrome_zip').join( | |
| 81 'chrome-%s.zip' % revision) | |
| 82 self.m.gsutil.download_url( | |
| 83 name='download chrome', | |
| 84 url=url, | |
| 85 dest=temp_zip_path) | |
| 86 self.m.zip.unzip(step_name='unzip chrome', | |
|
jbudorick
2016/05/04 18:10:43
nit: line break before this
| |
| 87 zip_file=zip_path, | |
| 88 output=dest_dir) | |
| 89 return self.m.path.join( | |
| 90 dest_dir, get_zip_name(), get_chrome_path_from_package()) | |
| 91 | |
| 92 def get_latest_snapshot_version(self): | |
| 93 """Returns the latest revision of snapshot build.""" | |
| 94 return self.get_latest_revision(self.get_snapshot_download_site()) | |
| 95 | |
| 96 def get_snapshot_download_site(self): | |
| 97 """Returns site to download snapshot build according to the platform.""" | |
| 98 return Url.GS_CHROMIUM_SNAPSHOT_URL | |
| OLD | NEW |