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

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: rebase 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
« no previous file with comments | « Source/core/testing/InspectorFrontendClientLocal.h ('k') | Source/web/WebDevToolsAgentImpl.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/testing/InspectorFrontendClientLocal.cpp
diff --git a/Source/core/testing/InspectorFrontendClientLocal.cpp b/Source/core/testing/InspectorFrontendClientLocal.cpp
index decd7d00020b63b0971707d9aa752e4624479d9c..a68a070d155b3be61305107b3fa6af9f10cef388 100644
--- a/Source/core/testing/InspectorFrontendClientLocal.cpp
+++ b/Source/core/testing/InspectorFrontendClientLocal.cpp
@@ -37,45 +37,62 @@
#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>
namespace WebCore {
-class InspectorBackendDispatchTask {
+class InspectorBackendMessageQueue : public RefCounted<InspectorBackendMessageQueue> {
WTF_MAKE_FAST_ALLOCATED;
public:
- InspectorBackendDispatchTask(InspectorController* inspectorController)
+ explicit InspectorBackendMessageQueue(InspectorController* inspectorController)
: m_inspectorController(inspectorController)
- , m_timer(this, &InspectorBackendDispatchTask::onTimer)
{
}
void dispatch(const String& message)
{
+ ASSERT(m_inspectorController);
m_messages.append(message);
- if (!m_timer.isActive())
- m_timer.startOneShot(0);
+ schedule();
}
- void reset()
+ void stop()
{
+ m_inspectorController = 0;
m_messages.clear();
- m_timer.stop();
}
- void onTimer(Timer<InspectorBackendDispatchTask>*)
+private:
+ void schedule()
{
+ class TaskImpl : public WebKit::WebThread::Task {
+ public:
+ RefPtr<InspectorBackendMessageQueue> owner;
+ virtual void run()
+ {
+ owner->deliver();
+ }
+ };
+ TaskImpl* taskImpl = new TaskImpl;
+ taskImpl->owner = this;
+ WebKit::Platform::current()->currentThread()->postTask(taskImpl);
+ }
+
+ void deliver()
+ {
+ if (!m_inspectorController)
+ return;
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;
};
@@ -84,11 +101,12 @@ InspectorFrontendClientLocal::InspectorFrontendClientLocal(InspectorController*
, m_frontendPage(frontendPage)
{
m_frontendPage->settings()->setAllowFileAccessFromFileURLs(true);
- m_dispatchTask = adoptPtr(new InspectorBackendDispatchTask(inspectorController));
+ m_messageQueue = adoptRef(new InspectorBackendMessageQueue(inspectorController));
}
InspectorFrontendClientLocal::~InspectorFrontendClientLocal()
{
+ m_messageQueue->stop();
if (m_frontendHost)
m_frontendHost->disconnectClient();
m_frontendPage = 0;
@@ -106,7 +124,7 @@ void InspectorFrontendClientLocal::windowObjectCleared()
void InspectorFrontendClientLocal::sendMessageToBackend(const String& message)
{
- m_dispatchTask->dispatch(message);
+ m_messageQueue->dispatch(message);
}
} // namespace WebCore
« no previous file with comments | « Source/core/testing/InspectorFrontendClientLocal.h ('k') | Source/web/WebDevToolsAgentImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698