| OLD | NEW |
| 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 "chromeos/dbus/nfc_client_helpers.h" | 5 #include "chromeos/dbus/nfc_client_helpers.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "dbus/values_util.h" | 8 #include "dbus/values_util.h" |
| 9 | 9 |
| 10 namespace chromeos { | 10 namespace chromeos { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 object_path_set.insert(object_path_set_iter, object_path); | 85 object_path_set.insert(object_path_set_iter, object_path); |
| 86 } | 86 } |
| 87 | 87 |
| 88 // Remove all objects that are not in |object_paths|. | 88 // Remove all objects that are not in |object_paths|. |
| 89 ObjectMap::const_iterator iter = object_map_.begin(); | 89 ObjectMap::const_iterator iter = object_map_.begin(); |
| 90 while (iter != object_map_.end()) { | 90 while (iter != object_map_.end()) { |
| 91 // It is safe to use a const reference here, as DBusObjectMap::RemoveObject | 91 // It is safe to use a const reference here, as DBusObjectMap::RemoveObject |
| 92 // won't access it after the iterator becomes invalidated. | 92 // won't access it after the iterator becomes invalidated. |
| 93 const dbus::ObjectPath &object_path = iter->first; | 93 const dbus::ObjectPath &object_path = iter->first; |
| 94 ++iter; | 94 ++iter; |
| 95 if (!ContainsKey(object_path_set, object_path)) | 95 if (!base::ContainsKey(object_path_set, object_path)) |
| 96 RemoveObject(object_path); | 96 RemoveObject(object_path); |
| 97 } | 97 } |
| 98 } | 98 } |
| 99 | 99 |
| 100 bool DBusObjectMap::AddObject(const dbus::ObjectPath& object_path) { | 100 bool DBusObjectMap::AddObject(const dbus::ObjectPath& object_path) { |
| 101 ObjectMap::iterator iter = object_map_.find(object_path); | 101 ObjectMap::iterator iter = object_map_.find(object_path); |
| 102 if (iter != object_map_.end()) | 102 if (iter != object_map_.end()) |
| 103 return false; | 103 return false; |
| 104 | 104 |
| 105 DCHECK(bus_); | 105 DCHECK(bus_); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 iter != paths_to_object_maps_.end(); ++iter) { | 187 iter != paths_to_object_maps_.end(); ++iter) { |
| 188 DBusObjectMap* object_map = iter->second; | 188 DBusObjectMap* object_map = iter->second; |
| 189 delete object_map; | 189 delete object_map; |
| 190 } | 190 } |
| 191 } | 191 } |
| 192 | 192 |
| 193 bool ObjectProxyTree::CreateObjectMap(const dbus::ObjectPath& object_path, | 193 bool ObjectProxyTree::CreateObjectMap(const dbus::ObjectPath& object_path, |
| 194 const std::string& service_name, | 194 const std::string& service_name, |
| 195 DBusObjectMap::Delegate* delegate, | 195 DBusObjectMap::Delegate* delegate, |
| 196 dbus::Bus* bus) { | 196 dbus::Bus* bus) { |
| 197 if (ContainsKey(paths_to_object_maps_, object_path)) { | 197 if (base::ContainsKey(paths_to_object_maps_, object_path)) { |
| 198 LOG(ERROR) << "Mapping already exists for object path: " | 198 LOG(ERROR) << "Mapping already exists for object path: " |
| 199 << object_path.value(); | 199 << object_path.value(); |
| 200 return false; | 200 return false; |
| 201 } | 201 } |
| 202 paths_to_object_maps_[object_path] = | 202 paths_to_object_maps_[object_path] = |
| 203 new DBusObjectMap(service_name, delegate, bus); | 203 new DBusObjectMap(service_name, delegate, bus); |
| 204 return true; | 204 return true; |
| 205 } | 205 } |
| 206 | 206 |
| 207 void ObjectProxyTree::RemoveObjectMap(const dbus::ObjectPath& object_path) { | 207 void ObjectProxyTree::RemoveObjectMap(const dbus::ObjectPath& object_path) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 NfcPropertySet* properties = | 244 NfcPropertySet* properties = |
| 245 object_map->GetObjectProperties(object_proxy_path); | 245 object_map->GetObjectProperties(object_proxy_path); |
| 246 if (properties) | 246 if (properties) |
| 247 return properties; | 247 return properties; |
| 248 } | 248 } |
| 249 return NULL; | 249 return NULL; |
| 250 } | 250 } |
| 251 | 251 |
| 252 } // namespace nfc_client_helpers | 252 } // namespace nfc_client_helpers |
| 253 } // namespace chromeos | 253 } // namespace chromeos |
| OLD | NEW |