Index: chrome/common/extensions/docs/server2/template_data_source.py |
diff --git a/chrome/common/extensions/docs/server2/template_data_source.py b/chrome/common/extensions/docs/server2/template_data_source.py |
index 306034b2f25bdfb980f3fc08662f6c26629c488a..7f6bd8061c903d697011d5965412e0c30e06ce24 100644 |
--- a/chrome/common/extensions/docs/server2/template_data_source.py |
+++ b/chrome/common/extensions/docs/server2/template_data_source.py |
@@ -3,9 +3,11 @@ |
# found in the LICENSE file. |
import logging |
+import time |
from docs_server_utils import FormatKey |
from file_system import FileNotFoundError |
+from request_scoped_fs_cache import RequestScopedFsCache |
from third_party.handlebar import Handlebar |
EXTENSIONS_URL = '/chrome/extensions' |
@@ -41,16 +43,16 @@ class TemplateDataSource(object): |
def __init__(self, |
channel_name, |
api_data_source_factory, |
- api_list_data_source, |
- intro_data_source, |
+ api_list_data_source_factory, |
+ intro_data_source_factory, |
samples_data_source_factory, |
cache_builder, |
public_template_path, |
private_template_path): |
self._branch_info = _MakeChannelDict(channel_name) |
self._api_data_source_factory = api_data_source_factory |
- self._api_list_data_source = api_list_data_source |
- self._intro_data_source = intro_data_source |
+ self._api_list_data_source_factory = api_list_data_source_factory |
+ self._intro_data_source_factory = intro_data_source_factory |
self._samples_data_source_factory = samples_data_source_factory |
self._cache = cache_builder.build(Handlebar) |
self._public_template_path = public_template_path |
@@ -64,10 +66,10 @@ class TemplateDataSource(object): |
return TemplateDataSource( |
self._branch_info, |
self._api_data_source_factory.Create(request), |
- self._api_list_data_source, |
- self._intro_data_source, |
+ self._api_list_data_source_factory.Create(), |
+ self._intro_data_source_factory.Create(), |
self._samples_data_source_factory.Create(request), |
- self._cache, |
+ self._cache.ScopeToRequest(), |
self._public_template_path, |
self._private_template_path, |
self._static_resources, |
@@ -96,6 +98,13 @@ class TemplateDataSource(object): |
self._request = request |
def Render(self, template_name): |
+ start_time = time.time() |
+ try: |
+ return self._DoRender(template_name) |
+ finally: |
+ logging.info("RENDER: %sms", (time.time() - start_time) * 1000) |
+ |
+ def _DoRender(self, template_name): |
"""This method will render a template named |template_name|, fetching all |
the partial templates needed from |self._cache|. Partials are retrieved |
from the TemplateDataSource with the |get| method. |
@@ -122,6 +131,13 @@ class TemplateDataSource(object): |
return self.get(key) |
def get(self, key): |
+ start_time = time.time() |
+ try: |
+ return self._do_get(key) |
+ finally: |
+ logging.info("TemplateDataSource: %sms", (time.time() - start_time) * 1000) |
+ |
+ def _do_get(self, key): |
return self.GetTemplate(self._private_template_path, key) |
def GetTemplate(self, base_path, template_name): |