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

Side by Side Diff: dbus/exported_object.cc

Issue 9378039: dbus: add ObjectPath type (Closed) Base URL: http://git.chromium.org/git/chromium/src@master
Patch Set: add patch for cryptohome_client Created 8 years, 10 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 | « dbus/exported_object.h ('k') | dbus/message.h » ('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) 2011 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 "dbus/exported_object.h" 5 #include "dbus/exported_object.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/threading/thread_restrictions.h" 12 #include "base/threading/thread_restrictions.h"
13 #include "base/time.h" 13 #include "base/time.h"
14 #include "dbus/bus.h" 14 #include "dbus/bus.h"
15 #include "dbus/message.h" 15 #include "dbus/message.h"
16 #include "dbus/object_path.h"
16 #include "dbus/scoped_dbus_error.h" 17 #include "dbus/scoped_dbus_error.h"
17 18
18 namespace dbus { 19 namespace dbus {
19 20
20 namespace { 21 namespace {
21 22
22 // Used for success ratio histograms. 1 for success, 0 for failure. 23 // Used for success ratio histograms. 1 for success, 0 for failure.
23 const int kSuccessRatioHistogramMaxValue = 2; 24 const int kSuccessRatioHistogramMaxValue = 2;
24 25
25 // Gets the absolute method name by concatenating the interface name and 26 // Gets the absolute method name by concatenating the interface name and
26 // the method name. Used for building keys for method_table_ in 27 // the method name. Used for building keys for method_table_ in
27 // ExportedObject. 28 // ExportedObject.
28 std::string GetAbsoluteMethodName( 29 std::string GetAbsoluteMethodName(
29 const std::string& interface_name, 30 const std::string& interface_name,
30 const std::string& method_name) { 31 const std::string& method_name) {
31 return interface_name + "." + method_name; 32 return interface_name + "." + method_name;
32 } 33 }
33 34
34 } // namespace 35 } // namespace
35 36
36 ExportedObject::ExportedObject(Bus* bus, 37 ExportedObject::ExportedObject(Bus* bus,
37 const std::string& service_name, 38 const std::string& service_name,
38 const std::string& object_path) 39 const ObjectPath& object_path)
39 : bus_(bus), 40 : bus_(bus),
40 service_name_(service_name), 41 service_name_(service_name),
41 object_path_(object_path), 42 object_path_(object_path),
42 object_is_registered_(false) { 43 object_is_registered_(false) {
43 } 44 }
44 45
45 ExportedObject::~ExportedObject() { 46 ExportedObject::~ExportedObject() {
46 DCHECK(!object_is_registered_); 47 DCHECK(!object_is_registered_);
47 } 48 }
48 49
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 ScopedDBusError error; 169 ScopedDBusError error;
169 170
170 DBusObjectPathVTable vtable = {}; 171 DBusObjectPathVTable vtable = {};
171 vtable.message_function = &ExportedObject::HandleMessageThunk; 172 vtable.message_function = &ExportedObject::HandleMessageThunk;
172 vtable.unregister_function = &ExportedObject::OnUnregisteredThunk; 173 vtable.unregister_function = &ExportedObject::OnUnregisteredThunk;
173 const bool success = bus_->TryRegisterObjectPath(object_path_, 174 const bool success = bus_->TryRegisterObjectPath(object_path_,
174 &vtable, 175 &vtable,
175 this, 176 this,
176 error.get()); 177 error.get());
177 if (!success) { 178 if (!success) {
178 LOG(ERROR) << "Failed to register the object: " << object_path_ << ": " 179 LOG(ERROR) << "Failed to register the object: " << object_path_.value()
179 << (error.is_set() ? error.message() : ""); 180 << ": " << (error.is_set() ? error.message() : "");
180 return false; 181 return false;
181 } 182 }
182 183
183 object_is_registered_ = true; 184 object_is_registered_ = true;
184 return true; 185 return true;
185 } 186 }
186 187
187 DBusHandlerResult ExportedObject::HandleMessage( 188 DBusHandlerResult ExportedObject::HandleMessage(
188 DBusConnection* connection, 189 DBusConnection* connection,
189 DBusMessage* raw_message) { 190 DBusMessage* raw_message) {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 return self->HandleMessage(connection, raw_message); 313 return self->HandleMessage(connection, raw_message);
313 } 314 }
314 315
315 void ExportedObject::OnUnregisteredThunk(DBusConnection *connection, 316 void ExportedObject::OnUnregisteredThunk(DBusConnection *connection,
316 void* user_data) { 317 void* user_data) {
317 ExportedObject* self = reinterpret_cast<ExportedObject*>(user_data); 318 ExportedObject* self = reinterpret_cast<ExportedObject*>(user_data);
318 return self->OnUnregistered(connection); 319 return self->OnUnregistered(connection);
319 } 320 }
320 321
321 } // namespace dbus 322 } // namespace dbus
OLDNEW
« no previous file with comments | « dbus/exported_object.h ('k') | dbus/message.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698