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

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

Issue 2358493002: Remove MTP support on Linux. (Closed)
Patch Set: move files Created 4 years, 2 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
OLDNEW
(Empty)
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.
4
5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_LINUX_SNAPSHOT_FILE_DETAILS_H_
6 #define CHROME_BROWSER_MEDIA_GALLERIES_LINUX_SNAPSHOT_FILE_DETAILS_H_
7
8 #include <stdint.h>
9
10 #include <string>
11
12 #include "base/callback.h"
13 #include "base/files/file.h"
14 #include "base/files/file_path.h"
15 #include "base/macros.h"
16 #include "chrome/browser/media_galleries/fileapi/mtp_device_async_delegate.h"
17
18 // Used to represent snapshot file request params.
19 struct SnapshotRequestInfo {
20 SnapshotRequestInfo(
21 uint32_t file_id,
22 const base::FilePath& snapshot_file_path,
23 const MTPDeviceAsyncDelegate::CreateSnapshotFileSuccessCallback&
24 success_callback,
25 const MTPDeviceAsyncDelegate::ErrorCallback& error_callback);
26 SnapshotRequestInfo(const SnapshotRequestInfo& other);
27 ~SnapshotRequestInfo();
28
29 // MTP device file id.
30 const uint32_t file_id;
31
32 // Local platform path of the snapshot file.
33 const base::FilePath snapshot_file_path;
34
35 // A callback to be called when CreateSnapshotFile() succeeds.
36 const MTPDeviceAsyncDelegate::CreateSnapshotFileSuccessCallback
37 success_callback;
38
39 // A callback to be called when CreateSnapshotFile() fails.
40 const MTPDeviceAsyncDelegate::ErrorCallback error_callback;
41 };
42
43 // SnapshotFileDetails tracks the current state of the snapshot file (e.g how
44 // many bytes written to the snapshot file, source file details, snapshot file
45 // metadata information, etc).
46 class SnapshotFileDetails {
47 public:
48 SnapshotFileDetails(const SnapshotRequestInfo& request_info,
49 const base::File::Info& file_info);
50
51 ~SnapshotFileDetails();
52
53 uint32_t file_id() const { return request_info_.file_id; }
54
55 base::FilePath snapshot_file_path() const {
56 return request_info_.snapshot_file_path;
57 }
58
59 uint32_t bytes_written() const { return bytes_written_; }
60
61 const base::File::Info& file_info() const {
62 return file_info_;
63 }
64
65 const MTPDeviceAsyncDelegate::CreateSnapshotFileSuccessCallback
66 success_callback() const {
67 return request_info_.success_callback;
68 }
69
70 const MTPDeviceAsyncDelegate::ErrorCallback error_callback() const {
71 return request_info_.error_callback;
72 }
73
74 bool error_occurred() const {
75 return error_occurred_;
76 }
77
78 void set_error_occurred(bool error);
79
80 // Adds |bytes_written| to |bytes_written_|.
81 // |bytes_written| specifies the total number of bytes transferred during the
82 // last write operation.
83 // If |bytes_written| is valid, returns true and adds |bytes_written| to
84 // |bytes_written_|.
85 // If |bytes_written| is invalid, returns false and does not add
86 // |bytes_written| to |bytes_written_|.
87 bool AddBytesWritten(uint32_t bytes_written);
88
89 // Returns true if the snapshot file is created successfully (no more write
90 // operation is required to complete the snapshot file).
91 bool IsSnapshotFileWriteComplete() const;
92
93 uint32_t BytesToRead() const;
94
95 private:
96 // Snapshot file request params.
97 const SnapshotRequestInfo request_info_;
98
99 // Metadata of the snapshot file (such as name, size, type, etc).
100 const base::File::Info file_info_;
101
102 // Number of bytes written into the snapshot file.
103 uint32_t bytes_written_;
104
105 // Whether an error occurred during file transfer.
106 bool error_occurred_;
107
108 DISALLOW_COPY_AND_ASSIGN(SnapshotFileDetails);
109 };
110
111 #endif // CHROME_BROWSER_MEDIA_GALLERIES_LINUX_SNAPSHOT_FILE_DETAILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698