| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/network/network_profile_handler.h" | 5 #include "chromeos/network/network_profile_handler.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 } | 149 } |
| 150 std::string userhash; | 150 std::string userhash; |
| 151 properties.GetStringWithoutPathExpansion(shill::kUserHashProperty, &userhash); | 151 properties.GetStringWithoutPathExpansion(shill::kUserHashProperty, &userhash); |
| 152 | 152 |
| 153 AddProfile(NetworkProfile(profile_path, userhash)); | 153 AddProfile(NetworkProfile(profile_path, userhash)); |
| 154 } | 154 } |
| 155 | 155 |
| 156 void NetworkProfileHandler::AddProfile(const NetworkProfile& profile) { | 156 void NetworkProfileHandler::AddProfile(const NetworkProfile& profile) { |
| 157 VLOG(2) << "Adding profile " << profile.ToDebugString() << "."; | 157 VLOG(2) << "Adding profile " << profile.ToDebugString() << "."; |
| 158 profiles_.push_back(profile); | 158 profiles_.push_back(profile); |
| 159 FOR_EACH_OBSERVER(NetworkProfileObserver, observers_, | 159 for (auto& observer : observers_) |
| 160 OnProfileAdded(profiles_.back())); | 160 observer.OnProfileAdded(profiles_.back()); |
| 161 } | 161 } |
| 162 | 162 |
| 163 void NetworkProfileHandler::RemoveProfile(const std::string& profile_path) { | 163 void NetworkProfileHandler::RemoveProfile(const std::string& profile_path) { |
| 164 VLOG(2) << "Removing profile for path " << profile_path << "."; | 164 VLOG(2) << "Removing profile for path " << profile_path << "."; |
| 165 ProfileList::iterator found = std::find_if(profiles_.begin(), profiles_.end(), | 165 ProfileList::iterator found = std::find_if(profiles_.begin(), profiles_.end(), |
| 166 ProfilePathEquals(profile_path)); | 166 ProfilePathEquals(profile_path)); |
| 167 if (found == profiles_.end()) | 167 if (found == profiles_.end()) |
| 168 return; | 168 return; |
| 169 NetworkProfile profile = *found; | 169 NetworkProfile profile = *found; |
| 170 profiles_.erase(found); | 170 profiles_.erase(found); |
| 171 FOR_EACH_OBSERVER(NetworkProfileObserver, observers_, | 171 for (auto& observer : observers_) |
| 172 OnProfileRemoved(profile)); | 172 observer.OnProfileRemoved(profile); |
| 173 } | 173 } |
| 174 | 174 |
| 175 const NetworkProfile* NetworkProfileHandler::GetProfileForPath( | 175 const NetworkProfile* NetworkProfileHandler::GetProfileForPath( |
| 176 const std::string& profile_path) const { | 176 const std::string& profile_path) const { |
| 177 ProfileList::const_iterator found = | 177 ProfileList::const_iterator found = |
| 178 std::find_if(profiles_.begin(), profiles_.end(), | 178 std::find_if(profiles_.begin(), profiles_.end(), |
| 179 ProfilePathEquals(profile_path)); | 179 ProfilePathEquals(profile_path)); |
| 180 | 180 |
| 181 if (found == profiles_.end()) | 181 if (found == profiles_.end()) |
| 182 return NULL; | 182 return NULL; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 base::Bind(&NetworkProfileHandler::GetManagerPropertiesCallback, | 217 base::Bind(&NetworkProfileHandler::GetManagerPropertiesCallback, |
| 218 weak_ptr_factory_.GetWeakPtr())); | 218 weak_ptr_factory_.GetWeakPtr())); |
| 219 } | 219 } |
| 220 | 220 |
| 221 NetworkProfileHandler::~NetworkProfileHandler() { | 221 NetworkProfileHandler::~NetworkProfileHandler() { |
| 222 DBusThreadManager::Get()->GetShillManagerClient()-> | 222 DBusThreadManager::Get()->GetShillManagerClient()-> |
| 223 RemovePropertyChangedObserver(this); | 223 RemovePropertyChangedObserver(this); |
| 224 } | 224 } |
| 225 | 225 |
| 226 } // namespace chromeos | 226 } // namespace chromeos |
| OLD | NEW |