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

Unified Diff: content/browser/service_worker/service_worker_provider_host_registry.h

Issue 325173002: ServiceWorker: Confirm the liveness of the associated context before handling message (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months 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: content/browser/service_worker/service_worker_provider_host_registry.h
diff --git a/content/browser/service_worker/service_worker_provider_host_registry.h b/content/browser/service_worker/service_worker_provider_host_registry.h
new file mode 100644
index 0000000000000000000000000000000000000000..080d394145053fc5d6f3eae3f98b21453386caff
--- /dev/null
+++ b/content/browser/service_worker/service_worker_provider_host_registry.h
@@ -0,0 +1,62 @@
+// Copyright 2014 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_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_REGISTRY_H_
+#define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_REGISTRY_H_
+
+#include "base/id_map.h"
+#include "base/memory/scoped_ptr.h"
+#include "content/common/content_export.h"
+
+namespace content {
+
+class ServiceWorkerProviderHost;
+
+class CONTENT_EXPORT ServiceWorkerProviderHostRegistry {
+ public:
+ typedef IDMap<ServiceWorkerProviderHost, IDMapOwnPointer> ProviderMap;
+ typedef IDMap<ProviderMap, IDMapOwnPointer> ProcessToProviderMap;
+
+ // Iterates over ServiceWorkerProviderHost objects in a ProcessToProviderMap.
+ class Iterator {
+ public:
+ ~Iterator();
+ ServiceWorkerProviderHost* GetProviderHost();
+ void Advance();
+ bool IsAtEnd();
+
+ private:
+ friend class ServiceWorkerProviderHostRegistry;
+ explicit Iterator(ProcessToProviderMap* map);
+ void Initialize();
+
+ ProcessToProviderMap* map_;
+ scoped_ptr<ProcessToProviderMap::iterator> provider_iterator_;
+ scoped_ptr<ProviderMap::iterator> provider_host_iterator_;
+
+ DISALLOW_COPY_AND_ASSIGN(Iterator);
+ };
+
+ ServiceWorkerProviderHostRegistry();
+ virtual ~ServiceWorkerProviderHostRegistry();
+
+ ServiceWorkerProviderHost* GetProviderHost(int process_id, int provider_id);
+ void AddProviderHost(scoped_ptr<ServiceWorkerProviderHost> provider_host);
+ void RemoveProviderHost(int process_id, int provider_id);
+ void RemoveAllProviderHostsForProcess(int process_id);
+ scoped_ptr<Iterator> GetProviderHostIterator();
+
+ private:
+ ProviderMap* GetProviderMapForProcess(int process_id) {
+ return providers_.Lookup(process_id);
+ }
+
+ ProcessToProviderMap providers_;
+
+ DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderHostRegistry);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_REGISTRY_H_

Powered by Google App Engine
This is Rietveld 408576698