OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 module blink.mojom; | 5 module blink.mojom; |
6 | 6 |
7 enum BackgroundFetchError { | 7 enum BackgroundFetchError { |
8 NONE, | 8 NONE, |
9 DUPLICATED_TAG, | 9 DUPLICATED_TAG, |
10 INVALID_TAG | 10 INVALID_TAG |
11 }; | 11 }; |
12 | 12 |
| 13 // Represents the definition of an icon developers can optionally provide with a |
| 14 // Background Fetch fetch. Analogous to the following structure in the spec: |
| 15 // https://wicg.github.io/background-fetch/#background-fetch-manager |
13 struct IconDefinition { | 16 struct IconDefinition { |
14 string src; | 17 string src; |
15 string sizes; | 18 string sizes; |
16 string type; | 19 string type; |
17 }; | 20 }; |
18 | 21 |
| 22 // Represents the optional options a developer can provide when starting a new |
| 23 // Background Fetch fetch. Analogous to the following structure in the spec: |
| 24 // https://wicg.github.io/background-fetch/#background-fetch-manager |
| 25 struct BackgroundFetchOptions { |
| 26 array<IconDefinition> icons; |
| 27 int64 total_download_size; |
| 28 string title; |
| 29 }; |
| 30 |
| 31 // Represents the information associated with a Background Fetch registration. |
| 32 // Analogous to the following structure in the spec: |
| 33 // https://wicg.github.io/background-fetch/#background-fetch-registration |
19 struct BackgroundFetchRegistration { | 34 struct BackgroundFetchRegistration { |
20 string tag; | 35 string tag; |
21 array<IconDefinition> icons; | 36 array<IconDefinition> icons; |
22 int64 total_download_size = 0; | 37 int64 total_download_size; |
23 string title = ""; | 38 string title; |
24 }; | 39 }; |
25 | 40 |
26 interface BackgroundFetchService { | 41 interface BackgroundFetchService { |
27 // TODO(peter): Implement support for the `fetch()` function in Mojo. | 42 // Creates a new Background Fetch registration identified by |tag| with the |
| 43 // given |options| for the sequence of |requests|. |
| 44 Fetch(int64 service_worker_registration_id, |
| 45 string tag, |
| 46 BackgroundFetchOptions options) |
| 47 => (BackgroundFetchError error, |
| 48 BackgroundFetchRegistration? registration); |
28 | 49 |
29 // Updates the user interface for the Background Fetch identified by the | 50 // Updates the user interface for the Background Fetch identified by the |
30 // |service_worker_registration_id| and the |tag|. | 51 // |service_worker_registration_id| and the |tag|. |
31 UpdateUI(int64 service_worker_registration_id, string tag, string title) | 52 UpdateUI(int64 service_worker_registration_id, string tag, string title) |
32 => (BackgroundFetchError error); | 53 => (BackgroundFetchError error); |
33 | 54 |
34 // Aborts the Background Fetch registration identified by the | 55 // Aborts the Background Fetch registration identified by the |
35 // |service_worker_registration_id| and the |tag|. | 56 // |service_worker_registration_id| and the |tag|. |
36 Abort(int64 service_worker_registration_id, string tag) | 57 Abort(int64 service_worker_registration_id, string tag) |
37 => (BackgroundFetchError error); | 58 => (BackgroundFetchError error); |
38 | 59 |
39 // Gets the Background Fetch registration identified by the | 60 // Gets the Background Fetch registration identified by the |
40 // |service_worker_registration_id| and the |tag|. | 61 // |service_worker_registration_id| and the |tag|. |
41 GetRegistration(int64 service_worker_registration_id, string tag) | 62 GetRegistration(int64 service_worker_registration_id, string tag) |
42 => (BackgroundFetchError error, | 63 => (BackgroundFetchError error, |
43 BackgroundFetchRegistration? registration); | 64 BackgroundFetchRegistration? registration); |
44 | 65 |
45 // Gets the sequence of tags for active Background Fetch registrations given | 66 // Gets the sequence of tags for active Background Fetch registrations given |
46 // the |service_worker_registration_id|. | 67 // the |service_worker_registration_id|. |
47 GetTags(int64 service_worker_registration_id) | 68 GetTags(int64 service_worker_registration_id) |
48 => (BackgroundFetchError error, | 69 => (BackgroundFetchError error, |
49 array<string> tags); | 70 array<string> tags); |
50 }; | 71 }; |
OLD | NEW |