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