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

Side by Side Diff: extensions/renderer/bindings/api_last_error.cc

Issue 2961103002: [Extensions Bindings] Add an ExceptionHandler class (Closed)
Patch Set: jbroman's Created 3 years, 5 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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/bindings/api_last_error.h" 5 #include "extensions/renderer/bindings/api_last_error.h"
6 6
7 #include "gin/converter.h" 7 #include "gin/converter.h"
8 #include "gin/data_object_builder.h" 8 #include "gin/data_object_builder.h"
9 #include "gin/handle.h" 9 #include "gin/handle.h"
10 #include "gin/object_template_builder.h" 10 #include "gin/object_template_builder.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 isolate, gin::StringToSymbol(isolate, kScriptSuppliedValueKey)); 106 isolate, gin::StringToSymbol(isolate, kScriptSuppliedValueKey));
107 v8::Maybe<bool> set_private = 107 v8::Maybe<bool> set_private =
108 holder->SetPrivate(context, script_value_key, value); 108 holder->SetPrivate(context, script_value_key, value);
109 if (!set_private.IsJust() || !set_private.FromJust()) 109 if (!set_private.IsJust() || !set_private.FromJust())
110 NOTREACHED(); 110 NOTREACHED();
111 } 111 }
112 112
113 } // namespace 113 } // namespace
114 114
115 APILastError::APILastError(const GetParent& get_parent, 115 APILastError::APILastError(const GetParent& get_parent,
116 const AddConsoleError& add_console_error) 116 const binding::AddConsoleError& add_console_error)
117 : get_parent_(get_parent), add_console_error_(add_console_error) {} 117 : get_parent_(get_parent), add_console_error_(add_console_error) {}
118 APILastError::APILastError(APILastError&& other) = default; 118 APILastError::APILastError(APILastError&& other) = default;
119 APILastError::~APILastError() = default; 119 APILastError::~APILastError() = default;
120 120
121 void APILastError::SetError(v8::Local<v8::Context> context, 121 void APILastError::SetError(v8::Local<v8::Context> context,
122 const std::string& error) { 122 const std::string& error) {
123 v8::Isolate* isolate = context->GetIsolate(); 123 v8::Isolate* isolate = context->GetIsolate();
124 DCHECK(isolate); 124 DCHECK(isolate);
125 v8::HandleScope handle_scope(isolate); 125 v8::HandleScope handle_scope(isolate);
126 126
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 v8::Isolate* isolate = context->GetIsolate(); 273 v8::Isolate* isolate = context->GetIsolate();
274 v8::Local<v8::String> key = gin::StringToSymbol(isolate, kLastErrorProperty); 274 v8::Local<v8::String> key = gin::StringToSymbol(isolate, kLastErrorProperty);
275 // This CreateDataProperty() can fail, but there's nothing to do if it does 275 // This CreateDataProperty() can fail, but there's nothing to do if it does
276 // (the exception will be caught by the TryCatch in SetError()). 276 // (the exception will be caught by the TryCatch in SetError()).
277 ignore_result(secondary_parent->CreateDataProperty( 277 ignore_result(secondary_parent->CreateDataProperty(
278 context, key, 278 context, key,
279 gin::DataObjectBuilder(isolate).Set("message", error).Build())); 279 gin::DataObjectBuilder(isolate).Set("message", error).Build()));
280 } 280 }
281 281
282 } // namespace extensions 282 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698