Only fsync leveldb's directory when the manifest is being updated.
[chromium-blink-merge.git] / chromeos / dbus / shill_ipconfig_client_stub.cc
blob8bb28841e5db87c63011cce49c3f7475634fa0d0
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
3 // found in the LICENSE file.
5 #include "chromeos/dbus/shill_ipconfig_client_stub.h"
7 #include "base/bind.h"
8 #include "base/message_loop.h"
9 #include "base/stl_util.h"
10 #include "base/values.h"
11 #include "chromeos/dbus/shill_property_changed_observer.h"
12 #include "dbus/bus.h"
13 #include "dbus/message.h"
14 #include "dbus/object_path.h"
15 #include "dbus/object_proxy.h"
16 #include "dbus/values_util.h"
17 #include "third_party/cros_system_api/dbus/service_constants.h"
19 namespace chromeos {
21 ShillIPConfigClientStub::ShillIPConfigClientStub() : weak_ptr_factory_(this) {
24 ShillIPConfigClientStub::~ShillIPConfigClientStub() {
27 void ShillIPConfigClientStub::AddPropertyChangedObserver(
28 const dbus::ObjectPath& ipconfig_path,
29 ShillPropertyChangedObserver* observer) {
32 void ShillIPConfigClientStub::RemovePropertyChangedObserver(
33 const dbus::ObjectPath& ipconfig_path,
34 ShillPropertyChangedObserver* observer) {
37 void ShillIPConfigClientStub::Refresh(const dbus::ObjectPath& ipconfig_path,
38 const VoidDBusMethodCallback& callback) {
41 void ShillIPConfigClientStub::GetProperties(
42 const dbus::ObjectPath& ipconfig_path,
43 const DictionaryValueCallback& callback) {
44 if (callback.is_null())
45 return;
46 const base::DictionaryValue* dict = NULL;
47 if (!ipconfigs_.GetDictionaryWithoutPathExpansion(ipconfig_path.value(),
48 &dict))
49 return;
50 base::MessageLoop::current()->PostTask(
51 FROM_HERE, base::Bind(&ShillIPConfigClientStub::PassProperties,
52 weak_ptr_factory_.GetWeakPtr(),
53 dict,
54 callback));
57 base::DictionaryValue* ShillIPConfigClientStub::CallGetPropertiesAndBlock(
58 const dbus::ObjectPath& ipconfig_path) {
59 return new base::DictionaryValue;
62 void ShillIPConfigClientStub::SetProperty(
63 const dbus::ObjectPath& ipconfig_path,
64 const std::string& name,
65 const base::Value& value,
66 const VoidDBusMethodCallback& callback) {
67 if (callback.is_null())
68 return;
69 base::DictionaryValue* dict = NULL;
70 if (ipconfigs_.GetDictionaryWithoutPathExpansion(ipconfig_path.value(),
71 &dict)) {
72 // Update existing ip config stub object's properties.
73 dict->SetWithoutPathExpansion(name, value.DeepCopy());
74 } else {
75 // Create a new stub ipconfig object, and update its properties.
76 DictionaryValue* dvalue = new DictionaryValue;
77 dvalue->SetWithoutPathExpansion(name, value.DeepCopy());
78 ipconfigs_.SetWithoutPathExpansion(ipconfig_path.value(),
79 dvalue);
81 base::MessageLoop::current()->PostTask(
82 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS));
85 void ShillIPConfigClientStub::ClearProperty(
86 const dbus::ObjectPath& ipconfig_path,
87 const std::string& name,
88 const VoidDBusMethodCallback& callback) {
89 if (callback.is_null())
90 return;
91 base::MessageLoop::current()->PostTask(
92 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS));
95 void ShillIPConfigClientStub::Remove(const dbus::ObjectPath& ipconfig_path,
96 const VoidDBusMethodCallback& callback) {
97 if (callback.is_null())
98 return;
99 base::MessageLoop::current()->PostTask(
100 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS));
103 void ShillIPConfigClientStub::PassProperties(
104 const base::DictionaryValue* values,
105 const DictionaryValueCallback& callback) const {
106 callback.Run(DBUS_METHOD_CALL_SUCCESS, *values);
109 } // namespace chromeos