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

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

Issue 2889163002: Remove raw DictionaryValue::Set in //components (Closed)
Patch Set: Nits Created 3 years, 6 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/memory/ptr_util.h"
10 #include "base/strings/string_split.h" 11 #include "base/strings/string_split.h"
11 #include "base/values.h" 12 #include "base/values.h"
12 #include "components/reading_list/core/reading_list_enable_flags.h" 13 #include "components/reading_list/core/reading_list_enable_flags.h"
13 #include "components/sync/protocol/app_notification_specifics.pb.h" 14 #include "components/sync/protocol/app_notification_specifics.pb.h"
14 #include "components/sync/protocol/app_setting_specifics.pb.h" 15 #include "components/sync/protocol/app_setting_specifics.pb.h"
15 #include "components/sync/protocol/app_specifics.pb.h" 16 #include "components/sync/protocol/app_specifics.pb.h"
16 #include "components/sync/protocol/autofill_specifics.pb.h" 17 #include "components/sync/protocol/autofill_specifics.pb.h"
17 #include "components/sync/protocol/bookmark_specifics.pb.h" 18 #include "components/sync/protocol/bookmark_specifics.pb.h"
18 #include "components/sync/protocol/extension_setting_specifics.pb.h" 19 #include "components/sync/protocol/extension_setting_specifics.pb.h"
19 #include "components/sync/protocol/extension_specifics.pb.h" 20 #include "components/sync/protocol/extension_specifics.pb.h"
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 // assigned. 556 // assigned.
556 // 557 //
557 // Don't forget to update the "SyncModelTypes" enum in histograms.xml when you 558 // Don't forget to update the "SyncModelTypes" enum in histograms.xml when you
558 // make changes to this list. 559 // make changes to this list.
559 int ModelTypeToHistogramInt(ModelType model_type) { 560 int ModelTypeToHistogramInt(ModelType model_type) {
560 if (model_type >= UNSPECIFIED && model_type < MODEL_TYPE_COUNT) 561 if (model_type >= UNSPECIFIED && model_type < MODEL_TYPE_COUNT)
561 return kModelTypeInfoMap[model_type].model_type_histogram_val; 562 return kModelTypeInfoMap[model_type].model_type_histogram_val;
562 return 0; 563 return 0;
563 } 564 }
564 565
565 base::Value* ModelTypeToValue(ModelType model_type) { 566 std::unique_ptr<base::Value> ModelTypeToValue(ModelType model_type) {
566 if (model_type >= FIRST_REAL_MODEL_TYPE) { 567 if (model_type >= FIRST_REAL_MODEL_TYPE) {
567 return new base::Value(ModelTypeToString(model_type)); 568 return base::MakeUnique<base::Value>(ModelTypeToString(model_type));
568 } else if (model_type == TOP_LEVEL_FOLDER) { 569 } else if (model_type == TOP_LEVEL_FOLDER) {
569 return new base::Value("Top-level folder"); 570 return base::MakeUnique<base::Value>("Top-level folder");
570 } else if (model_type == UNSPECIFIED) { 571 } else if (model_type == UNSPECIFIED) {
571 return new base::Value("Unspecified"); 572 return base::MakeUnique<base::Value>("Unspecified");
572 } 573 }
573 NOTREACHED(); 574 NOTREACHED();
574 return new base::Value(std::string()); 575 return base::MakeUnique<base::Value>(std::string());
575 } 576 }
576 577
577 ModelType ModelTypeFromValue(const base::Value& value) { 578 ModelType ModelTypeFromValue(const base::Value& value) {
578 if (value.IsType(base::Value::Type::STRING)) { 579 if (value.IsType(base::Value::Type::STRING)) {
579 std::string result; 580 std::string result;
580 CHECK(value.GetAsString(&result)); 581 CHECK(value.GetAsString(&result));
581 return ModelTypeFromString(result); 582 return ModelTypeFromString(result);
582 } else if (value.IsType(base::Value::Type::INTEGER)) { 583 } else if (value.IsType(base::Value::Type::INTEGER)) {
583 int result; 584 int result;
584 CHECK(value.GetAsInteger(&result)); 585 CHECK(value.GetAsInteger(&result));
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 bool TypeSupportsHierarchy(ModelType model_type) { 726 bool TypeSupportsHierarchy(ModelType model_type) {
726 // TODO(stanisc): crbug/438313: Should this also include TOP_LEVEL_FOLDER? 727 // TODO(stanisc): crbug/438313: Should this also include TOP_LEVEL_FOLDER?
727 return model_type == BOOKMARKS; 728 return model_type == BOOKMARKS;
728 } 729 }
729 730
730 bool TypeSupportsOrdering(ModelType model_type) { 731 bool TypeSupportsOrdering(ModelType model_type) {
731 return model_type == BOOKMARKS; 732 return model_type == BOOKMARKS;
732 } 733 }
733 734
734 } // namespace syncer 735 } // 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