InspectorWorkerAgent.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Copyright (C) 2011 Google Inc. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are
  6. * met:
  7. *
  8. * * Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * * Redistributions in binary form must reproduce the above
  11. * copyright notice, this list of conditions and the following disclaimer
  12. * in the documentation and/or other materials provided with the
  13. * distribution.
  14. * * Neither the name of Google Inc. nor the names of its
  15. * contributors may be used to endorse or promote products derived from
  16. * this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  22. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  23. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  26. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  28. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. #ifndef InspectorWorkerAgent_h
  31. #define InspectorWorkerAgent_h
  32. #if ENABLE(WORKERS)
  33. #include "InspectorBaseAgent.h"
  34. #include <wtf/Forward.h>
  35. #include <wtf/HashMap.h>
  36. namespace WebCore {
  37. class InspectorFrontend;
  38. class InspectorObject;
  39. class InspectorState;
  40. class InstrumentingAgents;
  41. class KURL;
  42. class WorkerContextProxy;
  43. typedef String ErrorString;
  44. class InspectorWorkerAgent : public InspectorBaseAgent<InspectorWorkerAgent>, public InspectorBackendDispatcher::WorkerCommandHandler {
  45. public:
  46. static PassOwnPtr<InspectorWorkerAgent> create(InstrumentingAgents*, InspectorCompositeState*);
  47. ~InspectorWorkerAgent();
  48. virtual void setFrontend(InspectorFrontend*);
  49. virtual void restore();
  50. virtual void clearFrontend();
  51. // Called from InspectorInstrumentation
  52. bool shouldPauseDedicatedWorkerOnStart();
  53. void didStartWorkerContext(WorkerContextProxy*, const KURL&);
  54. void workerContextTerminated(WorkerContextProxy*);
  55. // Called from InspectorBackendDispatcher
  56. virtual void enable(ErrorString*);
  57. virtual void disable(ErrorString*);
  58. virtual void canInspectWorkers(ErrorString*, bool*);
  59. virtual void connectToWorker(ErrorString*, int workerId);
  60. virtual void disconnectFromWorker(ErrorString*, int workerId);
  61. virtual void sendMessageToWorker(ErrorString*, int workerId, const RefPtr<InspectorObject>& message);
  62. virtual void setAutoconnectToWorkers(ErrorString*, bool value);
  63. private:
  64. InspectorWorkerAgent(InstrumentingAgents*, InspectorCompositeState*);
  65. void createWorkerFrontendChannelsForExistingWorkers();
  66. void createWorkerFrontendChannel(WorkerContextProxy*, const String& url);
  67. void destroyWorkerFrontendChannels();
  68. InspectorFrontend* m_inspectorFrontend;
  69. class WorkerFrontendChannel;
  70. typedef HashMap<int, WorkerFrontendChannel*> WorkerChannels;
  71. WorkerChannels m_idToChannel;
  72. typedef HashMap<WorkerContextProxy*, String> DedicatedWorkers;
  73. DedicatedWorkers m_dedicatedWorkers;
  74. };
  75. } // namespace WebCore
  76. #endif // !defined(InspectorWorkerAgent_h)
  77. #endif // ENABLE(WORKERS)