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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef SKY_ENGINE_BINDINGS2_EXCEPTION_STATE_H_
6 #define SKY_ENGINE_BINDINGS2_EXCEPTION_STATE_H_
7
8 #include "sky/engine/tonic/dart_persistent_value.h"
9 #include "sky/engine/wtf/Noncopyable.h"
10 #include "sky/engine/wtf/text/WTFString.h"
11
12 namespace blink {
13
14 typedef int ExceptionCode;
15
16 class ExceptionState {
17 WTF_MAKE_NONCOPYABLE(ExceptionState);
18
19 public:
20 enum Context {
21 ConstructionContext,
22 ExecutionContext,
23 DeletionContext,
24 GetterContext,
25 SetterContext,
26 EnumerationContext,
27 QueryContext,
28 IndexedGetterContext,
29 IndexedSetterContext,
30 IndexedDeletionContext,
31 UnknownContext, // FIXME: Remove this once we've flipped over to the new
32 // API.
33 };
34
35 ExceptionState();
36 ExceptionState(Context context, const char* interfaceName);
37 ExceptionState(Context context,
38 const char* propertyName,
39 const char* interfaceName);
40 ~ExceptionState();
41
42 void ThrowDOMException(const ExceptionCode& code, const String& message);
43 void ThrowTypeError(const String& message);
44 void ThrowRangeError(const String& message);
45
46 bool ThrowIfNeeded();
47 void ClearException();
48
49 ExceptionCode code() const { return code_; }
50 const String& message() const { return message_; }
51 bool had_exception() const { return had_exception_ || code_; }
52
53 Dart_Handle GetDartException(Dart_NativeArguments args, bool auto_scope);
54
55 private:
56 ExceptionCode code_;
57 String message_;
58 bool had_exception_;
59 DartPersistentValue exception_;
60 };
61
62 class NonThrowableExceptionState final : public ExceptionState {};
63
64 class TrackExceptionState final : public ExceptionState {};
65
66 } // namespace blink
67
68 #endif // SKY_ENGINE_BINDINGS2_EXCEPTION_STATE_H_
OLDNEW
« 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