OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_NAVIGATOR_CONNECT_MESSAGE_HANDLER_H_ |
| 6 #define CONTENT_BROWSER_SERVICE_WORKER_NAVIGATOR_CONNECT_MESSAGE_HANDLER_H_ |
| 7 |
| 8 #include <map> |
| 9 |
| 10 #include "content/browser/message_port_message_filter.h" |
| 11 #include "content/common/service_worker/service_worker_status_code.h" |
| 12 |
| 13 namespace content { |
| 14 |
| 15 struct CrossOriginServiceWorkerClient; |
| 16 class ServiceWorkerContextCore; |
| 17 class ServiceWorkerRegistration; |
| 18 |
| 19 class NavigatorConnectMessageHandler : public MessagePortHandler { |
| 20 public: |
| 21 explicit NavigatorConnectMessageHandler( |
| 22 base::WeakPtr<ServiceWorkerContextCore> context); |
| 23 ~NavigatorConnectMessageHandler() override; |
| 24 |
| 25 void RegisterMessagePort(const CrossOriginServiceWorkerClient& client); |
| 26 void ClearRegistration(int message_port_id); |
| 27 void SetServiceWorkerRegistation( |
| 28 int message_port_id, |
| 29 const scoped_refptr<ServiceWorkerRegistration>& |
| 30 service_worker_registration); |
| 31 |
| 32 // MessagePortHandler implementation. |
| 33 void SendMessage(int route_id, |
| 34 const base::string16& message, |
| 35 const std::vector<int>& sent_message_port_ids) override; |
| 36 void SendMessagesQueued(int route_id) override; |
| 37 |
| 38 private: |
| 39 void DoSendMessage(const CrossOriginServiceWorkerClient& client, |
| 40 const base::string16& message, |
| 41 const std::vector<int>& sent_message_port_ids, |
| 42 ServiceWorkerStatusCode service_worker_status, |
| 43 const scoped_refptr<ServiceWorkerRegistration>& |
| 44 service_worker_registration); |
| 45 |
| 46 base::WeakPtr<ServiceWorkerContextCore> context_; |
| 47 struct MessagePort; |
| 48 std::map<int, MessagePort> ports_; |
| 49 }; |
| 50 |
| 51 } // namespace content |
| 52 |
| 53 #endif // CONTENT_BROWSER_SERVICE_WORKER_NAVIGATOR_CONNECT_MESSAGE_HANDLER_H_ |
OLD | NEW |