1 // Copyright 2018 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 THIRD_PARTY_BLINK_PUBLIC_PLATFORM_MODULES_SERVICE_WORKER_WEB_SERVICE_WORKER_REGISTRATION_OBJECT_INFO_H_
6 #define THIRD_PARTY_BLINK_PUBLIC_PLATFORM_MODULES_SERVICE_WORKER_WEB_SERVICE_WORKER_REGISTRATION_OBJECT_INFO_H_
7 
8 #include "base/macros.h"
9 #include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h"
10 #include "third_party/blink/public/mojom/service_worker/service_worker_registration.mojom-shared.h"
11 #include "third_party/blink/public/platform/modules/service_worker/web_service_worker_object_info.h"
12 #include "third_party/blink/public/platform/web_url.h"
13 
14 namespace blink {
15 
16 // This is to carry blink.mojom.ServiceWorkerRegistrationObjectInfo data from
17 // //content across the boundary into Blink.
18 // TODO(crbug.com/879019): Remove this class once we make the following Mojo
19 // interfaces receive blink.mojom.ServiceWorkerRegistrationObjectInfo directly
20 // inside Blink.
21 //  - content.mojom.ServiceWorker
22 //  - content.mojom.ServiceWorkerContainer
23 //
24 // As we're on the border line between non-Blink and Blink variants, we need
25 // to use mojo::ScopedInterfaceEndpointHandle to pass Mojo types.
26 struct WebServiceWorkerRegistrationObjectInfo {
WebServiceWorkerRegistrationObjectInfoWebServiceWorkerRegistrationObjectInfo27   WebServiceWorkerRegistrationObjectInfo(
28       int64_t registration_id,
29       WebURL scope,
30       mojom::ServiceWorkerUpdateViaCache update_via_cache,
31       mojo::ScopedInterfaceEndpointHandle host_remote,
32       mojo::ScopedInterfaceEndpointHandle receiver,
33       WebServiceWorkerObjectInfo installing,
34       WebServiceWorkerObjectInfo waiting,
35       WebServiceWorkerObjectInfo active)
36       : registration_id(registration_id),
37         scope(std::move(scope)),
38         update_via_cache(update_via_cache),
39         host_remote(std::move(host_remote)),
40         receiver(std::move(receiver)),
41         installing(std::move(installing)),
42         waiting(std::move(waiting)),
43         active(std::move(active)) {}
44   WebServiceWorkerRegistrationObjectInfo(
45       WebServiceWorkerRegistrationObjectInfo&& other) = default;
46 
47   int64_t registration_id;
48 
49   WebURL scope;
50   mojom::ServiceWorkerUpdateViaCache update_via_cache;
51 
52   // For
53   // mojo::PendingAssociatedRemote<blink::mojom::ServiceWorkerRegistrationObjectHost>.
54   mojo::ScopedInterfaceEndpointHandle host_remote;
55   // For
56   // mojo::PendingAssociatedReceiver<blink::mojom::ServiceWorkerRegistrationObject>.
57   mojo::ScopedInterfaceEndpointHandle receiver;
58 
59   WebServiceWorkerObjectInfo installing;
60   WebServiceWorkerObjectInfo waiting;
61   WebServiceWorkerObjectInfo active;
62 
63   DISALLOW_COPY_AND_ASSIGN(WebServiceWorkerRegistrationObjectInfo);
64 };
65 
66 }  // namespace blink
67 
68 #endif  // THIRD_PARTY_BLINK_PUBLIC_PLATFORM_MODULES_SERVICE_WORKER_WEB_SERVICE_WORKER_REGISTRATION_OBJECT_INFO_H_
69