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

Side by Side Diff: chrome/common/extensions/docs/server2/gcs_file_system_provider.py

Issue 162043003: Add CachingFileSystem on top of CloudStorageFileSystem (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Trying again Created 6 years, 10 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 unified diff | Download patch
« no previous file with comments | « chrome/common/extensions/docs/server2/gcs_file_system.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 os 5 import os
6 import environment 6 import environment
7 7
8 from caching_file_system import CachingFileSystem
8 from empty_dir_file_system import EmptyDirFileSystem 9 from empty_dir_file_system import EmptyDirFileSystem
9 from extensions_paths import LOCAL_GCS_DIR, LOCAL_GCS_DEBUG_CONF 10 from extensions_paths import LOCAL_GCS_DIR, LOCAL_GCS_DEBUG_CONF
10 from local_file_system import LocalFileSystem 11 from local_file_system import LocalFileSystem
11 from path_util import IsDirectory 12 from path_util import IsDirectory
12 13
13 class CloudStorageFileSystemProvider(object): 14 class CloudStorageFileSystemProvider(object):
14 '''Provides CloudStorageFileSystem bound to a GCS bucket. 15 '''Provides CloudStorageFileSystem bound to a GCS bucket.
15 ''' 16 '''
16 def __init__(self, object_store_creator): 17 def __init__(self, object_store_creator):
17 self._object_store_creator = object_store_creator 18 self._object_store_creator = object_store_creator
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 use_local_fs = properties.get('use_local_fs', 'False')=='True' 75 use_local_fs = properties.get('use_local_fs', 'False')=='True'
75 debug_access_token = properties.get('access_token', None) 76 debug_access_token = properties.get('access_token', None)
76 debug_bucket_prefix = properties.get('remote_bucket_prefix', None) 77 debug_bucket_prefix = properties.get('remote_bucket_prefix', None)
77 78
78 if environment.IsDevServer() and use_local_fs: 79 if environment.IsDevServer() and use_local_fs:
79 return LocalFileSystem(os.path.join(LOCAL_GCS_DIR, bucket)) 80 return LocalFileSystem(os.path.join(LOCAL_GCS_DIR, bucket))
80 81
81 # gcs_file_system has strong dependencies on runtime appengine APIs, 82 # gcs_file_system has strong dependencies on runtime appengine APIs,
82 # so we only import it when we are sure we are not on preview.py or tests. 83 # so we only import it when we are sure we are not on preview.py or tests.
83 from gcs_file_system import CloudStorageFileSystem 84 from gcs_file_system import CloudStorageFileSystem
84 return CloudStorageFileSystem( 85 return CachingFileSystem(CloudStorageFileSystem(bucket,
85 bucket, debug_access_token, debug_bucket_prefix) 86 debug_access_token, debug_bucket_prefix),
86 87 self._object_store_creator)
87 88
88 @staticmethod 89 @staticmethod
89 def ForEmpty(): 90 def ForEmpty():
90 class EmptyImpl(object): 91 class EmptyImpl(object):
91 def Create(self, bucket): 92 def Create(self, bucket):
92 return EmptyDirFileSystem() 93 return EmptyDirFileSystem()
93 return EmptyImpl() 94 return EmptyImpl()
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/gcs_file_system.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698