blob: 5c031d213951e827999b29edfc39ad1c9a21e773 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
// 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 WEBKIT_FILEAPI_MEDIA_MTP_DEVICE_DELEGATE_H_
#define WEBKIT_FILEAPI_MEDIA_MTP_DEVICE_DELEGATE_H_
#include "base/file_path.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/platform_file.h"
#include "base/sequenced_task_runner_helpers.h"
#include "webkit/fileapi/file_system_file_util.h"
namespace base {
struct PlatformFileInfo;
class SequencedTaskRunner;
class Time;
}
namespace fileapi {
struct MTPDeviceDelegateDeleter;
// Delegate for media transfer protocol (MTP_ device to perform media device
// isolated file system operations. Class that implements this delegate does
// the actual communication with the MTP device.
class MTPDeviceDelegate
: public base::RefCountedThreadSafe<MTPDeviceDelegate,
MTPDeviceDelegateDeleter> {
public:
// Returns information about the given file path.
virtual base::PlatformFileError GetFileInfo(
const FilePath& file_path,
base::PlatformFileInfo* file_info) = 0;
// Returns a pointer to a new instance of AbstractFileEnumerator to enumerate
// the file entries of |root| path. The instance needs to be freed by the
// caller, and its lifetime should not extend past when the current call
// returns to the main media task runner thread.
virtual FileSystemFileUtil::AbstractFileEnumerator* CreateFileEnumerator(
const FilePath& root,
bool recursive) = 0;
// Updates the temporary snapshot file contents given by |local_path| with
// media file contents given by |device_file_path| and also returns the
// metadata of the temporary file.
virtual PlatformFileError CreateSnapshotFile(
const FilePath& device_file_path,
const FilePath& local_path,
base::PlatformFileInfo* file_info) = 0;
// Returns TaskRunner on which the operation is performed.
virtual base::SequencedTaskRunner* GetMediaTaskRunner() = 0;
// Helper function to destruct the delegate object on UI thread.
virtual void DeleteOnCorrectThread() const = 0;
protected:
virtual ~MTPDeviceDelegate() {}
private:
friend struct MTPDeviceDelegateDeleter;
friend class base::DeleteHelper<MTPDeviceDelegate>;
friend class base::RefCountedThreadSafe<MTPDeviceDelegate,
MTPDeviceDelegateDeleter>;
};
struct MTPDeviceDelegateDeleter {
static void Destruct(const MTPDeviceDelegate* delegate) {
delegate->DeleteOnCorrectThread();
}
};
} // namespace fileapi
#endif // WEBKIT_FILEAPI_MEDIA_MTP_DEVICE_DELEGATE_H_
|