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

Unified Diff: chrome/browser/extensions/api/myapi/myapi_api.h

Issue 17679004: testing adding an extension api Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 6 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
« no previous file with comments | « chrome/browser/extensions/api/myapi/myapi.cc ('k') | chrome/browser/extensions/api/myapi/myapi_api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/myapi/myapi_api.h
diff --git a/chrome/browser/extensions/api/myapi/myapi_api.h b/chrome/browser/extensions/api/myapi/myapi_api.h
new file mode 100644
index 0000000000000000000000000000000000000000..903d2acba70f27c52017a9c19c4be0437f06b619
--- /dev/null
+++ b/chrome/browser/extensions/api/myapi/myapi_api.h
@@ -0,0 +1,58 @@
+#include "chrome/common/extensions/api/myapi.h"
+#include "base/compiler_specific.h"
+#include "base/memory/ref_counted.h"
+#include "chrome/browser/extensions/event_router.h"
+#include "chrome/browser/extensions/extension_function.h"
+#include <stdlib.h> /* strtol */
+#include "base/strings/string_number_conversions.h"
+#include "base/memory/singleton.h"
+#include "base/values.h"
+#include <string>
+#include "base/bind.h"
+#include "base/files/file_path.h"
+#include "base/format_macros.h"
+#include "base/logging.h"
+#include "base/memory/scoped_vector.h"
+#include "base/posix/eintr_wrapper.h"
+#include "base/strings/string_number_conversions.h"
+#include "base/strings/stringprintf.h"
+#include "base/threading/sequenced_worker_pool.h"
+#include "base/time.h"
+#include "base/values.h"
+// You must follow a naming convention which is ApiNameFunctionNameFunction,
+// in this case MyapiDoBazFunction. This is so that the generated code
+// can find your implementation.
+
+namespace extensions {
+
+class MyapiDoBazFunction : public AsyncExtensionFunction {
+ public:
+ virtual ~MyapiDoBazFunction () {}
+
+ private:
+ // The MYAPI_DOBAZ entry is an enum you add right before ENUM_BOUNDARY
+ // in chrome/browser/extensions/extension_function_histogram_value.h
+ DECLARE_EXTENSION_FUNCTION("myapi.doBaz", MYAPI_DOBAZ);
+
+ virtual bool RunImpl() OVERRIDE {
+ // Args are passed in via the args_ member as a base::ListValue.
+ // Use the convenience member of the glue class to easily parse it.
+ scoped_ptr<api::myapi::DoBaz::Params> params(
+ api::myapi::DoBaz::Params::Create(*args_));
+ EXTENSION_FUNCTION_VALIDATE(params.get());
+
+ api::myapi::BazResult result;
+ result.x = params->options.id;
+ base::StringToInt(params->options.s, &result.y);
+
+ // Use the convenience member of the glue class to easily serialize
+ // to base::Value. ExtensionFunction owns the resulting base::Value.
+ SetResult(api::myapi::DoBaz::Results::Create(result));
+ // Not needed if you're a SyncExtensionFunction
+ // since it's set on the return value of RunImpl().
+ SendResponse(true /* success */);
+ return true;
+ }
+};
+
+}
« no previous file with comments | « chrome/browser/extensions/api/myapi/myapi.cc ('k') | chrome/browser/extensions/api/myapi/myapi_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698