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

Side by Side Diff: dbus/exported_object.h

Issue 8682032: Revert 111479 - chrome: dbus: support asynchronous method replies (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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 | « dbus/end_to_end_async_unittest.cc ('k') | dbus/exported_object.cc » ('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) 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 #ifndef DBUS_EXPORTED_OBJECT_H_ 5 #ifndef DBUS_EXPORTED_OBJECT_H_
6 #define DBUS_EXPORTED_OBJECT_H_ 6 #define DBUS_EXPORTED_OBJECT_H_
7 #pragma once 7 #pragma once
8 8
9 #include <dbus/dbus.h> 9 #include <dbus/dbus.h>
10 10
(...skipping 20 matching lines...) Expand all
31 // ExportedObject is a ref counted object, to ensure that |this| of the 31 // ExportedObject is a ref counted object, to ensure that |this| of the
32 // object is alive when callbacks referencing |this| are called. 32 // object is alive when callbacks referencing |this| are called.
33 class ExportedObject : public base::RefCountedThreadSafe<ExportedObject> { 33 class ExportedObject : public base::RefCountedThreadSafe<ExportedObject> {
34 public: 34 public:
35 // Client code should use Bus::GetExportedObject() instead of this 35 // Client code should use Bus::GetExportedObject() instead of this
36 // constructor. 36 // constructor.
37 ExportedObject(Bus* bus, 37 ExportedObject(Bus* bus,
38 const std::string& service_name, 38 const std::string& service_name,
39 const std::string& object_path); 39 const std::string& object_path);
40 40
41 // Called to send a response from an exported method. Response* is the
42 // response message. Callers should pass a NULL Response* in the event
43 // of an error that prevents the sending of a response.
44 typedef base::Callback<void (Response*)> ResponseSender;
45
46 // Called when an exported method is called. MethodCall* is the request 41 // Called when an exported method is called. MethodCall* is the request
47 // message. ResponseSender is the callback that should be used to send a 42 // message.
48 // response. 43 typedef base::Callback<Response* (MethodCall*)> MethodCallCallback;
49 typedef base::Callback<void (MethodCall*, ResponseSender)> MethodCallCallback;
50 44
51 // Called when method exporting is done. 45 // Called when method exporting is done.
52 // Parameters: 46 // Parameters:
53 // - the interface name. 47 // - the interface name.
54 // - the method name. 48 // - the method name.
55 // - whether exporting was successful or not. 49 // - whether exporting was successful or not.
56 typedef base::Callback<void (const std::string&, const std::string&, bool)> 50 typedef base::Callback<void (const std::string&, const std::string&, bool)>
57 OnExportedCallback; 51 OnExportedCallback;
58 52
59 // Exports the method specified by |interface_name| and |method_name|, 53 // Exports the method specified by |interface_name| and |method_name|,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 // Handles the incoming request messages and dispatches to the exported 117 // Handles the incoming request messages and dispatches to the exported
124 // methods. 118 // methods.
125 DBusHandlerResult HandleMessage(DBusConnection* connection, 119 DBusHandlerResult HandleMessage(DBusConnection* connection,
126 DBusMessage* raw_message); 120 DBusMessage* raw_message);
127 121
128 // Runs the method. Helper function for HandleMessage(). 122 // Runs the method. Helper function for HandleMessage().
129 void RunMethod(MethodCallCallback method_call_callback, 123 void RunMethod(MethodCallCallback method_call_callback,
130 MethodCall* method_call, 124 MethodCall* method_call,
131 base::TimeTicks start_time); 125 base::TimeTicks start_time);
132 126
133 // Callback invoked by service provider to send a response to a method call. 127 // Called on completion of the method run from RunMethod().
134 // Can be called immediately from a MethodCallCallback to implement a
135 // synchronous service or called later to implement an asynchronous service.
136 void SendResponse(base::TimeTicks start_time,
137 MethodCall* method_call,
138 Response* response);
139
140 // Called on completion of the method run from SendResponse().
141 // Takes ownership of |method_call| and |response|. 128 // Takes ownership of |method_call| and |response|.
142 void OnMethodCompleted(MethodCall* method_call, 129 void OnMethodCompleted(MethodCall* method_call,
143 Response* response, 130 Response* response,
144 base::TimeTicks start_time); 131 base::TimeTicks start_time);
145 132
146 // Called when the object is unregistered. 133 // Called when the object is unregistered.
147 void OnUnregistered(DBusConnection* connection); 134 void OnUnregistered(DBusConnection* connection);
148 135
149 // Redirects the function call to HandleMessage(). 136 // Redirects the function call to HandleMessage().
150 static DBusHandlerResult HandleMessageThunk(DBusConnection* connection, 137 static DBusHandlerResult HandleMessageThunk(DBusConnection* connection,
(...skipping 11 matching lines...) Expand all
162 149
163 // The method table where keys are absolute method names (i.e. interface 150 // The method table where keys are absolute method names (i.e. interface
164 // name + method name), and values are the corresponding callbacks. 151 // name + method name), and values are the corresponding callbacks.
165 typedef std::map<std::string, MethodCallCallback> MethodTable; 152 typedef std::map<std::string, MethodCallCallback> MethodTable;
166 MethodTable method_table_; 153 MethodTable method_table_;
167 }; 154 };
168 155
169 } // namespace dbus 156 } // namespace dbus
170 157
171 #endif // DBUS_EXPORTED_OBJECT_H_ 158 #endif // DBUS_EXPORTED_OBJECT_H_
OLDNEW
« no previous file with comments | « dbus/end_to_end_async_unittest.cc ('k') | dbus/exported_object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698