| 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/cros_disks_client.h" | 5 #include "chromeos/dbus/cros_disks_client.h" |
| 6 | 6 |
| 7 #include <map> |
| 8 |
| 7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 8 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| 9 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
| 10 #include "dbus/bus.h" | 12 #include "dbus/bus.h" |
| 11 #include "dbus/message.h" | 13 #include "dbus/message.h" |
| 12 #include "dbus/object_path.h" | 14 #include "dbus/object_path.h" |
| 13 #include "dbus/object_proxy.h" | 15 #include "dbus/object_proxy.h" |
| 14 #include "third_party/cros_system_api/dbus/service_constants.h" | 16 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 15 | 17 |
| 16 namespace chromeos { | 18 namespace chromeos { |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 kSignalEventTuples[i].event_type, | 241 kSignalEventTuples[i].event_type, |
| 240 mount_event_handler), | 242 mount_event_handler), |
| 241 base::Bind(&CrosDisksClientImpl::OnSignalConnected, | 243 base::Bind(&CrosDisksClientImpl::OnSignalConnected, |
| 242 weak_ptr_factory_.GetWeakPtr())); | 244 weak_ptr_factory_.GetWeakPtr())); |
| 243 } | 245 } |
| 244 proxy_->ConnectToSignal( | 246 proxy_->ConnectToSignal( |
| 245 cros_disks::kCrosDisksInterface, | 247 cros_disks::kCrosDisksInterface, |
| 246 cros_disks::kMountCompleted, | 248 cros_disks::kMountCompleted, |
| 247 base::Bind(&CrosDisksClientImpl::OnMountCompleted, | 249 base::Bind(&CrosDisksClientImpl::OnMountCompleted, |
| 248 weak_ptr_factory_.GetWeakPtr(), | 250 weak_ptr_factory_.GetWeakPtr(), |
| 249 mount_completed_handler ), | 251 mount_completed_handler), |
| 250 base::Bind(&CrosDisksClientImpl::OnSignalConnected, | 252 base::Bind(&CrosDisksClientImpl::OnSignalConnected, |
| 251 weak_ptr_factory_.GetWeakPtr())); | 253 weak_ptr_factory_.GetWeakPtr())); |
| 252 } | 254 } |
| 253 | 255 |
| 254 private: | 256 private: |
| 255 // A struct to contain a pair of signal name and mount event type. | 257 // A struct to contain a pair of signal name and mount event type. |
| 256 // Used by SetUpConnections. | 258 // Used by SetUpConnections. |
| 257 struct SignalEventTuple { | 259 struct SignalEventTuple { |
| 258 const char *signal_name; | 260 const char *signal_name; |
| 259 MountEventType event_type; | 261 MountEventType event_type; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 const GetDevicePropertiesCallback& callback, | 410 const GetDevicePropertiesCallback& callback, |
| 409 const ErrorCallback& error_callback) OVERRIDE {} | 411 const ErrorCallback& error_callback) OVERRIDE {} |
| 410 virtual void SetUpConnections( | 412 virtual void SetUpConnections( |
| 411 const MountEventHandler& mount_event_handler, | 413 const MountEventHandler& mount_event_handler, |
| 412 const MountCompletedHandler& mount_completed_handler) OVERRIDE {} | 414 const MountCompletedHandler& mount_completed_handler) OVERRIDE {} |
| 413 | 415 |
| 414 private: | 416 private: |
| 415 DISALLOW_COPY_AND_ASSIGN(CrosDisksClientStubImpl); | 417 DISALLOW_COPY_AND_ASSIGN(CrosDisksClientStubImpl); |
| 416 }; | 418 }; |
| 417 | 419 |
| 418 } // namespace | 420 } // namespace |
| 419 | 421 |
| 420 //////////////////////////////////////////////////////////////////////////////// | 422 //////////////////////////////////////////////////////////////////////////////// |
| 421 // DiskInfo | 423 // DiskInfo |
| 422 | 424 |
| 423 DiskInfo::DiskInfo(const std::string& device_path, dbus::Response* response) | 425 DiskInfo::DiskInfo(const std::string& device_path, dbus::Response* response) |
| 424 : device_path_(device_path), | 426 : device_path_(device_path), |
| 425 is_drive_(false), | 427 is_drive_(false), |
| 426 has_media_(false), | 428 has_media_(false), |
| 427 on_boot_device_(false), | 429 on_boot_device_(false), |
| 428 device_type_(DEVICE_TYPE_UNKNOWN), | 430 device_type_(DEVICE_TYPE_UNKNOWN), |
| 429 total_size_in_bytes_(0), | 431 total_size_in_bytes_(0), |
| 430 is_read_only_(false), | 432 is_read_only_(false), |
| 431 is_hidden_(true) { | 433 is_hidden_(true) { |
| 432 InitializeFromResponse(response); | 434 InitializeFromResponse(response); |
| 433 } | 435 } |
| 434 | 436 |
| 435 DiskInfo::~DiskInfo() { | 437 DiskInfo::~DiskInfo() { |
| 436 } | 438 } |
| 437 | 439 |
| 438 // Initialize |this| from |response| given by the cros-disks service. | 440 // Initializes |this| from |response| given by the cros-disks service. |
| 439 // Below is an example of |response|'s raw message (long string is ellipsized). | 441 // Below is an example of |response|'s raw message (long string is ellipsized). |
| 440 // | 442 // |
| 441 // | 443 // |
| 442 // message_type: MESSAGE_METHOD_RETURN | 444 // message_type: MESSAGE_METHOD_RETURN |
| 443 // destination: :1.8 | 445 // destination: :1.8 |
| 444 // sender: :1.16 | 446 // sender: :1.16 |
| 445 // signature: a{sv} | 447 // signature: a{sv} |
| 446 // serial: 96 | 448 // serial: 96 |
| 447 // reply_serial: 267 | 449 // reply_serial: 267 |
| 448 // | 450 // |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 // static | 573 // static |
| 572 CrosDisksClient* CrosDisksClient::Create(DBusClientImplementationType type, | 574 CrosDisksClient* CrosDisksClient::Create(DBusClientImplementationType type, |
| 573 dbus::Bus* bus) { | 575 dbus::Bus* bus) { |
| 574 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 576 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
| 575 return new CrosDisksClientImpl(bus); | 577 return new CrosDisksClientImpl(bus); |
| 576 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 578 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
| 577 return new CrosDisksClientStubImpl(); | 579 return new CrosDisksClientStubImpl(); |
| 578 } | 580 } |
| 579 | 581 |
| 580 } // namespace chromeos | 582 } // namespace chromeos |
| OLD | NEW |