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

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

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.h
diff --git a/content/common/background_fetch/background_fetch_struct_traits.h b/content/common/background_fetch/background_fetch_struct_traits.h
new file mode 100644
index 0000000000000000000000000000000000000000..c824610e2b29c85016fa5769692fa7500ff3737e
--- /dev/null
+++ b/content/common/background_fetch/background_fetch_struct_traits.h
@@ -0,0 +1,82 @@
+// 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.
+
+#ifndef CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_STRUCT_TRAITS_H_
+#define CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_STRUCT_TRAITS_H_
+
+#include <string>
+#include <vector>
+
+#include "content/common/background_fetch/background_fetch_types.h"
+#include "content/common/content_export.h"
+#include "mojo/public/cpp/bindings/struct_traits.h"
+#include "third_party/WebKit/public/platform/modules/background_fetch/background_fetch.mojom.h"
+
+namespace mojo {
+
+template <>
+struct CONTENT_EXPORT StructTraits<blink::mojom::BackgroundFetchOptionsDataView,
+ content::BackgroundFetchOptions> {
+ static const std::vector<content::IconDefinition>& icons(
+ const content::BackgroundFetchOptions& options) {
+ return options.icons;
+ }
+ static const std::string& title(
+ const content::BackgroundFetchOptions& options) {
+ return options.title;
+ }
+ static int64_t total_download_size(
+ const content::BackgroundFetchOptions& options) {
+ return options.total_download_size;
+ }
+
+ static bool Read(blink::mojom::BackgroundFetchOptionsDataView data,
+ content::BackgroundFetchOptions* options);
+};
+
+template <>
+struct CONTENT_EXPORT
+ StructTraits<blink::mojom::BackgroundFetchRegistrationDataView,
+ content::BackgroundFetchRegistration> {
+ static const std::string& tag(
+ const content::BackgroundFetchRegistration& registration) {
+ return registration.tag;
+ }
+ static const std::vector<content::IconDefinition>& icons(
+ const content::BackgroundFetchRegistration& registration) {
+ return registration.icons;
+ }
+ static const std::string& title(
+ const content::BackgroundFetchRegistration& registration) {
+ return registration.title;
+ }
+ static int64_t total_download_size(
+ const content::BackgroundFetchRegistration& registration) {
+ return registration.total_download_size;
+ }
+
+ static bool Read(blink::mojom::BackgroundFetchRegistrationDataView data,
+ content::BackgroundFetchRegistration* registration);
+};
+
+template <>
+struct CONTENT_EXPORT StructTraits<blink::mojom::IconDefinitionDataView,
+ content::IconDefinition> {
+ static const std::string& src(const content::IconDefinition& definition) {
+ return definition.src;
+ }
+ static const std::string& sizes(const content::IconDefinition& definition) {
+ return definition.sizes;
+ }
+ static const std::string& type(const content::IconDefinition& definition) {
+ return definition.type;
+ }
+
+ static bool Read(blink::mojom::IconDefinitionDataView data,
+ content::IconDefinition* definition);
+};
+
+} // namespace mojo
+
+#endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_STRUCT_TRAITS_H_

Powered by Google App Engine
This is Rietveld 408576698