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 #include "chromeos/dbus/session_manager_client.h" | 5 #include "chromeos/dbus/session_manager_client.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 } | 396 } |
397 | 397 |
398 void ExtractString(const std::string& method_name, | 398 void ExtractString(const std::string& method_name, |
399 dbus::Response* response, | 399 dbus::Response* response, |
400 std::string* extracted) { | 400 std::string* extracted) { |
401 if (!response) { | 401 if (!response) { |
402 LOG(ERROR) << "Failed to call " << method_name; | 402 LOG(ERROR) << "Failed to call " << method_name; |
403 return; | 403 return; |
404 } | 404 } |
405 dbus::MessageReader reader(response); | 405 dbus::MessageReader reader(response); |
406 uint8* values = NULL; | 406 const uint8* values = NULL; |
407 size_t length = 0; | 407 size_t length = 0; |
408 if (!reader.PopArrayOfBytes(&values, &length)) { | 408 if (!reader.PopArrayOfBytes(&values, &length)) { |
409 LOG(ERROR) << "Invalid response: " << response->ToString(); | 409 LOG(ERROR) << "Invalid response: " << response->ToString(); |
410 return; | 410 return; |
411 } | 411 } |
412 // static_cast does not work due to signedness. | 412 // static_cast does not work due to signedness. |
413 extracted->assign(reinterpret_cast<char*>(values), length); | 413 extracted->assign(reinterpret_cast<const char*>(values), length); |
414 } | 414 } |
415 | 415 |
416 // Called when kSessionManagerRetrievePolicy or | 416 // Called when kSessionManagerRetrievePolicy or |
417 // kSessionManagerRetrievePolicyForUser method is complete. | 417 // kSessionManagerRetrievePolicyForUser method is complete. |
418 void OnRetrievePolicy(const std::string& method_name, | 418 void OnRetrievePolicy(const std::string& method_name, |
419 const RetrievePolicyCallback& callback, | 419 const RetrievePolicyCallback& callback, |
420 dbus::Response* response) { | 420 dbus::Response* response) { |
421 std::string serialized_proto; | 421 std::string serialized_proto; |
422 ExtractString(method_name, response, &serialized_proto); | 422 ExtractString(method_name, response, &serialized_proto); |
423 callback.Run(serialized_proto); | 423 callback.Run(serialized_proto); |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 | 632 |
633 SessionManagerClient* SessionManagerClient::Create( | 633 SessionManagerClient* SessionManagerClient::Create( |
634 DBusClientImplementationType type) { | 634 DBusClientImplementationType type) { |
635 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 635 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
636 return new SessionManagerClientImpl(); | 636 return new SessionManagerClientImpl(); |
637 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 637 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
638 return new SessionManagerClientStubImpl(); | 638 return new SessionManagerClientStubImpl(); |
639 } | 639 } |
640 | 640 |
641 } // namespace chromeos | 641 } // namespace chromeos |
OLD | NEW |