Chromium Code Reviews| 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) |