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

Unified Diff: extensions/renderer/api_signature.h

Issue 2947463002: [Extensions Bindings] Add a bindings/ subdirectory under renderer (Closed)
Patch Set: . Created 3 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 | « extensions/renderer/api_request_handler_unittest.cc ('k') | extensions/renderer/api_signature.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/api_signature.h
diff --git a/extensions/renderer/api_signature.h b/extensions/renderer/api_signature.h
deleted file mode 100644
index a8f3fa873a2df6b9658771b20483b0bd11cd4441..0000000000000000000000000000000000000000
--- a/extensions/renderer/api_signature.h
+++ /dev/null
@@ -1,80 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef EXTENSIONS_RENDERER_API_SIGNATURE_H_
-#define EXTENSIONS_RENDERER_API_SIGNATURE_H_
-
-#include <memory>
-#include <string>
-#include <vector>
-
-#include "base/macros.h"
-#include "v8/include/v8.h"
-
-namespace base {
-class Value;
-class ListValue;
-}
-
-namespace extensions {
-class APITypeReferenceMap;
-class ArgumentSpec;
-
-// A representation of the expected signature for an API method, along with the
-// ability to match provided arguments and convert them to base::Values.
-class APISignature {
- public:
- explicit APISignature(const base::ListValue& specification);
- explicit APISignature(std::vector<std::unique_ptr<ArgumentSpec>> signature);
- ~APISignature();
-
- // Parses |arguments| against this signature, and populates |args_out| with
- // the v8 values (performing no conversion). The resulting vector may differ
- // from the list of arguments passed in because it will include null-filled
- // optional arguments.
- // Returns true if the arguments were successfully parsed and converted.
- bool ParseArgumentsToV8(v8::Local<v8::Context> context,
- const std::vector<v8::Local<v8::Value>>& arguments,
- const APITypeReferenceMap& type_refs,
- std::vector<v8::Local<v8::Value>>* args_out,
- std::string* error) const;
-
- // Parses |arguments| against this signature, converting to a base::ListValue.
- // Returns true if the arguments were successfully parsed and converted, and
- // populates |args_out| and |callback_out| with the JSON arguments and
- // callback values, respectively. On failure, returns false populates |error|.
- bool ParseArgumentsToJSON(v8::Local<v8::Context> context,
- const std::vector<v8::Local<v8::Value>>& arguments,
- const APITypeReferenceMap& type_refs,
- std::unique_ptr<base::ListValue>* args_out,
- v8::Local<v8::Function>* callback_out,
- std::string* error) const;
-
- // Converts |arguments| to a base::ListValue, ignoring the defined signature.
- // This is used when custom bindings modify the passed arguments to a form
- // that doesn't match the documented signature.
- bool ConvertArgumentsIgnoringSchema(
- v8::Local<v8::Context> context,
- const std::vector<v8::Local<v8::Value>>& arguments,
- std::unique_ptr<base::ListValue>* json_out,
- v8::Local<v8::Function>* callback_out) const;
-
- // Returns a developer-readable string of the expected signature. For
- // instance, if this signature expects a string 'someStr' and an optional int
- // 'someInt', this would return "string someStr, optional integer someInt".
- std::string GetExpectedSignature() const;
-
- private:
- // The list of expected arguments.
- std::vector<std::unique_ptr<ArgumentSpec>> signature_;
-
- // A developer-readable signature string, lazily set.
- mutable std::string expected_signature_;
-
- DISALLOW_COPY_AND_ASSIGN(APISignature);
-};
-
-} // namespace extensions
-
-#endif // EXTENSIONS_RENDERER_API_SIGNATURE_H_
« no previous file with comments | « extensions/renderer/api_request_handler_unittest.cc ('k') | extensions/renderer/api_signature.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698