Commit 85b95a20 authored by thestig@chromium.org's avatar thestig@chromium.org

chromeos: Add dbus MTPDClient.

BUG=chromium-os:29557
TEST=none
Review URL: https://chromiumcodereview.appspot.com/10825170

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150382 0039d316-1c4b-4281-b951-d872f2087c98
parent 7c578773
......@@ -95,6 +95,8 @@
'dbus/image_burner_client.h',
'dbus/introspectable_client.cc',
'dbus/introspectable_client.h',
'dbus/media_transfer_protocol_daemon_client.cc',
'dbus/media_transfer_protocol_daemon_client.h',
'dbus/modem_messaging_client.cc',
'dbus/modem_messaging_client.h',
'dbus/power_manager_client.cc',
......@@ -142,10 +144,10 @@
'dbus/mock_bluetooth_node_client.h',
'dbus/mock_bluetooth_out_of_band_client.cc',
'dbus/mock_bluetooth_out_of_band_client.h',
'dbus/mock_cros_disks_client.cc',
'dbus/mock_cros_disks_client.h',
'dbus/mock_cashew_client.cc',
'dbus/mock_cashew_client.h',
'dbus/mock_cros_disks_client.cc',
'dbus/mock_cros_disks_client.h',
'dbus/mock_cryptohome_client.cc',
'dbus/mock_cryptohome_client.h',
'dbus/mock_dbus_thread_manager.cc',
......@@ -170,6 +172,8 @@
'dbus/mock_image_burner_client.h',
'dbus/mock_introspectable_client.cc',
'dbus/mock_introspectable_client.h',
'dbus/mock_media_transfer_protocol_daemon_client.cc',
'dbus/mock_media_transfer_protocol_daemon_client.h',
'dbus/mock_modem_messaging_client.cc',
'dbus/mock_modem_messaging_client.h',
'dbus/mock_power_manager_client.cc',
......
......@@ -4,6 +4,8 @@
#include "chromeos/dbus/cros_disks_client.h"
#include <map>
#include "base/bind.h"
#include "base/stl_util.h"
#include "base/stringprintf.h"
......@@ -246,7 +248,7 @@ class CrosDisksClientImpl : public CrosDisksClient {
cros_disks::kMountCompleted,
base::Bind(&CrosDisksClientImpl::OnMountCompleted,
weak_ptr_factory_.GetWeakPtr(),
mount_completed_handler ),
mount_completed_handler),
base::Bind(&CrosDisksClientImpl::OnSignalConnected,
weak_ptr_factory_.GetWeakPtr()));
}
......@@ -415,7 +417,7 @@ class CrosDisksClientStubImpl : public CrosDisksClient {
DISALLOW_COPY_AND_ASSIGN(CrosDisksClientStubImpl);
};
} // namespace
} // namespace
////////////////////////////////////////////////////////////////////////////////
// DiskInfo
......@@ -435,7 +437,7 @@ DiskInfo::DiskInfo(const std::string& device_path, dbus::Response* response)
DiskInfo::~DiskInfo() {
}
// Initialize |this| from |response| given by the cros-disks service.
// Initializes |this| from |response| given by the cros-disks service.
// Below is an example of |response|'s raw message (long string is ellipsized).
//
//
......
......@@ -71,14 +71,14 @@ class DiskInfo {
~DiskInfo();
// Device path. (e.g. /sys/devices/pci0000:00/.../8:0:0:0/block/sdb/sdb1)
std::string device_path() const { return device_path_; }
const std::string& device_path() const { return device_path_; }
// Disk mount path. (e.g. /media/removable/VOLUME)
std::string mount_path() const { return mount_path_; }
const std::string& mount_path() const { return mount_path_; }
// Disk system path given by udev.
// (e.g. /sys/devices/pci0000:00/.../8:0:0:0/block/sdb/sdb1)
std::string system_path() const { return system_path_; }
const std::string& system_path() const { return system_path_; }
// Is a drive or not. (i.e. true with /dev/sdb, false with /dev/sdb1)
bool is_drive() const { return is_drive_; }
......@@ -90,13 +90,13 @@ class DiskInfo {
bool on_boot_device() const { return on_boot_device_; }
// Disk file path (e.g. /dev/sdb).
std::string file_path() const { return file_path_; }
const std::string& file_path() const { return file_path_; }
// Disk label.
std::string label() const { return label_; }
const std::string& label() const { return label_; }
// Disk model. (e.g. "TransMemory")
std::string drive_label() const { return drive_model_; }
const std::string& drive_label() const { return drive_model_; }
// Device type. Not working well, yet.
DeviceType device_type() const { return device_type_; }
......@@ -111,7 +111,7 @@ class DiskInfo {
bool is_hidden() const { return is_hidden_; }
// Returns file system uuid.
std::string uuid() const { return uuid_; }
const std::string& uuid() const { return uuid_; }
private:
void InitializeFromResponse(dbus::Response* response);
......@@ -146,34 +146,40 @@ class CHROMEOS_EXPORT CrosDisksClient {
// A callback to handle the result of Unmount.
// The argument is the device path.
typedef base::Callback<void(const std::string&)> UnmountCallback;
typedef base::Callback<void(const std::string& device_path)> UnmountCallback;
// A callback to handle the result of EnumerateAutoMountableDevices.
// The argument is the enumerated device paths.
typedef base::Callback<void(const std::vector<std::string>&)
typedef base::Callback<void(const std::vector<std::string>& device_paths)
> EnumerateAutoMountableDevicesCallback;
// A callback to handle the result of FormatDevice.
// The first argument is the device path.
// The second argument is true when formatting succeeded, false otherwise.
typedef base::Callback<void(const std::string&, bool)> FormatDeviceCallback;
typedef base::Callback<void(const std::string& device_path,
bool format_succeeded)> FormatDeviceCallback;
// A callback to handle the result of GetDeviceProperties.
// The argument is the information about the specified device.
typedef base::Callback<void(const DiskInfo&)> GetDevicePropertiesCallback;
typedef base::Callback<void(const DiskInfo& disk_info)
> GetDevicePropertiesCallback;
// A callback to handle MountCompleted signal.
// The first argument is the error code.
// The second argument is the source path.
// The third argument is the mount type.
// The fourth argument is the mount path.
typedef base::Callback<void(MountError, const std::string&, MountType,
const std::string&)> MountCompletedHandler;
typedef base::Callback<void(MountError error_code,
const std::string& source_path,
MountType mount_type,
const std::string& mount_path)
> MountCompletedHandler;
// A callback to handle mount events.
// The first argument is the event type.
// The second argument is the device path.
typedef base::Callback<void(MountEventType, const std::string&)
typedef base::Callback<void(MountEventType event_type,
const std::string& device_path)
> MountEventHandler;
virtual ~CrosDisksClient();
......
......@@ -4,6 +4,8 @@
#include "chromeos/dbus/dbus_thread_manager.h"
#include <map>
#include "base/chromeos/chromeos_version.h"
#include "base/command_line.h"
#include "base/threading/thread.h"
......@@ -32,6 +34,7 @@
#include "chromeos/dbus/ibus/ibus_input_context_client.h"
#include "chromeos/dbus/image_burner_client.h"
#include "chromeos/dbus/introspectable_client.h"
#include "chromeos/dbus/media_transfer_protocol_daemon_client.h"
#include "chromeos/dbus/modem_messaging_client.h"
#include "chromeos/dbus/power_manager_client.h"
#include "chromeos/dbus/session_manager_client.h"
......@@ -120,6 +123,10 @@ class DBusThreadManagerImpl : public DBusThreadManager {
// Create the introspectable object client.
introspectable_client_.reset(
IntrospectableClient::Create(client_type, system_bus_.get()));
// Create the media transfer protocol daemon client.
media_transfer_protocol_daemon_client_.reset(
MediaTransferProtocolDaemonClient::Create(client_type,
system_bus_.get()));
// Create the ModemMessaging client.
modem_messaging_client_.reset(
ModemMessagingClient::Create(client_type, system_bus_.get()));
......@@ -295,6 +302,12 @@ class DBusThreadManagerImpl : public DBusThreadManager {
return introspectable_client_.get();
}
// DBusThreadManager override.
virtual MediaTransferProtocolDaemonClient*
GetMediaTransferProtocolDaemonClient() OVERRIDE {
return media_transfer_protocol_daemon_client_.get();
}
// DBusThreadManager override.
virtual ModemMessagingClient* GetModemMessagingClient() OVERRIDE {
return modem_messaging_client_.get();
......@@ -343,7 +356,6 @@ class DBusThreadManagerImpl : public DBusThreadManager {
// DBusThreadManager override.
virtual IBusEngineService* GetIBusEngineService(
const dbus::ObjectPath& object_path) OVERRIDE {
const DBusClientImplementationType client_type =
base::chromeos::IsRunningOnChromeOS() ? REAL_DBUS_CLIENT_IMPLEMENTATION
: STUB_DBUS_CLIENT_IMPLEMENTATION;
......@@ -389,6 +401,8 @@ class DBusThreadManagerImpl : public DBusThreadManager {
scoped_ptr<GsmSMSClient> gsm_sms_client_;
scoped_ptr<ImageBurnerClient> image_burner_client_;
scoped_ptr<IntrospectableClient> introspectable_client_;
scoped_ptr<MediaTransferProtocolDaemonClient>
media_transfer_protocol_daemon_client_;
scoped_ptr<ModemMessagingClient> modem_messaging_client_;
scoped_ptr<PowerManagerClient> power_manager_client_;
scoped_ptr<SessionManagerClient> session_manager_client_;
......
......@@ -46,6 +46,7 @@ class IBusEngineFactoryService;
class IBusInputContextClient;
class ImageBurnerClient;
class IntrospectableClient;
class MediaTransferProtocolDaemonClient;
class ModemMessagingClient;
class PowerManagerClient;
class SessionManagerClient;
......@@ -199,6 +200,12 @@ class CHROMEOS_EXPORT DBusThreadManager {
// down.
virtual IntrospectableClient* GetIntrospectableClient() = 0;
// Returns the media transfer protocol client, owned by DBusThreadManager.
// Do not cache this pointer and use it after DBusThreadManager is shut
// down.
virtual MediaTransferProtocolDaemonClient*
GetMediaTransferProtocolDaemonClient() = 0;
// Returns the Modem Messaging client, owned by DBusThreadManager.
// Do not cache this pointer and use it after DBusThreadManager is shut
// down.
......
This diff is collapsed.
This diff is collapsed.
......@@ -23,6 +23,7 @@
#include "chromeos/dbus/mock_gsm_sms_client.h"
#include "chromeos/dbus/mock_image_burner_client.h"
#include "chromeos/dbus/mock_introspectable_client.h"
#include "chromeos/dbus/mock_media_transfer_protocol_daemon_client.h"
#include "chromeos/dbus/mock_modem_messaging_client.h"
#include "chromeos/dbus/mock_power_manager_client.h"
#include "chromeos/dbus/mock_session_manager_client.h"
......@@ -57,6 +58,8 @@ MockDBusThreadManager::MockDBusThreadManager()
mock_gsm_sms_client_(new MockGsmSMSClient),
mock_image_burner_client_(new MockImageBurnerClient),
mock_introspectable_client_(new MockIntrospectableClient),
mock_media_transfer_protocol_daemon_client_(
new MockMediaTransferProtocolDaemonClient),
mock_modem_messaging_client_(new MockModemMessagingClient),
mock_power_manager_client_(new MockPowerManagerClient),
mock_session_manager_client_(new MockSessionManagerClient),
......@@ -101,6 +104,8 @@ MockDBusThreadManager::MockDBusThreadManager()
.WillRepeatedly(Return(mock_image_burner_client()));
EXPECT_CALL(*this, GetIntrospectableClient())
.WillRepeatedly(Return(mock_introspectable_client()));
EXPECT_CALL(*this, GetMediaTransferProtocolDaemonClient())
.WillRepeatedly(Return(mock_media_transfer_protocol_daemon_client()));
EXPECT_CALL(*this, GetModemMessagingClient())
.WillRepeatedly(Return(mock_modem_messaging_client()));
EXPECT_CALL(*this, GetPowerManagerClient())
......
......@@ -37,6 +37,7 @@ class MockFlimflamServiceClient;
class MockGsmSMSClient;
class MockImageBurnerClient;
class MockIntrospectableClient;
class MockMediaTransferProtocolDaemonClient;
class MockModemMessagingClient;
class MockPowerManagerClient;
class MockSessionManagerClient;
......@@ -74,6 +75,8 @@ class MockDBusThreadManager : public DBusThreadManager {
MOCK_METHOD0(GetGsmSMSClient, GsmSMSClient*(void));
MOCK_METHOD0(GetImageBurnerClient, ImageBurnerClient*(void));
MOCK_METHOD0(GetIntrospectableClient, IntrospectableClient*(void));
MOCK_METHOD0(GetMediaTransferProtocolDaemonClient,
MediaTransferProtocolDaemonClient*(void));
MOCK_METHOD0(GetModemMessagingClient, ModemMessagingClient*(void));
MOCK_METHOD0(GetPowerManagerClient, PowerManagerClient*(void));
MOCK_METHOD0(GetSessionManagerClient, SessionManagerClient*(void));
......@@ -145,6 +148,10 @@ class MockDBusThreadManager : public DBusThreadManager {
MockIntrospectableClient* mock_introspectable_client() {
return mock_introspectable_client_.get();
}
MockMediaTransferProtocolDaemonClient*
mock_media_transfer_protocol_daemon_client() {
return mock_media_transfer_protocol_daemon_client_.get();
}
MockModemMessagingClient* mock_modem_messaging_client() {
return mock_modem_messaging_client_.get();
}
......@@ -184,6 +191,8 @@ class MockDBusThreadManager : public DBusThreadManager {
scoped_ptr<MockGsmSMSClient> mock_gsm_sms_client_;
scoped_ptr<MockImageBurnerClient> mock_image_burner_client_;
scoped_ptr<MockIntrospectableClient> mock_introspectable_client_;
scoped_ptr<MockMediaTransferProtocolDaemonClient>
mock_media_transfer_protocol_daemon_client_;
scoped_ptr<MockModemMessagingClient> mock_modem_messaging_client_;
scoped_ptr<MockPowerManagerClient> mock_power_manager_client_;
scoped_ptr<MockSessionManagerClient> mock_session_manager_client_;
......
......@@ -135,6 +135,12 @@ IntrospectableClient*
return NULL;
}
MediaTransferProtocolDaemonClient*
MockDBusThreadManagerWithoutGMock::GetMediaTransferProtocolDaemonClient() {
NOTIMPLEMENTED();
return NULL;
}
ModemMessagingClient*
MockDBusThreadManagerWithoutGMock::GetModemMessagingClient() {
NOTIMPLEMENTED();
......
......@@ -52,6 +52,8 @@ class MockDBusThreadManagerWithoutGMock : public DBusThreadManager {
virtual GsmSMSClient* GetGsmSMSClient() OVERRIDE;
virtual ImageBurnerClient* GetImageBurnerClient() OVERRIDE;
virtual IntrospectableClient* GetIntrospectableClient() OVERRIDE;
virtual MediaTransferProtocolDaemonClient*
GetMediaTransferProtocolDaemonClient() OVERRIDE;
virtual ModemMessagingClient* GetModemMessagingClient() OVERRIDE;
virtual PowerManagerClient* GetPowerManagerClient() OVERRIDE;
virtual SessionManagerClient* GetSessionManagerClient() OVERRIDE;
......
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chromeos/dbus/mock_media_transfer_protocol_daemon_client.h"
namespace chromeos {
MockMediaTransferProtocolDaemonClient::MockMediaTransferProtocolDaemonClient() {} // NOLINT
MockMediaTransferProtocolDaemonClient::~MockMediaTransferProtocolDaemonClient() {} // NOLINT
} // namespace chromeos
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMEOS_DBUS_MOCK_MEDIA_TRANSFER_PROTOCOL_DAEMON_CLIENT_H_
#define CHROMEOS_DBUS_MOCK_MEDIA_TRANSFER_PROTOCOL_DAEMON_CLIENT_H_
#include <string>
#include "chromeos/dbus/media_transfer_protocol_daemon_client.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace chromeos {
class MockMediaTransferProtocolDaemonClient
: public MediaTransferProtocolDaemonClient {
public:
MockMediaTransferProtocolDaemonClient();
virtual ~MockMediaTransferProtocolDaemonClient();
MOCK_METHOD2(EnumerateStorage, void(const EnumerateStorageCallback&,
const ErrorCallback&));
MOCK_METHOD3(GetStorageInfo, void(const std::string&,
const GetStorageInfoCallback&,
const ErrorCallback&));
MOCK_METHOD4(OpenStorage, void(const std::string&,
OpenStorageMode mode,
const OpenStorageCallback&,
const ErrorCallback&));
MOCK_METHOD3(CloseStorage, void(const std::string&,
const CloseStorageCallback&,
const ErrorCallback&));
MOCK_METHOD4(ReadDirectoryByPath, void(const std::string&,
const std::string&,
const ReadDirectoryCallback&,
const ErrorCallback&));
MOCK_METHOD4(ReadDirectoryById, void(const std::string&,
uint32,
const ReadDirectoryCallback&,
const ErrorCallback&));
MOCK_METHOD4(ReadFileByPath, void(const std::string&,
const std::string&,
const ReadFileCallback&,
const ErrorCallback&));
MOCK_METHOD4(ReadFileById, void(const std::string&,
uint32,
const ReadFileCallback&,
const ErrorCallback&));
MOCK_METHOD1(SetUpConnections, void(const MTPStorageEventHandler&));
};
} // namespace chromeos
#endif // CHROMEOS_DBUS_MOCK_MEDIA_TRANSFER_PROTOCOL_DAEMON_CLIENT_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment