| Index: content/browser/devtools/shared_worker_devtools_manager.h
|
| diff --git a/content/browser/devtools/worker_devtools_manager.h b/content/browser/devtools/shared_worker_devtools_manager.h
|
| similarity index 13%
|
| copy from content/browser/devtools/worker_devtools_manager.h
|
| copy to content/browser/devtools/shared_worker_devtools_manager.h
|
| index 7ea8840c7dd0447af956d9d06ed387ed3b3f273f..0b56529dd7b4de81741fe92e5746fd94207a384e 100644
|
| --- a/content/browser/devtools/worker_devtools_manager.h
|
| +++ b/content/browser/devtools/shared_worker_devtools_manager.h
|
| @@ -2,108 +2,82 @@
|
| // 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>
|
| +#ifndef CONTENT_BROWSER_DEVTOOLS_SHARED_WORKER_DEVTOOLS_MANAGER_H_
|
| +#define CONTENT_BROWSER_DEVTOOLS_SHARED_WORKER_DEVTOOLS_MANAGER_H_
|
|
|
| #include "base/basictypes.h"
|
| +#include "base/containers/scoped_ptr_hash_map.h"
|
| +#include "base/memory/scoped_vector.h"
|
| #include "base/memory/singleton.h"
|
| -#include "content/browser/worker_host/worker_process_host.h"
|
| -#include "content/common/content_export.h"
|
| +#include "base/strings/string16.h"
|
|
|
| -namespace content {
|
| +class GURL;
|
|
|
| +namespace content {
|
| class DevToolsAgentHost;
|
|
|
| -// All methods are supposed to be called on the IO thread.
|
| -class WorkerDevToolsManager {
|
| +// SharedWorkerDevToolsManager is used instead of WorkerDevToolsManager when
|
| +// "enable-embedded-shared-worker" flag is set.
|
| +// This class lives on UI thread.
|
| +class SharedWorkerDevToolsManager {
|
| public:
|
| typedef std::pair<int, int> WorkerId;
|
| - class WorkerDevToolsAgentHost;
|
| -
|
| - // 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);
|
| + class SharedWorkerDevToolsAgentHost;
|
| +
|
| + // Returns the SharedWorkerDevToolsManager singleton.
|
| + static SharedWorkerDevToolsManager* GetInstance();
|
| +
|
| + static DevToolsAgentHost* GetDevToolsAgentHostForWorker(int worker_process_id,
|
| + int worker_route_id);
|
| +
|
| + static bool HasDevToolsAgentHostForWorker(int worker_process_id,
|
| + int worker_route_id);
|
| +
|
| + void WorkerCreated(int worker_process_id,
|
| + int worker_route_id,
|
| + const GURL& url,
|
| + const base::string16& name);
|
| + void WorkerDestroyed(int worker_process_id, int worker_route_id);
|
| + void WorkerContextStarted(int worker_process_id, int worker_route_id);
|
|
|
| private:
|
| - friend struct DefaultSingletonTraits<WorkerDevToolsManager>;
|
| - class DetachedClientHosts;
|
| - 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 ConnectDevToolsAgentHostToWorker(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 NotifyConnectionFailedOnIOThread(int worker_process_id,
|
| - int worker_route_id);
|
| - static void NotifyConnectionFailedOnUIThread(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
|
| + friend struct DefaultSingletonTraits<SharedWorkerDevToolsManager>;
|
| +
|
| + SharedWorkerDevToolsManager();
|
| + virtual ~SharedWorkerDevToolsManager();
|
| +
|
| + bool ConnectDevToolsAgentHostToWorker(const WorkerId& worker_id);
|
| + void RemoveInspectedWorkerData(const WorkerId& worker_id);
|
| +
|
| + struct WorkerInfo;
|
| + typedef base::ScopedPtrHashMap<WorkerId, WorkerInfo> WorkerInfoMap;
|
| +
|
| + WorkerInfoMap::iterator FindTerminatedWorker(const GURL& url,
|
| + const base::string16& name);
|
| +
|
| + WorkerInfoMap uninspected_workers_;
|
| + WorkerInfoMap inspected_workers_;
|
| +
|
| + // Map of terminated workers for which there may be a devtools client. Worker
|
| + // entry is added into this map 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.
|
| + // - DevTools client which was inspecting terminated worker is closed and
|
| + // WorkerDevToolsManager is notified about that.
|
| + WorkerInfoMap terminated_workers_;
|
| +
|
| + // Map of the inspected workers that have been terminated and started again in
|
| + // paused state. WorkerId of WorkerInfo in this map is stil the old worker id.
|
| + // Worker data will be removed from this list in one of two cases:
|
| + // - DevTools client is closed and WorkerDevToolsManager was notified about
|
| + // that sent "resume" message to the worker.
|
| // - Existing DevTools client was reattached to the new worker.
|
| - PausedWorkers paused_workers_;
|
| + WorkerInfoMap paused_workers_;
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(WorkerDevToolsManager);
|
| + DISALLOW_COPY_AND_ASSIGN(SharedWorkerDevToolsManager);
|
| };
|
|
|
| } // namespace content
|
|
|
| -#endif // CONTENT_BROWSER_DEVTOOLS_WORKER_DEVTOOLS_MANAGER_H_
|
| +#endif // CONTENT_BROWSER_DEVTOOLS_SHARED_WORKER_DEVTOOLS_MANAGER_H_
|
|
|