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

Side by Side Diff: webkit/port/bridge/ExceptionContextV8.cpp

Issue 9019: Make ExceptionContext platform-independent using magic headers (2/2) (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « webkit/port/bindings/v8/v8_nodefilter.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2008, Google Inc. 1 // Copyright (c) 2008, Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
(...skipping 16 matching lines...) Expand all
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 29
30 #include "config.h" 30 #include "config.h"
31 #include "ExceptionContext.h" 31 #include "ExceptionContext.h"
32 32
33 #include "Node.h" 33 #include "Node.h"
34 34
35 namespace WebCore { 35 namespace WebCore {
36 36
37 // Unlike JSC, which stores exceptions in ExecState that is accessible from 37 ExceptionContext::ExceptionContext(Node*)
38 // ScriptController that is retrievable from Node*, V8 uses static chain of 38 : m_data()
39 // handlers (encapsulated as v8::TryCatch and here as ExceptionCatcher)
40 // to track exceptions, so it has no need for Node*.
41 ExceptionContext::ExceptionContext(Node* node)
42 { 39 {
43 } 40 }
44 41
45 ExceptionContext::ExceptionContext()
46 : m_exception()
47 , m_exceptionCatcher(0)
48 {
49 }
50
51 void ExceptionContext::setExceptionCatcher(ExceptionCatcher* exceptionCatcher)
52 {
53 if (m_exceptionCatcher && exceptionCatcher)
54 m_exceptionCatcher->detachContext();
55
56 m_exceptionCatcher = exceptionCatcher;
57 }
58
59 bool ExceptionContext::hadException() 42 bool ExceptionContext::hadException()
60 { 43 {
61 if (m_exceptionCatcher) 44 return !m_data.IsEmpty();
62 m_exceptionCatcher->updateContext();
63
64 return !m_exception.IsEmpty();
65 } 45 }
66 46
67 JSException ExceptionContext::exception() const
68 {
69 return m_exception;
70 }
71
72 JSException ExceptionContext::noException()
73 {
74 return v8::Local<v8::Value>();
75 }
76
77 ExceptionCatcher::ExceptionCatcher(ExceptionContext* exceptionContext)
78 : m_context(exceptionContext)
79 , m_catcher()
80 {
81 exceptionContext->setExceptionCatcher(this);
82 }
83
84 void ExceptionCatcher::detachContext()
85 {
86 m_context = 0;
87 }
88
89 void ExceptionCatcher::updateContext()
90 {
91 ASSERT(m_context);
92
93 if (m_catcher.HasCaught())
94 m_context->setException(m_catcher.Exception());
95 else
96 m_context->setException(ExceptionContext::noException());
97 }
98
99 ExceptionCatcher::~ExceptionCatcher()
100 {
101 if (!m_context)
102 return;
103
104 updateContext();
105 m_context->setExceptionCatcher(0);
106 }
107 47
108 } // namespace WebCore 48 } // namespace WebCore
OLDNEW
« no previous file with comments | « webkit/port/bindings/v8/v8_nodefilter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698