OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/cloud_devices/common/cloud_device_description.h" | 5 #include "components/cloud_devices/common/cloud_device_description.h" |
6 | 6 |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 base::DictionaryValue* description = NULL; | 40 base::DictionaryValue* description = NULL; |
41 if (!parsed || !parsed->GetAsDictionary(&description)) | 41 if (!parsed || !parsed->GetAsDictionary(&description)) |
42 return false; | 42 return false; |
43 ignore_result(parsed.release()); | 43 ignore_result(parsed.release()); |
44 return InitFromDictionary(make_scoped_ptr(description)); | 44 return InitFromDictionary(make_scoped_ptr(description)); |
45 } | 45 } |
46 | 46 |
47 std::string CloudDeviceDescription::ToString() const { | 47 std::string CloudDeviceDescription::ToString() const { |
48 std::string json; | 48 std::string json; |
49 base::JSONWriter::WriteWithOptions( | 49 base::JSONWriter::WriteWithOptions( |
50 root_.get(), base::JSONWriter::OPTIONS_PRETTY_PRINT, &json); | 50 *root_, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json); |
51 return json; | 51 return json; |
52 } | 52 } |
53 | 53 |
54 const base::DictionaryValue* CloudDeviceDescription::GetItem( | 54 const base::DictionaryValue* CloudDeviceDescription::GetItem( |
55 const std::string& path) const { | 55 const std::string& path) const { |
56 const base::DictionaryValue* value = NULL; | 56 const base::DictionaryValue* value = NULL; |
57 root_->GetDictionary(path, &value); | 57 root_->GetDictionary(path, &value); |
58 return value; | 58 return value; |
59 } | 59 } |
60 | 60 |
(...skipping 12 matching lines...) Expand all Loading... |
73 } | 73 } |
74 | 74 |
75 base::ListValue* CloudDeviceDescription::CreateListItem( | 75 base::ListValue* CloudDeviceDescription::CreateListItem( |
76 const std::string& path) { | 76 const std::string& path) { |
77 base::ListValue* value = new base::ListValue; | 77 base::ListValue* value = new base::ListValue; |
78 root_->Set(path, value); | 78 root_->Set(path, value); |
79 return value; | 79 return value; |
80 } | 80 } |
81 | 81 |
82 } // namespace cloud_devices | 82 } // namespace cloud_devices |
OLD | NEW |