diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-16 00:46:40 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-16 00:46:40 +0000 |
commit | 4c59809d91bef5c7ce54748fc35189cc62657f66 (patch) | |
tree | 2a08039858b1f635b0dd7ac393d8c4be31c0e8a5 /chrome/renderer/static_v8_external_string_resource.h | |
parent | ff1e67ec7c11ea1d960d16c29f43914b8fce7ae8 (diff) | |
download | chromium_src-4c59809d91bef5c7ce54748fc35189cc62657f66.zip chromium_src-4c59809d91bef5c7ce54748fc35189cc62657f66.tar.gz chromium_src-4c59809d91bef5c7ce54748fc35189cc62657f66.tar.bz2 |
Use a v8 external string resource for the extension api json.
BUG=95147
Review URL: http://codereview.chromium.org/7904026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@101424 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/static_v8_external_string_resource.h')
-rw-r--r-- | chrome/renderer/static_v8_external_string_resource.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/chrome/renderer/static_v8_external_string_resource.h b/chrome/renderer/static_v8_external_string_resource.h new file mode 100644 index 0000000..7a72b79 --- /dev/null +++ b/chrome/renderer/static_v8_external_string_resource.h @@ -0,0 +1,32 @@ +// Copyright (c) 2011 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 CHROME_RENDERER_EXTENSIONS_STATIC_V8_EXTERNAL_STRING_RESOURCE_H_ +#define CHROME_RENDERER_EXTENSIONS_STATIC_V8_EXTERNAL_STRING_RESOURCE_H_ +#pragma once + +#include "base/compiler_specific.h" +#include "base/string_piece.h" +#include "v8/include/v8.h" + +namespace base { +class StringPiece; +} + +// A very simple implementation of v8::ExternalAsciiStringResource that just +// wraps a buffer. The buffer must outlive the v8 runtime instance this resource +// is used in. +class StaticV8ExternalAsciiStringResource + : public v8::String::ExternalAsciiStringResource { + public: + explicit StaticV8ExternalAsciiStringResource(const base::StringPiece& buffer); + + virtual const char* data() const OVERRIDE; + virtual size_t length() const OVERRIDE; + + private: + base::StringPiece buffer_; +}; + +#endif // CHROME_RENDERER_EXTENSIONS_STATIC_V8_EXTERNAL_STRING_RESOURCE_H_ |