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

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

Issue 1167423002: Use V8 Maybe APIs in extensions/renderer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « extensions/renderer/i18n_custom_bindings.cc ('k') | extensions/renderer/messaging_bindings.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/renderer/logging_native_handler.h" 5 #include "extensions/renderer/logging_native_handler.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 9
10 namespace extensions { 10 namespace extensions {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 const v8::FunctionCallbackInfo<v8::Value>& args) { 60 const v8::FunctionCallbackInfo<v8::Value>& args) {
61 CHECK_EQ(1, args.Length()); 61 CHECK_EQ(1, args.Length());
62 LOG(WARNING) << *v8::String::Utf8Value(args[0]); 62 LOG(WARNING) << *v8::String::Utf8Value(args[0]);
63 } 63 }
64 64
65 void LoggingNativeHandler::ParseArgs( 65 void LoggingNativeHandler::ParseArgs(
66 const v8::FunctionCallbackInfo<v8::Value>& args, 66 const v8::FunctionCallbackInfo<v8::Value>& args,
67 bool* check_value, 67 bool* check_value,
68 std::string* error_message) { 68 std::string* error_message) {
69 CHECK_LE(args.Length(), 2); 69 CHECK_LE(args.Length(), 2);
70 *check_value = args[0]->BooleanValue(); 70 auto maybe = args[0]->BooleanValue(args.GetIsolate()->GetCurrentContext());
71 if (maybe.IsNothing()) {
72 *error_message = "Error: Cannot continue execution.";
73 return;
74 }
75 *check_value = maybe.FromJust();
71 if (args.Length() == 2) { 76 if (args.Length() == 2) {
72 *error_message = "Error: " + std::string(*v8::String::Utf8Value(args[1])); 77 *error_message = "Error: " + std::string(*v8::String::Utf8Value(args[1]));
73 } 78 }
74 79
75 v8::Local<v8::StackTrace> stack_trace = 80 v8::Local<v8::StackTrace> stack_trace =
76 v8::StackTrace::CurrentStackTrace(args.GetIsolate(), 10); 81 v8::StackTrace::CurrentStackTrace(args.GetIsolate(), 10);
77 if (stack_trace.IsEmpty() || stack_trace->GetFrameCount() <= 0) { 82 if (stack_trace.IsEmpty() || stack_trace->GetFrameCount() <= 0) {
78 *error_message += "\n <no stack trace>"; 83 *error_message += "\n <no stack trace>";
79 } else { 84 } else {
80 for (size_t i = 0; i < (size_t)stack_trace->GetFrameCount(); ++i) { 85 for (size_t i = 0; i < (size_t)stack_trace->GetFrameCount(); ++i) {
(...skipping 12 matching lines...) Expand all
93 std::string LoggingNativeHandler::ToStringOrDefault( 98 std::string LoggingNativeHandler::ToStringOrDefault(
94 const v8::Local<v8::String>& v8_string, 99 const v8::Local<v8::String>& v8_string,
95 const std::string& dflt) { 100 const std::string& dflt) {
96 if (v8_string.IsEmpty()) 101 if (v8_string.IsEmpty())
97 return dflt; 102 return dflt;
98 std::string ascii_value = *v8::String::Utf8Value(v8_string); 103 std::string ascii_value = *v8::String::Utf8Value(v8_string);
99 return ascii_value.empty() ? dflt : ascii_value; 104 return ascii_value.empty() ? dflt : ascii_value;
100 } 105 }
101 106
102 } // namespace extensions 107 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/i18n_custom_bindings.cc ('k') | extensions/renderer/messaging_bindings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698