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

Unified Diff: Source/core/testing/InspectorFrontendClientLocal.cpp

Issue 18729002: Enable message delivering in inspector-protocol tests when on pause (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
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/testing/InspectorFrontendClientLocal.cpp
diff --git a/Source/core/testing/InspectorFrontendClientLocal.cpp b/Source/core/testing/InspectorFrontendClientLocal.cpp
index decd7d00020b63b0971707d9aa752e4624479d9c..191736f86876a6915c850a26555da36f8af494e5 100644
--- a/Source/core/testing/InspectorFrontendClientLocal.cpp
+++ b/Source/core/testing/InspectorFrontendClientLocal.cpp
@@ -37,6 +37,8 @@
#include "core/page/Page.h"
#include "core/page/Settings.h"
#include "core/platform/Timer.h"
+#include "public/platform/Platform.h"
+#include "public/platform/WebThread.h"
#include <wtf/Deque.h>
#include <wtf/text/WTFString.h>
@@ -47,35 +49,46 @@ class InspectorBackendDispatchTask {
public:
InspectorBackendDispatchTask(InspectorController* inspectorController)
: m_inspectorController(inspectorController)
- , m_timer(this, &InspectorBackendDispatchTask::onTimer)
{
}
void dispatch(const String& message)
{
m_messages.append(message);
- if (!m_timer.isActive())
- m_timer.startOneShot(0);
+ schedule();
}
void reset()
{
m_messages.clear();
- m_timer.stop();
}
- void onTimer(Timer<InspectorBackendDispatchTask>*)
+private:
+ void schedule()
+ {
+ class TaskImpl : public WebKit::WebThread::Task {
+ public:
+ InspectorBackendDispatchTask* owner;
+ virtual void run()
+ {
+ owner->onTimer();
aandrey 2013/07/05 09:31:56 can this execute after owner is destructed?
Peter.Rybin 2013/07/10 21:24:25 I guess the old implementation didn't care about i
+ }
+ };
+ TaskImpl* taskImpl = new TaskImpl;
+ taskImpl->owner = this;
+ WebKit::Platform::current()->currentThread()->postDelayedTask(taskImpl, 0);
yurys 2013/07/08 11:13:04 Does it guarantee the sequence of execution for th
Peter.Rybin 2013/07/08 12:23:38 You mean order of execution? I am not sure. But an
yurys 2013/07/08 13:16:11 You are right. But if the order of execution is gu
+ }
+
+ void onTimer()
{
if (!m_messages.isEmpty()) {
// Dispatch can lead to the timer destruction -> schedule the next shot first.
- m_timer.startOneShot(0);
+ schedule();
m_inspectorController->dispatchMessageFromFrontend(m_messages.takeFirst());
}
}
-private:
InspectorController* m_inspectorController;
- Timer<InspectorBackendDispatchTask> m_timer;
Deque<String> m_messages;
};
« Source/bindings/v8/PageScriptDebugServer.h ('K') | « Source/bindings/v8/PageScriptDebugServer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698