[email protected] | 4c59809d | 2011-09-16 00:46:40 | [diff] [blame] | 1 | // Copyright (c) 2011 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 CHROME_RENDERER_EXTENSIONS_STATIC_V8_EXTERNAL_STRING_RESOURCE_H_ |
| 6 | #define CHROME_RENDERER_EXTENSIONS_STATIC_V8_EXTERNAL_STRING_RESOURCE_H_ |
[email protected] | 4c59809d | 2011-09-16 00:46:40 | [diff] [blame] | 7 | |
| 8 | #include "base/compiler_specific.h" |
[email protected] | 4570a25 | 2013-03-31 00:35:43 | [diff] [blame] | 9 | #include "base/strings/string_piece.h" |
[email protected] | 4c59809d | 2011-09-16 00:46:40 | [diff] [blame] | 10 | #include "v8/include/v8.h" |
| 11 | |
[email protected] | 4c59809d | 2011-09-16 00:46:40 | [diff] [blame] | 12 | // A very simple implementation of v8::ExternalAsciiStringResource that just |
| 13 | // wraps a buffer. The buffer must outlive the v8 runtime instance this resource |
| 14 | // is used in. |
| 15 | class StaticV8ExternalAsciiStringResource |
| 16 | : public v8::String::ExternalAsciiStringResource { |
| 17 | public: |
| 18 | explicit StaticV8ExternalAsciiStringResource(const base::StringPiece& buffer); |
[email protected] | 24e6ebe | 2011-12-21 13:29:06 | [diff] [blame] | 19 | virtual ~StaticV8ExternalAsciiStringResource(); |
[email protected] | 4c59809d | 2011-09-16 00:46:40 | [diff] [blame] | 20 | |
| 21 | virtual const char* data() const OVERRIDE; |
| 22 | virtual size_t length() const OVERRIDE; |
| 23 | |
| 24 | private: |
| 25 | base::StringPiece buffer_; |
| 26 | }; |
| 27 | |
| 28 | #endif // CHROME_RENDERER_EXTENSIONS_STATIC_V8_EXTERNAL_STRING_RESOURCE_H_ |