OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 #include "content/common/service_worker/service_worker_status_code_traits.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "content/common/service_worker/service_worker_status_code.h" |
| 9 #include "third_party/WebKit/public/platform/modules/serviceworker/service_worke
r_event_status.mojom.h" |
| 10 |
| 11 namespace mojo { |
| 12 |
| 13 // static |
| 14 blink::mojom::ServiceWorkerEventStatus EnumTraits< |
| 15 blink::mojom::ServiceWorkerEventStatus, |
| 16 content::ServiceWorkerStatusCode>::ToMojom(content::ServiceWorkerStatusCode |
| 17 input) { |
| 18 switch (input) { |
| 19 case content::SERVICE_WORKER_OK: |
| 20 return blink::mojom::ServiceWorkerEventStatus::COMPLETED; |
| 21 case content::SERVICE_WORKER_ERROR_EVENT_WAITUNTIL_REJECTED: |
| 22 return blink::mojom::ServiceWorkerEventStatus::REJECTED; |
| 23 case content::SERVICE_WORKER_ERROR_ABORT: |
| 24 return blink::mojom::ServiceWorkerEventStatus::ABORTED; |
| 25 default: |
| 26 NOTREACHED() << "Unexpected ServiceWorkerStatusCode: " << input; |
| 27 return blink::mojom::ServiceWorkerEventStatus::ABORTED; |
| 28 } |
| 29 } |
| 30 |
| 31 // static |
| 32 bool EnumTraits<blink::mojom::ServiceWorkerEventStatus, |
| 33 content::ServiceWorkerStatusCode>:: |
| 34 FromMojom(blink::mojom::ServiceWorkerEventStatus input, |
| 35 content::ServiceWorkerStatusCode* out) { |
| 36 switch (input) { |
| 37 case blink::mojom::ServiceWorkerEventStatus::COMPLETED: |
| 38 *out = content::SERVICE_WORKER_OK; |
| 39 return true; |
| 40 case blink::mojom::ServiceWorkerEventStatus::REJECTED: |
| 41 *out = content::SERVICE_WORKER_ERROR_EVENT_WAITUNTIL_REJECTED; |
| 42 return true; |
| 43 case blink::mojom::ServiceWorkerEventStatus::ABORTED: |
| 44 *out = content::SERVICE_WORKER_ERROR_ABORT; |
| 45 return true; |
| 46 } |
| 47 NOTREACHED(); |
| 48 return false; |
| 49 } |
| 50 |
| 51 } // namespace content |
OLD | NEW |