Only fsync leveldb's directory when the manifest is being updated.
[chromium-blink-merge.git] / chromeos / dbus / fake_cros_disks_client.cc
blobfe5873d2c262f51f823ddf70a91361d50c02a5cd
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chromeos/dbus/fake_cros_disks_client.h"
7 #include "base/bind.h"
8 #include "base/message_loop.h"
10 namespace chromeos {
12 FakeCrosDisksClient::FakeCrosDisksClient()
13 : unmount_call_count_(0),
14 unmount_success_(true),
15 format_device_call_count_(0),
16 format_device_success_(true) {
19 FakeCrosDisksClient::~FakeCrosDisksClient() {}
21 void FakeCrosDisksClient::Mount(const std::string& source_path,
22 const std::string& source_format,
23 const std::string& mount_label,
24 MountType type,
25 const MountCallback& callback,
26 const ErrorCallback& error_callback) {
29 void FakeCrosDisksClient::Unmount(const std::string& device_path,
30 UnmountOptions options,
31 const UnmountCallback& callback,
32 const UnmountCallback& error_callback) {
33 DCHECK(!callback.is_null());
34 DCHECK(!error_callback.is_null());
36 unmount_call_count_++;
37 last_unmount_device_path_ = device_path;
38 last_unmount_options_ = options;
39 base::MessageLoopProxy::current()->PostTask(
40 FROM_HERE,
41 base::Bind(unmount_success_ ? callback : error_callback,
42 device_path));
43 if(!unmount_listener_.is_null())
44 unmount_listener_.Run();
47 void FakeCrosDisksClient::EnumerateAutoMountableDevices(
48 const EnumerateAutoMountableDevicesCallback& callback,
49 const ErrorCallback& error_callback) {
52 void FakeCrosDisksClient::FormatDevice(const std::string& device_path,
53 const std::string& filesystem,
54 const FormatDeviceCallback& callback,
55 const ErrorCallback& error_callback) {
56 DCHECK(!callback.is_null());
57 DCHECK(!error_callback.is_null());
59 format_device_call_count_++;
60 last_format_device_device_path_ = device_path;
61 last_format_device_filesystem_ = filesystem;
62 if (format_device_success_) {
63 base::MessageLoopProxy::current()->PostTask(
64 FROM_HERE,
65 base::Bind(callback, device_path, true));
66 } else {
67 base::MessageLoopProxy::current()->PostTask(
68 FROM_HERE,
69 base::Bind(error_callback));
73 void FakeCrosDisksClient::GetDeviceProperties(
74 const std::string& device_path,
75 const GetDevicePropertiesCallback& callback,
76 const ErrorCallback& error_callback) {
79 void FakeCrosDisksClient::SetUpConnections(
80 const MountEventHandler& mount_event_handler,
81 const MountCompletedHandler& mount_completed_handler) {
82 mount_event_handler_ = mount_event_handler;
83 mount_completed_handler_ = mount_completed_handler;
86 bool FakeCrosDisksClient::SendMountEvent(MountEventType event,
87 const std::string& path) {
88 if (mount_event_handler_.is_null())
89 return false;
90 mount_event_handler_.Run(event, path);
91 return true;
94 bool FakeCrosDisksClient::SendMountCompletedEvent(
95 MountError error_code,
96 const std::string& source_path,
97 MountType mount_type,
98 const std::string& mount_path) {
99 if (mount_completed_handler_.is_null())
100 return false;
101 mount_completed_handler_.Run(error_code, source_path, mount_type, mount_path);
102 return true;
105 } // namespace chromeos