OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import json | 5 import json |
6 import logging | 6 import logging |
7 import operator | 7 import operator |
8 | 8 |
9 from appengine_url_fetcher import AppEngineUrlFetcher | 9 from environment_wrappers import CreateUrlFetcher |
10 import url_constants | 10 import url_constants |
11 | 11 |
12 | 12 |
13 class ChannelInfo(object): | 13 class ChannelInfo(object): |
14 '''Represents a Chrome channel with three pieces of information. |channel| is | 14 '''Represents a Chrome channel with three pieces of information. |channel| is |
15 one of 'stable', 'beta', 'dev', or 'master'. |branch| and |version| correspond | 15 one of 'stable', 'beta', 'dev', or 'master'. |branch| and |version| correspond |
16 with each other, and represent different releases of Chrome. Note that | 16 with each other, and represent different releases of Chrome. Note that |
17 |branch| and |version| can occasionally be the same for separate channels | 17 |branch| and |version| can occasionally be the same for separate channels |
18 (i.e. 'beta' and 'dev'), so all three fields are required to uniquely | 18 (i.e. 'beta' and 'dev'), so all three fields are required to uniquely |
19 identify a channel. | 19 identify a channel. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 return object_store_creator.Create(BranchUtility, category=category) | 53 return object_store_creator.Create(BranchUtility, category=category) |
54 self._branch_object_store = create_object_store('branch') | 54 self._branch_object_store = create_object_store('branch') |
55 self._version_object_store = create_object_store('version') | 55 self._version_object_store = create_object_store('version') |
56 self._fetch_result = self._fetcher.FetchAsync(fetch_url) | 56 self._fetch_result = self._fetcher.FetchAsync(fetch_url) |
57 self._history_result = self._fetcher.FetchAsync(history_url) | 57 self._history_result = self._fetcher.FetchAsync(history_url) |
58 | 58 |
59 @staticmethod | 59 @staticmethod |
60 def Create(object_store_creator): | 60 def Create(object_store_creator): |
61 return BranchUtility(url_constants.OMAHA_PROXY_URL, | 61 return BranchUtility(url_constants.OMAHA_PROXY_URL, |
62 url_constants.OMAHA_DEV_HISTORY, | 62 url_constants.OMAHA_DEV_HISTORY, |
63 AppEngineUrlFetcher(), | 63 CreateUrlFetcher(), |
64 object_store_creator) | 64 object_store_creator) |
65 | 65 |
66 @staticmethod | 66 @staticmethod |
67 def GetAllChannelNames(): | 67 def GetAllChannelNames(): |
68 return ('stable', 'beta', 'dev', 'master') | 68 return ('stable', 'beta', 'dev', 'master') |
69 | 69 |
70 @staticmethod | 70 @staticmethod |
71 def NewestChannel(channels): | 71 def NewestChannel(channels): |
72 channels = set(channels) | 72 channels = set(channels) |
73 for channel in reversed(BranchUtility.GetAllChannelNames()): | 73 for channel in reversed(BranchUtility.GetAllChannelNames()): |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 version_json = json.loads(self._history_result.Get().content) | 227 version_json = json.loads(self._history_result.Get().content) |
228 latest_version = 0 | 228 latest_version = 0 |
229 for entry in version_json: | 229 for entry in version_json: |
230 version_title = entry['version'].split('.') | 230 version_title = entry['version'].split('.') |
231 version = int(version_title[0]) | 231 version = int(version_title[0]) |
232 if version > latest_version: | 232 if version > latest_version: |
233 latest_version = version | 233 latest_version = version |
234 | 234 |
235 self._version_object_store.Set('latest', latest_version) | 235 self._version_object_store.Set('latest', latest_version) |
236 return latest_version | 236 return latest_version |
OLD | NEW |