1c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Copyright (c) 2012 The Chromium Authors. All rights reserved. 2c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// Use of this source code is governed by a BSD-style license that can be 3c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// found in the LICENSE file. 4c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott 5c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#include "sync/notifier/invalidator_state.h" 6c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott 7c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "base/logging.h" 8c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 9c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochnamespace syncer { 10731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick 11c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochconst char* InvalidatorStateToString(InvalidatorState state) { 12c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch switch (state) { 133f50c38dc070f4bb515c1b64450dae14f316474eKristian Monsen case TRANSIENT_INVALIDATION_ERROR: 14c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch return "TRANSIENT_INVALIDATION_ERROR"; 15c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch case INVALIDATION_CREDENTIALS_REJECTED: 16c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch return "INVALIDATION_CREDENTIALS_REJECTED"; 17c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott case INVALIDATIONS_ENABLED: 18c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott return "INVALIDATIONS_ENABLED"; 19c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch default: 20c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch NOTREACHED(); 21c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch return "UNKNOWN_INVALIDATOR_STATE"; 22c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch } 23c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch} 24c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 25731df977c0511bca2206b5f333555b1205ff1f43Iain MerrickInvalidatorState FromNotifierReason( 26731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick notifier::NotificationsDisabledReason reason) { 27731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick switch (reason) { 28731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick case notifier::NO_NOTIFICATION_ERROR: 29731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick return INVALIDATIONS_ENABLED; 30c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch case notifier::TRANSIENT_NOTIFICATION_ERROR: 31731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick return TRANSIENT_INVALIDATION_ERROR; 32731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick case notifier::NOTIFICATION_CREDENTIALS_REJECTED: 33731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick return INVALIDATION_CREDENTIALS_REJECTED; 34c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch default: 35731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick NOTREACHED(); 36731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick return DEFAULT_INVALIDATION_ERROR; 37731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick } 38731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick} 39c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 40731df977c0511bca2206b5f333555b1205ff1f43Iain Merricknotifier::NotificationsDisabledReason ToNotifierReasonForTest( 41731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick InvalidatorState state) { 42731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick switch (state) { 43c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch case TRANSIENT_INVALIDATION_ERROR: 44c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch return notifier::TRANSIENT_NOTIFICATION_ERROR; 45731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick case INVALIDATION_CREDENTIALS_REJECTED: 46731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick return notifier::NOTIFICATION_CREDENTIALS_REJECTED; 47731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick case INVALIDATIONS_ENABLED: 48c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Fall through. 49731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick default: 50731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick NOTREACHED(); 51731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick return notifier::TRANSIENT_NOTIFICATION_ERROR; 52731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick } 53c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch} 54731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick 55731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick} // namespace syncer 56731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick