| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/navigator_connect/navigator_connect_context_impl.h" | 5 #include "content/browser/navigator_connect/navigator_connect_context_impl.h" |
| 6 | 6 |
| 7 #include <stdint.h> |
| 8 |
| 7 #include "content/browser/message_port_service.h" | 9 #include "content/browser/message_port_service.h" |
| 8 #include "content/browser/navigator_connect/service_port_service_impl.h" | 10 #include "content/browser/navigator_connect/service_port_service_impl.h" |
| 9 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 11 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 10 #include "content/common/service_worker/service_worker_utils.h" | 12 #include "content/common/service_worker/service_worker_utils.h" |
| 11 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 12 #include "content/public/browser/navigator_connect_service_factory.h" | 14 #include "content/public/browser/navigator_connect_service_factory.h" |
| 13 #include "content/public/common/navigator_connect_client.h" | 15 #include "content/public/common/navigator_connect_client.h" |
| 14 | 16 |
| 15 namespace content { | 17 namespace content { |
| 16 | 18 |
| 17 struct NavigatorConnectContextImpl::Port { | 19 struct NavigatorConnectContextImpl::Port { |
| 18 // ID of this port. | 20 // ID of this port. |
| 19 int id; | 21 int id; |
| 20 // ID of the port this port is connected to. | 22 // ID of the port this port is connected to. |
| 21 int entangled_id; | 23 int entangled_id; |
| 22 | 24 |
| 23 // Service url and client origin describing this connection. These fields will | 25 // Service url and client origin describing this connection. These fields will |
| 24 // always be the same as the same fields for the entangled port. | 26 // always be the same as the same fields for the entangled port. |
| 25 GURL target_url; | 27 GURL target_url; |
| 26 GURL client_origin; | 28 GURL client_origin; |
| 27 | 29 |
| 28 // Set to nullptr when the ServicePortService goes away. | 30 // Set to nullptr when the ServicePortService goes away. |
| 29 ServicePortServiceImpl* service = nullptr; | 31 ServicePortServiceImpl* service = nullptr; |
| 30 | 32 |
| 31 // If this port is associated with a service worker, these fields store that | 33 // If this port is associated with a service worker, these fields store that |
| 32 // information. | 34 // information. |
| 33 int64 service_worker_registration_id = kInvalidServiceWorkerRegistrationId; | 35 int64_t service_worker_registration_id = kInvalidServiceWorkerRegistrationId; |
| 34 GURL service_worker_registration_origin; | 36 GURL service_worker_registration_origin; |
| 35 }; | 37 }; |
| 36 | 38 |
| 37 NavigatorConnectContextImpl::NavigatorConnectContextImpl( | 39 NavigatorConnectContextImpl::NavigatorConnectContextImpl( |
| 38 const scoped_refptr<ServiceWorkerContextWrapper>& service_worker_context) | 40 const scoped_refptr<ServiceWorkerContextWrapper>& service_worker_context) |
| 39 : service_worker_context_(service_worker_context), next_port_id_(0) {} | 41 : service_worker_context_(service_worker_context), next_port_id_(0) {} |
| 40 | 42 |
| 41 NavigatorConnectContextImpl::~NavigatorConnectContextImpl() { | 43 NavigatorConnectContextImpl::~NavigatorConnectContextImpl() { |
| 42 } | 44 } |
| 43 | 45 |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 DCHECK(active_version); | 213 DCHECK(active_version); |
| 212 | 214 |
| 213 const Port& port = ports_[port_id]; | 215 const Port& port = ports_[port_id]; |
| 214 NavigatorConnectClient client(port.target_url, port.client_origin, port_id); | 216 NavigatorConnectClient client(port.target_url, port.client_origin, port_id); |
| 215 active_version->DispatchCrossOriginMessageEvent( | 217 active_version->DispatchCrossOriginMessageEvent( |
| 216 client, message, sent_message_ports, | 218 client, message, sent_message_ports, |
| 217 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 219 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
| 218 } | 220 } |
| 219 | 221 |
| 220 } // namespace content | 222 } // namespace content |
| OLD | NEW |