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

Side by Side Diff: WebCore/bindings/v8/WorkerScriptController.cpp

Issue 9572031: Don't be so CRASH happy in the bindings layer. (Closed) Base URL: http://svn.webkit.org/repository/webkit/trunk/Source/
Patch Set: Created 8 years, 9 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 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. 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
11 * copyright notice, this list of conditions and the following disclaimer 11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the 12 * in the documentation and/or other materials provided with the
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include "WorkerObjectProxy.h" 46 #include "WorkerObjectProxy.h"
47 #include "WorkerThread.h" 47 #include "WorkerThread.h"
48 #include <v8.h> 48 #include <v8.h>
49 49
50 namespace WebCore { 50 namespace WebCore {
51 51
52 WorkerScriptController::WorkerScriptController(WorkerContext* workerContext) 52 WorkerScriptController::WorkerScriptController(WorkerContext* workerContext)
53 : m_workerContext(workerContext) 53 : m_workerContext(workerContext)
54 , m_isolate(v8::Isolate::New()) 54 , m_isolate(v8::Isolate::New())
55 , m_executionForbidden(false) 55 , m_executionForbidden(false)
56 , m_executionScheduledToTerminate(false)
56 { 57 {
57 V8BindingPerIsolateData* data = V8BindingPerIsolateData::create(m_isolate); 58 V8BindingPerIsolateData* data = V8BindingPerIsolateData::create(m_isolate);
58 data->allStores().append(&m_DOMDataStore); 59 data->allStores().append(&m_DOMDataStore);
59 data->setDOMDataStore(&m_DOMDataStore); 60 data->setDOMDataStore(&m_DOMDataStore);
60 m_isolate->Enter(); 61 m_isolate->Enter();
61 m_proxy = adoptPtr(new WorkerContextExecutionProxy(workerContext)); 62 m_proxy = adoptPtr(new WorkerContextExecutionProxy(workerContext));
62 } 63 }
63 64
64 WorkerScriptController::~WorkerScriptController() 65 WorkerScriptController::~WorkerScriptController()
65 { 66 {
(...skipping 19 matching lines...) Expand all
85 if (state.hadException) { 86 if (state.hadException) {
86 if (exception) 87 if (exception)
87 *exception = state.exception; 88 *exception = state.exception;
88 else 89 else
89 m_workerContext->reportException(state.errorMessage, state.lineNumbe r, state.sourceURL, 0); 90 m_workerContext->reportException(state.errorMessage, state.lineNumbe r, state.sourceURL, 0);
90 } 91 }
91 } 92 }
92 93
93 void WorkerScriptController::scheduleExecutionTermination() 94 void WorkerScriptController::scheduleExecutionTermination()
94 { 95 {
96 {
97 MutexLocker locker(m_scheduledTerminationMutex);
98 m_executionScheduledToTerminate = true;
99 }
95 v8::V8::TerminateExecution(m_isolate); 100 v8::V8::TerminateExecution(m_isolate);
96 } 101 }
97 102
103 bool WorkerScriptController::isExecutionTerminating() const
104 {
105 MutexLocker locker(m_scheduledTerminationMutex);
106 return m_executionScheduledToTerminate;
107 }
108
98 void WorkerScriptController::forbidExecution() 109 void WorkerScriptController::forbidExecution()
99 { 110 {
100 ASSERT(m_workerContext->isContextThread()); 111 ASSERT(m_workerContext->isContextThread());
101 m_executionForbidden = true; 112 m_executionForbidden = true;
102 } 113 }
103 114
104 bool WorkerScriptController::isExecutionForbidden() const 115 bool WorkerScriptController::isExecutionForbidden() const
105 { 116 {
106 ASSERT(m_workerContext->isContextThread()); 117 ASSERT(m_workerContext->isContextThread());
107 return m_executionForbidden; 118 return m_executionForbidden;
(...skipping 19 matching lines...) Expand all
127 // Return 0 if the current executing context is not the worker context. 138 // Return 0 if the current executing context is not the worker context.
128 if (global.IsEmpty()) 139 if (global.IsEmpty())
129 return 0; 140 return 0;
130 WorkerContext* workerContext = V8WorkerContext::toNative(global); 141 WorkerContext* workerContext = V8WorkerContext::toNative(global);
131 return workerContext->script(); 142 return workerContext->script();
132 } 143 }
133 144
134 } // namespace WebCore 145 } // namespace WebCore
135 146
136 #endif // ENABLE(WORKERS) 147 #endif // ENABLE(WORKERS)
OLDNEW
« no previous file with comments | « WebCore/bindings/v8/WorkerScriptController.h ('k') | WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698