OLD | NEW |
---|---|
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_MESSAGE_H_ | 5 #ifndef DBUS_MESSAGE_H_ |
6 #define DBUS_MESSAGE_H_ | 6 #define DBUS_MESSAGE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 #include <dbus/dbus.h> | 10 #include <dbus/dbus.h> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/memory/scoped_ptr.h" | |
13 #include "dbus/dbus_export.h" | 14 #include "dbus/dbus_export.h" |
14 #include "dbus/file_descriptor.h" | 15 #include "dbus/file_descriptor.h" |
15 #include "dbus/object_path.h" | 16 #include "dbus/object_path.h" |
16 | 17 |
17 namespace google { | 18 namespace google { |
18 namespace protobuf { | 19 namespace protobuf { |
19 | 20 |
20 class MessageLite; | 21 class MessageLite; |
21 | 22 |
22 } // namespace protobuf | 23 } // namespace protobuf |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
193 Signal(); | 194 Signal(); |
194 | 195 |
195 DISALLOW_COPY_AND_ASSIGN(Signal); | 196 DISALLOW_COPY_AND_ASSIGN(Signal); |
196 }; | 197 }; |
197 | 198 |
198 // Response is a type of message used for receiving a response from a | 199 // Response is a type of message used for receiving a response from a |
199 // method via D-Bus. | 200 // method via D-Bus. |
200 class CHROME_DBUS_EXPORT Response : public Message { | 201 class CHROME_DBUS_EXPORT Response : public Message { |
201 public: | 202 public: |
202 // Returns a newly created Response from the given raw message of the | 203 // Returns a newly created Response from the given raw message of the |
203 // type DBUS_MESSAGE_TYPE_METHOD_RETURN. The caller must delete the | 204 // type DBUS_MESSAGE_TYPE_METHOD_RETURN. |
satorux1
2013/01/30 06:36:58
Please keep: Takes the ownership of |raw_message|
alias of yukishiino
2013/01/30 13:13:44
Done.
| |
204 // returned object. Takes the ownership of |raw_message|. | 205 static scoped_ptr<Response> FromRawMessage(DBusMessage* raw_message); |
205 static Response* FromRawMessage(DBusMessage* raw_message); | |
206 | 206 |
207 // Returns a newly created Response from the given method call. The | 207 // Returns a newly created Response from the given method call. |
208 // caller must delete the returned object. Used for implementing | 208 // Used for implementing exported methods. |
satorux1
2013/01/30 06:36:58
ditto.
alias of yukishiino
2013/01/30 13:13:44
My understanding is that FromMethodCall does NOT t
satorux1
2013/01/31 01:32:54
You are right. Thanks.
| |
209 // exported methods. | 209 static scoped_ptr<Response> FromMethodCall(MethodCall* method_call); |
210 static Response* FromMethodCall(MethodCall* method_call); | |
211 | 210 |
212 // Returns a newly created Response with an empty payload. The caller | 211 // Returns a newly created Response with an empty payload. |
213 // must delete the returned object. Useful for testing. | 212 // Useful for testing. |
214 static Response* CreateEmpty(); | 213 static scoped_ptr<Response> CreateEmpty(); |
215 | 214 |
216 protected: | 215 protected: |
217 // Creates a Response message. The internal raw message is NULL. | 216 // Creates a Response message. The internal raw message is NULL. |
218 Response(); | 217 Response(); |
219 | 218 |
220 private: | 219 private: |
221 DISALLOW_COPY_AND_ASSIGN(Response); | 220 DISALLOW_COPY_AND_ASSIGN(Response); |
222 }; | 221 }; |
223 | 222 |
224 // ErrorResponse is a type of message used to return an error to the | 223 // ErrorResponse is a type of message used to return an error to the |
225 // caller of a method. | 224 // caller of a method. |
226 class CHROME_DBUS_EXPORT ErrorResponse: public Response { | 225 class CHROME_DBUS_EXPORT ErrorResponse: public Response { |
227 public: | 226 public: |
228 // Returns a newly created Response from the given raw message of the | 227 // Returns a newly created Response from the given raw message of the |
229 // type DBUS_MESSAGE_TYPE_METHOD_RETURN. The caller must delete the | 228 // type DBUS_MESSAGE_TYPE_METHOD_RETURN. |
230 // returned object. Takes the ownership of |raw_message|. | 229 static scoped_ptr<ErrorResponse> FromRawMessage(DBusMessage* raw_message); |
satorux1
2013/01/30 06:36:58
ditto
alias of yukishiino
2013/01/30 13:13:44
Done.
| |
231 static ErrorResponse* FromRawMessage(DBusMessage* raw_message); | |
232 | 230 |
233 // Returns a newly created ErrorResponse from the given method call, the | 231 // Returns a newly created ErrorResponse from the given method call, the |
234 // error name, and the error message. The error name looks like | 232 // error name, and the error message. The error name looks like |
235 // "org.freedesktop.DBus.Error.Failed". Used for returning an error to a | 233 // "org.freedesktop.DBus.Error.Failed". Used for returning an error to a |
236 // failed method call. | 234 // failed method call. |
237 static ErrorResponse* FromMethodCall(MethodCall* method_call, | 235 static scoped_ptr<ErrorResponse> FromMethodCall( |
238 const std::string& error_name, | 236 MethodCall* method_call, |
239 const std::string& error_message); | 237 const std::string& error_name, |
238 const std::string& error_message); | |
240 | 239 |
241 private: | 240 private: |
242 // Creates an ErrorResponse message. The internal raw message is NULL. | 241 // Creates an ErrorResponse message. The internal raw message is NULL. |
243 ErrorResponse(); | 242 ErrorResponse(); |
244 | 243 |
245 DISALLOW_COPY_AND_ASSIGN(ErrorResponse); | 244 DISALLOW_COPY_AND_ASSIGN(ErrorResponse); |
246 }; | 245 }; |
247 | 246 |
248 // MessageWriter is used to write outgoing messages for calling methods | 247 // MessageWriter is used to write outgoing messages for calling methods |
249 // and sending signals. | 248 // and sending signals. |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
476 | 475 |
477 Message* message_; | 476 Message* message_; |
478 DBusMessageIter raw_message_iter_; | 477 DBusMessageIter raw_message_iter_; |
479 | 478 |
480 DISALLOW_COPY_AND_ASSIGN(MessageReader); | 479 DISALLOW_COPY_AND_ASSIGN(MessageReader); |
481 }; | 480 }; |
482 | 481 |
483 } // namespace dbus | 482 } // namespace dbus |
484 | 483 |
485 #endif // DBUS_MESSAGE_H_ | 484 #endif // DBUS_MESSAGE_H_ |
OLD | NEW |