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

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

Issue 12737007: Merge 188631 "Don't throw exceptions when v8 objects/contexts ar..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1443/src/
Patch Set: Created 7 years, 9 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 "chrome/renderer/extensions/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/console.h"
9 #include "chrome/renderer/extensions/module_system.h" 10 #include "chrome/renderer/extensions/module_system.h"
10 #include "v8/include/v8.h" 11 #include "v8/include/v8.h"
11 12
12 namespace extensions { 13 namespace extensions {
13 14
14 namespace { 15 namespace {
15 // Key for the base::Bound routed function. 16 // Key for the base::Bound routed function.
16 const char* kHandlerFunction = "handler_function"; 17 const char* kHandlerFunction = "handler_function";
17 } // namespace 18 } // namespace
18 19
(...skipping 15 matching lines...) Expand all
34 v8::Handle<v8::Value> ObjectBackedNativeHandler::Router( 35 v8::Handle<v8::Value> ObjectBackedNativeHandler::Router(
35 const v8::Arguments& args) { 36 const v8::Arguments& args) {
36 v8::HandleScope handle_scope; 37 v8::HandleScope handle_scope;
37 v8::Handle<v8::Object> data = args.Data().As<v8::Object>(); 38 v8::Handle<v8::Object> data = args.Data().As<v8::Object>();
38 39
39 v8::Handle<v8::Value> handler_function_value = 40 v8::Handle<v8::Value> handler_function_value =
40 data->Get(v8::String::New(kHandlerFunction)); 41 data->Get(v8::String::New(kHandlerFunction));
41 // See comment in header file for why we do this. 42 // See comment in header file for why we do this.
42 if (handler_function_value.IsEmpty() || 43 if (handler_function_value.IsEmpty() ||
43 handler_function_value->IsUndefined()) { 44 handler_function_value->IsUndefined()) {
44 return v8::ThrowException(v8::String::New( 45 console::Error(v8::Context::GetCalling(),
45 "Extension view no longer exists")); 46 "Extension view no longer exists");
47 return v8::Undefined();
46 } 48 }
47 DCHECK(handler_function_value->IsExternal()); 49 DCHECK(handler_function_value->IsExternal());
48 return handle_scope.Close(static_cast<HandlerFunction*>( 50 return handle_scope.Close(static_cast<HandlerFunction*>(
49 handler_function_value.As<v8::External>()->Value())->Run(args)); 51 handler_function_value.As<v8::External>()->Value())->Run(args));
50 } 52 }
51 53
52 void ObjectBackedNativeHandler::RouteFunction( 54 void ObjectBackedNativeHandler::RouteFunction(
53 const std::string& name, 55 const std::string& name,
54 const HandlerFunction& handler_function) { 56 const HandlerFunction& handler_function) {
55 v8::HandleScope handle_scope; 57 v8::HandleScope handle_scope;
(...skipping 25 matching lines...) Expand all
81 handler_function_value.As<v8::External>()->Value()); 83 handler_function_value.As<v8::External>()->Value());
82 data->Delete(v8::String::New(kHandlerFunction)); 84 data->Delete(v8::String::New(kHandlerFunction));
83 data.Dispose(v8_context_->GetIsolate()); 85 data.Dispose(v8_context_->GetIsolate());
84 } 86 }
85 object_template_.reset(); 87 object_template_.reset();
86 v8_context_.reset(); 88 v8_context_.reset();
87 NativeHandler::Invalidate(); 89 NativeHandler::Invalidate();
88 } 90 }
89 91
90 } // extensions 92 } // extensions
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/module_system.cc ('k') | chrome/test/data/extensions/api_test/crazy_extension/background.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698