id_generator_custom_bindings.h 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. // Copyright 2014 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef EXTENSIONS_RENDERER_ID_GENERATOR_CUSTOM_BINDINGS_H_
  5. #define EXTENSIONS_RENDERER_ID_GENERATOR_CUSTOM_BINDINGS_H_
  6. #include "extensions/renderer/object_backed_native_handler.h"
  7. #include "v8/include/v8-forward.h"
  8. namespace extensions {
  9. class ScriptContext;
  10. // Implements function that can be used by JS layer to generate unique integer
  11. // identifiers.
  12. class IdGeneratorCustomBindings : public ObjectBackedNativeHandler {
  13. public:
  14. IdGeneratorCustomBindings(ScriptContext* context);
  15. // ObjectBackedNativeHandler:
  16. void AddRoutes() override;
  17. private:
  18. // Generate a unique ID global to the renderer.
  19. void GetNextId(const v8::FunctionCallbackInfo<v8::Value>& args);
  20. // Generate a unique ID scoped to the ScriptContext.
  21. void GetNextScopedId(const v8::FunctionCallbackInfo<v8::Value>& args);
  22. };
  23. } // namespace extensions
  24. #endif // EXTENSIONS_RENDERER_ID_GENERATOR_CUSTOM_BINDINGS_H_