Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5533)

Unified Diff: chrome/browser/worker_host/worker_process_host.h

Issue 390017: Added lifecycle management and sharing support for SharedWorkers. SharedWorkers (Closed)
Patch Set: Changed WebWorkerBase not not call a virtual function from the destructor Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/worker_host/worker_process_host.h
diff --git a/chrome/browser/worker_host/worker_process_host.h b/chrome/browser/worker_host/worker_process_host.h
index 1fae373a54a71d3d268a52543a74f2cb2bad17c0..8fc67f34140aba78ac3e9e725348c46c4d7e9321 100644
--- a/chrome/browser/worker_host/worker_process_host.h
+++ b/chrome/browser/worker_host/worker_process_host.h
@@ -17,16 +17,52 @@ class WorkerProcessHost : public ChildProcessHost {
public:
// Contains information about each worker instance, needed to forward messages
// between the renderer and worker processes.
- struct WorkerInstance {
+ class WorkerInstance {
jam 2009/11/12 20:11:23 nit: If this is a class, then it's against the cod
+ public:
+ WorkerInstance() : closed(false) {};
+
+ // Checks if this WorkerInstance matches the passed url/name params
jam 2009/11/12 20:11:23 nit: just to make it clear to someone reading the
+ // (per the comparison algorithm in the WebWorkers spec).
+ bool Matches(const GURL& url, const string16& name) const;
+
+ // Adds a document to a shared worker's document set.
+ void AddToDocumentSet(IPC::Message::Sender* parent,
+ unsigned long long document_id);
+
+ // Checks to see if a document is in the worker's document set.
+ bool IsInDocumentSet(IPC::Message::Sender* parent,
+ unsigned long long document_id) const;
+
+ // Removes a specific document from the set when that document is detached.
+ void RemoveFromDocumentSet(IPC::Message::Sender* parent,
+ unsigned long long document_id);
+
+ // Invoked when a render process exits, to remove all associated documents
+ // from the set.
+ void RemoveAllAssociatedDocuments(IPC::Message::Sender* parent);
+
+ // APIs to manage the sender list for a given instance.
+ void AddSender(IPC::Message::Sender* sender, int sender_route_id);
+ void RemoveSender(IPC::Message::Sender* sender, int sender_route_id);
+ void RemoveSenders(IPC::Message::Sender* sender);
+ bool HasSender(IPC::Message::Sender* sender, int sender_route_id) const;
+
+ // Unique identifier for an associated document.
+ typedef std::pair<IPC::Message::Sender*, unsigned long long> DocumentInfo;
+ typedef std::set<DocumentInfo> DocumentSet;
+
+ typedef std::pair<IPC::Message::Sender*, int> SenderInfo;
+ typedef std::set<SenderInfo> SenderList;
+
GURL url;
bool is_shared;
+ bool closed;
string16 name;
int renderer_id;
int render_view_route_id;
int worker_route_id;
- IPC::Message::Sender* sender;
- int sender_id;
- int sender_route_id;
+ SenderList senders;
+ DocumentSet document_set;
};
WorkerProcessHost(ResourceDispatcherHost* resource_dispatcher_host_);
@@ -40,15 +76,21 @@ class WorkerProcessHost : public ChildProcessHost {
// Returns true iff the given message from a renderer process was forwarded to
// the worker.
- bool FilterMessage(const IPC::Message& message, int sender_pid);
+ bool FilterMessage(const IPC::Message& message, IPC::Message::Sender* sender);
void SenderShutdown(IPC::Message::Sender* sender);
+ // Shuts down any shared workers that are no longer referenced by active
+ // documents.
+ void DocumentDetached(IPC::Message::Sender* sender,
+ unsigned long long document_id);
+
protected:
friend class WorkerService;
typedef std::list<WorkerInstance> Instances;
const Instances& instances() const { return instances_; }
+ Instances& mutable_instances() { return instances_; }
private:
// ResourceDispatcherHost::Receiver implementation:
@@ -59,6 +101,9 @@ class WorkerProcessHost : public ChildProcessHost {
// Called when a message arrives from the worker process.
void OnMessageReceived(const IPC::Message& message);
+ // Called when the app invokes close() from within worker context.
+ void OnWorkerContextClosed(int worker_route_id);
+
// Given a Sender, returns the callback that generates a new routing id.
static CallbackWithReturnValue<int>::Type* GetNextRouteIdCallback(
IPC::Message::Sender* sender);

Powered by Google App Engine
This is Rietveld 408576698