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

Side by Side 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: fix tests 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 19 matching lines...) Expand all
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "InspectorFrontendClientLocal.h" 32 #include "InspectorFrontendClientLocal.h"
33 33
34 #include "bindings/v8/ScriptObject.h" 34 #include "bindings/v8/ScriptObject.h"
35 #include "core/inspector/InspectorController.h" 35 #include "core/inspector/InspectorController.h"
36 #include "core/inspector/InspectorFrontendHost.h" 36 #include "core/inspector/InspectorFrontendHost.h"
37 #include "core/page/Page.h" 37 #include "core/page/Page.h"
38 #include "core/page/Settings.h" 38 #include "core/page/Settings.h"
39 #include "core/platform/Timer.h" 39 #include "core/platform/Timer.h"
40 #include "public/platform/Platform.h"
41 #include "public/platform/WebThread.h"
40 #include <wtf/Deque.h> 42 #include <wtf/Deque.h>
41 #include <wtf/text/WTFString.h> 43 #include <wtf/text/WTFString.h>
42 44
43 namespace WebCore { 45 namespace WebCore {
44 46
45 class InspectorBackendDispatchTask { 47 class InspectorBackendDispatchTask {
46 WTF_MAKE_FAST_ALLOCATED; 48 WTF_MAKE_FAST_ALLOCATED;
47 public: 49 public:
48 InspectorBackendDispatchTask(InspectorController* inspectorController) 50 InspectorBackendDispatchTask(InspectorController* inspectorController)
49 : m_inspectorController(inspectorController) 51 : m_inspectorController(inspectorController)
50 , m_timer(this, &InspectorBackendDispatchTask::onTimer)
51 { 52 {
52 } 53 }
53 54
54 void dispatch(const String& message) 55 void dispatch(const String& message)
55 { 56 {
56 m_messages.append(message); 57 m_messages.append(message);
57 if (!m_timer.isActive()) 58 schedule();
58 m_timer.startOneShot(0);
59 } 59 }
60 60
61 void reset() 61 private:
62 void schedule()
62 { 63 {
63 m_messages.clear(); 64 class TaskImpl : public WebKit::WebThread::Task {
64 m_timer.stop(); 65 public:
66 InspectorBackendDispatchTask* owner;
67 virtual void run()
68 {
69 owner->onTimer();
70 }
71 };
72 TaskImpl* taskImpl = new TaskImpl;
73 taskImpl->owner = this;
74 WebKit::Platform::current()->currentThread()->postTask(taskImpl);
65 } 75 }
66 76
67 void onTimer(Timer<InspectorBackendDispatchTask>*) 77 void onTimer()
68 { 78 {
69 if (!m_messages.isEmpty()) { 79 if (!m_messages.isEmpty()) {
70 // Dispatch can lead to the timer destruction -> schedule the next s hot first. 80 // Dispatch can lead to the timer destruction -> schedule the next s hot first.
71 m_timer.startOneShot(0); 81 schedule();
72 m_inspectorController->dispatchMessageFromFrontend(m_messages.takeFi rst()); 82 m_inspectorController->dispatchMessageFromFrontend(m_messages.takeFi rst());
73 } 83 }
74 } 84 }
75 85
76 private:
77 InspectorController* m_inspectorController; 86 InspectorController* m_inspectorController;
78 Timer<InspectorBackendDispatchTask> m_timer;
79 Deque<String> m_messages; 87 Deque<String> m_messages;
80 }; 88 };
81 89
82 InspectorFrontendClientLocal::InspectorFrontendClientLocal(InspectorController* inspectorController, Page* frontendPage) 90 InspectorFrontendClientLocal::InspectorFrontendClientLocal(InspectorController* inspectorController, Page* frontendPage)
83 : m_inspectorController(inspectorController) 91 : m_inspectorController(inspectorController)
84 , m_frontendPage(frontendPage) 92 , m_frontendPage(frontendPage)
85 { 93 {
86 m_frontendPage->settings()->setAllowFileAccessFromFileURLs(true); 94 m_frontendPage->settings()->setAllowFileAccessFromFileURLs(true);
87 m_dispatchTask = adoptPtr(new InspectorBackendDispatchTask(inspectorControll er)); 95 m_dispatchTask = adoptPtr(new InspectorBackendDispatchTask(inspectorControll er));
88 } 96 }
(...skipping 15 matching lines...) Expand all
104 ScriptGlobalObject::set(frontendScriptState, "InspectorFrontendHost", m_fron tendHost.get()); 112 ScriptGlobalObject::set(frontendScriptState, "InspectorFrontendHost", m_fron tendHost.get());
105 } 113 }
106 114
107 void InspectorFrontendClientLocal::sendMessageToBackend(const String& message) 115 void InspectorFrontendClientLocal::sendMessageToBackend(const String& message)
108 { 116 {
109 m_dispatchTask->dispatch(message); 117 m_dispatchTask->dispatch(message);
110 } 118 }
111 119
112 } // namespace WebCore 120 } // namespace WebCore
113 121
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698