Upstream version 11.40.271.0
[platform/framework/web/crosswalk.git] / src / extensions / renderer / static_v8_external_one_byte_string_resource.h
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
5 #ifndef EXTENSIONS_RENDERER_STATIC_V8_EXTERNAL_ONE_BYTE_STRING_RESOURCE_H_
6 #define EXTENSIONS_RENDERER_STATIC_V8_EXTERNAL_ONE_BYTE_STRING_RESOURCE_H_
7
8 #include "base/compiler_specific.h"
9 #include "base/strings/string_piece.h"
10 #include "v8/include/v8.h"
11
12 namespace extensions {
13
14 // A very simple implementation of v8::ExternalAsciiStringResource that just
15 // wraps a buffer. The buffer must outlive the v8 runtime instance this resource
16 // is used in.
17 class StaticV8ExternalOneByteStringResource
18     : public v8::String::ExternalOneByteStringResource {
19  public:
20   explicit StaticV8ExternalOneByteStringResource(
21       const base::StringPiece& buffer);
22   ~StaticV8ExternalOneByteStringResource() override;
23
24   const char* data() const override;
25   size_t length() const override;
26
27  private:
28   base::StringPiece buffer_;
29 };
30
31 }  // namespace extensions
32
33 #endif  // EXTENSIONS_RENDERER_STATIC_V8_EXTERNAL_ONE_BYTE_STRING_RESOURCE_H_