OLD | NEW |
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 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_TRY_CATCH_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_TRY_CATCH_H_ |
6 #define CONTENT_RENDERER_PEPPER_PEPPER_TRY_CATCH_H_ | 6 #define CONTENT_RENDERER_PEPPER_PEPPER_TRY_CATCH_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "content/common/content_export.h" | 9 #include "content/common/content_export.h" |
10 #include "content/renderer/pepper/v8_var_converter.h" | 10 #include "content/renderer/pepper/v8_var_converter.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 PepperTryCatchV8(PepperPluginInstanceImpl* instance, | 57 PepperTryCatchV8(PepperPluginInstanceImpl* instance, |
58 V8VarConverter::AllowObjectVars convert_objects, | 58 V8VarConverter::AllowObjectVars convert_objects, |
59 v8::Isolate* isolate); | 59 v8::Isolate* isolate); |
60 virtual ~PepperTryCatchV8(); | 60 virtual ~PepperTryCatchV8(); |
61 | 61 |
62 bool ThrowException(); | 62 bool ThrowException(); |
63 void ThrowException(const char* message); | 63 void ThrowException(const char* message); |
64 PP_Var* exception() { return &exception_; } | 64 PP_Var* exception() { return &exception_; } |
65 | 65 |
66 // PepperTryCatch | 66 // PepperTryCatch |
67 virtual void SetException(const char* message) OVERRIDE; | 67 virtual void SetException(const char* message) override; |
68 virtual bool HasException() OVERRIDE; | 68 virtual bool HasException() override; |
69 virtual v8::Handle<v8::Context> GetContext() OVERRIDE; | 69 virtual v8::Handle<v8::Context> GetContext() override; |
70 | 70 |
71 private: | 71 private: |
72 PP_Var exception_; | 72 PP_Var exception_; |
73 | 73 |
74 DISALLOW_COPY_AND_ASSIGN(PepperTryCatchV8); | 74 DISALLOW_COPY_AND_ASSIGN(PepperTryCatchV8); |
75 }; | 75 }; |
76 | 76 |
77 // Catches v8 exceptions and emits a var exception. | 77 // Catches v8 exceptions and emits a var exception. |
78 class PepperTryCatchVar : public PepperTryCatch { | 78 class PepperTryCatchVar : public PepperTryCatch { |
79 public: | 79 public: |
80 // The PP_Var exception will be placed in |exception|. The user of this class | 80 // The PP_Var exception will be placed in |exception|. The user of this class |
81 // is responsible for managing the lifetime of the exception. It is valid to | 81 // is responsible for managing the lifetime of the exception. It is valid to |
82 // pass NULL for |exception| in which case no exception will be set. | 82 // pass NULL for |exception| in which case no exception will be set. |
83 PepperTryCatchVar(PepperPluginInstanceImpl* instance, | 83 PepperTryCatchVar(PepperPluginInstanceImpl* instance, |
84 PP_Var* exception); | 84 PP_Var* exception); |
85 virtual ~PepperTryCatchVar(); | 85 virtual ~PepperTryCatchVar(); |
86 | 86 |
87 // PepperTryCatch | 87 // PepperTryCatch |
88 virtual void SetException(const char* message) OVERRIDE; | 88 virtual void SetException(const char* message) override; |
89 virtual bool HasException() OVERRIDE; | 89 virtual bool HasException() override; |
90 virtual v8::Handle<v8::Context> GetContext() OVERRIDE; | 90 virtual v8::Handle<v8::Context> GetContext() override; |
91 | 91 |
92 private: | 92 private: |
93 // Code which uses PepperTryCatchVar doesn't typically have a HandleScope, | 93 // Code which uses PepperTryCatchVar doesn't typically have a HandleScope, |
94 // make one for them. Note that this class is always allocated on the stack. | 94 // make one for them. Note that this class is always allocated on the stack. |
95 v8::HandleScope handle_scope_; | 95 v8::HandleScope handle_scope_; |
96 | 96 |
97 v8::Handle<v8::Context> context_; | 97 v8::Handle<v8::Context> context_; |
98 | 98 |
99 v8::TryCatch try_catch_; | 99 v8::TryCatch try_catch_; |
100 | 100 |
101 PP_Var* exception_; | 101 PP_Var* exception_; |
102 bool exception_is_set_; | 102 bool exception_is_set_; |
103 | 103 |
104 DISALLOW_COPY_AND_ASSIGN(PepperTryCatchVar); | 104 DISALLOW_COPY_AND_ASSIGN(PepperTryCatchVar); |
105 }; | 105 }; |
106 | 106 |
107 } // namespace content | 107 } // namespace content |
108 | 108 |
109 #endif // CONTENT_RENDERER_PEPPER_PEPPER_TRY_CATCH_H_ | 109 #endif // CONTENT_RENDERER_PEPPER_PEPPER_TRY_CATCH_H_ |
OLD | NEW |