cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / chrome / common / extensions / docs / server2 / host_file_system_iterator.py
blob867adec664ac02ad20d5e2789c910a5bf2dd47ce
1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
6 class HostFileSystemIterator(object):
7 '''Provides methods for iterating through host file systems, in both
8 ascending (oldest to newest version) and descending order.
9 '''
11 def __init__(self, file_system_provider, branch_utility):
12 self._file_system_provider = file_system_provider
13 self._branch_utility = branch_utility
15 def _ForEach(self, channel_info, callback, get_next):
16 '''Iterates through a sequence of file systems defined by |get_next| until
17 |callback| returns False, or until the end of the sequence of file systems
18 is reached. Returns the BranchUtility.ChannelInfo of the last file system
19 for which |callback| returned True.
20 '''
21 last_true = None
22 while channel_info is not None:
23 if channel_info.branch == 'master':
24 file_system = self._file_system_provider.GetMaster()
25 else:
26 file_system = self._file_system_provider.GetBranch(channel_info.branch)
27 if not callback(file_system, channel_info):
28 return last_true
29 last_true = channel_info
30 channel_info = get_next(channel_info)
31 return last_true
33 def Ascending(self, channel_info, callback):
34 return self._ForEach(channel_info, callback, self._branch_utility.Newer)
36 def Descending(self, channel_info, callback):
37 return self._ForEach(channel_info, callback, self._branch_utility.Older)