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

Unified Diff: tools/json_schema_compiler/cpp_bundle_generator.py

Issue 12375006: Added UMA stats for extensions events on addListener. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
Index: tools/json_schema_compiler/cpp_bundle_generator.py
diff --git a/tools/json_schema_compiler/cpp_bundle_generator.py b/tools/json_schema_compiler/cpp_bundle_generator.py
index e98f0c3023cbc619506dd8b56f1901be6b562a2f..5b188d6f3cdc5febba6849655bdcb0888f9a7589 100644
--- a/tools/json_schema_compiler/cpp_bundle_generator.py
+++ b/tools/json_schema_compiler/cpp_bundle_generator.py
@@ -6,6 +6,7 @@ import code
import cpp_util
from model import Platforms
from schema_util import CapitalizeFirstLetter
+from schema_util import JsEventNameToHistogramValue
from schema_util import JsFunctionNameToClassName
import json
@@ -96,6 +97,26 @@ class CppBundleGenerator(object):
c.Append("#endif // %s" % function_ifdefs, indent_level=0)
return c
+ def _GenerateEventHistogramMapAddAll(self):
+ c = code.Code()
+ c.Append('// static')
+ c.Append('void GeneratedEventHistogramMap::AddAll(std::map<std::string,')
+ c.Sblock(' extensions::events::HistogramValue>& map) {')
+ for namespace in self._model.namespaces.values():
+ for event in namespace.events.values():
+ if event.nocompile:
+ continue
+ event_name = "%s.%s" % (namespace.name, event.name)
+ histogram_value = event.histogram_name
+ if not histogram_value:
+ histogram_value = JsEventNameToHistogramValue(namespace.name,
+ event.name)
+ c.Append('map.insert(std::make_pair("%s", extensions::events::%s));' %
+ (event_name, histogram_value))
+
+ c.Eblock("}")
+ return c
+
def _GenerateFunctionRegistryRegisterAll(self):
c = code.Code()
c.Append('// static')
@@ -135,9 +156,15 @@ class _APIHGenerator(object):
def Generate(self, namespace):
c = code.Code()
+ c.Append('#include <map>')
c.Append('#include <string>')
c.Append()
c.Append('#include "base/basictypes.h"')
+
+ c.Append('#include '
+ '"chrome/browser/extensions/extension_event_histogram_value.h"')
+ c.Append('#include '
+ '"chrome/browser/extensions/extension_function_registry.h"')
c.Append()
c.Append("class ExtensionFunctionRegistry;")
c.Append()
@@ -149,6 +176,12 @@ class _APIHGenerator(object):
'ExtensionFunctionRegistry* registry);')
c.Eblock('};');
c.Append()
+ c.Append('class GeneratedEventHistogramMap {')
+ c.Sblock(' public:')
+ c.Append('static void AddAll(std::map<std::string,')
+ c.Append(' extensions::events::HistogramValue>& map);')
+ c.Eblock('};');
+ c.Append()
c.Concat(cpp_util.CloseNamespace(self._bundle._cpp_namespace))
return self._bundle._GenerateHeader('generated_api', c)
@@ -195,6 +228,8 @@ class _APICCGenerator(object):
c.Append()
c.Concat(self._bundle._GenerateFunctionRegistryRegisterAll())
c.Append()
+ c.Concat(self._bundle._GenerateEventHistogramMapAddAll())
+ c.Append()
c.Concat(cpp_util.CloseNamespace(self._bundle._cpp_namespace))
c.Append()
return c

Powered by Google App Engine
This is Rietveld 408576698