| 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;
|
| + }
|
| +};
|
| +
|
| +}
|
|
|