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