Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(257)

Side by Side Diff: chromeos/dbus/shill_network_client.cc

Issue 10915106: Renaming instances of "flimflam" with "shill", now that we're only (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Upload after merge Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chromeos/dbus/shill_network_client.h ('k') | chromeos/dbus/shill_network_client_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/flimflam_network_client.h" 5 #include "chromeos/dbus/shill_network_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "dbus/bus.h" 11 #include "dbus/bus.h"
12 #include "dbus/message.h" 12 #include "dbus/message.h"
13 #include "dbus/object_path.h" 13 #include "dbus/object_path.h"
14 #include "dbus/object_proxy.h" 14 #include "dbus/object_proxy.h"
15 #include "dbus/values_util.h" 15 #include "dbus/values_util.h"
16 #include "third_party/cros_system_api/dbus/service_constants.h" 16 #include "third_party/cros_system_api/dbus/service_constants.h"
17 17
18 namespace chromeos { 18 namespace chromeos {
19 19
20 namespace { 20 namespace {
21 21
22 // The FlimflamNetworkClient implementation. 22 // The ShillNetworkClient implementation.
23 class FlimflamNetworkClientImpl : public FlimflamNetworkClient { 23 class ShillNetworkClientImpl : public ShillNetworkClient {
24 public: 24 public:
25 explicit FlimflamNetworkClientImpl(dbus::Bus* bus) 25 explicit ShillNetworkClientImpl(dbus::Bus* bus)
26 : bus_(bus), 26 : bus_(bus),
27 helpers_deleter_(&helpers_) { 27 helpers_deleter_(&helpers_) {
28 } 28 }
29 29
30 // FlimflamNetworkClient override. 30 // ShillNetworkClient override.
31 virtual void SetPropertyChangedHandler( 31 virtual void SetPropertyChangedHandler(
32 const dbus::ObjectPath& network_path, 32 const dbus::ObjectPath& network_path,
33 const PropertyChangedHandler& handler) OVERRIDE { 33 const PropertyChangedHandler& handler) OVERRIDE {
34 GetHelper(network_path)->SetPropertyChangedHandler(handler); 34 GetHelper(network_path)->SetPropertyChangedHandler(handler);
35 } 35 }
36 36
37 // FlimflamNetworkClient override. 37 // ShillNetworkClient override.
38 virtual void ResetPropertyChangedHandler( 38 virtual void ResetPropertyChangedHandler(
39 const dbus::ObjectPath& network_path) OVERRIDE { 39 const dbus::ObjectPath& network_path) OVERRIDE {
40 GetHelper(network_path)->ResetPropertyChangedHandler(); 40 GetHelper(network_path)->ResetPropertyChangedHandler();
41 } 41 }
42 42
43 // FlimflamNetworkClient override. 43 // ShillNetworkClient override.
44 virtual void GetProperties(const dbus::ObjectPath& network_path, 44 virtual void GetProperties(const dbus::ObjectPath& network_path,
45 const DictionaryValueCallback& callback) OVERRIDE { 45 const DictionaryValueCallback& callback) OVERRIDE {
46 dbus::MethodCall method_call(flimflam::kFlimflamNetworkInterface, 46 dbus::MethodCall method_call(flimflam::kFlimflamNetworkInterface,
47 flimflam::kGetPropertiesFunction); 47 flimflam::kGetPropertiesFunction);
48 GetHelper(network_path)->CallDictionaryValueMethod(&method_call, callback); 48 GetHelper(network_path)->CallDictionaryValueMethod(&method_call, callback);
49 } 49 }
50 50
51 // FlimflamNetworkClient override. 51 // ShillNetworkClient override.
52 virtual base::DictionaryValue* CallGetPropertiesAndBlock( 52 virtual base::DictionaryValue* CallGetPropertiesAndBlock(
53 const dbus::ObjectPath& network_path) OVERRIDE { 53 const dbus::ObjectPath& network_path) OVERRIDE {
54 dbus::MethodCall method_call(flimflam::kFlimflamNetworkInterface, 54 dbus::MethodCall method_call(flimflam::kFlimflamNetworkInterface,
55 flimflam::kGetPropertiesFunction); 55 flimflam::kGetPropertiesFunction);
56 return GetHelper(network_path)->CallDictionaryValueMethodAndBlock( 56 return GetHelper(network_path)->CallDictionaryValueMethodAndBlock(
57 &method_call); 57 &method_call);
58 } 58 }
59 59
60 private: 60 private:
61 typedef std::map<std::string, FlimflamClientHelper*> HelperMap; 61 typedef std::map<std::string, ShillClientHelper*> HelperMap;
62 62
63 // Returns the corresponding FlimflamClientHelper for the profile. 63 // Returns the corresponding ShillClientHelper for the profile.
64 FlimflamClientHelper* GetHelper(const dbus::ObjectPath& network_path) { 64 ShillClientHelper* GetHelper(const dbus::ObjectPath& network_path) {
65 HelperMap::iterator it = helpers_.find(network_path.value()); 65 HelperMap::iterator it = helpers_.find(network_path.value());
66 if (it != helpers_.end()) 66 if (it != helpers_.end())
67 return it->second; 67 return it->second;
68 68
69 // There is no helper for the profile, create it. 69 // There is no helper for the profile, create it.
70 dbus::ObjectProxy* object_proxy = 70 dbus::ObjectProxy* object_proxy =
71 bus_->GetObjectProxy(flimflam::kFlimflamServiceName, network_path); 71 bus_->GetObjectProxy(flimflam::kFlimflamServiceName, network_path);
72 FlimflamClientHelper* helper = new FlimflamClientHelper(bus_, object_proxy); 72 ShillClientHelper* helper = new ShillClientHelper(bus_, object_proxy);
73 helper->MonitorPropertyChanged(flimflam::kFlimflamNetworkInterface); 73 helper->MonitorPropertyChanged(flimflam::kFlimflamNetworkInterface);
74 helpers_.insert(HelperMap::value_type(network_path.value(), helper)); 74 helpers_.insert(HelperMap::value_type(network_path.value(), helper));
75 return helper; 75 return helper;
76 } 76 }
77 77
78 dbus::Bus* bus_; 78 dbus::Bus* bus_;
79 HelperMap helpers_; 79 HelperMap helpers_;
80 STLValueDeleter<HelperMap> helpers_deleter_; 80 STLValueDeleter<HelperMap> helpers_deleter_;
81 81
82 DISALLOW_COPY_AND_ASSIGN(FlimflamNetworkClientImpl); 82 DISALLOW_COPY_AND_ASSIGN(ShillNetworkClientImpl);
83 }; 83 };
84 84
85 // A stub implementation of FlimflamNetworkClient. 85 // A stub implementation of ShillNetworkClient.
86 class FlimflamNetworkClientStubImpl : public FlimflamNetworkClient { 86 class ShillNetworkClientStubImpl : public ShillNetworkClient {
87 public: 87 public:
88 FlimflamNetworkClientStubImpl() : weak_ptr_factory_(this) {} 88 ShillNetworkClientStubImpl() : weak_ptr_factory_(this) {}
89 89
90 virtual ~FlimflamNetworkClientStubImpl() {} 90 virtual ~ShillNetworkClientStubImpl() {}
91 91
92 // FlimflamNetworkClient override. 92 // ShillNetworkClient override.
93 virtual void SetPropertyChangedHandler( 93 virtual void SetPropertyChangedHandler(
94 const dbus::ObjectPath& network_path, 94 const dbus::ObjectPath& network_path,
95 const PropertyChangedHandler& handler) OVERRIDE {} 95 const PropertyChangedHandler& handler) OVERRIDE {}
96 96
97 // FlimflamNetworkClient override. 97 // ShillNetworkClient override.
98 virtual void ResetPropertyChangedHandler( 98 virtual void ResetPropertyChangedHandler(
99 const dbus::ObjectPath& network_path) OVERRIDE {} 99 const dbus::ObjectPath& network_path) OVERRIDE {}
100 100
101 // FlimflamNetworkClient override. 101 // ShillNetworkClient override.
102 virtual void GetProperties(const dbus::ObjectPath& network_path, 102 virtual void GetProperties(const dbus::ObjectPath& network_path,
103 const DictionaryValueCallback& callback) OVERRIDE { 103 const DictionaryValueCallback& callback) OVERRIDE {
104 MessageLoop::current()->PostTask( 104 MessageLoop::current()->PostTask(
105 FROM_HERE, 105 FROM_HERE,
106 base::Bind(&FlimflamNetworkClientStubImpl::PassEmptyDictionaryValue, 106 base::Bind(&ShillNetworkClientStubImpl::PassEmptyDictionaryValue,
107 weak_ptr_factory_.GetWeakPtr(), 107 weak_ptr_factory_.GetWeakPtr(),
108 callback)); 108 callback));
109 } 109 }
110 110
111 // FlimflamNetworkClient override. 111 // ShillNetworkClient override.
112 virtual base::DictionaryValue* CallGetPropertiesAndBlock( 112 virtual base::DictionaryValue* CallGetPropertiesAndBlock(
113 const dbus::ObjectPath& network_path) OVERRIDE { 113 const dbus::ObjectPath& network_path) OVERRIDE {
114 return new base::DictionaryValue; 114 return new base::DictionaryValue;
115 } 115 }
116 116
117 private: 117 private:
118 void PassEmptyDictionaryValue(const DictionaryValueCallback& callback) const { 118 void PassEmptyDictionaryValue(const DictionaryValueCallback& callback) const {
119 base::DictionaryValue dictionary; 119 base::DictionaryValue dictionary;
120 callback.Run(DBUS_METHOD_CALL_SUCCESS, dictionary); 120 callback.Run(DBUS_METHOD_CALL_SUCCESS, dictionary);
121 } 121 }
122 122
123 // Note: This should remain the last member so it'll be destroyed and 123 // Note: This should remain the last member so it'll be destroyed and
124 // invalidate its weak pointers before any other members are destroyed. 124 // invalidate its weak pointers before any other members are destroyed.
125 base::WeakPtrFactory<FlimflamNetworkClientStubImpl> weak_ptr_factory_; 125 base::WeakPtrFactory<ShillNetworkClientStubImpl> weak_ptr_factory_;
126 126
127 DISALLOW_COPY_AND_ASSIGN(FlimflamNetworkClientStubImpl); 127 DISALLOW_COPY_AND_ASSIGN(ShillNetworkClientStubImpl);
128 }; 128 };
129 129
130 } // namespace 130 } // namespace
131 131
132 FlimflamNetworkClient::FlimflamNetworkClient() {} 132 ShillNetworkClient::ShillNetworkClient() {}
133 133
134 FlimflamNetworkClient::~FlimflamNetworkClient() {} 134 ShillNetworkClient::~ShillNetworkClient() {}
135 135
136 // static 136 // static
137 FlimflamNetworkClient* FlimflamNetworkClient::Create( 137 ShillNetworkClient* ShillNetworkClient::Create(
138 DBusClientImplementationType type, 138 DBusClientImplementationType type,
139 dbus::Bus* bus) { 139 dbus::Bus* bus) {
140 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) 140 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION)
141 return new FlimflamNetworkClientImpl(bus); 141 return new ShillNetworkClientImpl(bus);
142 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); 142 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type);
143 return new FlimflamNetworkClientStubImpl(); 143 return new ShillNetworkClientStubImpl();
144 } 144 }
145 145
146 } // namespace chromeos 146 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/shill_network_client.h ('k') | chromeos/dbus/shill_network_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698