| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010-2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2010-2011 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 #include "web/InspectorEmulationAgent.h" | 83 #include "web/InspectorEmulationAgent.h" |
| 84 #include "web/InspectorOverlay.h" | 84 #include "web/InspectorOverlay.h" |
| 85 #include "web/InspectorRenderingAgent.h" | 85 #include "web/InspectorRenderingAgent.h" |
| 86 #include "web/WebFrameWidgetImpl.h" | 86 #include "web/WebFrameWidgetImpl.h" |
| 87 #include "web/WebInputEventConversion.h" | 87 #include "web/WebInputEventConversion.h" |
| 88 #include "web/WebLocalFrameImpl.h" | 88 #include "web/WebLocalFrameImpl.h" |
| 89 #include "web/WebSettingsImpl.h" | 89 #include "web/WebSettingsImpl.h" |
| 90 #include "web/WebViewImpl.h" | 90 #include "web/WebViewImpl.h" |
| 91 #include "wtf/MathExtras.h" | 91 #include "wtf/MathExtras.h" |
| 92 #include "wtf/Noncopyable.h" | 92 #include "wtf/Noncopyable.h" |
| 93 #include "wtf/PtrUtil.h" | |
| 94 #include "wtf/text/WTFString.h" | 93 #include "wtf/text/WTFString.h" |
| 95 #include <memory> | |
| 96 | 94 |
| 97 namespace blink { | 95 namespace blink { |
| 98 | 96 |
| 99 namespace { | 97 namespace { |
| 100 | 98 |
| 101 bool isMainFrame(WebLocalFrameImpl* frame) | 99 bool isMainFrame(WebLocalFrameImpl* frame) |
| 102 { | 100 { |
| 103 // TODO(dgozman): sometimes view->mainFrameImpl() does return null, even tho
ugh |frame| is meant to be main frame. | 101 // TODO(dgozman): sometimes view->mainFrameImpl() does return null, even tho
ugh |frame| is meant to be main frame. |
| 104 // See http://crbug.com/526162. | 102 // See http://crbug.com/526162. |
| 105 return frame->viewImpl() && !frame->parent(); | 103 return frame->viewImpl() && !frame->parent(); |
| 106 } | 104 } |
| 107 | 105 |
| 108 } | 106 } |
| 109 | 107 |
| 110 class ClientMessageLoopAdapter : public MainThreadDebugger::ClientMessageLoop { | 108 class ClientMessageLoopAdapter : public MainThreadDebugger::ClientMessageLoop { |
| 111 public: | 109 public: |
| 112 ~ClientMessageLoopAdapter() override | 110 ~ClientMessageLoopAdapter() override |
| 113 { | 111 { |
| 114 s_instance = nullptr; | 112 s_instance = nullptr; |
| 115 } | 113 } |
| 116 | 114 |
| 117 static void ensureMainThreadDebuggerCreated(WebDevToolsAgentClient* client) | 115 static void ensureMainThreadDebuggerCreated(WebDevToolsAgentClient* client) |
| 118 { | 116 { |
| 119 if (s_instance) | 117 if (s_instance) |
| 120 return; | 118 return; |
| 121 std::unique_ptr<ClientMessageLoopAdapter> instance = wrapUnique(new Clie
ntMessageLoopAdapter(wrapUnique(client->createClientMessageLoop()))); | 119 OwnPtr<ClientMessageLoopAdapter> instance = adoptPtr(new ClientMessageLo
opAdapter(adoptPtr(client->createClientMessageLoop()))); |
| 122 s_instance = instance.get(); | 120 s_instance = instance.get(); |
| 123 MainThreadDebugger::instance()->setClientMessageLoop(std::move(instance)
); | 121 MainThreadDebugger::instance()->setClientMessageLoop(std::move(instance)
); |
| 124 } | 122 } |
| 125 | 123 |
| 126 static void webViewImplClosed(WebViewImpl* view) | 124 static void webViewImplClosed(WebViewImpl* view) |
| 127 { | 125 { |
| 128 if (s_instance) | 126 if (s_instance) |
| 129 s_instance->m_frozenViews.remove(view); | 127 s_instance->m_frozenViews.remove(view); |
| 130 } | 128 } |
| 131 | 129 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 147 if (s_instance) | 145 if (s_instance) |
| 148 s_instance->runForCreateWindow(frame); | 146 s_instance->runForCreateWindow(frame); |
| 149 } | 147 } |
| 150 | 148 |
| 151 static bool resumeForCreateWindow() | 149 static bool resumeForCreateWindow() |
| 152 { | 150 { |
| 153 return s_instance ? s_instance->quitForCreateWindow() : false; | 151 return s_instance ? s_instance->quitForCreateWindow() : false; |
| 154 } | 152 } |
| 155 | 153 |
| 156 private: | 154 private: |
| 157 ClientMessageLoopAdapter(std::unique_ptr<WebDevToolsAgentClient::WebKitClien
tMessageLoop> messageLoop) | 155 ClientMessageLoopAdapter(PassOwnPtr<WebDevToolsAgentClient::WebKitClientMess
ageLoop> messageLoop) |
| 158 : m_runningForDebugBreak(false) | 156 : m_runningForDebugBreak(false) |
| 159 , m_runningForCreateWindow(false) | 157 , m_runningForCreateWindow(false) |
| 160 , m_messageLoop(std::move(messageLoop)) | 158 , m_messageLoop(std::move(messageLoop)) |
| 161 { | 159 { |
| 162 DCHECK(m_messageLoop.get()); | 160 DCHECK(m_messageLoop.get()); |
| 163 } | 161 } |
| 164 | 162 |
| 165 void run(LocalFrame* frame) override | 163 void run(LocalFrame* frame) override |
| 166 { | 164 { |
| 167 if (m_runningForDebugBreak) | 165 if (m_runningForDebugBreak) |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 m_runningForCreateWindow = false; | 260 m_runningForCreateWindow = false; |
| 263 if (!m_runningForDebugBreak) | 261 if (!m_runningForDebugBreak) |
| 264 m_messageLoop->quitNow(); | 262 m_messageLoop->quitNow(); |
| 265 return true; | 263 return true; |
| 266 } | 264 } |
| 267 return false; | 265 return false; |
| 268 } | 266 } |
| 269 | 267 |
| 270 bool m_runningForDebugBreak; | 268 bool m_runningForDebugBreak; |
| 271 bool m_runningForCreateWindow; | 269 bool m_runningForCreateWindow; |
| 272 std::unique_ptr<WebDevToolsAgentClient::WebKitClientMessageLoop> m_messageLo
op; | 270 OwnPtr<WebDevToolsAgentClient::WebKitClientMessageLoop> m_messageLoop; |
| 273 typedef HashSet<WebViewImpl*> FrozenViewsSet; | 271 typedef HashSet<WebViewImpl*> FrozenViewsSet; |
| 274 FrozenViewsSet m_frozenViews; | 272 FrozenViewsSet m_frozenViews; |
| 275 WebFrameWidgetsSet m_frozenWidgets; | 273 WebFrameWidgetsSet m_frozenWidgets; |
| 276 static ClientMessageLoopAdapter* s_instance; | 274 static ClientMessageLoopAdapter* s_instance; |
| 277 }; | 275 }; |
| 278 | 276 |
| 279 ClientMessageLoopAdapter* ClientMessageLoopAdapter::s_instance = nullptr; | 277 ClientMessageLoopAdapter* ClientMessageLoopAdapter::s_instance = nullptr; |
| 280 | 278 |
| 281 // static | 279 // static |
| 282 WebDevToolsAgentImpl* WebDevToolsAgentImpl::create(WebLocalFrameImpl* frame, Web
DevToolsAgentClient* client) | 280 WebDevToolsAgentImpl* WebDevToolsAgentImpl::create(WebLocalFrameImpl* frame, Web
DevToolsAgentClient* client) |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 } | 639 } |
| 642 | 640 |
| 643 void WebDevToolsAgentImpl::didProcessTask() | 641 void WebDevToolsAgentImpl::didProcessTask() |
| 644 { | 642 { |
| 645 if (!attached()) | 643 if (!attached()) |
| 646 return; | 644 return; |
| 647 ThreadDebugger::idleStarted(V8PerIsolateData::mainThreadIsolate()); | 645 ThreadDebugger::idleStarted(V8PerIsolateData::mainThreadIsolate()); |
| 648 flushProtocolNotifications(); | 646 flushProtocolNotifications(); |
| 649 } | 647 } |
| 650 | 648 |
| 651 void WebDevToolsAgentImpl::runDebuggerTask(int sessionId, std::unique_ptr<WebDev
ToolsAgent::MessageDescriptor> descriptor) | 649 void WebDevToolsAgentImpl::runDebuggerTask(int sessionId, PassOwnPtr<WebDevTools
Agent::MessageDescriptor> descriptor) |
| 652 { | 650 { |
| 653 WebDevToolsAgent* webagent = descriptor->agent(); | 651 WebDevToolsAgent* webagent = descriptor->agent(); |
| 654 if (!webagent) | 652 if (!webagent) |
| 655 return; | 653 return; |
| 656 | 654 |
| 657 WebDevToolsAgentImpl* agentImpl = static_cast<WebDevToolsAgentImpl*>(webagen
t); | 655 WebDevToolsAgentImpl* agentImpl = static_cast<WebDevToolsAgentImpl*>(webagen
t); |
| 658 if (agentImpl->attached()) | 656 if (agentImpl->attached()) |
| 659 agentImpl->dispatchMessageFromFrontend(sessionId, descriptor->method(),
descriptor->message()); | 657 agentImpl->dispatchMessageFromFrontend(sessionId, descriptor->method(),
descriptor->message()); |
| 660 } | 658 } |
| 661 | 659 |
| 662 void WebDevToolsAgent::interruptAndDispatch(int sessionId, MessageDescriptor* ra
wDescriptor) | 660 void WebDevToolsAgent::interruptAndDispatch(int sessionId, MessageDescriptor* ra
wDescriptor) |
| 663 { | 661 { |
| 664 // rawDescriptor can't be a std::unique_ptr because interruptAndDispatch is
a WebKit API function. | 662 // rawDescriptor can't be a PassOwnPtr because interruptAndDispatch is a Web
Kit API function. |
| 665 MainThreadDebugger::interruptMainThreadAndRun(threadSafeBind(WebDevToolsAgen
tImpl::runDebuggerTask, sessionId, passed(wrapUnique(rawDescriptor)))); | 663 MainThreadDebugger::interruptMainThreadAndRun(threadSafeBind(WebDevToolsAgen
tImpl::runDebuggerTask, sessionId, passed(adoptPtr(rawDescriptor)))); |
| 666 } | 664 } |
| 667 | 665 |
| 668 bool WebDevToolsAgent::shouldInterruptForMethod(const WebString& method) | 666 bool WebDevToolsAgent::shouldInterruptForMethod(const WebString& method) |
| 669 { | 667 { |
| 670 return method == "Debugger.pause" | 668 return method == "Debugger.pause" |
| 671 || method == "Debugger.setBreakpoint" | 669 || method == "Debugger.setBreakpoint" |
| 672 || method == "Debugger.setBreakpointByUrl" | 670 || method == "Debugger.setBreakpointByUrl" |
| 673 || method == "Debugger.removeBreakpoint" | 671 || method == "Debugger.removeBreakpoint" |
| 674 || method == "Debugger.setBreakpointsActive"; | 672 || method == "Debugger.setBreakpointsActive"; |
| 675 } | 673 } |
| 676 | 674 |
| 677 } // namespace blink | 675 } // namespace blink |
| OLD | NEW |