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

Side by Side Diff: dbus/exported_object.h

Issue 12092061: Code cleaning: Uses scoped_ptr<> to express ownership rather than writing ownership in comments. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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) 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_EXPORTED_OBJECT_H_ 5 #ifndef DBUS_EXPORTED_OBJECT_H_
6 #define DBUS_EXPORTED_OBJECT_H_ 6 #define DBUS_EXPORTED_OBJECT_H_
7 7
8 #include <dbus/dbus.h> 8 #include <dbus/dbus.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 25 matching lines...) Expand all
36 public: 36 public:
37 // Client code should use Bus::GetExportedObject() instead of this 37 // Client code should use Bus::GetExportedObject() instead of this
38 // constructor. 38 // constructor.
39 ExportedObject(Bus* bus, const ObjectPath& object_path); 39 ExportedObject(Bus* bus, const ObjectPath& object_path);
40 40
41 // Called to send a response from an exported method. |response| is the 41 // Called to send a response from an exported method. |response| is the
42 // response message. Callers should pass NULL in the event of an error that 42 // response message. Callers should pass NULL in the event of an error that
43 // prevents the sending of a response. 43 // prevents the sending of a response.
44 // 44 //
45 // ResponseSender takes ownership of |response| hence client code should 45 // ResponseSender takes ownership of |response| hence client code should
46 // not delete |response|. 46 // not delete |response|.
satorux1 2013/01/30 06:36:58 Please remove the line 44-46. The comment is no lo
alias of yukishiino 2013/01/30 13:13:44 Done.
47 // TODO(satorux): Change this to take scoped_ptr<Response> to make 47 typedef base::Callback<void (scoped_ptr<Response> response)> ResponseSender;
48 // ownership clearer. crbug.com/163231
49 typedef base::Callback<void (Response* response)> ResponseSender;
50 48
51 // Called when an exported method is called. |method_call| is the request 49 // Called when an exported method is called. |method_call| is the request
52 // message. |sender| is the callback that's used to send a response. 50 // message. |sender| is the callback that's used to send a response.
53 // 51 //
54 // |method_call| is owned by ExportedObject, hence client code should not 52 // |method_call| is owned by ExportedObject, hence client code should not
55 // delete |method_call|. 53 // delete |method_call|.
56 typedef base::Callback<void (MethodCall* method_call, ResponseSender sender)> 54 typedef base::Callback<void (MethodCall* method_call, ResponseSender sender)>
57 MethodCallCallback; 55 MethodCallCallback;
58 56
59 // Called when method exporting is done. 57 // Called when method exporting is done.
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 // BLOCKING CALL. 125 // BLOCKING CALL.
128 bool Register(); 126 bool Register();
129 127
130 // Handles the incoming request messages and dispatches to the exported 128 // Handles the incoming request messages and dispatches to the exported
131 // methods. 129 // methods.
132 DBusHandlerResult HandleMessage(DBusConnection* connection, 130 DBusHandlerResult HandleMessage(DBusConnection* connection,
133 DBusMessage* raw_message); 131 DBusMessage* raw_message);
134 132
135 // Runs the method. Helper function for HandleMessage(). 133 // Runs the method. Helper function for HandleMessage().
136 void RunMethod(MethodCallCallback method_call_callback, 134 void RunMethod(MethodCallCallback method_call_callback,
137 MethodCall* method_call, 135 scoped_ptr<MethodCall> method_call,
138 base::TimeTicks start_time); 136 base::TimeTicks start_time);
139 137
140 // Callback invoked by service provider to send a response to a method call. 138 // Callback invoked by service provider to send a response to a method call.
141 // Can be called immediately from a MethodCallCallback to implement a 139 // Can be called immediately from a MethodCallCallback to implement a
142 // synchronous service or called later to implement an asynchronous service. 140 // synchronous service or called later to implement an asynchronous service.
143 void SendResponse(base::TimeTicks start_time, 141 void SendResponse(base::TimeTicks start_time,
144 MethodCall* method_call, 142 scoped_ptr<MethodCall> method_call,
145 Response* response); 143 scoped_ptr<Response> response);
146 144
147 // Called on completion of the method run from SendResponse(). 145 // Called on completion of the method run from SendResponse().
148 // Takes ownership of |method_call| and |response|. 146 // Takes ownership of |method_call| and |response|.
149 void OnMethodCompleted(MethodCall* method_call, 147 void OnMethodCompleted(scoped_ptr<MethodCall> method_call,
150 Response* response, 148 scoped_ptr<Response> response,
151 base::TimeTicks start_time); 149 base::TimeTicks start_time);
152 150
153 // Called when the object is unregistered. 151 // Called when the object is unregistered.
154 void OnUnregistered(DBusConnection* connection); 152 void OnUnregistered(DBusConnection* connection);
155 153
156 // Redirects the function call to HandleMessage(). 154 // Redirects the function call to HandleMessage().
157 static DBusHandlerResult HandleMessageThunk(DBusConnection* connection, 155 static DBusHandlerResult HandleMessageThunk(DBusConnection* connection,
158 DBusMessage* raw_message, 156 DBusMessage* raw_message,
159 void* user_data); 157 void* user_data);
160 158
161 // Redirects the function call to OnUnregistered(). 159 // Redirects the function call to OnUnregistered().
162 static void OnUnregisteredThunk(DBusConnection* connection, 160 static void OnUnregisteredThunk(DBusConnection* connection,
163 void* user_data); 161 void* user_data);
164 162
165 scoped_refptr<Bus> bus_; 163 scoped_refptr<Bus> bus_;
166 ObjectPath object_path_; 164 ObjectPath object_path_;
167 bool object_is_registered_; 165 bool object_is_registered_;
168 166
169 // The method table where keys are absolute method names (i.e. interface 167 // The method table where keys are absolute method names (i.e. interface
170 // name + method name), and values are the corresponding callbacks. 168 // name + method name), and values are the corresponding callbacks.
171 typedef std::map<std::string, MethodCallCallback> MethodTable; 169 typedef std::map<std::string, MethodCallCallback> MethodTable;
172 MethodTable method_table_; 170 MethodTable method_table_;
173 }; 171 };
174 172
175 } // namespace dbus 173 } // namespace dbus
176 174
177 #endif // DBUS_EXPORTED_OBJECT_H_ 175 #endif // DBUS_EXPORTED_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698