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

Unified Diff: appengine/findit/gae_libs/gitiles/cached_gitiles_repository.py

Issue 2605943002: Removing the mutation in the factories for getting dep repositories (Closed)
Patch Set: Added the Factory method to CachedGitilesRepository Created 4 years 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: appengine/findit/gae_libs/gitiles/cached_gitiles_repository.py
diff --git a/appengine/findit/gae_libs/gitiles/cached_gitiles_repository.py b/appengine/findit/gae_libs/gitiles/cached_gitiles_repository.py
index 1aa50d98e16d5d1eafd756075acabdcd8ef577fc..70f2426dab68fd979a25ccfb5c70a659d7e11f60 100644
--- a/appengine/findit/gae_libs/gitiles/cached_gitiles_repository.py
+++ b/appengine/findit/gae_libs/gitiles/cached_gitiles_repository.py
@@ -23,3 +23,19 @@ class CachedGitilesRepository(GitilesRepository):
cache=PickledMemCache())
def _SendRequestForTextResponse(self, url): # pragma: no cover
return super(CachedGitilesRepository, self)._SendRequestForTextResponse(url)
+
+ @classmethod
+ def Factory(cls, http_client): # pragma: no cover
Sharu Jiang 2016/12/30 00:00:46 This is general enough that we can move this to ``
wrengr 2017/01/03 19:01:02 Done.
+ """Construct a factory for creating ``CachedGitilesRepository`` instances.
+
+ Args:
+ http_client: the http client to be shared among all created repository
+ instances.
+
+ Returns:
+ A function from repo urls to ``CachedGitilesRepository``
+ instances. All instances produced by this function are novel
+ (i.e., newly allocated), but they all share the same underlying
+ ``http_client``.
+ """
+ return lambda repo_url: cls(http_client, repo_url)

Powered by Google App Engine
This is Rietveld 408576698