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
);
23 base::FilePath device_file_path
;
25 // Local platform path of the snapshot file.
26 base::FilePath snapshot_file_path
;
28 // A callback to be called when CreateSnapshotFile() succeeds.
29 MTPDeviceAsyncDelegate::CreateSnapshotFileSuccessCallback
32 // A callback to be called when CreateSnapshotFile() fails.
33 MTPDeviceAsyncDelegate::ErrorCallback error_callback
;
36 // Provides the details for the the creation of snapshot file.
37 class SnapshotFileDetails
{
39 explicit SnapshotFileDetails(const SnapshotRequestInfo
& request_info
);
40 ~SnapshotFileDetails();
42 void set_file_info(const base::File::Info
& file_info
);
43 void set_device_file_stream(IStream
* file_stream
);
44 void set_optimal_transfer_size(DWORD optimal_transfer_size
);
46 SnapshotRequestInfo
request_info() const {
50 base::File::Info
file_info() const {
54 IStream
* device_file_stream() const {
55 return file_stream_
.get();
58 DWORD
optimal_transfer_size() const {
59 return optimal_transfer_size_
;
62 // Returns true if the data contents of the device file is written to the
64 bool IsSnapshotFileWriteComplete() const;
66 // Adds |bytes_written| to |bytes_written_|.
67 // |bytes_written| specifies the total number of bytes transferred during
68 // the last write operation.
69 // If |bytes_written| is valid, returns true and adds |bytes_written| to
71 // If |bytes_written| is invalid, returns false and does not add
72 // |bytes_written| to |bytes_written_|.
73 bool AddBytesWritten(DWORD bytes_written
);
76 // Snapshot file request params.
77 SnapshotRequestInfo request_info_
;
79 // Metadata of the created snapshot file.
80 base::File::Info file_info_
;
82 // Used to read the device file contents.
83 base::win::ScopedComPtr
<IStream
> file_stream_
;
85 // The number of bytes of data to read from the |file_stream| object
86 // during each IStream::Read() operation.
87 DWORD optimal_transfer_size_
;
89 // Total number of bytes written into the snapshot file.
93 #endif // CHROME_BROWSER_MEDIA_GALLERIES_WIN_SNAPSHOT_FILE_DETAILS_H_