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

Side by Side Diff: content/renderer/pepper/pepper_try_catch.h

Issue 1113783002: Use Local instead of Handle in src/content/* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 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 11 matching lines...) Expand all
22 public: 22 public:
23 // PepperTryCatch objects should only be used as stack variables. This object 23 // PepperTryCatch objects should only be used as stack variables. This object
24 // takes a reference on the given PepperPluginInstanceImpl. 24 // takes a reference on the given PepperPluginInstanceImpl.
25 PepperTryCatch(PepperPluginInstanceImpl* instance, 25 PepperTryCatch(PepperPluginInstanceImpl* instance,
26 V8VarConverter* var_converter); 26 V8VarConverter* var_converter);
27 virtual ~PepperTryCatch(); 27 virtual ~PepperTryCatch();
28 28
29 virtual void SetException(const char* message) = 0; 29 virtual void SetException(const char* message) = 0;
30 virtual bool HasException() = 0; 30 virtual bool HasException() = 0;
31 // Gets the context to execute scripts in. 31 // Gets the context to execute scripts in.
32 virtual v8::Handle<v8::Context> GetContext() = 0; 32 virtual v8::Local<v8::Context> GetContext() = 0;
33 33
34 // Convenience functions for doing conversions to/from V8 values and sets an 34 // Convenience functions for doing conversions to/from V8 values and sets an
35 // exception if there is an error in the conversion. 35 // exception if there is an error in the conversion.
36 v8::Handle<v8::Value> ToV8(PP_Var var); 36 v8::Local<v8::Value> ToV8(PP_Var var);
37 ppapi::ScopedPPVar FromV8(v8::Handle<v8::Value> v8_value); 37 ppapi::ScopedPPVar FromV8(v8::Local<v8::Value> v8_value);
38 38
39 protected: 39 protected:
40 // Make sure that |instance_| is alive for the lifetime of PepperTryCatch. 40 // Make sure that |instance_| is alive for the lifetime of PepperTryCatch.
41 // PepperTryCatch is used mostly in Pepper scripting code, where it can be 41 // PepperTryCatch is used mostly in Pepper scripting code, where it can be
42 // possible to enter JavaScript synchronously which can cause the plugin to 42 // possible to enter JavaScript synchronously which can cause the plugin to
43 // be deleted. 43 // be deleted.
44 // 44 //
45 // Note that PepperTryCatch objects should only ever be on the stack, so this 45 // Note that PepperTryCatch objects should only ever be on the stack, so this
46 // shouldn't keep the instance around for too long. 46 // shouldn't keep the instance around for too long.
47 scoped_refptr<PepperPluginInstanceImpl> instance_; 47 scoped_refptr<PepperPluginInstanceImpl> instance_;
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 ~PepperTryCatchV8() override; 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 void SetException(const char* message) override; 65 void SetException(const char* message) override;
66 bool HasException() override; 66 bool HasException() override;
67 v8::Handle<v8::Context> GetContext() override; 67 v8::Local<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 ~PepperTryCatchVar() override; 84 ~PepperTryCatchVar() override;
85 85
86 // PepperTryCatch 86 // PepperTryCatch
87 void SetException(const char* message) override; 87 void SetException(const char* message) override;
88 bool HasException() override; 88 bool HasException() override;
89 v8::Handle<v8::Context> GetContext() override; 89 v8::Local<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::Local<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_
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_plugin_instance_impl.cc ('k') | content/renderer/pepper/pepper_try_catch.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698