Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Side by Side Diff: chrome/renderer/extensions/object_backed_native_handler.cc

Issue 127923002: Provide an Isolate for v8::ObjectTemplate::New. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | content/renderer/pepper/v8_var_converter_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // TODO(dcarney): Remove this when UnsafePersistent is removed. 5 // TODO(dcarney): Remove this when UnsafePersistent is removed.
6 #define V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR 6 #define V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR
7 7
8 #include "chrome/renderer/extensions/object_backed_native_handler.h" 8 #include "chrome/renderer/extensions/object_backed_native_handler.h"
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/linked_ptr.h" 11 #include "base/memory/linked_ptr.h"
12 #include "chrome/renderer/extensions/chrome_v8_context.h" 12 #include "chrome/renderer/extensions/chrome_v8_context.h"
13 #include "chrome/renderer/extensions/console.h" 13 #include "chrome/renderer/extensions/console.h"
14 #include "chrome/renderer/extensions/module_system.h" 14 #include "chrome/renderer/extensions/module_system.h"
15 #include "v8/include/v8.h" 15 #include "v8/include/v8.h"
16 16
17 namespace extensions { 17 namespace extensions {
18 18
19 namespace { 19 namespace {
20 // Key for the base::Bound routed function. 20 // Key for the base::Bound routed function.
21 const char* kHandlerFunction = "handler_function"; 21 const char* kHandlerFunction = "handler_function";
22 } // namespace 22 } // namespace
23 23
24 ObjectBackedNativeHandler::ObjectBackedNativeHandler( 24 ObjectBackedNativeHandler::ObjectBackedNativeHandler(
25 ChromeV8Context* context) 25 ChromeV8Context* context)
26 : context_(context), 26 : context_(context),
27 object_template_(v8::ObjectTemplate::New()) { 27 object_template_(v8::ObjectTemplate::New(
28 context->v8_context()->GetIsolate())) {
28 } 29 }
29 30
30 ObjectBackedNativeHandler::~ObjectBackedNativeHandler() { 31 ObjectBackedNativeHandler::~ObjectBackedNativeHandler() {
31 Invalidate(); 32 Invalidate();
32 } 33 }
33 34
34 v8::Handle<v8::Object> ObjectBackedNativeHandler::NewInstance() { 35 v8::Handle<v8::Object> ObjectBackedNativeHandler::NewInstance() {
35 return object_template_.NewHandle(v8::Isolate::GetCurrent())->NewInstance(); 36 return object_template_.NewHandle(v8::Isolate::GetCurrent())->NewInstance();
36 } 37 }
37 38
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 handler_function_value.As<v8::External>()->Value()); 92 handler_function_value.As<v8::External>()->Value());
92 data->Delete(v8::String::NewFromUtf8(isolate, kHandlerFunction)); 93 data->Delete(v8::String::NewFromUtf8(isolate, kHandlerFunction));
93 it->dispose(); 94 it->dispose();
94 } 95 }
95 object_template_.reset(); 96 object_template_.reset();
96 context_ = NULL; 97 context_ = NULL;
97 NativeHandler::Invalidate(); 98 NativeHandler::Invalidate();
98 } 99 }
99 100
100 } // namespace extensions 101 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | content/renderer/pepper/v8_var_converter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698