Index: content/browser/service_worker/navigator_connect_message_handler.h |
diff --git a/content/browser/service_worker/navigator_connect_message_handler.h b/content/browser/service_worker/navigator_connect_message_handler.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ad1acb93096c6d5b8eb10163a7ddde55f95270ae |
--- /dev/null |
+++ b/content/browser/service_worker/navigator_connect_message_handler.h |
@@ -0,0 +1,53 @@ |
+// 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_NAVIGATOR_CONNECT_MESSAGE_HANDLER_H_ |
+#define CONTENT_BROWSER_SERVICE_WORKER_NAVIGATOR_CONNECT_MESSAGE_HANDLER_H_ |
+ |
+#include <map> |
+ |
+#include "content/browser/message_port_message_filter.h" |
+#include "content/common/service_worker/service_worker_status_code.h" |
+ |
+namespace content { |
+ |
+struct CrossOriginServiceWorkerClient; |
+class ServiceWorkerContextCore; |
+class ServiceWorkerRegistration; |
+ |
+class NavigatorConnectMessageHandler : public MessagePortHandler { |
+ public: |
+ explicit NavigatorConnectMessageHandler( |
+ base::WeakPtr<ServiceWorkerContextCore> context); |
+ ~NavigatorConnectMessageHandler() override; |
+ |
+ void RegisterMessagePort(const CrossOriginServiceWorkerClient& client); |
+ void ClearRegistration(int message_port_id); |
+ void SetServiceWorkerRegistation( |
+ int message_port_id, |
+ const scoped_refptr<ServiceWorkerRegistration>& |
+ service_worker_registration); |
+ |
+ // MessagePortHandler implementation. |
+ void SendMessage(int route_id, |
+ const base::string16& message, |
+ const std::vector<int>& sent_message_port_ids) override; |
+ void SendMessagesQueued(int route_id) override; |
+ |
+ private: |
+ void DoSendMessage(const CrossOriginServiceWorkerClient& client, |
+ const base::string16& message, |
+ const std::vector<int>& sent_message_port_ids, |
+ ServiceWorkerStatusCode service_worker_status, |
+ const scoped_refptr<ServiceWorkerRegistration>& |
+ service_worker_registration); |
+ |
+ base::WeakPtr<ServiceWorkerContextCore> context_; |
+ struct MessagePort; |
+ std::map<int, MessagePort> ports_; |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_BROWSER_SERVICE_WORKER_NAVIGATOR_CONNECT_MESSAGE_HANDLER_H_ |