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

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

Issue 660383002: Docserver: Persist stat cache for versioned file systems (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 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 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 posixpath 5 import posixpath
6 6
7 from file_system import FileSystem, FileNotFoundError 7 from file_system import FileSystem, FileNotFoundError
8 from future import Future 8 from future import Future
9 from test_file_system import _List, _StatTracker, TestFileSystem 9 from test_file_system import _List, _StatTracker, TestFileSystem
10 from path_util import IsDirectory 10 from path_util import IsDirectory
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 stat.version = stradd(stat.version, self._stat_tracker.GetVersion(path)) 79 stat.version = stradd(stat.version, self._stat_tracker.GetVersion(path))
80 if stat.child_versions: 80 if stat.child_versions:
81 for child_path, child_version in stat.child_versions.iteritems(): 81 for child_path, child_version in stat.child_versions.iteritems():
82 stat.child_versions[child_path] = stradd( 82 stat.child_versions[child_path] = stradd(
83 stat.child_versions[child_path], 83 stat.child_versions[child_path],
84 self._stat_tracker.GetVersion(posixpath.join(path, child_path))) 84 self._stat_tracker.GetVersion(posixpath.join(path, child_path)))
85 85
86 return stat 86 return stat
87 87
88 def GetCommitID(self): 88 def GetCommitID(self):
89 return Future(value=self._stat_tracker.GetVersion('')) 89 return Future(value=str(self._stat_tracker.GetVersion('')))
90 90
91 def GetPreviousCommitID(self): 91 def GetPreviousCommitID(self):
92 return Future(value=self._stat_tracker.GetVersion('') - 1) 92 return Future(value=str(self._stat_tracker.GetVersion('') - 1))
93 93
94 def GetIdentity(self): 94 def GetIdentity(self):
95 return self._file_system.GetIdentity() 95 return self._file_system.GetIdentity()
96 96
97 def __str__(self): 97 def __str__(self):
98 return repr(self) 98 return repr(self)
99 99
100 def __repr__(self): 100 def __repr__(self):
101 return 'MockFileSystem(read_count=%s, stat_count=%s, updates=%s)' % ( 101 return 'MockFileSystem(read_count=%s, stat_count=%s, updates=%s)' % (
102 self._read_count, self._stat_count, len(self._updates)) 102 self._read_count, self._stat_count, len(self._updates))
(...skipping 26 matching lines...) Expand all
129 self._read_resolve_count = 0 129 self._read_resolve_count = 0
130 self._stat_count = 0 130 self._stat_count = 0
131 131
132 def Update(self, update): 132 def Update(self, update):
133 self._updates.append(TestFileSystem(update)) 133 self._updates.append(TestFileSystem(update))
134 for path in _List(update).iterkeys(): 134 for path in _List(update).iterkeys():
135 # Any files (not directories) which changed are now at the version 135 # Any files (not directories) which changed are now at the version
136 # derived from |_updates|. 136 # derived from |_updates|.
137 if not IsDirectory(path): 137 if not IsDirectory(path):
138 self._stat_tracker.SetVersion(path, len(self._updates)) 138 self._stat_tracker.SetVersion(path, len(self._updates))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698