diff options
Diffstat (limited to 'WebCore')
-rw-r--r-- | WebCore/bindings/js/ScriptController.cpp | 6 | ||||
-rw-r--r-- | WebCore/bindings/js/ScriptController.h | 4 | ||||
-rw-r--r-- | WebCore/bindings/v8/DOMObjectsInclude.h | 36 | ||||
-rw-r--r-- | WebCore/bindings/v8/DerivedSourcesAllInOne.cpp | 122 | ||||
-rw-r--r-- | WebCore/bindings/v8/ScriptController.cpp | 9 | ||||
-rw-r--r-- | WebCore/bindings/v8/ScriptController.h | 3 | ||||
-rw-r--r-- | WebCore/bindings/v8/V8Index.cpp | 32 | ||||
-rw-r--r-- | WebCore/bindings/v8/V8Index.h | 38 | ||||
-rw-r--r-- | WebCore/loader/icon/IconDatabase.cpp | 13 | ||||
-rw-r--r-- | WebCore/page/Geolocation.cpp | 107 | ||||
-rw-r--r-- | WebCore/page/Geolocation.h | 34 | ||||
-rw-r--r-- | WebCore/storage/Database.cpp | 10 |
12 files changed, 235 insertions, 179 deletions
diff --git a/WebCore/bindings/js/ScriptController.cpp b/WebCore/bindings/js/ScriptController.cpp index 6de9b75..45f8c75 100644 --- a/WebCore/bindings/js/ScriptController.cpp +++ b/WebCore/bindings/js/ScriptController.cpp @@ -38,12 +38,18 @@ #include "npruntime_impl.h" #include "runtime_root.h" #include <debugger/Debugger.h> +#include <runtime/InitializeThreading.h> #include <runtime/JSLock.h> using namespace JSC; namespace WebCore { +void ScriptController::initializeThreading() +{ + JSC::initializeThreading(); +} + ScriptController::ScriptController(Frame* frame) : m_frame(frame) , m_handlerLineNumber(0) diff --git a/WebCore/bindings/js/ScriptController.h b/WebCore/bindings/js/ScriptController.h index 56e8f0c..9ae10fb 100644 --- a/WebCore/bindings/js/ScriptController.h +++ b/WebCore/bindings/js/ScriptController.h @@ -80,6 +80,10 @@ public: return m_windowShell->window(); } + // This function must be called from the main thread. It is safe to call it repeatedly. + // Darwin is an exception to this rule: it is OK to call this function from any thread, even reentrantly. + static void initializeThreading(); + ScriptValue evaluate(const ScriptSourceCode&); void evaluateInIsolatedWorld(unsigned worldID, const Vector<ScriptSourceCode>&); diff --git a/WebCore/bindings/v8/DOMObjectsInclude.h b/WebCore/bindings/v8/DOMObjectsInclude.h index ec5c466..fb7ba81 100644 --- a/WebCore/bindings/v8/DOMObjectsInclude.h +++ b/WebCore/bindings/v8/DOMObjectsInclude.h @@ -31,7 +31,6 @@ #ifndef DOMObjectsInclude_h #define DOMObjectsInclude_h -#include "AbstractWorker.h" #include "BarInfo.h" #include "BeforeLoadEvent.h" #include "CanvasArray.h" @@ -76,7 +75,6 @@ #include "CSSValueList.h" #include "CSSVariablesDeclaration.h" #include "CSSVariablesRule.h" -#include "Database.h" #include "DocumentType.h" #include "DocumentFragment.h" #include "DOMCoreException.h" @@ -137,18 +135,12 @@ #include "ScriptExecutionContext.h" #include "SecurityOrigin.h" #include "Settings.h" -#include "SharedWorker.h" -#include "SharedWorkerContext.h" -#include "SQLTransaction.h" -#include "SQLResultSet.h" -#include "SQLResultSetRowList.h" #include "StyleSheet.h" #include "StyleSheetList.h" #include "TextEvent.h" #include "TextMetrics.h" #include "TimeRanges.h" #include "TreeWalker.h" -#include "XSLTProcessor.h" #include "V8AbstractEventListener.h" #include "V8CustomEventListener.h" #include "V8DOMWindow.h" @@ -169,15 +161,18 @@ #include "XMLHttpRequestProgressEvent.h" #include "XMLHttpRequestUpload.h" #include "XMLSerializer.h" -#include "XPathException.h" -#include "XPathExpression.h" -#include "XPathNSResolver.h" -#include "XPathResult.h" #if ENABLE(OFFLINE_WEB_APPLICATIONS) #include "DOMApplicationCache.h" #endif +#if ENABLE(DATABASE) +#include "Database.h" +#include "SQLTransaction.h" +#include "SQLResultSet.h" +#include "SQLResultSetRowList.h" +#endif // DATABASE + #if ENABLE(DATAGRID) #include "DataGridColumn.h" #include "DataGridColumnList.h" @@ -246,6 +241,7 @@ #endif #if ENABLE(WORKERS) +#include "AbstractWorker.h" #include "DedicatedWorkerContext.h" #include "Worker.h" #include "WorkerContext.h" @@ -253,6 +249,11 @@ #include "WorkerNavigator.h" #endif // WORKERS +#if ENABLE(SHARED_WORKERS) +#include "SharedWorker.h" +#include "SharedWorkerContext.h" +#endif // SHARED_WORKERS + #if ENABLE(NOTIFICATIONS) #include "Notification.h" #include "NotificationCenter.h" @@ -260,14 +261,19 @@ #if ENABLE(XPATH) #include "XPathEvaluator.h" +#include "XPathException.h" +#include "XPathExpression.h" +#include "XPathNSResolver.h" +#include "XPathResult.h" #endif // XPATH -#if PLATFORM(ANDROID) -// TODO: Upstream INSPECTOR guard. +#if ENABLE(XSLT) +#include "XSLTProcessor.h" +#endif // XSLT + #if ENABLE(INSPECTOR) #include "InspectorBackend.h" #endif // INSPECTOR -#endif namespace WebCore { diff --git a/WebCore/bindings/v8/DerivedSourcesAllInOne.cpp b/WebCore/bindings/v8/DerivedSourcesAllInOne.cpp index c56a695..98832f3 100644 --- a/WebCore/bindings/v8/DerivedSourcesAllInOne.cpp +++ b/WebCore/bindings/v8/DerivedSourcesAllInOne.cpp @@ -28,11 +28,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#if PLATFORM(ANDROID) // This source file coalesces the V8 derived sources into a single object file to -#else -// This source file coalesces the HTML elements into a single object file to -#endif // reduce bloat and allow us to link release builds on 32-bit Windows. #include "bindings/V8Attr.cpp" @@ -87,9 +83,6 @@ #include "bindings/V8Document.cpp" #include "bindings/V8DocumentFragment.cpp" #include "bindings/V8DocumentType.cpp" -#if ENABLE(OFFLINE_WEB_APPLICATIONS) -#include "bindings/V8DOMApplicationCache.cpp" -#endif #include "bindings/V8DOMCoreException.cpp" #include "bindings/V8DOMImplementation.cpp" #include "bindings/V8DOMParser.cpp" @@ -194,13 +187,6 @@ #include "bindings/V8NodeIterator.cpp" #include "bindings/V8NodeList.cpp" #include "bindings/V8Notation.cpp" -#if PLATFORM(ANDROID) -// TODO: Upstream NOTIFICATIONS guard. -#if ENABLE(NOTIFICATIONS) -#include "bindings/V8Notification.cpp" -#include "bindings/V8NotificationCenter.cpp" -#endif -#endif #include "bindings/V8OverflowEvent.cpp" #include "bindings/V8PageTransitionEvent.cpp" #include "bindings/V8Plugin.cpp" @@ -212,9 +198,42 @@ #include "bindings/V8Rect.cpp" #include "bindings/V8RGBColor.cpp" #include "bindings/V8Screen.cpp" +#include "bindings/V8StyleSheet.cpp" +#include "bindings/V8StyleSheetList.cpp" +#include "bindings/V8Text.cpp" +#include "bindings/V8TextEvent.cpp" +#include "bindings/V8TextMetrics.cpp" +#include "bindings/V8TimeRanges.cpp" +#include "bindings/V8TreeWalker.cpp" +#include "bindings/V8UIEvent.cpp" +#include "bindings/V8ValidityState.cpp" +#include "bindings/V8WebKitAnimationEvent.cpp" +#include "bindings/V8WebKitCSSKeyframeRule.cpp" +#include "bindings/V8WebKitCSSKeyframesRule.cpp" +#include "bindings/V8WebKitCSSMatrix.cpp" +#include "bindings/V8WebKitCSSTransformValue.cpp" +#include "bindings/V8WebKitPoint.cpp" +#include "bindings/V8WebKitTransitionEvent.cpp" +#include "bindings/V8WheelEvent.cpp" +#include "bindings/V8XMLHttpRequest.cpp" +#include "bindings/V8XMLHttpRequestException.cpp" +#include "bindings/V8XMLHttpRequestProgressEvent.cpp" +#include "bindings/V8XMLHttpRequestUpload.cpp" +#include "bindings/V8XMLSerializer.cpp" + +#if ENABLE(OFFLINE_WEB_APPLICATIONS) +#include "bindings/V8DOMApplicationCache.cpp" +#endif + +#if ENABLE(DOM_STORAGE) +#include "bindings/V8Storage.cpp" +#include "bindings/V8StorageEvent.cpp" +#endif + +#if ENABLE(WEB_SOCKETS) +#include "bindings/V8WebSocket.cpp" +#endif -#if PLATFORM(ANDROID) -// TODO: Upstream DATABASE guard. #if ENABLE(DATABASE) #include "bindings/V8Database.cpp" #include "bindings/V8SQLError.cpp" @@ -222,17 +241,20 @@ #include "bindings/V8SQLResultSetRowList.cpp" #include "bindings/V8SQLTransaction.cpp" #endif + +#if ENABLE(WORKERS) +#include "bindings/V8AbstractWorker.cpp" +#include "bindings/V8DedicatedWorkerContext.cpp" +#include "bindings/V8Worker.cpp" +#include "bindings/V8WorkerContext.cpp" +#include "bindings/V8WorkerLocation.cpp" +#include "bindings/V8WorkerNavigator.cpp" #endif -#if ENABLE(DOM_STORAGE) -#include "bindings/V8Storage.cpp" -#include "bindings/V8StorageEvent.cpp" +#if ENABLE(SHARED_WORKERS) +#include "bindings/V8SharedWorker.cpp" #endif -#include "bindings/V8StyleSheet.cpp" -#include "bindings/V8StyleSheetList.cpp" -#if PLATFORM(ANDROID) -// TODO: Upstream SVG guard. #if ENABLE(SVG) #include "bindings/V8SVGAElement.cpp" #include "bindings/V8SVGAltGlyphElement.cpp" @@ -344,48 +366,7 @@ #include "bindings/V8SVGViewElement.cpp" #include "bindings/V8SVGZoomEvent.cpp" #endif -#endif - -#include "bindings/V8Text.cpp" -#include "bindings/V8TextEvent.cpp" -#include "bindings/V8TextMetrics.cpp" -#include "bindings/V8TimeRanges.cpp" -#include "bindings/V8TreeWalker.cpp" -#include "bindings/V8UIEvent.cpp" -#include "bindings/V8ValidityState.cpp" -#include "bindings/V8WebKitAnimationEvent.cpp" -#include "bindings/V8WebKitCSSKeyframeRule.cpp" -#include "bindings/V8WebKitCSSKeyframesRule.cpp" -#include "bindings/V8WebKitCSSMatrix.cpp" -#include "bindings/V8WebKitCSSTransformValue.cpp" -#include "bindings/V8WebKitPoint.cpp" -#include "bindings/V8WebKitTransitionEvent.cpp" -#if ENABLE(WEB_SOCKETS) -#include "bindings/V8WebSocket.cpp" -#endif -#include "bindings/V8WheelEvent.cpp" - -#if PLATFORM(ANDROID) -// TODO: Upstream WORKERS guard. -#if ENABLE(WORKERS) -#include "bindings/V8AbstractWorker.cpp" -#include "bindings/V8DedicatedWorkerContext.cpp" -#include "bindings/V8SharedWorker.cpp" -#include "bindings/V8Worker.cpp" -#include "bindings/V8WorkerContext.cpp" -#include "bindings/V8WorkerLocation.cpp" -#include "bindings/V8WorkerNavigator.cpp" -#endif -#endif - -#include "bindings/V8XMLHttpRequest.cpp" -#include "bindings/V8XMLHttpRequestException.cpp" -#include "bindings/V8XMLHttpRequestProgressEvent.cpp" -#include "bindings/V8XMLHttpRequestUpload.cpp" -#include "bindings/V8XMLSerializer.cpp" -#if PLATFORM(ANDROID) -// TODO: Upstream XPATH guard. #if ENABLE(XPATH) #include "bindings/V8XPathEvaluator.cpp" #include "bindings/V8XPathException.cpp" @@ -393,18 +374,19 @@ #include "bindings/V8XPathNSResolver.cpp" #include "bindings/V8XPathResult.cpp" #endif -#endif -#if PLATFORM(ANDROID) -// TODO: Upstream XSLT guard. #if ENABLE(XSLT) #include "bindings/V8XSLTProcessor.cpp" #endif -#endif -#if PLATFORM(ANDROID) -// TODO: Upstream INSPECTOR guard. #if ENABLE(INSPECTOR) #include "bindings/V8InspectorBackend.cpp" #endif + +#if PLATFORM(ANDROID) +// TODO: Upstream NOTIFICATIONS guard. +#if ENABLE(NOTIFICATIONS) +#include "bindings/V8Notification.cpp" +#include "bindings/V8NotificationCenter.cpp" +#endif #endif diff --git a/WebCore/bindings/v8/ScriptController.cpp b/WebCore/bindings/v8/ScriptController.cpp index d2c1db2..85af072 100644 --- a/WebCore/bindings/v8/ScriptController.cpp +++ b/WebCore/bindings/v8/ScriptController.cpp @@ -60,6 +60,15 @@ namespace WebCore { +void ScriptController::initializeThreading() +{ + static bool initializedThreading = false; + if (!initializedThreading) { + WTF::initializeThreading(); + initializedThreading = true; + } +} + void ScriptController::setFlags(const char* string, int length) { v8::V8::SetFlagsFromString(string, length); diff --git a/WebCore/bindings/v8/ScriptController.h b/WebCore/bindings/v8/ScriptController.h index 9658b05..ec15103 100644 --- a/WebCore/bindings/v8/ScriptController.h +++ b/WebCore/bindings/v8/ScriptController.h @@ -59,6 +59,9 @@ namespace WebCore { // or this accessor should be made JSProxy* V8Proxy* proxy() { return m_proxy.get(); } + // This function must be called from the main thread. It is safe to call it repeatedly. + static void initializeThreading(); + // Evaluate a script file in the environment of this proxy. // If succeeded, 'succ' is set to true and result is returned // as a string. diff --git a/WebCore/bindings/v8/V8Index.cpp b/WebCore/bindings/v8/V8Index.cpp index 396c93f..2cbd16d 100644 --- a/WebCore/bindings/v8/V8Index.cpp +++ b/WebCore/bindings/v8/V8Index.cpp @@ -410,8 +410,6 @@ #include "V8CanvasUnsignedShortArray.h" #endif -#if PLATFORM(ANDROID) -// TODO: Upstream these guards to webkit.org #if ENABLE(DATABASE) #include "V8Database.h" #include "V8SQLError.h" @@ -420,25 +418,12 @@ #include "V8SQLTransaction.h" #endif -#if ENABLE(GEOLOCATION) -#include "V8Coordinates.h" -#include "V8Geolocation.h" -#include "V8Geoposition.h" -#include "V8PositionError.h" -#endif - -#if ENABLE(TOUCH_EVENTS) -#include "V8Touch.h" -#include "V8TouchList.h" -#include "V8TouchEvent.h" -#endif - #if ENABLE(XPATH) #include "V8XPathResult.h" #include "V8XPathException.h" #include "V8XPathExpression.h" -#include "V8XPathEvaluator.h" #include "V8XPathNSResolver.h" +#include "V8XPathEvaluator.h" #endif #if ENABLE(XSLT) @@ -449,6 +434,21 @@ #include "V8InspectorBackend.h" #endif +#if PLATFORM(ANDROID) +// TODO: Upstream these guards to webkit.org +#if ENABLE(GEOLOCATION) +#include "V8Coordinates.h" +#include "V8Geolocation.h" +#include "V8Geoposition.h" +#include "V8PositionError.h" +#endif + +#if ENABLE(TOUCH_EVENTS) +#include "V8Touch.h" +#include "V8TouchList.h" +#include "V8TouchEvent.h" +#endif + #include "V8VoidCallback.h" #endif // PLATFORM(ANDROID) diff --git a/WebCore/bindings/v8/V8Index.h b/WebCore/bindings/v8/V8Index.h index 6255079..179b963 100644 --- a/WebCore/bindings/v8/V8Index.h +++ b/WebCore/bindings/v8/V8Index.h @@ -83,7 +83,7 @@ typedef v8::Persistent<v8::FunctionTemplate> (*FunctionTemplateFactory)(); #endif #if ENABLE(OFFLINE_WEB_APPLICATIONS) -#define APPLICATIONCACHE_NONNODE_WRAPPER_TYPES(V) \ +#define APPLICATIONCACHE_NONNODE_WRAPPER_TYPES(V) \ V(DOMAPPLICATIONCACHE, DOMApplicationCache) #else #define APPLICATIONCACHE_NONNODE_WRAPPER_TYPES(V) @@ -100,7 +100,9 @@ typedef v8::Persistent<v8::FunctionTemplate> (*FunctionTemplateFactory)(); #if ENABLE(SHARED_WORKERS) #define SHARED_WORKER_ACTIVE_OBJECT_WRAPPER_TYPES(V) \ V(SHAREDWORKER, SharedWorker) -#define SHARED_WORKER_NONNODE_WRAPPER_TYPES(V) + +#define SHARED_WORKER_NONNODE_WRAPPER_TYPES(V) \ + V(SHAREDWORKERCONTEXT, SharedWorkerContext) #else #define SHARED_WORKER_ACTIVE_OBJECT_WRAPPER_TYPES(V) #define SHARED_WORKER_NONNODE_WRAPPER_TYPES(V) @@ -363,7 +365,7 @@ typedef v8::Persistent<v8::FunctionTemplate> (*FunctionTemplateFactory)(); V(CANVASPIXELARRAY, CanvasPixelArray) \ V(KEYBOARDEVENT, KeyboardEvent) \ V(LOCATION, Location) \ - V(MEDIA, Media) \ + V(MEDIA, Media) \ V(MEDIALIST, MediaList) #define DOM_OBJECT_TYPES_2(V) \ @@ -463,17 +465,6 @@ typedef v8::Persistent<v8::FunctionTemplate> (*FunctionTemplateFactory)(); #define DOM_OBJECT_3D_CANVAS_TYPES(V) #endif -#if PLATFORM(ANDROID) -// TODO: Upstream these guards. -#if ENABLE(TOUCH_EVENTS) -#define DOM_OBJECT_TOUCH_EVENT_TYPES(V) \ - V(TOUCHLIST, TouchList) \ - V(TOUCHEVENT, TouchEvent) \ - V(TOUCH, Touch) -#else -#define DOM_OBJECT_TOUCH_EVENT_TYPES(V) -#endif - #if ENABLE(XPATH) #define DOM_OBJECT_XPATH_TYPES(V) \ V(XPATHEVALUATOR, XPathEvaluator) \ @@ -492,6 +483,13 @@ typedef v8::Persistent<v8::FunctionTemplate> (*FunctionTemplateFactory)(); #define DOM_OBJECT_XSLT_TYPES(V) #endif +#if ENABLE(INSPECTOR) +#define DOM_OBJECT_INSPECTOR_TYPES(V) \ + V(INSPECTORBACKEND, InspectorBackend) +#else +#define DOM_OBJECT_INSPECTOR_TYPES(V) +#endif + #if ENABLE(GEOLOCATION) #define DOM_OBJECT_GEOLOCATION_TYPES(V) \ V(COORDINATES, Coordinates) \ @@ -502,11 +500,15 @@ typedef v8::Persistent<v8::FunctionTemplate> (*FunctionTemplateFactory)(); #define DOM_OBJECT_GEOLOCATION_TYPES(V) #endif -#if ENABLE(INSPECTOR) -#define DOM_OBJECT_INSPECTOR_TYPES(V) \ - V(INSPECTORBACKEND, InspectorBackend) +#if PLATFORM(ANDROID) +// TODO: Upstream this guard. +#if ENABLE(TOUCH_EVENTS) +#define DOM_OBJECT_TOUCH_EVENT_TYPES(V) \ + V(TOUCHLIST, TouchList) \ + V(TOUCHEVENT, TouchEvent) \ + V(TOUCH, Touch) #else -#define DOM_OBJECT_INSPECTOR_TYPES(V) +#define DOM_OBJECT_TOUCH_EVENT_TYPES(V) #endif #endif diff --git a/WebCore/loader/icon/IconDatabase.cpp b/WebCore/loader/icon/IconDatabase.cpp index 8982cda..5a9bfaa 100644 --- a/WebCore/loader/icon/IconDatabase.cpp +++ b/WebCore/loader/icon/IconDatabase.cpp @@ -36,6 +36,7 @@ #include "IconRecord.h" #include "IntSize.h" #include "Logging.h" +#include "ScriptController.h" #include "SQLiteStatement.h" #include "SQLiteTransaction.h" #include "SuddenTermination.h" @@ -43,12 +44,6 @@ #include <wtf/MainThread.h> #include <wtf/StdLibExtras.h> -#if USE(JSC) -#include <runtime/InitializeThreading.h> -#elif USE(V8) -#include "InitializeThreading.h" -#endif - // For methods that are meant to support API from the main thread - should not be called internally #define ASSERT_NOT_SYNC_THREAD() ASSERT(!m_syncThreadRunning || !IS_ICON_SYNC_THREAD()) @@ -98,11 +93,7 @@ static IconDatabaseClient* defaultClient() IconDatabase* iconDatabase() { if (!sharedIconDatabase) { -#if USE(JSC) - JSC::initializeThreading(); -#elif USE(V8) - V8::initializeThreading(); -#endif + ScriptController::initializeThreading(); sharedIconDatabase = new IconDatabase; } return sharedIconDatabase; diff --git a/WebCore/page/Geolocation.cpp b/WebCore/page/Geolocation.cpp index ba3516d..74b3f79 100644 --- a/WebCore/page/Geolocation.cpp +++ b/WebCore/page/Geolocation.cpp @@ -41,7 +41,7 @@ namespace WebCore { -static const char* permissionDeniedErrorMessage = "User denied Geolocation"; +static const char permissionDeniedErrorMessage[] = "User denied Geolocation"; Geolocation::GeoNotifier::GeoNotifier(Geolocation* geolocation, PassRefPtr<PositionCallback> successCallback, PassRefPtr<PositionErrorCallback> errorCallback, PassRefPtr<PositionOptions> options) : m_geolocation(geolocation) @@ -49,7 +49,6 @@ Geolocation::GeoNotifier::GeoNotifier(Geolocation* geolocation, PassRefPtr<Posit , m_errorCallback(errorCallback) , m_options(options) , m_timer(this, &Geolocation::GeoNotifier::timerFired) - , m_fatalError(0) { ASSERT(m_geolocation); ASSERT(m_successCallback); @@ -60,10 +59,17 @@ Geolocation::GeoNotifier::GeoNotifier(Geolocation* geolocation, PassRefPtr<Posit void Geolocation::GeoNotifier::setFatalError(PassRefPtr<PositionError> error) { + // This method is called at most once on a given GeoNotifier object. + ASSERT(!m_fatalError); m_fatalError = error; m_timer.startOneShot(0); } +bool Geolocation::GeoNotifier::hasZeroTimeout() const +{ + return m_options->hasTimeout() && m_options->timeout() == 0; +} + void Geolocation::GeoNotifier::setCachedPosition(Geoposition* cachedPosition) { // We do not take owenership from the caller, but add our own ref count. @@ -96,12 +102,52 @@ void Geolocation::GeoNotifier::timerFired(Timer<GeoNotifier>*) } if (m_errorCallback) { - RefPtr<PositionError> error = PositionError::create(PositionError::TIMEOUT, "Timed out"); + RefPtr<PositionError> error = PositionError::create(PositionError::TIMEOUT, "Timeout expired"); m_errorCallback->handleEvent(error.get()); } m_geolocation->requestTimedOut(this); } +void Geolocation::Watchers::set(int id, PassRefPtr<GeoNotifier> notifier) +{ + m_idToNotifierMap.set(id, notifier); + m_notifierToIdMap.set(notifier, id); +} + +void Geolocation::Watchers::remove(int id) +{ + IdToNotifierMap::iterator iter = m_idToNotifierMap.find(id); + if (iter == m_idToNotifierMap.end()) + return; + m_notifierToIdMap.remove(iter->second); + m_idToNotifierMap.remove(iter); +} + +void Geolocation::Watchers::remove(GeoNotifier* notifier) +{ + NotifierToIdMap::iterator iter = m_notifierToIdMap.find(notifier); + if (iter == m_notifierToIdMap.end()) + return; + m_idToNotifierMap.remove(iter->second); + m_notifierToIdMap.remove(iter); +} + +void Geolocation::Watchers::clear() +{ + m_idToNotifierMap.clear(); + m_notifierToIdMap.clear(); +} + +bool Geolocation::Watchers::isEmpty() const +{ + return m_idToNotifierMap.isEmpty(); +} + +void Geolocation::Watchers::getNotifiersVector(Vector<RefPtr<GeoNotifier> >& copy) const +{ + copyValuesToVector(m_idToNotifierMap, copy); +} + static const char* databaseName = "/CachedPosition.db"; class CachedPositionManager { @@ -275,7 +321,7 @@ void Geolocation::disconnectFrame() void Geolocation::getCurrentPosition(PassRefPtr<PositionCallback> successCallback, PassRefPtr<PositionErrorCallback> errorCallback, PassRefPtr<PositionOptions> options) { - RefPtr<GeoNotifier> notifier = makeRequest(successCallback, errorCallback, options); + RefPtr<GeoNotifier> notifier = startRequest(successCallback, errorCallback, options); ASSERT(notifier); m_oneShots.add(notifier); @@ -283,24 +329,23 @@ void Geolocation::getCurrentPosition(PassRefPtr<PositionCallback> successCallbac int Geolocation::watchPosition(PassRefPtr<PositionCallback> successCallback, PassRefPtr<PositionErrorCallback> errorCallback, PassRefPtr<PositionOptions> options) { - RefPtr<GeoNotifier> notifier = makeRequest(successCallback, errorCallback, options); + RefPtr<GeoNotifier> notifier = startRequest(successCallback, errorCallback, options); ASSERT(notifier); - static int sIdentifier = 0; - m_watchers.set(++sIdentifier, notifier); - - return sIdentifier; + static int nextAvailableWatchId = 1; + m_watchers.set(nextAvailableWatchId, notifier.release()); + return nextAvailableWatchId++; } -PassRefPtr<Geolocation::GeoNotifier> Geolocation::makeRequest(PassRefPtr<PositionCallback> successCallback, PassRefPtr<PositionErrorCallback> errorCallback, PassRefPtr<PositionOptions> options) +PassRefPtr<Geolocation::GeoNotifier> Geolocation::startRequest(PassRefPtr<PositionCallback> successCallback, PassRefPtr<PositionErrorCallback> errorCallback, PassRefPtr<PositionOptions> options) { RefPtr<GeoNotifier> notifier = GeoNotifier::create(this, successCallback, errorCallback, options); // Check whether permissions have already been denied. Note that if this is the case, // the permission state can not change again in the lifetime of this page. - if (isDenied()) { + if (isDenied()) notifier->setFatalError(PositionError::create(PositionError::PERMISSION_DENIED, permissionDeniedErrorMessage)); - } else { + else { if (haveSuitableCachedPosition(notifier->m_options.get())) { ASSERT(m_cachedPositionManager->cachedPosition()); if (isAllowed()) @@ -310,7 +355,7 @@ PassRefPtr<Geolocation::GeoNotifier> Geolocation::makeRequest(PassRefPtr<Positio requestPermission(); } } else { - if (m_service->startUpdating(notifier->m_options.get())) + if (notifier->hasZeroTimeout() || m_service->startUpdating(notifier->m_options.get())) notifier->startTimerIfNeeded(); else notifier->setFatalError(PositionError::create(PositionError::UNKNOWN_ERROR, "Failed to start Geolocation service")); @@ -324,12 +369,7 @@ void Geolocation::fatalErrorOccurred(Geolocation::GeoNotifier* notifier) { // This request has failed fatally. Remove it from our lists. m_oneShots.remove(notifier); - for (GeoNotifierMap::iterator iter = m_watchers.begin(); iter != m_watchers.end(); ++iter) { - if (iter->second == notifier) { - m_watchers.remove(iter); - break; - } - } + m_watchers.remove(notifier); if (!hasListeners()) m_service->stopUpdating(); @@ -400,7 +440,7 @@ void Geolocation::setIsAllowed(bool allowed) m_allowGeolocation = allowed ? Yes : No; if (!isAllowed()) { - RefPtr<WebCore::PositionError> error = PositionError::create(PositionError::PERMISSION_DENIED, permissionDeniedErrorMessage); + RefPtr<PositionError> error = PositionError::create(PositionError::PERMISSION_DENIED, permissionDeniedErrorMessage); error->setIsFatal(true); handleError(error.get()); return; @@ -462,7 +502,7 @@ void Geolocation::stopTimersForOneShots() void Geolocation::stopTimersForWatchers() { Vector<RefPtr<GeoNotifier> > copy; - copyValuesToVector(m_watchers, copy); + m_watchers.getNotifiersVector(copy); stopTimer(copy); } @@ -476,15 +516,16 @@ void Geolocation::stopTimers() void Geolocation::handleError(PositionError* error) { ASSERT(error); - + Vector<RefPtr<GeoNotifier> > oneShotsCopy; copyToVector(m_oneShots, oneShotsCopy); Vector<RefPtr<GeoNotifier> > watchersCopy; - copyValuesToVector(m_watchers, watchersCopy); + m_watchers.getNotifiersVector(watchersCopy); // Clear the lists before we make the callbacks, to avoid clearing notifiers - // added by calls to Geolocation methods from the callbacks. + // added by calls to Geolocation methods from the callbacks, and to prevent + // further callbacks to these notifiers. m_oneShots.clear(); if (error->isFatal()) m_watchers.clear(); @@ -514,19 +555,20 @@ void Geolocation::requestPermission() page->chrome()->requestGeolocationPermissionForFrame(m_frame, this); } -void Geolocation::geolocationServicePositionChanged(GeolocationService*) +void Geolocation::geolocationServicePositionChanged(GeolocationService* service) { + ASSERT_UNUSED(service, service == m_service); ASSERT(m_service->lastPosition()); m_cachedPositionManager->setCachedPosition(m_service->lastPosition()); // Stop all currently running timers. stopTimers(); - + if (!isAllowed()) { // requestPermission() will ask the chrome for permission. This may be // implemented synchronously or asynchronously. In both cases, - // makeSucessCallbacks() will be called if permission is granted, so + // makeSuccessCallbacks() will be called if permission is granted, so // there's nothing more to do here. requestPermission(); return; @@ -539,15 +581,16 @@ void Geolocation::makeSuccessCallbacks() { ASSERT(m_service->lastPosition()); ASSERT(isAllowed()); - + Vector<RefPtr<GeoNotifier> > oneShotsCopy; copyToVector(m_oneShots, oneShotsCopy); - + Vector<RefPtr<GeoNotifier> > watchersCopy; - copyValuesToVector(m_watchers, watchersCopy); - + m_watchers.getNotifiersVector(watchersCopy); + // Clear the lists before we make the callbacks, to avoid clearing notifiers - // added by calls to Geolocation methods from the callbacks. + // added by calls to Geolocation methods from the callbacks, and to prevent + // further callbacks to these notifiers. m_oneShots.clear(); sendPosition(oneShotsCopy, m_service->lastPosition()); diff --git a/WebCore/page/Geolocation.h b/WebCore/page/Geolocation.h index 401189b..d9b23c4 100644 --- a/WebCore/page/Geolocation.h +++ b/WebCore/page/Geolocation.h @@ -82,7 +82,8 @@ private: public: static PassRefPtr<GeoNotifier> create(Geolocation* geolocation, PassRefPtr<PositionCallback> positionCallback, PassRefPtr<PositionErrorCallback> positionErrorCallback, PassRefPtr<PositionOptions> options) { return adoptRef(new GeoNotifier(geolocation, positionCallback, positionErrorCallback, options)); } - void setFatalError(PassRefPtr<PositionError> error); + void setFatalError(PassRefPtr<PositionError>); + bool hasZeroTimeout() const; void setCachedPosition(Geoposition* cachedPosition); void startTimerIfNeeded(); void timerFired(Timer<GeoNotifier>*); @@ -96,14 +97,29 @@ private: RefPtr<Geoposition> m_cachedPosition; private: - GeoNotifier(Geolocation* geolocation, PassRefPtr<PositionCallback>, PassRefPtr<PositionErrorCallback>, PassRefPtr<PositionOptions>); + GeoNotifier(Geolocation*, PassRefPtr<PositionCallback>, PassRefPtr<PositionErrorCallback>, PassRefPtr<PositionOptions>); + }; + + class Watchers { + public: + void set(int id, PassRefPtr<GeoNotifier>); + void remove(int id); + void remove(GeoNotifier*); + void clear(); + bool isEmpty() const; + void getNotifiersVector(Vector<RefPtr<GeoNotifier> >&) const; + private: + typedef HashMap<int, RefPtr<GeoNotifier> > IdToNotifierMap; + typedef HashMap<RefPtr<GeoNotifier>, int> NotifierToIdMap; + IdToNotifierMap m_idToNotifierMap; + NotifierToIdMap m_notifierToIdMap; }; bool hasListeners() const { return !m_oneShots.isEmpty() || !m_watchers.isEmpty(); } void sendError(Vector<RefPtr<GeoNotifier> >&, PositionError*); void sendPosition(Vector<RefPtr<GeoNotifier> >&, Geoposition*); - + static void stopTimer(Vector<RefPtr<GeoNotifier> >&); void stopTimersForOneShots(); void stopTimersForWatchers(); @@ -113,26 +129,26 @@ private: void handleError(PositionError*); void requestPermission(); - PassRefPtr<GeoNotifier> makeRequest(PassRefPtr<PositionCallback>, PassRefPtr<PositionErrorCallback>, PassRefPtr<PositionOptions>); // GeolocationServiceClient virtual void geolocationServicePositionChanged(GeolocationService*); virtual void geolocationServiceErrorOccurred(GeolocationService*); + PassRefPtr<GeoNotifier> startRequest(PassRefPtr<PositionCallback>, PassRefPtr<PositionErrorCallback>, PassRefPtr<PositionOptions>); + // EventListener virtual bool operator==(const EventListener&); virtual void handleEvent(ScriptExecutionContext*, Event*); - void fatalErrorOccurred(GeoNotifier* notifier); - void requestTimedOut(GeoNotifier* notifier); - void requestReturnedCachedPosition(GeoNotifier* notifier); + void fatalErrorOccurred(GeoNotifier*); + void requestTimedOut(GeoNotifier*); + void requestReturnedCachedPosition(GeoNotifier*); bool haveSuitableCachedPosition(PositionOptions*); typedef HashSet<RefPtr<GeoNotifier> > GeoNotifierSet; - typedef HashMap<int, RefPtr<GeoNotifier> > GeoNotifierMap; GeoNotifierSet m_oneShots; - GeoNotifierMap m_watchers; + Watchers m_watchers; Frame* m_frame; OwnPtr<GeolocationService> m_service; diff --git a/WebCore/storage/Database.cpp b/WebCore/storage/Database.cpp index 3a8225b..403e132 100644 --- a/WebCore/storage/Database.cpp +++ b/WebCore/storage/Database.cpp @@ -46,6 +46,7 @@ #include "NotImplemented.h" #include "Page.h" #include "OriginQuotaManager.h" +#include "ScriptController.h" #include "SQLiteDatabase.h" #include "SQLiteFileSystem.h" #include "SQLiteStatement.h" @@ -57,9 +58,6 @@ #if USE(JSC) #include "JSDOMWindow.h" -#include <runtime/InitializeThreading.h> -#elif USE(V8) -#include "InitializeThreading.h" #endif namespace WebCore { @@ -165,11 +163,7 @@ Database::Database(Document* document, const String& name, const String& expecte if (m_name.isNull()) m_name = ""; -#if USE(JSC) - JSC::initializeThreading(); -#elif USE(V8) - V8::initializeThreading(); -#endif + ScriptController::initializeThreading(); m_guid = guidForOriginAndName(m_securityOrigin->toString(), name); |