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

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

Issue 2664753002: Remove base::StringValue (Closed)
Patch Set: Rebase 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 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 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 // assigned. 546 // assigned.
547 // 547 //
548 // Don't forget to update the "SyncModelTypes" enum in histograms.xml when you 548 // Don't forget to update the "SyncModelTypes" enum in histograms.xml when you
549 // make changes to this list. 549 // make changes to this list.
550 int ModelTypeToHistogramInt(ModelType model_type) { 550 int ModelTypeToHistogramInt(ModelType model_type) {
551 if (model_type >= UNSPECIFIED && model_type < MODEL_TYPE_COUNT) 551 if (model_type >= UNSPECIFIED && model_type < MODEL_TYPE_COUNT)
552 return kModelTypeInfoMap[model_type].model_type_histogram_val; 552 return kModelTypeInfoMap[model_type].model_type_histogram_val;
553 return 0; 553 return 0;
554 } 554 }
555 555
556 base::StringValue* ModelTypeToValue(ModelType model_type) { 556 base::Value* ModelTypeToValue(ModelType model_type) {
557 if (model_type >= FIRST_REAL_MODEL_TYPE) { 557 if (model_type >= FIRST_REAL_MODEL_TYPE) {
558 return new base::StringValue(ModelTypeToString(model_type)); 558 return new base::Value(ModelTypeToString(model_type));
559 } else if (model_type == TOP_LEVEL_FOLDER) { 559 } else if (model_type == TOP_LEVEL_FOLDER) {
560 return new base::StringValue("Top-level folder"); 560 return new base::Value("Top-level folder");
561 } else if (model_type == UNSPECIFIED) { 561 } else if (model_type == UNSPECIFIED) {
562 return new base::StringValue("Unspecified"); 562 return new base::Value("Unspecified");
563 } 563 }
564 NOTREACHED(); 564 NOTREACHED();
565 return new base::StringValue(std::string()); 565 return new base::Value(std::string());
566 } 566 }
567 567
568 ModelType ModelTypeFromValue(const base::Value& value) { 568 ModelType ModelTypeFromValue(const base::Value& value) {
569 if (value.IsType(base::Value::Type::STRING)) { 569 if (value.IsType(base::Value::Type::STRING)) {
570 std::string result; 570 std::string result;
571 CHECK(value.GetAsString(&result)); 571 CHECK(value.GetAsString(&result));
572 return ModelTypeFromString(result); 572 return ModelTypeFromString(result);
573 } else if (value.IsType(base::Value::Type::INTEGER)) { 573 } else if (value.IsType(base::Value::Type::INTEGER)) {
574 int result; 574 int result;
575 CHECK(value.GetAsInteger(&result)); 575 CHECK(value.GetAsInteger(&result));
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 bool TypeSupportsHierarchy(ModelType model_type) { 716 bool TypeSupportsHierarchy(ModelType model_type) {
717 // TODO(stanisc): crbug/438313: Should this also include TOP_LEVEL_FOLDER? 717 // TODO(stanisc): crbug/438313: Should this also include TOP_LEVEL_FOLDER?
718 return model_type == BOOKMARKS; 718 return model_type == BOOKMARKS;
719 } 719 }
720 720
721 bool TypeSupportsOrdering(ModelType model_type) { 721 bool TypeSupportsOrdering(ModelType model_type) {
722 return model_type == BOOKMARKS; 722 return model_type == BOOKMARKS;
723 } 723 }
724 724
725 } // namespace syncer 725 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/syncable/entry_kernel.cc ('k') | components/sync/syncable/model_type_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698