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 <dbus/dbus.h> | 8 #include <dbus/dbus.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 #include <stdint.h> | 10 #include <stdint.h> |
| 11 |
| 12 #include <memory> |
11 #include <string> | 13 #include <string> |
12 #include <vector> | 14 #include <vector> |
13 | 15 |
14 #include "base/macros.h" | 16 #include "base/macros.h" |
15 #include "base/memory/scoped_ptr.h" | |
16 #include "dbus/dbus_export.h" | 17 #include "dbus/dbus_export.h" |
17 #include "dbus/file_descriptor.h" | 18 #include "dbus/file_descriptor.h" |
18 #include "dbus/object_path.h" | 19 #include "dbus/object_path.h" |
19 | 20 |
20 namespace google { | 21 namespace google { |
21 namespace protobuf { | 22 namespace protobuf { |
22 | 23 |
23 class MessageLite; | 24 class MessageLite; |
24 | 25 |
25 } // namespace protobuf | 26 } // namespace protobuf |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 | 198 |
198 DISALLOW_COPY_AND_ASSIGN(Signal); | 199 DISALLOW_COPY_AND_ASSIGN(Signal); |
199 }; | 200 }; |
200 | 201 |
201 // Response is a type of message used for receiving a response from a | 202 // Response is a type of message used for receiving a response from a |
202 // method via D-Bus. | 203 // method via D-Bus. |
203 class CHROME_DBUS_EXPORT Response : public Message { | 204 class CHROME_DBUS_EXPORT Response : public Message { |
204 public: | 205 public: |
205 // Returns a newly created Response from the given raw message of the | 206 // Returns a newly created Response from the given raw message of the |
206 // type DBUS_MESSAGE_TYPE_METHOD_RETURN. Takes the ownership of |raw_message|. | 207 // type DBUS_MESSAGE_TYPE_METHOD_RETURN. Takes the ownership of |raw_message|. |
207 static scoped_ptr<Response> FromRawMessage(DBusMessage* raw_message); | 208 static std::unique_ptr<Response> FromRawMessage(DBusMessage* raw_message); |
208 | 209 |
209 // Returns a newly created Response from the given method call. | 210 // Returns a newly created Response from the given method call. |
210 // Used for implementing exported methods. Does NOT take the ownership of | 211 // Used for implementing exported methods. Does NOT take the ownership of |
211 // |method_call|. | 212 // |method_call|. |
212 static scoped_ptr<Response> FromMethodCall(MethodCall* method_call); | 213 static std::unique_ptr<Response> FromMethodCall(MethodCall* method_call); |
213 | 214 |
214 // Returns a newly created Response with an empty payload. | 215 // Returns a newly created Response with an empty payload. |
215 // Useful for testing. | 216 // Useful for testing. |
216 static scoped_ptr<Response> CreateEmpty(); | 217 static std::unique_ptr<Response> CreateEmpty(); |
217 | 218 |
218 protected: | 219 protected: |
219 // Creates a Response message. The internal raw message is NULL. | 220 // Creates a Response message. The internal raw message is NULL. |
220 Response(); | 221 Response(); |
221 | 222 |
222 private: | 223 private: |
223 DISALLOW_COPY_AND_ASSIGN(Response); | 224 DISALLOW_COPY_AND_ASSIGN(Response); |
224 }; | 225 }; |
225 | 226 |
226 // ErrorResponse is a type of message used to return an error to the | 227 // ErrorResponse is a type of message used to return an error to the |
227 // caller of a method. | 228 // caller of a method. |
228 class CHROME_DBUS_EXPORT ErrorResponse: public Response { | 229 class CHROME_DBUS_EXPORT ErrorResponse: public Response { |
229 public: | 230 public: |
230 // Returns a newly created Response from the given raw message of the | 231 // Returns a newly created Response from the given raw message of the |
231 // type DBUS_MESSAGE_TYPE_METHOD_RETURN. Takes the ownership of |raw_message|. | 232 // type DBUS_MESSAGE_TYPE_METHOD_RETURN. Takes the ownership of |raw_message|. |
232 static scoped_ptr<ErrorResponse> FromRawMessage(DBusMessage* raw_message); | 233 static std::unique_ptr<ErrorResponse> FromRawMessage( |
| 234 DBusMessage* raw_message); |
233 | 235 |
234 // Returns a newly created ErrorResponse from the given method call, the | 236 // Returns a newly created ErrorResponse from the given method call, the |
235 // error name, and the error message. The error name looks like | 237 // error name, and the error message. The error name looks like |
236 // "org.freedesktop.DBus.Error.Failed". Used for returning an error to a | 238 // "org.freedesktop.DBus.Error.Failed". Used for returning an error to a |
237 // failed method call. Does NOT take the ownership of |method_call|. | 239 // failed method call. Does NOT take the ownership of |method_call|. |
238 static scoped_ptr<ErrorResponse> FromMethodCall( | 240 static std::unique_ptr<ErrorResponse> FromMethodCall( |
239 MethodCall* method_call, | 241 MethodCall* method_call, |
240 const std::string& error_name, | 242 const std::string& error_name, |
241 const std::string& error_message); | 243 const std::string& error_message); |
242 | 244 |
243 private: | 245 private: |
244 // Creates an ErrorResponse message. The internal raw message is NULL. | 246 // Creates an ErrorResponse message. The internal raw message is NULL. |
245 ErrorResponse(); | 247 ErrorResponse(); |
246 | 248 |
247 DISALLOW_COPY_AND_ASSIGN(ErrorResponse); | 249 DISALLOW_COPY_AND_ASSIGN(ErrorResponse); |
248 }; | 250 }; |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 | 494 |
493 Message* message_; | 495 Message* message_; |
494 DBusMessageIter raw_message_iter_; | 496 DBusMessageIter raw_message_iter_; |
495 | 497 |
496 DISALLOW_COPY_AND_ASSIGN(MessageReader); | 498 DISALLOW_COPY_AND_ASSIGN(MessageReader); |
497 }; | 499 }; |
498 | 500 |
499 } // namespace dbus | 501 } // namespace dbus |
500 | 502 |
501 #endif // DBUS_MESSAGE_H_ | 503 #endif // DBUS_MESSAGE_H_ |
OLD | NEW |