Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 from caching_file_system import CachingFileSystem | |
| 6 from local_file_system import LocalFileSystem | |
| 7 from object_store_creator import ObjectStoreCreator | |
| 8 from offline_file_system import OfflineFileSystem | |
| 9 from subversion_file_system import SubversionFileSystem | |
| 10 from test_branch_utility import TestBranchUtility | |
| 11 | |
| 12 | |
| 13 class HostFileSystemCreator(object): | |
| 14 '''Creates file systems using a create method provided by a servlet. | |
| 15 ''' | |
| 16 def __init__(self, | |
| 17 branch_utility, | |
| 18 create_method, | |
| 19 object_store_creator=None, | |
|
not at google - send to devlin
2013/07/09 23:11:55
how/why can/should this be None?
epeterson
2013/07/16 00:28:23
It is None no longer!
| |
| 20 offline=True): | |
|
not at google - send to devlin
2013/07/09 23:11:55
always default to False. it makes sense here.
epeterson
2013/07/16 00:28:23
Done.
| |
| 21 self._branch_utility = branch_utility | |
| 22 self._create_method = create_method | |
| 23 self._object_store_creator = object_store_creator | |
| 24 if object_store_creator: | |
| 25 self._caching = True | |
| 26 self._offline = offline | |
| 27 | |
| 28 def CreateAtVersion(self, version): | |
| 29 branch = self._branch_utility.GetBranchForVersion(version) | |
| 30 return self.CreateAtBranch(branch) | |
| 31 | |
| 32 def CreateAtBranch(self, branch): | |
| 33 fs = self._create_method(branch) | |
| 34 if self._offline: | |
| 35 fs = OfflineFileSystem(fs) | |
| 36 if self._caching: | |
| 37 fs = CachingFileSystem(fs, self._object_store_creator) | |
| 38 return fs | |
| 39 | |
| 40 @staticmethod | |
| 41 def ForTest(file_system, object_store_creator): | |
| 42 return HostFileSystemCreator(TestBranchUtility.CreateWithCannedData(), | |
| 43 lambda _: file_system, | |
| 44 object_store_creator, | |
| 45 offline=False) | |
| 46 | |
| 47 @staticmethod | |
| 48 def ForLocal(object_store_creator): | |
| 49 return HostFileSystemCreator( | |
| 50 TestBranchUtility.CreateWithCannedData(), | |
| 51 lambda _: CachingFileSystem(LocalFileSystem.Create(), | |
| 52 object_store_creator), | |
| 53 object_store_creator, | |
| 54 offline=False) | |
| OLD | NEW |