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

Side by Side Diff: dbus/bus.cc

Issue 9373039: Allow dbus clients to silence logging when a service is unavailable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove string.h include 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
OLDNEW
1 // Copyright (c) 2011 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 // TODO(satorux): 5 // TODO(satorux):
6 // - Handle "disconnected" signal. 6 // - Handle "disconnected" signal.
7 7
8 #include "dbus/bus.h" 8 #include "dbus/bus.h"
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/message_loop_proxy.h" 13 #include "base/message_loop_proxy.h"
14 #include "base/stl_util.h" 14 #include "base/stl_util.h"
15 #include "base/string_number_conversions.h"
15 #include "base/threading/thread.h" 16 #include "base/threading/thread.h"
16 #include "base/threading/thread_restrictions.h" 17 #include "base/threading/thread_restrictions.h"
17 #include "base/time.h" 18 #include "base/time.h"
18 #include "dbus/exported_object.h" 19 #include "dbus/exported_object.h"
19 #include "dbus/object_proxy.h" 20 #include "dbus/object_proxy.h"
20 #include "dbus/scoped_dbus_error.h" 21 #include "dbus/scoped_dbus_error.h"
21 22
22 namespace dbus { 23 namespace dbus {
23 24
24 namespace { 25 namespace {
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 DCHECK(registered_object_paths_.empty()); 202 DCHECK(registered_object_paths_.empty());
202 DCHECK_EQ(0, num_pending_watches_); 203 DCHECK_EQ(0, num_pending_watches_);
203 // TODO(satorux): This check fails occasionally in browser_tests for tests 204 // TODO(satorux): This check fails occasionally in browser_tests for tests
204 // that run very quickly. Perhaps something does not have time to clean up. 205 // that run very quickly. Perhaps something does not have time to clean up.
205 // Despite the check failing, the tests seem to run fine. crosbug.com/23416 206 // Despite the check failing, the tests seem to run fine. crosbug.com/23416
206 // DCHECK_EQ(0, num_pending_timeouts_); 207 // DCHECK_EQ(0, num_pending_timeouts_);
207 } 208 }
208 209
209 ObjectProxy* Bus::GetObjectProxy(const std::string& service_name, 210 ObjectProxy* Bus::GetObjectProxy(const std::string& service_name,
210 const std::string& object_path) { 211 const std::string& object_path) {
212 return GetObjectProxyWithOptions(service_name, object_path,
213 ObjectProxy::DEFAULT_OPTIONS);
214 }
215
216 ObjectProxy* Bus::GetObjectProxyWithOptions(const std::string& service_name,
217 const std::string& object_path,
218 int options) {
211 AssertOnOriginThread(); 219 AssertOnOriginThread();
212 220
213 // Check if we already have the requested object proxy. 221 // Check if we already have the requested object proxy.
214 const std::string key = service_name + object_path; 222 std::string key = service_name + object_path;
223 if (options)
224 key += base::IntToString(options);
satorux1 2012/02/10 18:09:01 This looks like a hack. Can you change the key to
adamk 2012/02/10 19:28:21 Done.
215 ObjectProxyTable::iterator iter = object_proxy_table_.find(key); 225 ObjectProxyTable::iterator iter = object_proxy_table_.find(key);
216 if (iter != object_proxy_table_.end()) { 226 if (iter != object_proxy_table_.end()) {
217 return iter->second; 227 return iter->second;
218 } 228 }
219 229
220 scoped_refptr<ObjectProxy> object_proxy = 230 scoped_refptr<ObjectProxy> object_proxy =
221 new ObjectProxy(this, service_name, object_path); 231 new ObjectProxy(this, service_name, object_path, options);
222 object_proxy_table_[key] = object_proxy; 232 object_proxy_table_[key] = object_proxy;
223 233
224 return object_proxy.get(); 234 return object_proxy.get();
225 } 235 }
226 236
227 ExportedObject* Bus::GetExportedObject(const std::string& service_name, 237 ExportedObject* Bus::GetExportedObject(const std::string& service_name,
228 const std::string& object_path) { 238 const std::string& object_path) {
229 AssertOnOriginThread(); 239 AssertOnOriginThread();
230 240
231 // Check if we already have the requested exported object. 241 // Check if we already have the requested exported object.
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 } 758 }
749 759
750 void Bus::OnDispatchStatusChangedThunk(DBusConnection* connection, 760 void Bus::OnDispatchStatusChangedThunk(DBusConnection* connection,
751 DBusDispatchStatus status, 761 DBusDispatchStatus status,
752 void* data) { 762 void* data) {
753 Bus* self = static_cast<Bus*>(data); 763 Bus* self = static_cast<Bus*>(data);
754 return self->OnDispatchStatusChanged(connection, status); 764 return self->OnDispatchStatusChanged(connection, status);
755 } 765 }
756 766
757 } // namespace dbus 767 } // namespace dbus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698