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

Unified Diff: sky/engine/bindings2/exception_state.h

Issue 918333002: Add the c++ code part of bindings2/ (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Updated per earlier reviews Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/engine/bindings2/exception_messages.cc ('k') | sky/engine/bindings2/exception_state.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/engine/bindings2/exception_state.h
diff --git a/sky/engine/bindings2/exception_state.h b/sky/engine/bindings2/exception_state.h
new file mode 100644
index 0000000000000000000000000000000000000000..e73b88a6fe501d6aa8c8591fb2b8da6e9bef1f75
--- /dev/null
+++ b/sky/engine/bindings2/exception_state.h
@@ -0,0 +1,68 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SKY_ENGINE_BINDINGS2_EXCEPTION_STATE_H_
+#define SKY_ENGINE_BINDINGS2_EXCEPTION_STATE_H_
+
+#include "sky/engine/tonic/dart_persistent_value.h"
+#include "sky/engine/wtf/Noncopyable.h"
+#include "sky/engine/wtf/text/WTFString.h"
+
+namespace blink {
+
+typedef int ExceptionCode;
+
+class ExceptionState {
+ WTF_MAKE_NONCOPYABLE(ExceptionState);
+
+ public:
+ enum Context {
+ ConstructionContext,
+ ExecutionContext,
+ DeletionContext,
+ GetterContext,
+ SetterContext,
+ EnumerationContext,
+ QueryContext,
+ IndexedGetterContext,
+ IndexedSetterContext,
+ IndexedDeletionContext,
+ UnknownContext, // FIXME: Remove this once we've flipped over to the new
+ // API.
+ };
+
+ ExceptionState();
+ ExceptionState(Context context, const char* interfaceName);
+ ExceptionState(Context context,
+ const char* propertyName,
+ const char* interfaceName);
+ ~ExceptionState();
+
+ void ThrowDOMException(const ExceptionCode& code, const String& message);
+ void ThrowTypeError(const String& message);
+ void ThrowRangeError(const String& message);
+
+ bool ThrowIfNeeded();
+ void ClearException();
+
+ ExceptionCode code() const { return code_; }
+ const String& message() const { return message_; }
+ bool had_exception() const { return had_exception_ || code_; }
+
+ Dart_Handle GetDartException(Dart_NativeArguments args, bool auto_scope);
+
+ private:
+ ExceptionCode code_;
+ String message_;
+ bool had_exception_;
+ DartPersistentValue exception_;
+};
+
+class NonThrowableExceptionState final : public ExceptionState {};
+
+class TrackExceptionState final : public ExceptionState {};
+
+} // namespace blink
+
+#endif // SKY_ENGINE_BINDINGS2_EXCEPTION_STATE_H_
« no previous file with comments | « sky/engine/bindings2/exception_messages.cc ('k') | sky/engine/bindings2/exception_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698