summaryrefslogtreecommitdiffstats
path: root/extensions/renderer/native_handler.h
diff options
context:
space:
mode:
authorrockot@chromium.org <rockot@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-04 22:45:15 +0000
committerrockot@chromium.org <rockot@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-04 22:45:15 +0000
commitb8ce52f740745c9f7cb26b0f01372a58801ddac7 (patch)
tree7c12b11b68b2fa1a7a9460954665a10099ee2a2a /extensions/renderer/native_handler.h
parente55d7249edde4cf2bfaf9b1a391947741f10f78a (diff)
downloadchromium_src-b8ce52f740745c9f7cb26b0f01372a58801ddac7.zip
chromium_src-b8ce52f740745c9f7cb26b0f01372a58801ddac7.tar.gz
chromium_src-b8ce52f740745c9f7cb26b0f01372a58801ddac7.tar.bz2
Create an extensions_renderer target
This moves a small group of source files from //chrome/renderer/extensions to //extensions/renderer and establishes a new extensions_renderer target based on sources there. BUG=359154 TBR=jochen@chromium.org for v8 DEPS copy to //extensions TBR=sky@chromium.org for chrome/test mechanical change Review URL: https://codereview.chromium.org/223393002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@261908 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'extensions/renderer/native_handler.h')
-rw-r--r--extensions/renderer/native_handler.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/extensions/renderer/native_handler.h b/extensions/renderer/native_handler.h
new file mode 100644
index 0000000..c0660c8
--- /dev/null
+++ b/extensions/renderer/native_handler.h
@@ -0,0 +1,46 @@
+// Copyright 2014 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 EXTENSIONS_RENDERER_NATIVE_HANDLER_H_
+#define EXTENSIONS_RENDERER_NATIVE_HANDLER_H_
+
+#include "base/basictypes.h"
+#include "v8/include/v8.h"
+
+namespace extensions {
+
+// NativeHandlers are intended to be used with a ModuleSystem. The ModuleSystem
+// will assume ownership of the NativeHandler, and as a ModuleSystem is tied to
+// a single v8::Context, this implies that NativeHandlers will also be tied to
+// a single v8::Context.
+// TODO(koz): Rename this to NativeJavaScriptModule.
+class NativeHandler {
+ public:
+ NativeHandler();
+ virtual ~NativeHandler();
+
+ // Create a new instance of the object this handler specifies.
+ virtual v8::Handle<v8::Object> NewInstance() = 0;
+
+ // Invalidate this object so it cannot be used any more. This is needed
+ // because it's possible for this to outlive its owner context. Invalidate
+ // must be called before this happens.
+ //
+ // Subclasses should override to invalidate their own V8 state. If they do
+ // they must call their superclass' Invalidate().
+ virtual void Invalidate();
+
+ protected:
+ // Allow subclasses to query valid state.
+ bool is_valid() { return is_valid_; }
+
+ private:
+ bool is_valid_;
+
+ DISALLOW_COPY_AND_ASSIGN(NativeHandler);
+};
+
+} // namespace extensions
+
+#endif // EXTENSIONS_RENDERER_NATIVE_HANDLER_H_