Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Side by Side Diff: chrome/browser/media_galleries/win/snapshot_file_details.h

Issue 145303002: Convert Media Galleries to use base::File (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_WIN_SNAPSHOT_FILE_DETAILS_H_ 5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_WIN_SNAPSHOT_FILE_DETAILS_H_
6 #define CHROME_BROWSER_MEDIA_GALLERIES_WIN_SNAPSHOT_FILE_DETAILS_H_ 6 #define CHROME_BROWSER_MEDIA_GALLERIES_WIN_SNAPSHOT_FILE_DETAILS_H_
7 7
8 #include "base/files/file.h"
8 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
9 #include "base/platform_file.h"
10 #include "base/win/scoped_comptr.h" 10 #include "base/win/scoped_comptr.h"
11 #include "chrome/browser/media_galleries/fileapi/mtp_device_async_delegate.h" 11 #include "chrome/browser/media_galleries/fileapi/mtp_device_async_delegate.h"
12 12
13 // Structure used to represent snapshot file request params. 13 // Structure used to represent snapshot file request params.
14 struct SnapshotRequestInfo { 14 struct SnapshotRequestInfo {
15 SnapshotRequestInfo( 15 SnapshotRequestInfo(
16 const base::FilePath& device_file_path, 16 const base::FilePath& device_file_path,
17 const base::FilePath& snapshot_file_path, 17 const base::FilePath& snapshot_file_path,
18 const MTPDeviceAsyncDelegate::CreateSnapshotFileSuccessCallback& 18 const MTPDeviceAsyncDelegate::CreateSnapshotFileSuccessCallback&
19 success_callback, 19 success_callback,
(...skipping 12 matching lines...) Expand all
32 // A callback to be called when CreateSnapshotFile() fails. 32 // A callback to be called when CreateSnapshotFile() fails.
33 MTPDeviceAsyncDelegate::ErrorCallback error_callback; 33 MTPDeviceAsyncDelegate::ErrorCallback error_callback;
34 }; 34 };
35 35
36 // Provides the details for the the creation of snapshot file. 36 // Provides the details for the the creation of snapshot file.
37 class SnapshotFileDetails { 37 class SnapshotFileDetails {
38 public: 38 public:
39 explicit SnapshotFileDetails(const SnapshotRequestInfo& request_info); 39 explicit SnapshotFileDetails(const SnapshotRequestInfo& request_info);
40 ~SnapshotFileDetails(); 40 ~SnapshotFileDetails();
41 41
42 void set_file_info(const base::PlatformFileInfo& file_info); 42 void set_file_info(const base::File::Info& file_info);
43 void set_device_file_stream(IStream* file_stream); 43 void set_device_file_stream(IStream* file_stream);
44 void set_optimal_transfer_size(DWORD optimal_transfer_size); 44 void set_optimal_transfer_size(DWORD optimal_transfer_size);
45 45
46 SnapshotRequestInfo request_info() const { 46 SnapshotRequestInfo request_info() const {
47 return request_info_; 47 return request_info_;
48 } 48 }
49 49
50 base::PlatformFileInfo file_info() const { 50 base::File::Info file_info() const {
51 return file_info_; 51 return file_info_;
52 } 52 }
53 53
54 IStream* device_file_stream() const { 54 IStream* device_file_stream() const {
55 return file_stream_.get(); 55 return file_stream_.get();
56 } 56 }
57 57
58 DWORD optimal_transfer_size() const { 58 DWORD optimal_transfer_size() const {
59 return optimal_transfer_size_; 59 return optimal_transfer_size_;
60 } 60 }
61 61
62 // Returns true if the data contents of the device file is written to the 62 // Returns true if the data contents of the device file is written to the
63 // snapshot file. 63 // snapshot file.
64 bool IsSnapshotFileWriteComplete() const; 64 bool IsSnapshotFileWriteComplete() const;
65 65
66 // Adds |bytes_written| to |bytes_written_|. 66 // Adds |bytes_written| to |bytes_written_|.
67 // |bytes_written| specifies the total number of bytes transferred during 67 // |bytes_written| specifies the total number of bytes transferred during
68 // the last write operation. 68 // the last write operation.
69 // If |bytes_written| is valid, returns true and adds |bytes_written| to 69 // If |bytes_written| is valid, returns true and adds |bytes_written| to
70 // |bytes_written_|. 70 // |bytes_written_|.
71 // If |bytes_written| is invalid, returns false and does not add 71 // If |bytes_written| is invalid, returns false and does not add
72 // |bytes_written| to |bytes_written_|. 72 // |bytes_written| to |bytes_written_|.
73 bool AddBytesWritten(DWORD bytes_written); 73 bool AddBytesWritten(DWORD bytes_written);
74 74
75 private: 75 private:
76 // Snapshot file request params. 76 // Snapshot file request params.
77 SnapshotRequestInfo request_info_; 77 SnapshotRequestInfo request_info_;
78 78
79 // Metadata of the created snapshot file. 79 // Metadata of the created snapshot file.
80 base::PlatformFileInfo file_info_; 80 base::File::Info file_info_;
81 81
82 // Used to read the device file contents. 82 // Used to read the device file contents.
83 base::win::ScopedComPtr<IStream> file_stream_; 83 base::win::ScopedComPtr<IStream> file_stream_;
84 84
85 // The number of bytes of data to read from the |file_stream| object 85 // The number of bytes of data to read from the |file_stream| object
86 // during each IStream::Read() operation. 86 // during each IStream::Read() operation.
87 DWORD optimal_transfer_size_; 87 DWORD optimal_transfer_size_;
88 88
89 // Total number of bytes written into the snapshot file. 89 // Total number of bytes written into the snapshot file.
90 DWORD bytes_written_; 90 DWORD bytes_written_;
91 }; 91 };
92 92
93 #endif // CHROME_BROWSER_MEDIA_GALLERIES_WIN_SNAPSHOT_FILE_DETAILS_H_ 93 #endif // CHROME_BROWSER_MEDIA_GALLERIES_WIN_SNAPSHOT_FILE_DETAILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698