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

Side by Side Diff: dbus/exported_object.cc

Issue 9363045: Revert 121920 - dbus: add ObjectPath type (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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 | Annotate | Revision Log
« 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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"
17 #include "dbus/scoped_dbus_error.h" 16 #include "dbus/scoped_dbus_error.h"
18 17
19 namespace dbus { 18 namespace dbus {
20 19
21 namespace { 20 namespace {
22 21
23 // Used for success ratio histograms. 1 for success, 0 for failure. 22 // Used for success ratio histograms. 1 for success, 0 for failure.
24 const int kSuccessRatioHistogramMaxValue = 2; 23 const int kSuccessRatioHistogramMaxValue = 2;
25 24
26 // Gets the absolute method name by concatenating the interface name and 25 // Gets the absolute method name by concatenating the interface name and
27 // the method name. Used for building keys for method_table_ in 26 // the method name. Used for building keys for method_table_ in
28 // ExportedObject. 27 // ExportedObject.
29 std::string GetAbsoluteMethodName( 28 std::string GetAbsoluteMethodName(
30 const std::string& interface_name, 29 const std::string& interface_name,
31 const std::string& method_name) { 30 const std::string& method_name) {
32 return interface_name + "." + method_name; 31 return interface_name + "." + method_name;
33 } 32 }
34 33
35 } // namespace 34 } // namespace
36 35
37 ExportedObject::ExportedObject(Bus* bus, 36 ExportedObject::ExportedObject(Bus* bus,
38 const std::string& service_name, 37 const std::string& service_name,
39 const ObjectPath& object_path) 38 const std::string& object_path)
40 : bus_(bus), 39 : bus_(bus),
41 service_name_(service_name), 40 service_name_(service_name),
42 object_path_(object_path), 41 object_path_(object_path),
43 object_is_registered_(false) { 42 object_is_registered_(false) {
44 } 43 }
45 44
46 ExportedObject::~ExportedObject() { 45 ExportedObject::~ExportedObject() {
47 DCHECK(!object_is_registered_); 46 DCHECK(!object_is_registered_);
48 } 47 }
49 48
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 ScopedDBusError error; 168 ScopedDBusError error;
170 169
171 DBusObjectPathVTable vtable = {}; 170 DBusObjectPathVTable vtable = {};
172 vtable.message_function = &ExportedObject::HandleMessageThunk; 171 vtable.message_function = &ExportedObject::HandleMessageThunk;
173 vtable.unregister_function = &ExportedObject::OnUnregisteredThunk; 172 vtable.unregister_function = &ExportedObject::OnUnregisteredThunk;
174 const bool success = bus_->TryRegisterObjectPath(object_path_, 173 const bool success = bus_->TryRegisterObjectPath(object_path_,
175 &vtable, 174 &vtable,
176 this, 175 this,
177 error.get()); 176 error.get());
178 if (!success) { 177 if (!success) {
179 LOG(ERROR) << "Failed to register the object: " << object_path_.value() 178 LOG(ERROR) << "Failed to register the object: " << object_path_ << ": "
180 << ": " << (error.is_set() ? error.message() : ""); 179 << (error.is_set() ? error.message() : "");
181 return false; 180 return false;
182 } 181 }
183 182
184 object_is_registered_ = true; 183 object_is_registered_ = true;
185 return true; 184 return true;
186 } 185 }
187 186
188 DBusHandlerResult ExportedObject::HandleMessage( 187 DBusHandlerResult ExportedObject::HandleMessage(
189 DBusConnection* connection, 188 DBusConnection* connection,
190 DBusMessage* raw_message) { 189 DBusMessage* raw_message) {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 return self->HandleMessage(connection, raw_message); 312 return self->HandleMessage(connection, raw_message);
314 } 313 }
315 314
316 void ExportedObject::OnUnregisteredThunk(DBusConnection *connection, 315 void ExportedObject::OnUnregisteredThunk(DBusConnection *connection,
317 void* user_data) { 316 void* user_data) {
318 ExportedObject* self = reinterpret_cast<ExportedObject*>(user_data); 317 ExportedObject* self = reinterpret_cast<ExportedObject*>(user_data);
319 return self->OnUnregistered(connection); 318 return self->OnUnregistered(connection);
320 } 319 }
321 320
322 } // namespace dbus 321 } // 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