OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_LINUX_MTP_READ_FILE_WORKER_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_READ_FILE_WORKER_H_ |
6 #define CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_READ_FILE_WORKER_H_ | 6 #define CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_READ_FILE_WORKER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/files/file.h" |
11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
13 #include "base/platform_file.h" | |
14 | 14 |
15 namespace base { | 15 namespace base { |
16 class FilePath; | 16 class FilePath; |
17 } | 17 } |
18 | 18 |
19 class SnapshotFileDetails; | 19 class SnapshotFileDetails; |
20 struct SnapshotRequestInfo; | 20 struct SnapshotRequestInfo; |
21 | 21 |
22 // Worker class to copy the contents of the media transfer protocol(MTP) device | 22 // Worker class to copy the contents of the media transfer protocol(MTP) device |
23 // file to the given snapshot file. | 23 // file to the given snapshot file. |
24 class MTPReadFileWorker { | 24 class MTPReadFileWorker { |
25 public: | 25 public: |
26 explicit MTPReadFileWorker(const std::string& device_handle); | 26 explicit MTPReadFileWorker(const std::string& device_handle); |
27 ~MTPReadFileWorker(); | 27 ~MTPReadFileWorker(); |
28 | 28 |
29 // Dispatches the request to MediaTransferProtocolManager to get the media | 29 // Dispatches the request to MediaTransferProtocolManager to get the media |
30 // file contents. | 30 // file contents. |
31 // | 31 // |
32 // |request_info| specifies the snapshot file request params. | 32 // |request_info| specifies the snapshot file request params. |
33 // |snapshot_file_info| specifies the metadata of the snapshot file. | 33 // |snapshot_file_info| specifies the metadata of the snapshot file. |
34 void WriteDataIntoSnapshotFile( | 34 void WriteDataIntoSnapshotFile( |
35 const SnapshotRequestInfo& request_info, | 35 const SnapshotRequestInfo& request_info, |
36 const base::PlatformFileInfo& snapshot_file_info); | 36 const base::File::Info& snapshot_file_info); |
37 | 37 |
38 private: | 38 private: |
39 // Called when WriteDataIntoSnapshotFile() completes. | 39 // Called when WriteDataIntoSnapshotFile() completes. |
40 // | 40 // |
41 // |snapshot_file_details| contains the current state of the snapshot file | 41 // |snapshot_file_details| contains the current state of the snapshot file |
42 // (such as how many bytes written to the snapshot file, media device file | 42 // (such as how many bytes written to the snapshot file, media device file |
43 // path, snapshot file path, bytes remaining, etc). | 43 // path, snapshot file path, bytes remaining, etc). |
44 // | 44 // |
45 // If there is an error, |snapshot_file_details.error_callback| is invoked on | 45 // If there is an error, |snapshot_file_details.error_callback| is invoked on |
46 // the IO thread to notify the caller about the failure. | 46 // the IO thread to notify the caller about the failure. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 // The device unique identifier to query the device. | 80 // The device unique identifier to query the device. |
81 const std::string device_handle_; | 81 const std::string device_handle_; |
82 | 82 |
83 // For callbacks that may run after destruction. | 83 // For callbacks that may run after destruction. |
84 base::WeakPtrFactory<MTPReadFileWorker> weak_ptr_factory_; | 84 base::WeakPtrFactory<MTPReadFileWorker> weak_ptr_factory_; |
85 | 85 |
86 DISALLOW_COPY_AND_ASSIGN(MTPReadFileWorker); | 86 DISALLOW_COPY_AND_ASSIGN(MTPReadFileWorker); |
87 }; | 87 }; |
88 | 88 |
89 #endif // CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_READ_FILE_WORKER_H_ | 89 #endif // CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_READ_FILE_WORKER_H_ |
OLD | NEW |