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

Side by Side Diff: third_party/WebKit/Source/web/WebDevToolsAgentImpl.cpp

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from Kent; merge. Created 4 years, 6 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-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
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
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 void run(LocalFrame* frame) override 162 void run(LocalFrame* frame) override
161 { 163 {
162 if (m_runningForDebugBreak) 164 if (m_runningForDebugBreak)
163 return; 165 return;
164 166
165 m_runningForDebugBreak = true; 167 m_runningForDebugBreak = true;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 m_runningForCreateWindow = false; 259 m_runningForCreateWindow = false;
258 if (!m_runningForDebugBreak) 260 if (!m_runningForDebugBreak)
259 m_messageLoop->quitNow(); 261 m_messageLoop->quitNow();
260 return true; 262 return true;
261 } 263 }
262 return false; 264 return false;
263 } 265 }
264 266
265 bool m_runningForDebugBreak; 267 bool m_runningForDebugBreak;
266 bool m_runningForCreateWindow; 268 bool m_runningForCreateWindow;
267 OwnPtr<WebDevToolsAgentClient::WebKitClientMessageLoop> m_messageLoop; 269 std::unique_ptr<WebDevToolsAgentClient::WebKitClientMessageLoop> m_messageLo op;
268 typedef HashSet<WebViewImpl*> FrozenViewsSet; 270 typedef HashSet<WebViewImpl*> FrozenViewsSet;
269 FrozenViewsSet m_frozenViews; 271 FrozenViewsSet m_frozenViews;
270 WebFrameWidgetsSet m_frozenWidgets; 272 WebFrameWidgetsSet m_frozenWidgets;
271 static ClientMessageLoopAdapter* s_instance; 273 static ClientMessageLoopAdapter* s_instance;
272 }; 274 };
273 275
274 ClientMessageLoopAdapter* ClientMessageLoopAdapter::s_instance = nullptr; 276 ClientMessageLoopAdapter* ClientMessageLoopAdapter::s_instance = nullptr;
275 277
276 // static 278 // static
277 WebDevToolsAgentImpl* WebDevToolsAgentImpl::create(WebLocalFrameImpl* frame, Web DevToolsAgentClient* client) 279 WebDevToolsAgentImpl* WebDevToolsAgentImpl::create(WebLocalFrameImpl* frame, Web DevToolsAgentClient* client)
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 } 638 }
637 639
638 void WebDevToolsAgentImpl::didProcessTask() 640 void WebDevToolsAgentImpl::didProcessTask()
639 { 641 {
640 if (!attached()) 642 if (!attached())
641 return; 643 return;
642 ThreadDebugger::idleStarted(V8PerIsolateData::mainThreadIsolate()); 644 ThreadDebugger::idleStarted(V8PerIsolateData::mainThreadIsolate());
643 flushProtocolNotifications(); 645 flushProtocolNotifications();
644 } 646 }
645 647
646 void WebDevToolsAgentImpl::runDebuggerTask(int sessionId, PassOwnPtr<WebDevTools Agent::MessageDescriptor> descriptor) 648 void WebDevToolsAgentImpl::runDebuggerTask(int sessionId, std::unique_ptr<WebDev ToolsAgent::MessageDescriptor> descriptor)
647 { 649 {
648 WebDevToolsAgent* webagent = descriptor->agent(); 650 WebDevToolsAgent* webagent = descriptor->agent();
649 if (!webagent) 651 if (!webagent)
650 return; 652 return;
651 653
652 WebDevToolsAgentImpl* agentImpl = static_cast<WebDevToolsAgentImpl*>(webagen t); 654 WebDevToolsAgentImpl* agentImpl = static_cast<WebDevToolsAgentImpl*>(webagen t);
653 if (agentImpl->attached()) 655 if (agentImpl->attached())
654 agentImpl->dispatchMessageFromFrontend(sessionId, descriptor->method(), descriptor->message()); 656 agentImpl->dispatchMessageFromFrontend(sessionId, descriptor->method(), descriptor->message());
655 } 657 }
656 658
657 void WebDevToolsAgent::interruptAndDispatch(int sessionId, MessageDescriptor* ra wDescriptor) 659 void WebDevToolsAgent::interruptAndDispatch(int sessionId, MessageDescriptor* ra wDescriptor)
658 { 660 {
659 // rawDescriptor can't be a PassOwnPtr because interruptAndDispatch is a Web Kit API function. 661 // rawDescriptor can't be a std::unique_ptr because interruptAndDispatch is a WebKit API function.
660 MainThreadDebugger::interruptMainThreadAndRun(threadSafeBind(WebDevToolsAgen tImpl::runDebuggerTask, sessionId, passed(adoptPtr(rawDescriptor)))); 662 MainThreadDebugger::interruptMainThreadAndRun(threadSafeBind(WebDevToolsAgen tImpl::runDebuggerTask, sessionId, passed(wrapUnique(rawDescriptor))));
661 } 663 }
662 664
663 bool WebDevToolsAgent::shouldInterruptForMethod(const WebString& method) 665 bool WebDevToolsAgent::shouldInterruptForMethod(const WebString& method)
664 { 666 {
665 return method == "Debugger.pause" 667 return method == "Debugger.pause"
666 || method == "Debugger.setBreakpoint" 668 || method == "Debugger.setBreakpoint"
667 || method == "Debugger.setBreakpointByUrl" 669 || method == "Debugger.setBreakpointByUrl"
668 || method == "Debugger.removeBreakpoint" 670 || method == "Debugger.removeBreakpoint"
669 || method == "Debugger.setBreakpointsActive"; 671 || method == "Debugger.setBreakpointsActive";
670 } 672 }
671 673
672 } // namespace blink 674 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698