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

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

Issue 74783006: Remove deprecated v8::External::New calls (chromium side) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 | chrome/renderer/extensions/module_system.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/console.h" 5 #include "chrome/renderer/extensions/console.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/debug/alias.h" 8 #include "base/debug/alias.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 info.Data().As<v8::External>()->Value()); 70 info.Data().As<v8::External>()->Value());
71 std::string message; 71 std::string message;
72 for (int i = 0; i < info.Length(); ++i) { 72 for (int i = 0; i < info.Length(); ++i) {
73 if (i > 0) 73 if (i > 0)
74 message += " "; 74 message += " ";
75 message += *v8::String::AsciiValue(info[i]); 75 message += *v8::String::AsciiValue(info[i]);
76 } 76 }
77 (*log_method)(v8::Context::GetCalling(), message); 77 (*log_method)(v8::Context::GetCalling(), message);
78 } 78 }
79 79
80 void BindLogMethod(v8::Local<v8::Object> target, 80 void BindLogMethod(v8::Isolate* isolate,
81 v8::Local<v8::Object> target,
81 const std::string& name, 82 const std::string& name,
82 LogMethod log_method) { 83 LogMethod log_method) {
83 v8::Local<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New( 84 v8::Local<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New(
84 &BoundLogMethodCallback, 85 &BoundLogMethodCallback,
85 v8::External::New(reinterpret_cast<void*>(log_method))); 86 v8::External::New(isolate, reinterpret_cast<void*>(log_method)));
86 target->Set(v8::String::New(name.c_str()), tmpl->GetFunction()); 87 target->Set(v8::String::New(name.c_str()), tmpl->GetFunction());
87 } 88 }
88 89
89 } // namespace 90 } // namespace
90 91
91 void Debug(content::RenderView* render_view, const std::string& message) { 92 void Debug(content::RenderView* render_view, const std::string& message) {
92 AddMessage(render_view, content::CONSOLE_MESSAGE_LEVEL_DEBUG, message); 93 AddMessage(render_view, content::CONSOLE_MESSAGE_LEVEL_DEBUG, message);
93 } 94 }
94 95
95 void Log(content::RenderView* render_view, const std::string& message) { 96 void Log(content::RenderView* render_view, const std::string& message) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 } 166 }
166 content::RenderView* render_view = ByContextFinder::Find(context); 167 content::RenderView* render_view = ByContextFinder::Find(context);
167 if (!render_view) { 168 if (!render_view) {
168 LOG(WARNING) << "Could not log \"" << message << "\": no render view found"; 169 LOG(WARNING) << "Could not log \"" << message << "\": no render view found";
169 return; 170 return;
170 } 171 }
171 AddMessage(render_view, level, message); 172 AddMessage(render_view, level, message);
172 } 173 }
173 174
174 v8::Local<v8::Object> AsV8Object() { 175 v8::Local<v8::Object> AsV8Object() {
175 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); 176 v8::Isolate* isolate = v8::Isolate::GetCurrent();
177 v8::HandleScope handle_scope(isolate);
176 v8::Local<v8::Object> console_object = v8::Object::New(); 178 v8::Local<v8::Object> console_object = v8::Object::New();
177 BindLogMethod(console_object, "debug", &Debug); 179 BindLogMethod(isolate, console_object, "debug", &Debug);
178 BindLogMethod(console_object, "log", &Log); 180 BindLogMethod(isolate, console_object, "log", &Log);
179 BindLogMethod(console_object, "warn", &Warn); 181 BindLogMethod(isolate, console_object, "warn", &Warn);
180 BindLogMethod(console_object, "error", &Error); 182 BindLogMethod(isolate, console_object, "error", &Error);
181 return handle_scope.Close(console_object); 183 return handle_scope.Close(console_object);
182 } 184 }
183 185
184 } // namespace console 186 } // namespace console
185 } // namespace extensions 187 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/renderer/extensions/module_system.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698