OLD | NEW |
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/introspectable_client.h" | 5 #include "chromeos/dbus/introspectable_client.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 84 |
85 // Weak pointer factory for generating 'this' pointers that might live longer | 85 // Weak pointer factory for generating 'this' pointers that might live longer |
86 // than we do. | 86 // than we do. |
87 // Note: This should remain the last member so it'll be destroyed and | 87 // Note: This should remain the last member so it'll be destroyed and |
88 // invalidate its weak pointers before any other members are destroyed. | 88 // invalidate its weak pointers before any other members are destroyed. |
89 base::WeakPtrFactory<IntrospectableClientImpl> weak_ptr_factory_; | 89 base::WeakPtrFactory<IntrospectableClientImpl> weak_ptr_factory_; |
90 | 90 |
91 DISALLOW_COPY_AND_ASSIGN(IntrospectableClientImpl); | 91 DISALLOW_COPY_AND_ASSIGN(IntrospectableClientImpl); |
92 }; | 92 }; |
93 | 93 |
94 // The IntrospectableClient implementation used on Linux desktop, which does | |
95 // nothing. | |
96 class IntrospectableClientStubImpl : public IntrospectableClient { | |
97 public: | |
98 // IntrospectableClient override. | |
99 virtual void Init(dbus::Bus* bus) OVERRIDE {} | |
100 virtual void Introspect(const std::string& service_name, | |
101 const dbus::ObjectPath& object_path, | |
102 const IntrospectCallback& callback) OVERRIDE { | |
103 VLOG(1) << "Introspect: " << service_name << " " << object_path.value(); | |
104 callback.Run(service_name, object_path, "", false); | |
105 } | |
106 }; | |
107 | |
108 IntrospectableClient::IntrospectableClient() { | 94 IntrospectableClient::IntrospectableClient() { |
109 } | 95 } |
110 | 96 |
111 IntrospectableClient::~IntrospectableClient() { | 97 IntrospectableClient::~IntrospectableClient() { |
112 } | 98 } |
113 | 99 |
114 // static | 100 // static |
115 std::vector<std::string> | 101 std::vector<std::string> |
116 IntrospectableClient::GetInterfacesFromIntrospectResult( | 102 IntrospectableClient::GetInterfacesFromIntrospectResult( |
117 const std::string& xml_data) { | 103 const std::string& xml_data) { |
(...skipping 20 matching lines...) Expand all Loading... |
138 if (!reader.NodeAttribute(kInterfaceNameAttribute, &interface_name)) | 124 if (!reader.NodeAttribute(kInterfaceNameAttribute, &interface_name)) |
139 continue; | 125 continue; |
140 | 126 |
141 interfaces.push_back(interface_name); | 127 interfaces.push_back(interface_name); |
142 } while (reader.Read()); | 128 } while (reader.Read()); |
143 | 129 |
144 return interfaces; | 130 return interfaces; |
145 } | 131 } |
146 | 132 |
147 // static | 133 // static |
148 IntrospectableClient* IntrospectableClient::Create( | 134 IntrospectableClient* IntrospectableClient::Create() { |
149 DBusClientImplementationType type) { | 135 return new IntrospectableClientImpl(); |
150 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | |
151 return new IntrospectableClientImpl(); | |
152 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | |
153 return new IntrospectableClientStubImpl(); | |
154 } | 136 } |
155 | 137 |
156 } // namespace chromeos | 138 } // namespace chromeos |
OLD | NEW |