Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / common / extensions / docs / server2 / host_file_system_provider.py
index ac50ccd..3231c77 100644 (file)
@@ -6,7 +6,6 @@ from caching_file_system import CachingFileSystem
 from gitiles_file_system import GitilesFileSystem
 from local_file_system import LocalFileSystem
 from offline_file_system import OfflineFileSystem
-from gitiles_file_system import GitilesFileSystem
 from third_party.json_schema_compiler.memoize import memoize
 
 
@@ -22,7 +21,8 @@ class HostFileSystemProvider(object):
                pinned_commit=None,
                default_master_instance=None,
                offline=False,
-               constructor_for_test=None):
+               constructor_for_test=None,
+               cache_only=False):
     '''
     |object_store_creator|
       Provides caches for file systems that need one.
@@ -36,12 +36,16 @@ class HostFileSystemProvider(object):
       If True all provided file systems will be wrapped in an OfflineFileSystem.
     |constructor_for_test|
       Provides a custom constructor rather than creating GitilesFileSystems.
+    |cache_only|
+      If True, all provided file systems will be cache-only, meaning that cache
+      misses will result in errors rather than cache updates.
     '''
     self._object_store_creator = object_store_creator
     self._pinned_commit = pinned_commit
     self._default_master_instance = default_master_instance
     self._offline = offline
     self._constructor_for_test = constructor_for_test
+    self._cache_only = cache_only
 
   @memoize
   def GetMaster(self, commit=None):
@@ -60,10 +64,6 @@ class HostFileSystemProvider(object):
       if self._default_master_instance is not None:
         return self._default_master_instance
       return self._Create('master', commit=self._pinned_commit)
-    if self._pinned_commit is not None:
-      # XXX(ahernandez): THIS IS WRONG. Should be
-      # commit = Oldest(commit, self._pinned_commit).
-      commit = min(commit, self._pinned_commit)
     return self._Create('master', commit=commit)
 
   @memoize
@@ -92,7 +92,8 @@ class HostFileSystemProvider(object):
       file_system = GitilesFileSystem.Create(branch=branch, commit=commit)
     if self._offline:
       file_system = OfflineFileSystem(file_system)
-    return CachingFileSystem(file_system, self._object_store_creator)
+    return CachingFileSystem(file_system, self._object_store_creator,
+        fail_on_miss=self._cache_only)
 
   @staticmethod
   def ForLocal(object_store_creator, **optargs):