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

Unified Diff: chrome/common/extensions/docs/server2/host_file_system_creator.py

Issue 18323018: Linking AvailabilityFinder with APIDataSource and intro-table templates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: HostFileSystemCreator, Intro Table data structure changes Created 7 years, 5 months 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
Index: chrome/common/extensions/docs/server2/host_file_system_creator.py
diff --git a/chrome/common/extensions/docs/server2/host_file_system_creator.py b/chrome/common/extensions/docs/server2/host_file_system_creator.py
new file mode 100644
index 0000000000000000000000000000000000000000..1fd5cf8af5060c34c531f1e40e019bcda5f16b4b
--- /dev/null
+++ b/chrome/common/extensions/docs/server2/host_file_system_creator.py
@@ -0,0 +1,54 @@
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+from caching_file_system import CachingFileSystem
+from local_file_system import LocalFileSystem
+from object_store_creator import ObjectStoreCreator
+from offline_file_system import OfflineFileSystem
+from subversion_file_system import SubversionFileSystem
+from test_branch_utility import TestBranchUtility
+
+
+class HostFileSystemCreator(object):
+ '''Creates file systems using a create method provided by a servlet.
+ '''
+ def __init__(self,
+ branch_utility,
+ create_method,
+ 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!
+ 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.
+ self._branch_utility = branch_utility
+ self._create_method = create_method
+ self._object_store_creator = object_store_creator
+ if object_store_creator:
+ self._caching = True
+ self._offline = offline
+
+ def CreateAtVersion(self, version):
+ branch = self._branch_utility.GetBranchForVersion(version)
+ return self.CreateAtBranch(branch)
+
+ def CreateAtBranch(self, branch):
+ fs = self._create_method(branch)
+ if self._offline:
+ fs = OfflineFileSystem(fs)
+ if self._caching:
+ fs = CachingFileSystem(fs, self._object_store_creator)
+ return fs
+
+ @staticmethod
+ def ForTest(file_system, object_store_creator):
+ return HostFileSystemCreator(TestBranchUtility.CreateWithCannedData(),
+ lambda _: file_system,
+ object_store_creator,
+ offline=False)
+
+ @staticmethod
+ def ForLocal(object_store_creator):
+ return HostFileSystemCreator(
+ TestBranchUtility.CreateWithCannedData(),
+ lambda _: CachingFileSystem(LocalFileSystem.Create(),
+ object_store_creator),
+ object_store_creator,
+ offline=False)

Powered by Google App Engine
This is Rietveld 408576698