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

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

Issue 1880273002: [DevTools] Create last agents on attach, modify InspectorDatabaseAgent to support it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: two databases in the test Created 4 years, 8 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
« no previous file with comments | « third_party/WebKit/Source/web/WebDevToolsAgentImpl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 #include "web/WebInputEventConversion.h" 93 #include "web/WebInputEventConversion.h"
94 #include "web/WebLocalFrameImpl.h" 94 #include "web/WebLocalFrameImpl.h"
95 #include "web/WebSettingsImpl.h" 95 #include "web/WebSettingsImpl.h"
96 #include "web/WebViewImpl.h" 96 #include "web/WebViewImpl.h"
97 #include "wtf/MathExtras.h" 97 #include "wtf/MathExtras.h"
98 #include "wtf/Noncopyable.h" 98 #include "wtf/Noncopyable.h"
99 #include "wtf/text/WTFString.h" 99 #include "wtf/text/WTFString.h"
100 100
101 namespace blink { 101 namespace blink {
102 102
103 namespace {
104
105 bool isMainFrame(WebLocalFrameImpl* frame)
106 {
107 // TODO(dgozman): sometimes view->mainFrameImpl() does return null, even tho ugh |frame| is meant to be main frame.
108 // See http://crbug.com/526162.
109 return frame->viewImpl() && !frame->parent();
110 }
111
112 }
113
103 class ClientMessageLoopAdapter : public MainThreadDebugger::ClientMessageLoop { 114 class ClientMessageLoopAdapter : public MainThreadDebugger::ClientMessageLoop {
104 public: 115 public:
105 ~ClientMessageLoopAdapter() override 116 ~ClientMessageLoopAdapter() override
106 { 117 {
107 s_instance = nullptr; 118 s_instance = nullptr;
108 } 119 }
109 120
110 static void ensureMainThreadDebuggerCreated(WebDevToolsAgentClient* client) 121 static void ensureMainThreadDebuggerCreated(WebDevToolsAgentClient* client)
111 { 122 {
112 if (s_instance) 123 if (s_instance)
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 FrozenViewsSet m_frozenViews; 272 FrozenViewsSet m_frozenViews;
262 WebFrameWidgetsSet m_frozenWidgets; 273 WebFrameWidgetsSet m_frozenWidgets;
263 static ClientMessageLoopAdapter* s_instance; 274 static ClientMessageLoopAdapter* s_instance;
264 }; 275 };
265 276
266 ClientMessageLoopAdapter* ClientMessageLoopAdapter::s_instance = nullptr; 277 ClientMessageLoopAdapter* ClientMessageLoopAdapter::s_instance = nullptr;
267 278
268 // static 279 // static
269 WebDevToolsAgentImpl* WebDevToolsAgentImpl::create(WebLocalFrameImpl* frame, Web DevToolsAgentClient* client) 280 WebDevToolsAgentImpl* WebDevToolsAgentImpl::create(WebLocalFrameImpl* frame, Web DevToolsAgentClient* client)
270 { 281 {
271 WebViewImpl* view = frame->viewImpl(); 282 if (!isMainFrame(frame)) {
272 // TODO(dgozman): sometimes view->mainFrameImpl() does return null, even tho ugh |frame| is meant to be main frame. 283 WebDevToolsAgentImpl* agent = new WebDevToolsAgentImpl(frame, client, nu llptr, false);
273 // See http://crbug.com/526162.
274 bool isMainFrame = view && !frame->parent();
275 if (!isMainFrame) {
276 WebDevToolsAgentImpl* agent = new WebDevToolsAgentImpl(frame, client, nu llptr);
277 if (frame->frameWidget()) 284 if (frame->frameWidget())
278 agent->layerTreeViewChanged(toWebFrameWidgetImpl(frame->frameWidget( ))->layerTreeView()); 285 agent->layerTreeViewChanged(toWebFrameWidgetImpl(frame->frameWidget( ))->layerTreeView());
279 return agent; 286 return agent;
280 } 287 }
281 288
282 WebDevToolsAgentImpl* agent = new WebDevToolsAgentImpl(frame, client, Inspec torOverlay::create(view)); 289 WebViewImpl* view = frame->viewImpl();
283 // TODO(dgozman): we should actually pass the view instead of frame, but dur ing 290 WebDevToolsAgentImpl* agent = new WebDevToolsAgentImpl(frame, client, Inspec torOverlay::create(view), true);
284 // remote->local transition we cannot access mainFrameImpl() yet, so we have to store the
285 // frame which will become the main frame later.
286 agent->m_agents.append(InspectorRenderingAgent::create(frame, agent->m_overl ay.get()));
287 agent->m_agents.append(InspectorEmulationAgent::create(frame, agent));
288 // TODO(dgozman): migrate each of the following agents to frame once module is ready.
289 agent->m_agents.append(InspectorDatabaseAgent::create(view->page()));
290 agent->m_agents.append(DeviceOrientationInspectorAgent::create(view->page()) );
291 agent->m_agents.append(InspectorAccessibilityAgent::create(view->page()));
292 agent->m_agents.append(InspectorDOMStorageAgent::create(view->page()));
293 agent->m_agents.append(InspectorCacheStorageAgent::create());
294 agent->layerTreeViewChanged(view->layerTreeView()); 291 agent->layerTreeViewChanged(view->layerTreeView());
295 return agent; 292 return agent;
296 } 293 }
297 294
298 WebDevToolsAgentImpl::WebDevToolsAgentImpl( 295 WebDevToolsAgentImpl::WebDevToolsAgentImpl(
299 WebLocalFrameImpl* webLocalFrameImpl, 296 WebLocalFrameImpl* webLocalFrameImpl,
300 WebDevToolsAgentClient* client, 297 WebDevToolsAgentClient* client,
301 InspectorOverlay* overlay) 298 InspectorOverlay* overlay,
299 bool includeViewAgents)
302 : m_client(client) 300 : m_client(client)
303 , m_webLocalFrameImpl(webLocalFrameImpl) 301 , m_webLocalFrameImpl(webLocalFrameImpl)
304 , m_attached(false) 302 , m_attached(false)
305 #if DCHECK_IS_ON() 303 #if DCHECK_IS_ON()
306 , m_hasBeenDisposed(false) 304 , m_hasBeenDisposed(false)
307 #endif 305 #endif
308 , m_instrumentingAgents(m_webLocalFrameImpl->frame()->instrumentingAgents()) 306 , m_instrumentingAgents(m_webLocalFrameImpl->frame()->instrumentingAgents())
309 , m_resourceContentLoader(InspectorResourceContentLoader::create(m_webLocalF rameImpl->frame())) 307 , m_resourceContentLoader(InspectorResourceContentLoader::create(m_webLocalF rameImpl->frame()))
310 , m_overlay(overlay) 308 , m_overlay(overlay)
311 , m_inspectedFrames(InspectedFrames::create(m_webLocalFrameImpl->frame())) 309 , m_inspectedFrames(InspectedFrames::create(m_webLocalFrameImpl->frame()))
312 , m_domAgent(nullptr) 310 , m_domAgent(nullptr)
313 , m_pageAgent(nullptr) 311 , m_pageAgent(nullptr)
314 , m_resourceAgent(nullptr) 312 , m_resourceAgent(nullptr)
315 , m_layerTreeAgent(nullptr) 313 , m_layerTreeAgent(nullptr)
316 , m_tracingAgent(nullptr) 314 , m_tracingAgent(nullptr)
317 , m_agents(m_instrumentingAgents.get()) 315 , m_agents(m_instrumentingAgents.get())
318 , m_deferredAgentsInitialized(false) 316 , m_deferredAgentsInitialized(false)
317 , m_includeViewAgents(includeViewAgents)
319 , m_sessionId(0) 318 , m_sessionId(0)
320 , m_stateMuted(false) 319 , m_stateMuted(false)
321 , m_layerTreeId(0) 320 , m_layerTreeId(0)
322 { 321 {
323 DCHECK(isMainThread()); 322 DCHECK(isMainThread());
324 DCHECK(m_webLocalFrameImpl->frame()); 323 DCHECK(m_webLocalFrameImpl->frame());
325 } 324 }
326 325
327 WebDevToolsAgentImpl::~WebDevToolsAgentImpl() 326 WebDevToolsAgentImpl::~WebDevToolsAgentImpl()
328 { 327 {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 m_agents.append(InspectorProfilerAgent::create(m_v8Session->profilerAgent(), m_overlay.get())); 439 m_agents.append(InspectorProfilerAgent::create(m_v8Session->profilerAgent(), m_overlay.get()));
441 440
442 m_agents.append(InspectorHeapProfilerAgent::create(isolate, m_v8Session->hea pProfilerAgent())); 441 m_agents.append(InspectorHeapProfilerAgent::create(isolate, m_v8Session->hea pProfilerAgent()));
443 442
444 InspectorPageAgent* pageAgent = InspectorPageAgent::create(m_inspectedFrames .get(), this, m_resourceContentLoader.get(), debuggerAgent); 443 InspectorPageAgent* pageAgent = InspectorPageAgent::create(m_inspectedFrames .get(), this, m_resourceContentLoader.get(), debuggerAgent);
445 m_pageAgent = pageAgent; 444 m_pageAgent = pageAgent;
446 m_agents.append(pageAgent); 445 m_agents.append(pageAgent);
447 446
448 runtimeAgent->setClearConsoleCallback(bind<>(&InspectorConsoleAgent::clearAl lMessages, pageConsoleAgent)); 447 runtimeAgent->setClearConsoleCallback(bind<>(&InspectorConsoleAgent::clearAl lMessages, pageConsoleAgent));
449 m_tracingAgent->setLayerTreeId(m_layerTreeId); 448 m_tracingAgent->setLayerTreeId(m_layerTreeId);
449
450 if (m_includeViewAgents) {
451 // TODO(dgozman): we should actually pass the view instead of frame, but during
452 // remote->local transition we cannot access mainFrameImpl() yet, so we have to store the
453 // frame which will become the main frame later.
454 m_agents.append(InspectorRenderingAgent::create(m_webLocalFrameImpl, m_o verlay.get()));
455 m_agents.append(InspectorEmulationAgent::create(m_webLocalFrameImpl, thi s));
456 // TODO(dgozman): migrate each of the following agents to frame once mod ule is ready.
457 Page* page = m_webLocalFrameImpl->viewImpl()->page();
458 m_agents.append(InspectorDatabaseAgent::create(page));
459 m_agents.append(DeviceOrientationInspectorAgent::create(page));
460 m_agents.append(InspectorAccessibilityAgent::create(page));
461 m_agents.append(InspectorDOMStorageAgent::create(page));
462 m_agents.append(InspectorCacheStorageAgent::create());
463 }
464
450 if (m_overlay) 465 if (m_overlay)
451 m_overlay->init(cssAgent, debuggerAgent, m_domAgent); 466 m_overlay->init(cssAgent, debuggerAgent, m_domAgent);
452 } 467 }
453 468
454 void WebDevToolsAgentImpl::attach(const WebString& hostId, int sessionId) 469 void WebDevToolsAgentImpl::attach(const WebString& hostId, int sessionId)
455 { 470 {
456 if (m_attached) 471 if (m_attached)
457 return; 472 return;
458 473
459 // Set the attached bit first so that sync notifications were delivered. 474 // Set the attached bit first so that sync notifications were delivered.
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 if (!protocol::Dispatcher::getCommandName(message, &commandName)) 734 if (!protocol::Dispatcher::getCommandName(message, &commandName))
720 return false; 735 return false;
721 return commandName == "Debugger.pause" 736 return commandName == "Debugger.pause"
722 || commandName == "Debugger.setBreakpoint" 737 || commandName == "Debugger.setBreakpoint"
723 || commandName == "Debugger.setBreakpointByUrl" 738 || commandName == "Debugger.setBreakpointByUrl"
724 || commandName == "Debugger.removeBreakpoint" 739 || commandName == "Debugger.removeBreakpoint"
725 || commandName == "Debugger.setBreakpointsActive"; 740 || commandName == "Debugger.setBreakpointsActive";
726 } 741 }
727 742
728 } // namespace blink 743 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebDevToolsAgentImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698