OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_CHROMEOS_FILE_MANAGER_SNAPSHOT_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_MANAGER_SNAPSHOT_MANAGER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_FILE_MANAGER_SNAPSHOT_MANAGER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_FILE_MANAGER_SNAPSHOT_MANAGER_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <deque> | 10 #include <deque> |
9 | 11 |
10 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
11 #include "base/files/file.h" | 13 #include "base/files/file.h" |
| 14 #include "base/macros.h" |
12 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
13 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
14 | 17 |
15 class Profile; | 18 class Profile; |
16 | 19 |
17 namespace base { | 20 namespace base { |
18 class FilePath; | 21 class FilePath; |
19 } // namespace base | 22 } // namespace base |
20 | 23 |
21 namespace storage { | 24 namespace storage { |
(...skipping 21 matching lines...) Expand all Loading... |
43 // Creates a snapshot file copy of a file system file |absolute_file_path| and | 46 // Creates a snapshot file copy of a file system file |absolute_file_path| and |
44 // returns back to |callback|. Returns empty path for failure. | 47 // returns back to |callback|. Returns empty path for failure. |
45 void CreateManagedSnapshot(const base::FilePath& absolute_file_path, | 48 void CreateManagedSnapshot(const base::FilePath& absolute_file_path, |
46 const LocalPathCallback& callback); | 49 const LocalPathCallback& callback); |
47 | 50 |
48 // Struct for keeping the snapshot file reference with its file size used for | 51 // Struct for keeping the snapshot file reference with its file size used for |
49 // computing the necessity of clean up. | 52 // computing the necessity of clean up. |
50 struct FileReferenceWithSizeInfo { | 53 struct FileReferenceWithSizeInfo { |
51 FileReferenceWithSizeInfo( | 54 FileReferenceWithSizeInfo( |
52 scoped_refptr<storage::ShareableFileReference> ref, | 55 scoped_refptr<storage::ShareableFileReference> ref, |
53 int64 size); | 56 int64_t size); |
54 ~FileReferenceWithSizeInfo(); | 57 ~FileReferenceWithSizeInfo(); |
55 scoped_refptr<storage::ShareableFileReference> file_ref; | 58 scoped_refptr<storage::ShareableFileReference> file_ref; |
56 int64 file_size; | 59 int64_t file_size; |
57 }; | 60 }; |
58 | 61 |
59 private: | 62 private: |
60 // Part of CreateManagedSnapshot. | 63 // Part of CreateManagedSnapshot. |
61 void CreateManagedSnapshotAfterSpaceComputed( | 64 void CreateManagedSnapshotAfterSpaceComputed( |
62 const storage::FileSystemURL& filesystem_url, | 65 const storage::FileSystemURL& filesystem_url, |
63 const LocalPathCallback& callback, | 66 const LocalPathCallback& callback, |
64 int64 needed_space); | 67 int64_t needed_space); |
65 | 68 |
66 // Part of CreateManagedSnapshot. | 69 // Part of CreateManagedSnapshot. |
67 void OnCreateSnapshotFile( | 70 void OnCreateSnapshotFile( |
68 const LocalPathCallback& callback, | 71 const LocalPathCallback& callback, |
69 base::File::Error result, | 72 base::File::Error result, |
70 const base::File::Info& file_info, | 73 const base::File::Info& file_info, |
71 const base::FilePath& platform_path, | 74 const base::FilePath& platform_path, |
72 const scoped_refptr<storage::ShareableFileReference>& file_ref); | 75 const scoped_refptr<storage::ShareableFileReference>& file_ref); |
73 | 76 |
74 Profile* profile_; | 77 Profile* profile_; |
75 std::deque<FileReferenceWithSizeInfo> file_refs_; | 78 std::deque<FileReferenceWithSizeInfo> file_refs_; |
76 | 79 |
77 // Note: This should remain the last member so it'll be destroyed and | 80 // Note: This should remain the last member so it'll be destroyed and |
78 // invalidate the weak pointers before any other members are destroyed. | 81 // invalidate the weak pointers before any other members are destroyed. |
79 base::WeakPtrFactory<SnapshotManager> weak_ptr_factory_; | 82 base::WeakPtrFactory<SnapshotManager> weak_ptr_factory_; |
80 DISALLOW_COPY_AND_ASSIGN(SnapshotManager); | 83 DISALLOW_COPY_AND_ASSIGN(SnapshotManager); |
81 }; | 84 }; |
82 | 85 |
83 } // namespace file_manager | 86 } // namespace file_manager |
84 | 87 |
85 #endif // CHROME_BROWSER_CHROMEOS_FILE_MANAGER_SNAPSHOT_MANAGER_H_ | 88 #endif // CHROME_BROWSER_CHROMEOS_FILE_MANAGER_SNAPSHOT_MANAGER_H_ |
OLD | NEW |