summaryrefslogtreecommitdiffstats
path: root/content/browser/devtools/worker_devtools_manager.h
diff options
context:
space:
mode:
authorpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-19 11:44:19 +0000
committerpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-19 11:44:19 +0000
commit70019150e9f7f53074cacb335de0d238bbc37380 (patch)
tree444eddb81717f95b38585bfedde240d9643ba6a2 /content/browser/devtools/worker_devtools_manager.h
parent08b035b9918342155f54549486d6108807c3bfad (diff)
downloadchromium_src-70019150e9f7f53074cacb335de0d238bbc37380.zip
chromium_src-70019150e9f7f53074cacb335de0d238bbc37380.tar.gz
chromium_src-70019150e9f7f53074cacb335de0d238bbc37380.tar.bz2
DevTools: rename debugger/ to devtools/, move DevTools files into content/renderer/devtools.
Review URL: https://codereview.chromium.org/11630004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@173903 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/devtools/worker_devtools_manager.h')
-rw-r--r--content/browser/devtools/worker_devtools_manager.h109
1 files changed, 109 insertions, 0 deletions
diff --git a/content/browser/devtools/worker_devtools_manager.h b/content/browser/devtools/worker_devtools_manager.h
new file mode 100644
index 0000000..13ef33b
--- /dev/null
+++ b/content/browser/devtools/worker_devtools_manager.h
@@ -0,0 +1,109 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_DEVTOOLS_WORKER_DEVTOOLS_MANAGER_H_
+#define CONTENT_BROWSER_DEVTOOLS_WORKER_DEVTOOLS_MANAGER_H_
+
+#include <list>
+#include <map>
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/memory/singleton.h"
+#include "content/browser/worker_host/worker_process_host.h"
+#include "content/common/content_export.h"
+
+namespace content {
+
+class DevToolsAgentHost;
+
+// All methods are supposed to be called on the IO thread.
+class WorkerDevToolsManager {
+ public:
+ // Returns the WorkerDevToolsManager singleton.
+ static WorkerDevToolsManager* GetInstance();
+
+ // Called on the UI thread.
+ static DevToolsAgentHost* GetDevToolsAgentHostForWorker(
+ int worker_process_id,
+ int worker_route_id);
+
+ void ForwardToDevToolsClient(int worker_process_id,
+ int worker_route_id,
+ const std::string& message);
+ void SaveAgentRuntimeState(int worker_process_id,
+ int worker_route_id,
+ const std::string& state);
+
+ // Called on the IO thread.
+ void WorkerCreated(
+ WorkerProcessHost* process,
+ const WorkerProcessHost::WorkerInstance& instance);
+ void WorkerDestroyed(WorkerProcessHost* process, int worker_route_id);
+ void WorkerContextStarted(WorkerProcessHost* process, int worker_route_id);
+
+ private:
+ friend struct DefaultSingletonTraits<WorkerDevToolsManager>;
+ typedef std::pair<int, int> WorkerId;
+ class AgentHosts;
+ class DetachedClientHosts;
+ class WorkerDevToolsAgentHost;
+ struct InspectedWorker;
+ typedef std::list<InspectedWorker> InspectedWorkersList;
+
+ WorkerDevToolsManager();
+ virtual ~WorkerDevToolsManager();
+
+ void RemoveInspectedWorkerData(const WorkerId& id);
+ InspectedWorkersList::iterator FindInspectedWorker(int host_id, int route_id);
+
+ void RegisterDevToolsAgentHostForWorker(int worker_process_id,
+ int worker_route_id);
+ void ForwardToWorkerDevToolsAgent(int worker_process_host_id,
+ int worker_route_id,
+ const IPC::Message& message);
+ static void ForwardToDevToolsClientOnUIThread(
+ int worker_process_id,
+ int worker_route_id,
+ const std::string& message);
+ static void SaveAgentRuntimeStateOnUIThread(
+ int worker_process_id,
+ int worker_route_id,
+ const std::string& state);
+ static void NotifyWorkerDestroyedOnIOThread(int worker_process_id,
+ int worker_route_id);
+ static void NotifyWorkerDestroyedOnUIThread(int worker_process_id,
+ int worker_route_id);
+ static void SendResumeToWorker(const WorkerId& id);
+
+ InspectedWorkersList inspected_workers_;
+
+ struct TerminatedInspectedWorker;
+ typedef std::list<TerminatedInspectedWorker> TerminatedInspectedWorkers;
+ // List of terminated workers for which there may be a devtools client on
+ // the UI thread. Worker entry is added into this list when inspected worker
+ // is terminated and will be removed in one of two cases:
+ // - shared worker with the same URL and name is started(in wich case we will
+ // try to reattach existing DevTools client to the new worker).
+ // - DevTools client which was inspecting terminated worker is closed on the
+ // UI thread and and WorkerDevToolsManager is notified about that on the IO
+ // thread.
+ TerminatedInspectedWorkers terminated_workers_;
+
+ typedef std::map<WorkerId, WorkerId> PausedWorkers;
+ // Map from old to new worker id for the inspected workers that have been
+ // terminated and started again in paused state. Worker data will be removed
+ // from this list in one of two cases:
+ // - DevTools client is closed on the UI thread, WorkerDevToolsManager was
+ // notified about that on the IO thread and sent "resume" message to the
+ // worker.
+ // - Existing DevTools client was reattached to the new worker.
+ PausedWorkers paused_workers_;
+
+ DISALLOW_COPY_AND_ASSIGN(WorkerDevToolsManager);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_DEVTOOLS_WORKER_DEVTOOLS_MANAGER_H_