Skip to content

Instantly share code, notes, and snippets.

Created May 29, 2013 01:15
Show Gist options
  • Save anonymous/5667331 to your computer and use it in GitHub Desktop.
Save anonymous/5667331 to your computer and use it in GitHub Desktop.
namespace {
const char kAlarms[] = "<schema here>";
const char kAppRuntime[] = "...";
const char kAppWindow[] = "...";
...
}
namespace extensions {
namespace api {
struct Static {
Static() {
schemas["alarms"] = kAlarms;
schemas["app.currentWindowInternal"] = kAppCurrentWindowInternal;
schemas["app.runtime"] = kAppRuntime;
...
}
std::map<std::string, const char*> schemas;
};
base::LazyInstance<Static> g_lazy_instance;
// static
base::StringPiece GeneratedSchemas::Get(const std::string& name) {
return IsGenerated(name) ? g_lazy_instance.Get().schemas[name] : "";
}
// static
bool GeneratedSchemas::IsGenerated(std::string name) {
return g_lazy_instance.Get().schemas.count(name) > 0;
}
} // namespace api
} // namespace extensions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment