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

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

Issue 234413005: Move most of ChromeV8Context to a base ScriptContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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
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 #include "chrome/renderer/extensions/object_backed_native_handler.h" 5 #include "extensions/renderer/object_backed_native_handler.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/linked_ptr.h" 8 #include "base/memory/linked_ptr.h"
9 #include "chrome/renderer/extensions/chrome_v8_context.h" 9 #include "extensions/renderer/console.h"
10 #include "chrome/renderer/extensions/console.h" 10 #include "extensions/renderer/module_system.h"
11 #include "chrome/renderer/extensions/module_system.h" 11 #include "extensions/renderer/script_context.h"
12 #include "v8/include/v8.h" 12 #include "v8/include/v8.h"
13 13
14 namespace extensions { 14 namespace extensions {
15 15
16 namespace { 16 namespace {
17 // Key for the base::Bound routed function. 17 // Key for the base::Bound routed function.
18 const char* kHandlerFunction = "handler_function"; 18 const char* kHandlerFunction = "handler_function";
19 } // namespace 19 } // namespace
20 20
21 ObjectBackedNativeHandler::ObjectBackedNativeHandler(ChromeV8Context* context) 21 ObjectBackedNativeHandler::ObjectBackedNativeHandler(ScriptContext* context)
22 : router_data_(context->v8_context()->GetIsolate()), 22 : router_data_(context->v8_context()->GetIsolate()),
23 context_(context), 23 context_(context),
24 object_template_( 24 object_template_(
25 v8::ObjectTemplate::New(context->v8_context()->GetIsolate())) {} 25 v8::ObjectTemplate::New(context->v8_context()->GetIsolate())) {}
26 26
27 ObjectBackedNativeHandler::~ObjectBackedNativeHandler() { 27 ObjectBackedNativeHandler::~ObjectBackedNativeHandler() { Invalidate(); }
28 Invalidate();
29 }
30 28
31 v8::Handle<v8::Object> ObjectBackedNativeHandler::NewInstance() { 29 v8::Handle<v8::Object> ObjectBackedNativeHandler::NewInstance() {
32 return object_template_.NewHandle(v8::Isolate::GetCurrent())->NewInstance(); 30 return object_template_.NewHandle(v8::Isolate::GetCurrent())->NewInstance();
33 } 31 }
34 32
35 // static 33 // static
36 void ObjectBackedNativeHandler::Router( 34 void ObjectBackedNativeHandler::Router(
37 const v8::FunctionCallbackInfo<v8::Value>& args) { 35 const v8::FunctionCallbackInfo<v8::Value>& args) {
38 v8::HandleScope handle_scope(args.GetIsolate()); 36 v8::HandleScope handle_scope(args.GetIsolate());
39 v8::Handle<v8::Object> data = args.Data().As<v8::Object>(); 37 v8::Handle<v8::Object> data = args.Data().As<v8::Object>();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 delete static_cast<HandlerFunction*>( 88 delete static_cast<HandlerFunction*>(
91 handler_function_value.As<v8::External>()->Value()); 89 handler_function_value.As<v8::External>()->Value());
92 data->Delete(v8::String::NewFromUtf8(isolate, kHandlerFunction)); 90 data->Delete(v8::String::NewFromUtf8(isolate, kHandlerFunction));
93 } 91 }
94 router_data_.Clear(); 92 router_data_.Clear();
95 object_template_.reset(); 93 object_template_.reset();
96 context_ = NULL; 94 context_ = NULL;
97 NativeHandler::Invalidate(); 95 NativeHandler::Invalidate();
98 } 96 }
99 97
100 } // namespace extensions 98 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698