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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 : m_running(false) | 110 : m_running(false) |
111 , m_messageLoop(messageLoop) { } | 111 , m_messageLoop(messageLoop) { } |
112 | 112 |
113 | 113 |
114 virtual void run(Page* page) | 114 virtual void run(Page* page) |
115 { | 115 { |
116 if (m_running) | 116 if (m_running) |
117 return; | 117 return; |
118 m_running = true; | 118 m_running = true; |
119 | 119 |
| 120 // 0. Flush pending frontend messages. |
| 121 WebViewImpl* viewImpl = WebViewImpl::fromPage(page); |
| 122 WebDevToolsAgentImpl* agent = static_cast<WebDevToolsAgentImpl*>(viewImp
l->devToolsAgent()); |
| 123 agent->flushPendingFrontendMessages(); |
| 124 |
120 Vector<WebViewImpl*> views; | 125 Vector<WebViewImpl*> views; |
121 | 126 |
122 // 1. Disable input events. | 127 // 1. Disable input events. |
123 const HashSet<Page*>& pages = Page::ordinaryPages(); | 128 const HashSet<Page*>& pages = Page::ordinaryPages(); |
124 HashSet<Page*>::const_iterator end = pages.end(); | 129 HashSet<Page*>::const_iterator end = pages.end(); |
125 for (HashSet<Page*>::const_iterator it = pages.begin(); it != end; ++it
) { | 130 for (HashSet<Page*>::const_iterator it = pages.begin(); it != end; ++it
) { |
126 WebViewImpl* view = WebViewImpl::fromPage(*it); | 131 WebViewImpl* view = WebViewImpl::fromPage(*it); |
127 if (!view) | 132 if (!view) |
128 continue; | 133 continue; |
129 m_frozenViews.add(view); | 134 m_frozenViews.add(view); |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 m_webViewImpl->removePageOverlay(this); | 565 m_webViewImpl->removePageOverlay(this); |
561 } | 566 } |
562 | 567 |
563 void WebDevToolsAgentImpl::sendMessageToFrontend(PassRefPtr<WebCore::JSONObject>
message) | 568 void WebDevToolsAgentImpl::sendMessageToFrontend(PassRefPtr<WebCore::JSONObject>
message) |
564 { | 569 { |
565 m_frontendMessageQueue.append(message); | 570 m_frontendMessageQueue.append(message); |
566 } | 571 } |
567 | 572 |
568 void WebDevToolsAgentImpl::flush() | 573 void WebDevToolsAgentImpl::flush() |
569 { | 574 { |
570 for (size_t i = 0; i < m_frontendMessageQueue.size(); ++i) | 575 flushPendingFrontendMessages(); |
571 m_client->sendMessageToInspectorFrontend(m_frontendMessageQueue[i]->toJS
ONString()); | |
572 m_frontendMessageQueue.clear(); | |
573 } | 576 } |
574 | 577 |
575 void WebDevToolsAgentImpl::updateInspectorStateCookie(const String& state) | 578 void WebDevToolsAgentImpl::updateInspectorStateCookie(const String& state) |
576 { | 579 { |
577 m_client->saveAgentRuntimeState(state); | 580 m_client->saveAgentRuntimeState(state); |
578 } | 581 } |
579 | 582 |
580 void WebDevToolsAgentImpl::clearBrowserCache() | 583 void WebDevToolsAgentImpl::clearBrowserCache() |
581 { | 584 { |
582 m_client->clearBrowserCache(); | 585 m_client->clearBrowserCache(); |
(...skipping 13 matching lines...) Expand all Loading... |
596 { | 599 { |
597 inspectorController()->setLayerTreeId(layerTreeId); | 600 inspectorController()->setLayerTreeId(layerTreeId); |
598 } | 601 } |
599 | 602 |
600 void WebDevToolsAgentImpl::evaluateInWebInspector(long callId, const WebString&
script) | 603 void WebDevToolsAgentImpl::evaluateInWebInspector(long callId, const WebString&
script) |
601 { | 604 { |
602 InspectorController* ic = inspectorController(); | 605 InspectorController* ic = inspectorController(); |
603 ic->evaluateForTestInFrontend(callId, script); | 606 ic->evaluateForTestInFrontend(callId, script); |
604 } | 607 } |
605 | 608 |
| 609 void WebDevToolsAgentImpl::flushPendingFrontendMessages() |
| 610 { |
| 611 InspectorController* ic = inspectorController(); |
| 612 ic->flushPendingFrontendMessages(); |
| 613 |
| 614 for (size_t i = 0; i < m_frontendMessageQueue.size(); ++i) |
| 615 m_client->sendMessageToInspectorFrontend(m_frontendMessageQueue[i]->toJS
ONString()); |
| 616 m_frontendMessageQueue.clear(); |
| 617 } |
| 618 |
606 void WebDevToolsAgentImpl::willProcessTask() | 619 void WebDevToolsAgentImpl::willProcessTask() |
607 { | 620 { |
| 621 if (!m_attached) |
| 622 return; |
608 if (InspectorController* ic = inspectorController()) | 623 if (InspectorController* ic = inspectorController()) |
609 ic->willProcessTask(); | 624 ic->willProcessTask(); |
610 } | 625 } |
611 | 626 |
612 void WebDevToolsAgentImpl::didProcessTask() | 627 void WebDevToolsAgentImpl::didProcessTask() |
613 { | 628 { |
| 629 if (!m_attached) |
| 630 return; |
614 if (InspectorController* ic = inspectorController()) | 631 if (InspectorController* ic = inspectorController()) |
615 ic->didProcessTask(); | 632 ic->didProcessTask(); |
616 if (m_attached) | 633 flushPendingFrontendMessages(); |
617 flush(); | |
618 } | 634 } |
619 | 635 |
620 WebString WebDevToolsAgent::inspectorProtocolVersion() | 636 WebString WebDevToolsAgent::inspectorProtocolVersion() |
621 { | 637 { |
622 return WebCore::inspectorProtocolVersion(); | 638 return WebCore::inspectorProtocolVersion(); |
623 } | 639 } |
624 | 640 |
625 bool WebDevToolsAgent::supportsInspectorProtocolVersion(const WebString& version
) | 641 bool WebDevToolsAgent::supportsInspectorProtocolVersion(const WebString& version
) |
626 { | 642 { |
627 return WebCore::supportsInspectorProtocolVersion(version); | 643 return WebCore::supportsInspectorProtocolVersion(version); |
(...skipping 20 matching lines...) Expand all Loading... |
648 || commandName == InspectorBackendDispatcher::commandName(InspectorBacke
ndDispatcher::kProfiler_startCmd) | 664 || commandName == InspectorBackendDispatcher::commandName(InspectorBacke
ndDispatcher::kProfiler_startCmd) |
649 || commandName == InspectorBackendDispatcher::commandName(InspectorBacke
ndDispatcher::kProfiler_stopCmd); | 665 || commandName == InspectorBackendDispatcher::commandName(InspectorBacke
ndDispatcher::kProfiler_stopCmd); |
650 } | 666 } |
651 | 667 |
652 void WebDevToolsAgent::processPendingMessages() | 668 void WebDevToolsAgent::processPendingMessages() |
653 { | 669 { |
654 PageScriptDebugServer::shared().runPendingTasks(); | 670 PageScriptDebugServer::shared().runPendingTasks(); |
655 } | 671 } |
656 | 672 |
657 } // namespace blink | 673 } // namespace blink |
OLD | NEW |