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

Side by Side Diff: components/sync/syncable/model_type.cc

Issue 2539363004: Make base::Value::TYPE a scoped enum. (Closed)
Patch Set: Rebase Created 4 years 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/sync/base/model_type.h" 5 #include "components/sync/base/model_type.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 } else if (model_type == TOP_LEVEL_FOLDER) { 608 } else if (model_type == TOP_LEVEL_FOLDER) {
609 return new base::StringValue("Top-level folder"); 609 return new base::StringValue("Top-level folder");
610 } else if (model_type == UNSPECIFIED) { 610 } else if (model_type == UNSPECIFIED) {
611 return new base::StringValue("Unspecified"); 611 return new base::StringValue("Unspecified");
612 } 612 }
613 NOTREACHED(); 613 NOTREACHED();
614 return new base::StringValue(std::string()); 614 return new base::StringValue(std::string());
615 } 615 }
616 616
617 ModelType ModelTypeFromValue(const base::Value& value) { 617 ModelType ModelTypeFromValue(const base::Value& value) {
618 if (value.IsType(base::Value::TYPE_STRING)) { 618 if (value.IsType(base::Value::Type::STRING)) {
619 std::string result; 619 std::string result;
620 CHECK(value.GetAsString(&result)); 620 CHECK(value.GetAsString(&result));
621 return ModelTypeFromString(result); 621 return ModelTypeFromString(result);
622 } else if (value.IsType(base::Value::TYPE_INTEGER)) { 622 } else if (value.IsType(base::Value::Type::INTEGER)) {
623 int result; 623 int result;
624 CHECK(value.GetAsInteger(&result)); 624 CHECK(value.GetAsInteger(&result));
625 return ModelTypeFromInt(result); 625 return ModelTypeFromInt(result);
626 } else { 626 } else {
627 NOTREACHED() << "Unsupported value type: " << value.GetType(); 627 NOTREACHED() << "Unsupported value type: " << value.GetType();
628 return UNSPECIFIED; 628 return UNSPECIFIED;
629 } 629 }
630 } 630 }
631 631
632 ModelType ModelTypeFromString(const std::string& model_type_string) { 632 ModelType ModelTypeFromString(const std::string& model_type_string) {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 bool TypeSupportsHierarchy(ModelType model_type) { 765 bool TypeSupportsHierarchy(ModelType model_type) {
766 // TODO(stanisc): crbug/438313: Should this also include TOP_LEVEL_FOLDER? 766 // TODO(stanisc): crbug/438313: Should this also include TOP_LEVEL_FOLDER?
767 return model_type == BOOKMARKS; 767 return model_type == BOOKMARKS;
768 } 768 }
769 769
770 bool TypeSupportsOrdering(ModelType model_type) { 770 bool TypeSupportsOrdering(ModelType model_type) {
771 return model_type == BOOKMARKS; 771 return model_type == BOOKMARKS;
772 } 772 }
773 773
774 } // namespace syncer 774 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/driver/sync_policy_handler.cc ('k') | components/sync_preferences/pref_model_associator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698