Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(421)

Unified Diff: content/common/background_fetch/background_fetch_struct_traits.cc

Issue 2762573003: Implement BackgroundFetchManager.fetch() and struct traits (Closed)
Patch Set: First round of comments Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/common/background_fetch/background_fetch_struct_traits.cc
diff --git a/content/common/background_fetch/background_fetch_struct_traits.cc b/content/common/background_fetch/background_fetch_struct_traits.cc
new file mode 100644
index 0000000000000000000000000000000000000000..50dd6d654cb5c7fbe5d9be00f462bd9c704a6514
--- /dev/null
+++ b/content/common/background_fetch/background_fetch_struct_traits.cc
@@ -0,0 +1,47 @@
+// Copyright 2017 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/background_fetch/background_fetch_struct_traits.h"
+
+#include "mojo/public/cpp/bindings/array_data_view.h"
+
+namespace mojo {
+
+// static
+bool StructTraits<blink::mojom::BackgroundFetchOptionsDataView,
+ content::BackgroundFetchOptions>::
+ Read(blink::mojom::BackgroundFetchOptionsDataView data,
+ content::BackgroundFetchOptions* options) {
+ if (!data.ReadIcons(&options->icons) || !data.ReadTitle(&options->title))
+ return false;
+
+ options->total_download_size = data.total_download_size();
+ return true;
+}
+
+// static
+bool StructTraits<blink::mojom::BackgroundFetchRegistrationDataView,
+ content::BackgroundFetchRegistration>::
+ Read(blink::mojom::BackgroundFetchRegistrationDataView data,
+ content::BackgroundFetchRegistration* registration) {
+ if (!data.ReadTag(&registration->tag) ||
+ !data.ReadIcons(&registration->icons) ||
+ !data.ReadTitle(&registration->title)) {
+ return false;
+ }
+
+ registration->total_download_size = data.total_download_size();
+ return true;
+}
+
+// static
+bool StructTraits<
+ blink::mojom::IconDefinitionDataView,
+ content::IconDefinition>::Read(blink::mojom::IconDefinitionDataView data,
+ content::IconDefinition* definition) {
+ return data.ReadSrc(&definition->src) && data.ReadSizes(&definition->sizes) &&
+ data.ReadType(&definition->type);
+}
+
+} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698