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

Unified Diff: Source/core/page/Performance.cpp

Issue 18916003: Performance.onwebkitresourcetimingbufferfull should be a Function (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/page/Performance.cpp
diff --git a/Source/core/page/Performance.cpp b/Source/core/page/Performance.cpp
index 21e2e08f2c977404659524c4b80d3b020cdc8399..0fdd70a6ba4560895a29b1a2b0d17f85ce117737 100644
--- a/Source/core/page/Performance.cpp
+++ b/Source/core/page/Performance.cpp
@@ -32,6 +32,7 @@
#include "config.h"
#include "core/page/Performance.h"
+#include "bindings/v8/ScriptFunctionCall.h"
#include "core/dom/Document.h"
#include "core/loader/DocumentLoader.h"
#include "core/page/MemoryInfo.h"
@@ -52,6 +53,7 @@ Performance::Performance(Frame* frame)
: DOMWindowProperty(frame)
, m_resourceTimingBufferSize(defaultResourceTimingBufferSize)
, m_userTiming(0)
+ , m_onwebkitresourcetimingbufferfull(v8::Null())
{
ScriptWrappable::init(this);
}
@@ -60,18 +62,6 @@ Performance::~Performance()
{
}
-const AtomicString& Performance::interfaceName() const
-{
- return eventNames().interfaceForPerformance;
-}
-
-ScriptExecutionContext* Performance::scriptExecutionContext() const
-{
- if (!frame())
- return 0;
- return frame()->document();
-}
-
PassRefPtr<MemoryInfo> Performance::memory() const
{
return MemoryInfo::create(m_frame);
@@ -152,11 +142,39 @@ void Performance::webkitClearResourceTimings()
m_resourceTimingBuffer.clear();
}
-void Performance::webkitSetResourceTimingBufferSize(unsigned size)
+void Performance::callResourceTimingBufferFullCallback(ScriptState* scriptState)
+{
+ if (!scriptState || m_onwebkitresourcetimingbufferfull.isNull())
+ return;
+
+ v8::HandleScope handleScope;
+ ScriptCallback callback(scriptState, m_onwebkitresourcetimingbufferfull);
+ v8::Handle<v8::Context> context = scriptState->context();
+ if (context.IsEmpty())
+ return;
+
+ v8::Context::Scope scope(context);
+ callback.call();
+}
+
+void Performance::webkitSetResourceTimingBufferSize(ScriptState* scriptState, unsigned size)
{
m_resourceTimingBufferSize = size;
if (isResourceTimingBufferFull())
- dispatchEvent(Event::create(eventNames().webkitresourcetimingbufferfullEvent, false, false));
+ callResourceTimingBufferFullCallback(scriptState);
+}
+
+void Performance::setOnwebkitresourcetimingbufferfull(const ScriptValue& callback)
+{
+ if (callback.isNull() || callback.isUndefined()) {
+ m_onwebkitresourcetimingbufferfull = ScriptValue(v8::Null());
+ return;
+ }
+
+ if (!callback.isFunction())
arv (Not doing code reviews) 2013/07/09 18:19:58 This is a bit inconsistent. WebIDL says throw a T
+ return;
+
+ m_onwebkitresourcetimingbufferfull = callback;
}
void Performance::addResourceTiming(const String& initiatorName, Document* initiatorDocument, const ResourceRequest& request, const ResourceResponse& response, double initiationTime, double finishTime)
@@ -169,7 +187,7 @@ void Performance::addResourceTiming(const String& initiatorName, Document* initi
m_resourceTimingBuffer.append(entry);
if (isResourceTimingBufferFull())
- dispatchEvent(Event::create(eventNames().webkitresourcetimingbufferfullEvent, false, false));
+ callResourceTimingBufferFullCallback(mainWorldScriptState(frame()));
}
bool Performance::isResourceTimingBufferFull()
@@ -177,16 +195,6 @@ bool Performance::isResourceTimingBufferFull()
return m_resourceTimingBuffer.size() >= m_resourceTimingBufferSize;
}
-EventTargetData* Performance::eventTargetData()
-{
- return &m_eventTargetData;
-}
-
-EventTargetData* Performance::ensureEventTargetData()
-{
- return &m_eventTargetData;
-}
-
void Performance::mark(const String& markName, ExceptionCode& ec)
{
ec = 0;

Powered by Google App Engine
This is Rietveld 408576698