1 // Copyright 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 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_WIN_SNAPSHOT_FILE_DETAILS_H_
6 #define CHROME_BROWSER_MEDIA_GALLERIES_WIN_SNAPSHOT_FILE_DETAILS_H_
8 #include "base/files/file.h"
9 #include "base/files/file_path.h"
10 #include "base/win/scoped_comptr.h"
11 #include "chrome/browser/media_galleries/fileapi/mtp_device_async_delegate.h"
13 // Structure used to represent snapshot file request params.
14 struct SnapshotRequestInfo
{
16 const base::FilePath
& device_file_path
,
17 const base::FilePath
& snapshot_file_path
,
18 const MTPDeviceAsyncDelegate::CreateSnapshotFileSuccessCallback
&
20 const MTPDeviceAsyncDelegate::ErrorCallback
& error_callback
);
21 ~SnapshotRequestInfo();
24 base::FilePath device_file_path
;
26 // Local platform path of the snapshot file.
27 base::FilePath snapshot_file_path
;
29 // A callback to be called when CreateSnapshotFile() succeeds.
30 MTPDeviceAsyncDelegate::CreateSnapshotFileSuccessCallback
33 // A callback to be called when CreateSnapshotFile() fails.
34 MTPDeviceAsyncDelegate::ErrorCallback error_callback
;
37 // Provides the details for the the creation of snapshot file.
38 class SnapshotFileDetails
{
40 explicit SnapshotFileDetails(const SnapshotRequestInfo
& request_info
);
41 ~SnapshotFileDetails();
43 void set_file_info(const base::File::Info
& file_info
);
44 void set_device_file_stream(IStream
* file_stream
);
45 void set_optimal_transfer_size(DWORD optimal_transfer_size
);
47 SnapshotRequestInfo
request_info() const {
51 base::File::Info
file_info() const {
55 IStream
* device_file_stream() const {
56 return file_stream_
.get();
59 DWORD
optimal_transfer_size() const {
60 return optimal_transfer_size_
;
63 // Returns true if the data contents of the device file is written to the
65 bool IsSnapshotFileWriteComplete() const;
67 // Adds |bytes_written| to |bytes_written_|.
68 // |bytes_written| specifies the total number of bytes transferred during
69 // the last write operation.
70 // If |bytes_written| is valid, returns true and adds |bytes_written| to
72 // If |bytes_written| is invalid, returns false and does not add
73 // |bytes_written| to |bytes_written_|.
74 bool AddBytesWritten(DWORD bytes_written
);
77 // Snapshot file request params.
78 SnapshotRequestInfo request_info_
;
80 // Metadata of the created snapshot file.
81 base::File::Info file_info_
;
83 // Used to read the device file contents.
84 base::win::ScopedComPtr
<IStream
> file_stream_
;
86 // The number of bytes of data to read from the |file_stream| object
87 // during each IStream::Read() operation.
88 DWORD optimal_transfer_size_
;
90 // Total number of bytes written into the snapshot file.
94 #endif // CHROME_BROWSER_MEDIA_GALLERIES_WIN_SNAPSHOT_FILE_DETAILS_H_