| 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/dbus/shill_profile_client_stub.h" | 5 #include "chromeos/dbus/shill_profile_client_stub.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 return; | 67 return; |
| 68 | 68 |
| 69 scoped_ptr<base::DictionaryValue> properties(profile->properties.DeepCopy()); | 69 scoped_ptr<base::DictionaryValue> properties(profile->properties.DeepCopy()); |
| 70 base::ListValue* entry_paths = new base::ListValue; | 70 base::ListValue* entry_paths = new base::ListValue; |
| 71 properties->SetWithoutPathExpansion(flimflam::kEntriesProperty, entry_paths); | 71 properties->SetWithoutPathExpansion(flimflam::kEntriesProperty, entry_paths); |
| 72 for (base::DictionaryValue::Iterator it(profile->entries); !it.IsAtEnd(); | 72 for (base::DictionaryValue::Iterator it(profile->entries); !it.IsAtEnd(); |
| 73 it.Advance()) { | 73 it.Advance()) { |
| 74 entry_paths->AppendString(it.key()); | 74 entry_paths->AppendString(it.key()); |
| 75 } | 75 } |
| 76 | 76 |
| 77 MessageLoop::current()->PostTask( | 77 base::MessageLoop::current()->PostTask( |
| 78 FROM_HERE, | 78 FROM_HERE, |
| 79 base::Bind(&PassDictionary, callback, base::Owned(properties.release()))); | 79 base::Bind(&PassDictionary, callback, base::Owned(properties.release()))); |
| 80 } | 80 } |
| 81 | 81 |
| 82 void ShillProfileClientStub::GetEntry( | 82 void ShillProfileClientStub::GetEntry( |
| 83 const dbus::ObjectPath& profile_path, | 83 const dbus::ObjectPath& profile_path, |
| 84 const std::string& entry_path, | 84 const std::string& entry_path, |
| 85 const DictionaryValueCallbackWithoutStatus& callback, | 85 const DictionaryValueCallbackWithoutStatus& callback, |
| 86 const ErrorCallback& error_callback) { | 86 const ErrorCallback& error_callback) { |
| 87 ProfileProperties* profile = GetProfile(profile_path, error_callback); | 87 ProfileProperties* profile = GetProfile(profile_path, error_callback); |
| 88 if (!profile) | 88 if (!profile) |
| 89 return; | 89 return; |
| 90 | 90 |
| 91 base::DictionaryValue* entry = NULL; | 91 base::DictionaryValue* entry = NULL; |
| 92 profile->entries.GetDictionaryWithoutPathExpansion(entry_path, &entry); | 92 profile->entries.GetDictionaryWithoutPathExpansion(entry_path, &entry); |
| 93 if (!entry) { | 93 if (!entry) { |
| 94 error_callback.Run("Error.InvalidProfileEntry", "Invalid profile entry"); | 94 error_callback.Run("Error.InvalidProfileEntry", "Invalid profile entry"); |
| 95 return; | 95 return; |
| 96 } | 96 } |
| 97 | 97 |
| 98 MessageLoop::current()->PostTask( | 98 base::MessageLoop::current()->PostTask( |
| 99 FROM_HERE, | 99 FROM_HERE, |
| 100 base::Bind(&PassDictionary, callback, base::Owned(entry->DeepCopy()))); | 100 base::Bind(&PassDictionary, callback, base::Owned(entry->DeepCopy()))); |
| 101 } | 101 } |
| 102 | 102 |
| 103 void ShillProfileClientStub::DeleteEntry(const dbus::ObjectPath& profile_path, | 103 void ShillProfileClientStub::DeleteEntry(const dbus::ObjectPath& profile_path, |
| 104 const std::string& entry_path, | 104 const std::string& entry_path, |
| 105 const base::Closure& callback, | 105 const base::Closure& callback, |
| 106 const ErrorCallback& error_callback) { | 106 const ErrorCallback& error_callback) { |
| 107 ProfileProperties* profile = GetProfile(profile_path, error_callback); | 107 ProfileProperties* profile = GetProfile(profile_path, error_callback); |
| 108 if (!profile) | 108 if (!profile) |
| 109 return; | 109 return; |
| 110 | 110 |
| 111 if (!profile->entries.RemoveWithoutPathExpansion(entry_path, NULL)) { | 111 if (!profile->entries.RemoveWithoutPathExpansion(entry_path, NULL)) { |
| 112 error_callback.Run("Error.InvalidProfileEntry", "Invalid profile entry"); | 112 error_callback.Run("Error.InvalidProfileEntry", "Invalid profile entry"); |
| 113 return; | 113 return; |
| 114 } | 114 } |
| 115 | 115 |
| 116 MessageLoop::current()->PostTask(FROM_HERE, callback); | 116 base::MessageLoop::current()->PostTask(FROM_HERE, callback); |
| 117 } | 117 } |
| 118 | 118 |
| 119 ShillProfileClient::TestInterface* ShillProfileClientStub::GetTestInterface() { | 119 ShillProfileClient::TestInterface* ShillProfileClientStub::GetTestInterface() { |
| 120 return this; | 120 return this; |
| 121 } | 121 } |
| 122 | 122 |
| 123 void ShillProfileClientStub::AddProfile(const std::string& profile_path, | 123 void ShillProfileClientStub::AddProfile(const std::string& profile_path, |
| 124 const std::string& userhash) { | 124 const std::string& userhash) { |
| 125 if (GetProfile(dbus::ObjectPath(profile_path), ErrorCallback())) | 125 if (GetProfile(dbus::ObjectPath(profile_path), ErrorCallback())) |
| 126 return; | 126 return; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 if (found == profiles_.end()) { | 168 if (found == profiles_.end()) { |
| 169 if (!error_callback.is_null()) | 169 if (!error_callback.is_null()) |
| 170 error_callback.Run("Error.InvalidProfile", "Invalid profile"); | 170 error_callback.Run("Error.InvalidProfile", "Invalid profile"); |
| 171 return NULL; | 171 return NULL; |
| 172 } | 172 } |
| 173 | 173 |
| 174 return found->second; | 174 return found->second; |
| 175 } | 175 } |
| 176 | 176 |
| 177 } // namespace chromeos | 177 } // namespace chromeos |
| OLD | NEW |