0
Files
src/gin/array_buffer.h
Bill Budge 2ca35149f4 Reland "[wtf] Eliminate ArrayBufferContents page memory methods."
This is a reland of fe99f02317.

Original change's description:
> [wtf] Eliminate ArrayBufferContents page memory methods.
>
> - Removes ReserveMemory method.
> - Removes ReleaseReservedMemory, this is now just base::FreePages.
> - Removes SetProtection, this is now base::SetPermissions.
> - Removes dependency on sandbox/linux. base::AllocPages / FreePages
>   now updates address space limits.
>
> Bug: chromium:799573
> Change-Id: Iabc57c61511dfdc7b7ca2aa93c56ed21a22692f4
> Reviewed-on: https://chromium-review.googlesource.com/923173
> Reviewed-by: Jeremy Roman <jbroman@chromium.org>
> Reviewed-by: Kenneth Russell <kbr@chromium.org>
> Reviewed-by: Kentaro Hara <haraken@chromium.org>
> Commit-Queue: Bill Budge <bbudge@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#537868}

TBR=kbr@chromium.org

Bug: chromium:799573
Change-Id: I62ec635b0f685cc4d33d71fb97fc21ebd3ac0da6
Reviewed-on: https://chromium-review.googlesource.com/928801
Commit-Queue: Bill Budge <bbudge@chromium.org>
Reviewed-by: Bill Budge <bbudge@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Jeremy Roman <jbroman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#538246}
2018-02-21 23:22:22 +00:00

84 lines
2.0 KiB
C++

// Copyright 2013 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 GIN_ARRAY_BUFFER_H_
#define GIN_ARRAY_BUFFER_H_
#include <stddef.h>
#include <stdint.h>
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "gin/converter.h"
#include "gin/gin_export.h"
#include "v8/include/v8.h"
namespace gin {
class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
public:
void* Allocate(size_t length) override;
void* AllocateUninitialized(size_t length) override;
void Free(void* data, size_t length) override;
GIN_EXPORT static ArrayBufferAllocator* SharedInstance();
};
class GIN_EXPORT ArrayBuffer {
public:
ArrayBuffer();
ArrayBuffer(v8::Isolate* isolate, v8::Local<v8::ArrayBuffer> buffer);
~ArrayBuffer();
ArrayBuffer& operator=(const ArrayBuffer& other);
void* bytes() const { return bytes_; }
size_t num_bytes() const { return num_bytes_; }
private:
class Private;
scoped_refptr<Private> private_;
void* bytes_;
size_t num_bytes_;
DISALLOW_COPY(ArrayBuffer);
};
template<>
struct GIN_EXPORT Converter<ArrayBuffer> {
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
ArrayBuffer* out);
};
class GIN_EXPORT ArrayBufferView {
public:
ArrayBufferView();
ArrayBufferView(v8::Isolate* isolate, v8::Local<v8::ArrayBufferView> view);
~ArrayBufferView();
ArrayBufferView& operator=(const ArrayBufferView& other);
void* bytes() const {
return static_cast<uint8_t*>(array_buffer_.bytes()) + offset_;
}
size_t num_bytes() const { return num_bytes_; }
private:
ArrayBuffer array_buffer_;
size_t offset_;
size_t num_bytes_;
DISALLOW_COPY(ArrayBufferView);
};
template<>
struct GIN_EXPORT Converter<ArrayBufferView> {
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
ArrayBufferView* out);
};
} // namespace gin
#endif // GIN_ARRAY_BUFFER_H_