| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 #include "public/web/WebViewClient.h" | 68 #include "public/web/WebViewClient.h" |
| 69 #include "web/WebInputEventConversion.h" | 69 #include "web/WebInputEventConversion.h" |
| 70 #include "web/WebLocalFrameImpl.h" | 70 #include "web/WebLocalFrameImpl.h" |
| 71 #include "web/WebViewImpl.h" | 71 #include "web/WebViewImpl.h" |
| 72 #include "wtf/CurrentTime.h" | 72 #include "wtf/CurrentTime.h" |
| 73 #include "wtf/MathExtras.h" | 73 #include "wtf/MathExtras.h" |
| 74 #include "wtf/Noncopyable.h" | 74 #include "wtf/Noncopyable.h" |
| 75 #include "wtf/text/WTFString.h" | 75 #include "wtf/text/WTFString.h" |
| 76 | 76 |
| 77 using namespace WebCore; | 77 using namespace WebCore; |
| 78 using namespace std; | |
| 79 | 78 |
| 80 namespace OverlayZOrders { | 79 namespace OverlayZOrders { |
| 81 // Use 99 as a big z-order number so that highlight is above other overlays. | 80 // Use 99 as a big z-order number so that highlight is above other overlays. |
| 82 static const int highlight = 99; | 81 static const int highlight = 99; |
| 83 } | 82 } |
| 84 | 83 |
| 85 namespace blink { | 84 namespace blink { |
| 86 | 85 |
| 87 class ClientMessageLoopAdapter : public PageScriptDebugServer::ClientMessageLoop
{ | 86 class ClientMessageLoopAdapter : public PageScriptDebugServer::ClientMessageLoop
{ |
| 88 public: | 87 public: |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 public: | 446 public: |
| 448 CountingVisitor() : m_totalObjectsCount(0) | 447 CountingVisitor() : m_totalObjectsCount(0) |
| 449 { | 448 { |
| 450 } | 449 } |
| 451 | 450 |
| 452 virtual bool visitObject(const void* ptr) | 451 virtual bool visitObject(const void* ptr) |
| 453 { | 452 { |
| 454 ++m_totalObjectsCount; | 453 ++m_totalObjectsCount; |
| 455 return true; | 454 return true; |
| 456 } | 455 } |
| 457 size_t totalObjectsCount() const | 456 std::size_t totalObjectsCount() const |
| 458 { | 457 { |
| 459 return m_totalObjectsCount; | 458 return m_totalObjectsCount; |
| 460 } | 459 } |
| 461 | 460 |
| 462 private: | 461 private: |
| 463 size_t m_totalObjectsCount; | 462 std::size_t m_totalObjectsCount; |
| 464 }; | 463 }; |
| 465 | 464 |
| 466 CountingVisitor counter; | 465 CountingVisitor counter; |
| 467 m_client->visitAllocatedObjects(&counter); | 466 m_client->visitAllocatedObjects(&counter); |
| 468 | 467 |
| 469 class PointerCollector : public WebDevToolsAgentClient::AllocatedObjectVisit
or { | 468 class PointerCollector : public WebDevToolsAgentClient::AllocatedObjectVisit
or { |
| 470 public: | 469 public: |
| 471 explicit PointerCollector(size_t maxObjectsCount) | 470 explicit PointerCollector(std::size_t maxObjectsCount) |
| 472 : m_maxObjectsCount(maxObjectsCount) | 471 : m_maxObjectsCount(maxObjectsCount) |
| 473 , m_index(0) | 472 , m_index(0) |
| 474 , m_success(true) | 473 , m_success(true) |
| 475 , m_pointers(new const void*[maxObjectsCount]) | 474 , m_pointers(new const void*[maxObjectsCount]) |
| 476 { | 475 { |
| 477 } | 476 } |
| 478 virtual ~PointerCollector() | 477 virtual ~PointerCollector() |
| 479 { | 478 { |
| 480 delete[] m_pointers; | 479 delete[] m_pointers; |
| 481 } | 480 } |
| 482 virtual bool visitObject(const void* ptr) | 481 virtual bool visitObject(const void* ptr) |
| 483 { | 482 { |
| 484 if (m_index == m_maxObjectsCount) { | 483 if (m_index == m_maxObjectsCount) { |
| 485 m_success = false; | 484 m_success = false; |
| 486 return false; | 485 return false; |
| 487 } | 486 } |
| 488 m_pointers[m_index++] = ptr; | 487 m_pointers[m_index++] = ptr; |
| 489 return true; | 488 return true; |
| 490 } | 489 } |
| 491 | 490 |
| 492 bool success() const { return m_success; } | 491 bool success() const { return m_success; } |
| 493 | 492 |
| 494 void copyTo(HashSet<const void*>& set) | 493 void copyTo(HashSet<const void*>& set) |
| 495 { | 494 { |
| 496 for (size_t i = 0; i < m_index; i++) | 495 for (std::size_t i = 0; i < m_index; i++) |
| 497 set.add(m_pointers[i]); | 496 set.add(m_pointers[i]); |
| 498 } | 497 } |
| 499 | 498 |
| 500 private: | 499 private: |
| 501 const size_t m_maxObjectsCount; | 500 const std::size_t m_maxObjectsCount; |
| 502 size_t m_index; | 501 std::size_t m_index; |
| 503 bool m_success; | 502 bool m_success; |
| 504 const void** m_pointers; | 503 const void** m_pointers; |
| 505 }; | 504 }; |
| 506 | 505 |
| 507 // Double size to allow room for all objects that may have been allocated | 506 // Double size to allow room for all objects that may have been allocated |
| 508 // since we counted them. | 507 // since we counted them. |
| 509 size_t estimatedMaxObjectsCount = counter.totalObjectsCount() * 2; | 508 std::size_t estimatedMaxObjectsCount = counter.totalObjectsCount() * 2; |
| 510 while (true) { | 509 while (true) { |
| 511 PointerCollector collector(estimatedMaxObjectsCount); | 510 PointerCollector collector(estimatedMaxObjectsCount); |
| 512 m_client->visitAllocatedObjects(&collector); | 511 m_client->visitAllocatedObjects(&collector); |
| 513 if (collector.success()) { | 512 if (collector.success()) { |
| 514 collector.copyTo(set); | 513 collector.copyTo(set); |
| 515 break; | 514 break; |
| 516 } | 515 } |
| 517 estimatedMaxObjectsCount *= 2; | 516 estimatedMaxObjectsCount *= 2; |
| 518 } | 517 } |
| 519 } | 518 } |
| 520 | 519 |
| 521 void WebDevToolsAgentImpl::dumpUncountedAllocatedObjects(const HashMap<const voi
d*, size_t>& map) | 520 void WebDevToolsAgentImpl::dumpUncountedAllocatedObjects(const HashMap<const voi
d*, std::size_t>& map) |
| 522 { | 521 { |
| 523 class InstrumentedObjectSizeProvider : public WebDevToolsAgentClient::Instru
mentedObjectSizeProvider { | 522 class InstrumentedObjectSizeProvider : public WebDevToolsAgentClient::Instru
mentedObjectSizeProvider { |
| 524 public: | 523 public: |
| 525 InstrumentedObjectSizeProvider(const HashMap<const void*, size_t>& map)
: m_map(map) { } | 524 InstrumentedObjectSizeProvider(const HashMap<const void*, std::size_t>&
map) : m_map(map) { } |
| 526 virtual size_t objectSize(const void* ptr) const | 525 virtual std::size_t objectSize(const void* ptr) const |
| 527 { | 526 { |
| 528 HashMap<const void*, size_t>::const_iterator i = m_map.find(ptr); | 527 HashMap<const void*, std::size_t>::const_iterator i = m_map.find(ptr
); |
| 529 return i == m_map.end() ? 0 : i->value; | 528 return i == m_map.end() ? 0 : i->value; |
| 530 } | 529 } |
| 531 | 530 |
| 532 private: | 531 private: |
| 533 const HashMap<const void*, size_t>& m_map; | 532 const HashMap<const void*, std::size_t>& m_map; |
| 534 }; | 533 }; |
| 535 | 534 |
| 536 InstrumentedObjectSizeProvider provider(map); | 535 InstrumentedObjectSizeProvider provider(map); |
| 537 m_client->dumpUncountedAllocatedObjects(&provider); | 536 m_client->dumpUncountedAllocatedObjects(&provider); |
| 538 } | 537 } |
| 539 | 538 |
| 540 void WebDevToolsAgentImpl::setTraceEventCallback(const String& categoryFilter, T
raceEventCallback callback) | 539 void WebDevToolsAgentImpl::setTraceEventCallback(const String& categoryFilter, T
raceEventCallback callback) |
| 541 { | 540 { |
| 542 m_client->setTraceEventCallback(categoryFilter, callback); | 541 m_client->setTraceEventCallback(categoryFilter, callback); |
| 543 } | 542 } |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 { | 671 { |
| 673 InspectorController* ic = inspectorController(); | 672 InspectorController* ic = inspectorController(); |
| 674 ic->evaluateForTestInFrontend(callId, script); | 673 ic->evaluateForTestInFrontend(callId, script); |
| 675 } | 674 } |
| 676 | 675 |
| 677 void WebDevToolsAgentImpl::flushPendingFrontendMessages() | 676 void WebDevToolsAgentImpl::flushPendingFrontendMessages() |
| 678 { | 677 { |
| 679 InspectorController* ic = inspectorController(); | 678 InspectorController* ic = inspectorController(); |
| 680 ic->flushPendingFrontendMessages(); | 679 ic->flushPendingFrontendMessages(); |
| 681 | 680 |
| 682 for (size_t i = 0; i < m_frontendMessageQueue.size(); ++i) | 681 for (std::size_t i = 0; i < m_frontendMessageQueue.size(); ++i) |
| 683 m_client->sendMessageToInspectorFrontend(m_frontendMessageQueue[i]->toJS
ONString()); | 682 m_client->sendMessageToInspectorFrontend(m_frontendMessageQueue[i]->toJS
ONString()); |
| 684 m_frontendMessageQueue.clear(); | 683 m_frontendMessageQueue.clear(); |
| 685 } | 684 } |
| 686 | 685 |
| 687 void WebDevToolsAgentImpl::willProcessTask() | 686 void WebDevToolsAgentImpl::willProcessTask() |
| 688 { | 687 { |
| 689 if (!m_attached) | 688 if (!m_attached) |
| 690 return; | 689 return; |
| 691 if (InspectorController* ic = inspectorController()) | 690 if (InspectorController* ic = inspectorController()) |
| 692 ic->willProcessTask(); | 691 ic->willProcessTask(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 722 || commandName == InspectorBackendDispatcher::commandName(InspectorBacke
ndDispatcher::kDebugger_removeBreakpointCmd) | 721 || commandName == InspectorBackendDispatcher::commandName(InspectorBacke
ndDispatcher::kDebugger_removeBreakpointCmd) |
| 723 || commandName == InspectorBackendDispatcher::commandName(InspectorBacke
ndDispatcher::kDebugger_setBreakpointsActiveCmd); | 722 || commandName == InspectorBackendDispatcher::commandName(InspectorBacke
ndDispatcher::kDebugger_setBreakpointsActiveCmd); |
| 724 } | 723 } |
| 725 | 724 |
| 726 void WebDevToolsAgent::processPendingMessages() | 725 void WebDevToolsAgent::processPendingMessages() |
| 727 { | 726 { |
| 728 PageScriptDebugServer::shared().runPendingTasks(); | 727 PageScriptDebugServer::shared().runPendingTasks(); |
| 729 } | 728 } |
| 730 | 729 |
| 731 } // namespace blink | 730 } // namespace blink |
| OLD | NEW |