Index: content/common/service_worker/service_worker_type_converters.cc |
diff --git a/content/common/service_worker/service_worker_type_converters.cc b/content/common/service_worker/service_worker_type_converters.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e3a8896a1f2167fdad970ec30545d3cd21d9df25 |
--- /dev/null |
+++ b/content/common/service_worker/service_worker_type_converters.cc |
@@ -0,0 +1,30 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "content/common/service_worker/service_worker_type_converters.h" |
+ |
+#include "base/logging.h" |
+ |
+namespace mojo { |
+ |
+// TODO(iclelland): Make these enums equivalent so that conversion can be a |
+// static cast. |
+content::ServiceWorkerStatusCode |
+TypeConverter<content::ServiceWorkerStatusCode, |
+ content::ServiceWorkerEventStatus>:: |
+ Convert(content::ServiceWorkerEventStatus status) { |
+ content::ServiceWorkerStatusCode status_code = content::SERVICE_WORKER_OK; |
Marijn Kruisselbrink
2015/07/17 17:12:15
Should the default really be SERVICE_WORKER_OK? It
iclelland
2015/07/20 16:06:16
Hence the NOTREACHED() further down -- the value h
|
+ if (status == content::SERVICE_WORKER_EVENT_STATUS_COMPLETED) { |
+ status_code = content::SERVICE_WORKER_OK; |
+ } else if (status == content::SERVICE_WORKER_EVENT_STATUS_REJECTED) { |
+ status_code = content::SERVICE_WORKER_ERROR_EVENT_WAITUNTIL_REJECTED; |
+ } else if (status == content::SERVICE_WORKER_EVENT_STATUS_ABORTED) { |
+ status_code = content::SERVICE_WORKER_ERROR_ABORT; |
+ } else { |
+ NOTREACHED(); |
+ } |
+ return status_code; |
+} |
+ |
+} // namespace |