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

Side by Side Diff: dbus/bus.h

Issue 11364033: dbus: Make it possible to build as shared_library. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CHROME_DBUS_EXPORT Created 8 years, 1 month 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 | « no previous file | dbus/dbus.gyp » ('j') | dbus/dbus_export.h » ('J')
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 #ifndef DBUS_BUS_H_ 5 #ifndef DBUS_BUS_H_
6 #define DBUS_BUS_H_ 6 #define DBUS_BUS_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <utility> 11 #include <utility>
12 #include <dbus/dbus.h> 12 #include <dbus/dbus.h>
13 13
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/synchronization/waitable_event.h" 16 #include "base/synchronization/waitable_event.h"
17 #include "base/threading/platform_thread.h" 17 #include "base/threading/platform_thread.h"
18 #include "base/tracked_objects.h" 18 #include "base/tracked_objects.h"
19 #include "dbus/dbus_export.h"
19 #include "dbus/object_path.h" 20 #include "dbus/object_path.h"
20 21
21 class MessageLoop; 22 class MessageLoop;
22 23
23 namespace base { 24 namespace base {
24 class Thread; 25 class Thread;
25 class MessageLoopProxy; 26 class MessageLoopProxy;
26 } 27 }
27 28
28 namespace dbus { 29 namespace dbus {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 // exported_object.ExportMethod(interface_name, method_name, 124 // exported_object.ExportMethod(interface_name, method_name,
124 // base::Bind(&Echo), 125 // base::Bind(&Echo),
125 // base::Bind(&OnExported)); 126 // base::Bind(&OnExported));
126 // 127 //
127 // WHY IS THIS A REF COUNTED OBJECT? 128 // WHY IS THIS A REF COUNTED OBJECT?
128 // 129 //
129 // Bus is a ref counted object, to ensure that |this| of the object is 130 // Bus is a ref counted object, to ensure that |this| of the object is
130 // alive when callbacks referencing |this| are called. However, after the 131 // alive when callbacks referencing |this| are called. However, after the
131 // bus is shut down, |connection_| can be NULL. Hence, callbacks should 132 // bus is shut down, |connection_| can be NULL. Hence, callbacks should
132 // not rely on that |connection_| is alive. 133 // not rely on that |connection_| is alive.
133 class Bus : public base::RefCountedThreadSafe<Bus> { 134 class CHROME_DBUS_EXPORT Bus : public base::RefCountedThreadSafe<Bus> {
134 public: 135 public:
135 // Specifies the bus type. SESSION is used to communicate with per-user 136 // Specifies the bus type. SESSION is used to communicate with per-user
136 // services like GNOME applications. SYSTEM is used to communicate with 137 // services like GNOME applications. SYSTEM is used to communicate with
137 // system-wide services like NetworkManager. CUSTOM_ADDRESS is used to 138 // system-wide services like NetworkManager. CUSTOM_ADDRESS is used to
138 // communicate with an user specified address. 139 // communicate with an user specified address.
139 enum BusType { 140 enum BusType {
140 SESSION = DBUS_BUS_SESSION, 141 SESSION = DBUS_BUS_SESSION,
141 SYSTEM = DBUS_BUS_SYSTEM, 142 SYSTEM = DBUS_BUS_SYSTEM,
142 CUSTOM_ADDRESS, 143 CUSTOM_ADDRESS,
143 }; 144 };
144 145
145 // Specifies the connection type. PRIVATE should usually be used unless 146 // Specifies the connection type. PRIVATE should usually be used unless
146 // you are sure that SHARED is safe for you, which is unlikely the case 147 // you are sure that SHARED is safe for you, which is unlikely the case
147 // in Chrome. 148 // in Chrome.
148 // 149 //
149 // PRIVATE gives you a private connection, that won't be shared with 150 // PRIVATE gives you a private connection, that won't be shared with
150 // other Bus objects. 151 // other Bus objects.
151 // 152 //
152 // SHARED gives you a connection shared among other Bus objects, which 153 // SHARED gives you a connection shared among other Bus objects, which
153 // is unsafe if the connection is shared with multiple threads. 154 // is unsafe if the connection is shared with multiple threads.
154 enum ConnectionType { 155 enum ConnectionType {
155 PRIVATE, 156 PRIVATE,
156 SHARED, 157 SHARED,
157 }; 158 };
158 159
159 // Options used to create a Bus object. 160 // Options used to create a Bus object.
160 struct Options { 161 struct CHROME_DBUS_EXPORT Options {
161 Options(); 162 Options();
162 ~Options(); 163 ~Options();
163 164
164 BusType bus_type; // SESSION by default. 165 BusType bus_type; // SESSION by default.
165 ConnectionType connection_type; // PRIVATE by default. 166 ConnectionType connection_type; // PRIVATE by default.
166 // If dbus_thread_message_loop_proxy is set, the bus object will use that 167 // If dbus_thread_message_loop_proxy is set, the bus object will use that
167 // message loop to process asynchronous operations. 168 // message loop to process asynchronous operations.
168 // 169 //
169 // The thread servicing the message loop proxy should meet the following 170 // The thread servicing the message loop proxy should meet the following
170 // requirements: 171 // requirements:
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 int num_pending_timeouts_; 547 int num_pending_timeouts_;
547 548
548 std::string address_; 549 std::string address_;
549 550
550 DISALLOW_COPY_AND_ASSIGN(Bus); 551 DISALLOW_COPY_AND_ASSIGN(Bus);
551 }; 552 };
552 553
553 } // namespace dbus 554 } // namespace dbus
554 555
555 #endif // DBUS_BUS_H_ 556 #endif // DBUS_BUS_H_
OLDNEW
« no previous file with comments | « no previous file | dbus/dbus.gyp » ('j') | dbus/dbus_export.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698