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

Side by Side Diff: components/policy/core/common/registry_dict_win.cc

Issue 665663002: Use scoped_ptr::Pass instead of scoped_ptr::PassAs<T>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git/+/master
Patch Set: Format Created 6 years, 2 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
« no previous file with comments | « chromecast/browser/url_request_context_factory.cc ('k') | device/test/usb_test_gadget_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/policy/core/common/registry_dict_win.h" 5 #include "components/policy/core/common/registry_dict_win.h"
6 6
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 return result.Pass(); 46 return result.Pass();
47 } else if (value.GetAsList(&list)) { 47 } else if (value.GetAsList(&list)) {
48 scoped_ptr<base::ListValue> result(new base::ListValue()); 48 scoped_ptr<base::ListValue> result(new base::ListValue());
49 for (base::ListValue::const_iterator entry(list->begin()); 49 for (base::ListValue::const_iterator entry(list->begin());
50 entry != list->end(); ++entry) { 50 entry != list->end(); ++entry) {
51 scoped_ptr<base::Value> converted = 51 scoped_ptr<base::Value> converted =
52 ConvertValue(**entry, schema.GetItems()); 52 ConvertValue(**entry, schema.GetItems());
53 if (converted) 53 if (converted)
54 result->Append(converted.release()); 54 result->Append(converted.release());
55 } 55 }
56 return result.PassAs<base::Value>(); 56 return result.Pass();
57 } 57 }
58 return make_scoped_ptr(value.DeepCopy()).Pass(); 58 return make_scoped_ptr(value.DeepCopy());
59 } 59 }
60 60
61 // Else, do some conversions to map windows registry data types to JSON types. 61 // Else, do some conversions to map windows registry data types to JSON types.
62 std::string string_value; 62 std::string string_value;
63 int int_value = 0; 63 int int_value = 0;
64 switch (schema.type()) { 64 switch (schema.type()) {
65 case base::Value::TYPE_NULL: { 65 case base::Value::TYPE_NULL: {
66 return make_scoped_ptr(base::Value::CreateNullValue()).Pass(); 66 return make_scoped_ptr(base::Value::CreateNullValue()).Pass();
67 } 67 }
68 case base::Value::TYPE_BOOLEAN: { 68 case base::Value::TYPE_BOOLEAN: {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 scoped_ptr<base::ListValue> result(new base::ListValue()); 101 scoped_ptr<base::ListValue> result(new base::ListValue());
102 for (int i = 1; ; ++i) { 102 for (int i = 1; ; ++i) {
103 const base::Value* entry = NULL; 103 const base::Value* entry = NULL;
104 if (!dict->Get(base::IntToString(i), &entry)) 104 if (!dict->Get(base::IntToString(i), &entry))
105 break; 105 break;
106 scoped_ptr<base::Value> converted = 106 scoped_ptr<base::Value> converted =
107 ConvertValue(*entry, schema.GetItems()); 107 ConvertValue(*entry, schema.GetItems());
108 if (converted) 108 if (converted)
109 result->Append(converted.release()); 109 result->Append(converted.release());
110 } 110 }
111 return result.PassAs<base::Value>(); 111 return result.Pass();
112 } 112 }
113 // Fall through in order to accept lists encoded as JSON strings. 113 // Fall through in order to accept lists encoded as JSON strings.
114 } 114 }
115 case base::Value::TYPE_DICTIONARY: { 115 case base::Value::TYPE_DICTIONARY: {
116 // Dictionaries may be encoded as JSON strings. 116 // Dictionaries may be encoded as JSON strings.
117 if (value.GetAsString(&string_value)) { 117 if (value.GetAsString(&string_value)) {
118 scoped_ptr<base::Value> result(base::JSONReader::Read(string_value)); 118 scoped_ptr<base::Value> result(base::JSONReader::Read(string_value));
119 if (result && result->IsType(schema.type())) 119 if (result && result->IsType(schema.type()))
120 return result.Pass(); 120 return result.Pass();
121 } 121 }
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 return result.Pass(); 341 return result.Pass();
342 } 342 }
343 default: 343 default:
344 LOG(WARNING) << "Can't convert registry key to schema type " << type; 344 LOG(WARNING) << "Can't convert registry key to schema type " << type;
345 } 345 }
346 346
347 return nullptr; 347 return nullptr;
348 } 348 }
349 349
350 } // namespace policy 350 } // namespace policy
OLDNEW
« no previous file with comments | « chromecast/browser/url_request_context_factory.cc ('k') | device/test/usb_test_gadget_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698