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

Unified Diff: content/browser/background_sync/background_sync_registration.cc

Issue 1230213004: [Background Sync] Sent sync registration details to worker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bgsync-event-mek
Patch Set: Remove const ref from mojo StructPtr (with rebase) Created 5 years, 5 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/browser/background_sync/background_sync_registration.cc
diff --git a/content/browser/background_sync/background_sync_registration.cc b/content/browser/background_sync/background_sync_registration.cc
index d5a9b0abe5e17e1339361f8ea28e9db81a41a480..427580a4174186c7ee6147f44865fe28001a7015 100644
--- a/content/browser/background_sync/background_sync_registration.cc
+++ b/content/browser/background_sync/background_sync_registration.cc
@@ -4,6 +4,78 @@
#include "content/browser/background_sync/background_sync_registration.h"
+namespace mojo {
+
+#define COMPILE_ASSERT_MATCHING_ENUM(mojo_name, browser_name) \
+ COMPILE_ASSERT(static_cast<int>(content::mojo_name) == \
+ static_cast<int>(content::browser_name), \
+ mismatching_enums)
+
+COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_PERIODICITY_PERIODIC,
+ SYNC_PERIODIC);
+COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_PERIODICITY_ONE_SHOT,
+ SYNC_ONE_SHOT);
+COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_PERIODICITY_MAX, SYNC_ONE_SHOT);
+COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_PERIODICITY_MAX,
+ SyncPeriodicity_MAX);
+COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_NETWORK_STATE_ANY,
+ NETWORK_STATE_ANY);
+COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_NETWORK_STATE_AVOID_CELLULAR,
+ NETWORK_STATE_AVOID_CELLULAR);
+COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_NETWORK_STATE_ONLINE,
+ NETWORK_STATE_ONLINE);
+COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_NETWORK_STATE_MAX,
+ NETWORK_STATE_ONLINE);
+COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_NETWORK_STATE_MAX,
+ SyncNetworkState_MAX);
+COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_POWER_STATE_AUTO,
+ POWER_STATE_AUTO);
+COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_POWER_STATE_AVOID_DRAINING,
+ POWER_STATE_AVOID_DRAINING);
+COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_POWER_STATE_MAX,
+ POWER_STATE_AVOID_DRAINING);
+COMPILE_ASSERT_MATCHING_ENUM(BACKGROUND_SYNC_POWER_STATE_MAX,
+ SyncPowerState_MAX);
+
+// static
+scoped_ptr<content::BackgroundSyncRegistration> TypeConverter<
+ scoped_ptr<content::BackgroundSyncRegistration>,
+ content::SyncRegistrationPtr>::Convert(const content::SyncRegistrationPtr&
+ in) {
+ scoped_ptr<content::BackgroundSyncRegistration> out(
+ new content::BackgroundSyncRegistration());
+ out->set_id(in->id);
+ content::BackgroundSyncRegistrationOptions* options = out->options();
+ options->tag = in->tag;
+ options->min_period = in->min_period_ms;
+ options->power_state = static_cast<content::SyncPowerState>(in->power_state);
+ options->network_state =
+ static_cast<content::SyncNetworkState>(in->network_state);
+ options->periodicity = static_cast<content::SyncPeriodicity>(in->periodicity);
+ return out;
+}
+
+// static
+content::SyncRegistrationPtr
+TypeConverter<content::SyncRegistrationPtr,
+ content::BackgroundSyncRegistration>::
+ Convert(const content::BackgroundSyncRegistration& in) {
+ content::SyncRegistrationPtr out(content::SyncRegistration::New());
+ out->id = in.id();
+ const content::BackgroundSyncRegistrationOptions* options = in.options();
+ out->tag = options->tag;
+ out->min_period_ms = options->min_period;
+ out->periodicity =
+ static_cast<content::BackgroundSyncPeriodicity>(options->periodicity);
+ out->power_state =
+ static_cast<content::BackgroundSyncPowerState>(options->power_state);
+ out->network_state =
+ static_cast<content::BackgroundSyncNetworkState>(options->network_state);
+ return out.Pass();
+}
+
+} // namespace
+
namespace content {
// TODO(thakis): Remove this once http://crbug.com/488634 is fixed.

Powered by Google App Engine
This is Rietveld 408576698