Diff
Modified: trunk/Source/WebCore/ChangeLog (144407 => 144408)
--- trunk/Source/WebCore/ChangeLog 2013-03-01 02:12:54 UTC (rev 144407)
+++ trunk/Source/WebCore/ChangeLog 2013-03-01 03:35:07 UTC (rev 144408)
@@ -1,3 +1,29 @@
+2013-02-28 Ankur Taly <[email protected]>
+
+ WebKit API for enabling DOM logging for certain worlds
+ https://bugs.webkit.org/show_bug.cgi?id=110779
+
+ Reviewed by Adam Barth.
+
+ Adds additional static methods to DOMWrapperWorld for managing the
+ mapping between worldIDs and logger objects (where DOM logging messages
+ are sent), and also defines a class (V8DOMActivityLogger) for logger
+ objects.
+
+ * WebCore.gypi:
+ * bindings/v8/DOMWrapperWorld.cpp:
+ (WebCore):
+ (WebCore::domActivityLoggers):
+ (WebCore::DOMWrapperWorld::setDOMActivityLogger):
+ (WebCore::DOMWrapperWorld::getDOMActivityLogger):
+ * bindings/v8/DOMWrapperWorld.h:
+ (DOMWrapperWorld):
+ * bindings/v8/V8DOMActivityLogger.h: Added.
+ (WebCore):
+ (V8DOMActivityLogger):
+ (WebCore::V8DOMActivityLogger::~V8DOMActivityLogger):
+ (WebCore::V8DOMActivityLogger::log):
+
2013-02-28 Adam Barth <[email protected]>
The threaded HTML parser shouldn't need to invalidate the speculation buffer on every document.write
Modified: trunk/Source/WebCore/WebCore.gypi (144407 => 144408)
--- trunk/Source/WebCore/WebCore.gypi 2013-03-01 02:12:54 UTC (rev 144407)
+++ trunk/Source/WebCore/WebCore.gypi 2013-03-01 03:35:07 UTC (rev 144408)
@@ -1270,6 +1270,7 @@
'bindings/v8/V8Collection.h',
'bindings/v8/V8DOMConfiguration.cpp',
'bindings/v8/V8DOMConfiguration.h',
+ 'bindings/v8/V8DOMActivityLogger.h',
'bindings/v8/V8DOMWindowShell.cpp',
'bindings/v8/V8DOMWindowShell.h',
'bindings/v8/V8DOMWrapper.cpp',
Modified: trunk/Source/WebCore/bindings/v8/DOMWrapperWorld.cpp (144407 => 144408)
--- trunk/Source/WebCore/bindings/v8/DOMWrapperWorld.cpp 2013-03-01 02:12:54 UTC (rev 144407)
+++ trunk/Source/WebCore/bindings/v8/DOMWrapperWorld.cpp 2013-03-01 03:35:07 UTC (rev 144408)
@@ -33,8 +33,10 @@
#include "DOMDataStore.h"
#include "V8Binding.h"
+#include "V8DOMActivityLogger.h"
#include "V8DOMWindow.h"
#include "V8DOMWrapper.h"
+#include <wtf/HashTraits.h>
#include <wtf/MainThread.h>
#include <wtf/StdLibExtras.h>
@@ -220,4 +222,24 @@
isolatedWorldContentSecurityPolicies().remove(worldID);
}
+typedef HashMap<int, OwnPtr<V8DOMActivityLogger>, WTF::IntHash<int>, WTF::UnsignedWithZeroKeyHashTraits<int> > DOMActivityLoggerMap;
+static DOMActivityLoggerMap& domActivityLoggers()
+{
+ ASSERT(isMainThread());
+ DEFINE_STATIC_LOCAL(DOMActivityLoggerMap, map, ());
+ return map;
+}
+
+void DOMWrapperWorld::setActivityLogger(int worldId, PassOwnPtr<V8DOMActivityLogger> logger)
+{
+ domActivityLoggers().set(worldId, logger);
+}
+
+V8DOMActivityLogger* DOMWrapperWorld::activityLogger(int worldId)
+{
+ DOMActivityLoggerMap& loggers = domActivityLoggers();
+ DOMActivityLoggerMap::iterator it = loggers.find(worldId);
+ return it == loggers.end() ? 0 : it->value.get();
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/bindings/v8/DOMWrapperWorld.h (144407 => 144408)
--- trunk/Source/WebCore/bindings/v8/DOMWrapperWorld.h 2013-03-01 02:12:54 UTC (rev 144407)
+++ trunk/Source/WebCore/bindings/v8/DOMWrapperWorld.h 2013-03-01 03:35:07 UTC (rev 144408)
@@ -32,6 +32,7 @@
#define DOMWrapperWorld_h
#include "SecurityOrigin.h"
+#include "V8DOMActivityLogger.h"
#include "V8PerContextData.h"
#include <v8.h>
#include <wtf/PassRefPtr.h>
@@ -87,6 +88,11 @@
static void clearIsolatedWorldContentSecurityPolicy(int worldID);
bool isolatedWorldHasContentSecurityPolicy();
+ // Associate a logger with the world identified by worldId (worlId may be 0
+ // identifying the main world).
+ static void setActivityLogger(int worldId, PassOwnPtr<V8DOMActivityLogger>);
+ static V8DOMActivityLogger* activityLogger(int worldId);
+
// FIXME: this is a workaround for a problem in WebViewImpl.
// Do not use this anywhere else!!
static PassRefPtr<DOMWrapperWorld> createUninitializedWorld();
Added: trunk/Source/WebCore/bindings/v8/V8DOMActivityLogger.h (0 => 144408)
--- trunk/Source/WebCore/bindings/v8/V8DOMActivityLogger.h (rev 0)
+++ trunk/Source/WebCore/bindings/v8/V8DOMActivityLogger.h 2013-03-01 03:35:07 UTC (rev 144408)
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef V8DOMActivityLogger_h
+#define V8DOMActivityLogger_h
+
+#include "v8.h"
+
+namespace WebCore {
+
+class V8DOMActivityLogger {
+public:
+ virtual ~V8DOMActivityLogger() { }
+
+ virtual void log(const char* apiName, int argc, const v8::Handle<v8::Value>* argv, const char* extraInfo) { }
+};
+
+} // namespace WebCore
+
+#endif // V8DOMActivityLogger_h
Modified: trunk/Source/WebKit/chromium/ChangeLog (144407 => 144408)
--- trunk/Source/WebKit/chromium/ChangeLog 2013-03-01 02:12:54 UTC (rev 144407)
+++ trunk/Source/WebKit/chromium/ChangeLog 2013-03-01 03:35:07 UTC (rev 144408)
@@ -1,3 +1,33 @@
+2013-02-28 Ankur Taly <[email protected]>
+
+ WebKit API for enabling DOM logging for certain worlds
+ https://bugs.webkit.org/show_bug.cgi?id=110779
+
+ Reviewed by Adam Barth.
+
+ This patch adds initial plumbing for enabling logging of DOM
+ activity by _javascript_ code running withing v8, on a
+ per-world basis. In particular it adds methods to the chromium
+ WebKit API for associating a logger object with world ids for which
+ DOM activity logging is enabled.
+
+
+ * WebKit.gyp:
+ * public/WebDOMActivityLogger.h: Added.
+ (v8):
+ (WebKit):
+ (WebDOMActivityLogger):
+ (WebKit::WebDOMActivityLogger::~WebDOMActivityLogger):
+ (WebKit::WebDOMActivityLogger::log):
+ * src/WebDOMActivityLogger.cpp: Added.
+ (WebKit):
+ (DOMActivityLoggerContainer):
+ (WebKit::DOMActivityLoggerContainer::DOMActivityLoggerContainer):
+ (WebKit::DOMActivityLoggerContainer::~DOMActivityLoggerContainer):
+ (WebKit::DOMActivityLoggerContainer::log):
+ (WebKit::hasDOMActivityLogger):
+ (WebKit::setDOMActivityLogger):
+
2013-02-28 Sheriff Bot <[email protected]>
Unreviewed. Rolled Chromium DEPS to r185341. Requested by
Added: trunk/Source/WebKit/chromium/public/WebDOMActivityLogger.h (0 => 144408)
--- trunk/Source/WebKit/chromium/public/WebDOMActivityLogger.h (rev 0)
+++ trunk/Source/WebKit/chromium/public/WebDOMActivityLogger.h 2013-03-01 03:35:07 UTC (rev 144408)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebDOMActivityLogger_h
+#define WebDOMActivityLogger_h
+
+#include "../../../Platform/chromium/public/WebCommon.h"
+#include <v8.h>
+
+namespace WebKit {
+
+class WebDOMActivityLogger {
+public:
+ virtual ~WebDOMActivityLogger() { }
+ virtual void log(const char* apiName, int argc, const v8::Handle<v8::Value>* argv, const char* extraInfo) { }
+};
+
+// Checks if a logger already exists for the world identified
+// by worldId (worldId may be 0 identifying the main world).
+WEBKIT_EXPORT bool hasDOMActivityLogger(int worldId);
+
+// Checks if the provided logger is non-null and if so associates it
+// with the world identified by worldId (worldId may be 0 identifying the main world).
+WEBKIT_EXPORT void setDOMActivityLogger(int worldId, WebDOMActivityLogger*);
+
+} // namespace WebKit
+
+#endif
Added: trunk/Source/WebKit/chromium/src/WebDOMActivityLogger.cpp (0 => 144408)
--- trunk/Source/WebKit/chromium/src/WebDOMActivityLogger.cpp (rev 0)
+++ trunk/Source/WebKit/chromium/src/WebDOMActivityLogger.cpp 2013-03-01 03:35:07 UTC (rev 144408)
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebDOMActivityLogger.h"
+
+#include "DOMWrapperWorld.h"
+#include "V8DOMActivityLogger.h"
+#include <wtf/PassRefPtr.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+class DOMActivityLoggerContainer : public V8DOMActivityLogger {
+public:
+ explicit DOMActivityLoggerContainer(PassOwnPtr<WebDOMActivityLogger> logger)
+ : m_domActivityLogger(logger)
+ {
+ }
+
+ virtual void log(const char* apiName, int argc, const v8::Handle<v8::Value>* argv, const char* extraInfo)
+ {
+ m_domActivityLogger->log(apiName, argc, argv, extraInfo);
+ }
+
+private:
+ OwnPtr<WebDOMActivityLogger> m_domActivityLogger;
+};
+
+bool hasDOMActivityLogger(int worldId)
+{
+ return DOMWrapperWorld::activityLogger(worldId);
+}
+
+void setDOMActivityLogger(int worldId, WebDOMActivityLogger* logger)
+{
+ ASSERT(logger);
+ DOMWrapperWorld::setActivityLogger(worldId, adoptPtr(new DOMActivityLoggerContainer(adoptPtr(logger))));
+}
+
+} // namespace WebKit