OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_MANAGER_SNAPSHOT_MANAGER_H_ | |
6 #define CHROME_BROWSER_CHROMEOS_FILE_MANAGER_SNAPSHOT_MANAGER_H_ | |
7 | |
8 #include "base/callback_forward.h" | |
9 #include "base/files/file.h" | |
10 #include "base/files/file_path.h" | |
11 #include "base/memory/ref_counted.h" | |
12 #include "base/memory/weak_ptr.h" | |
13 #include "webkit/common/blob/shareable_file_reference.h" | |
hashimoto
2014/06/19 06:16:52
nit: Can't be replaced with a forward declaration?
kinaba
2014/06/20 01:17:08
Done.
| |
14 | |
15 class Profile; | |
16 | |
17 namespace file_manager { | |
18 | |
19 // Utility class for creating a snapshot of a file system file on local disk. | |
20 // The class wraps the underlying implementation of fileapi's CreateSnapshotFile | |
21 // and prolongs the lifetime of snapshot files so that the client code that just | |
22 // accepts file paths works without problems. | |
23 class SnapshotManager { | |
24 public: | |
25 // The callback type for CreateManagedSnapshot. | |
26 typedef base::Callback<void(const base::FilePath&)> LocalPathCallback; | |
27 | |
28 explicit SnapshotManager(Profile* profile); | |
29 ~SnapshotManager(); | |
30 | |
31 // Creates a snapshot file copy of a file system file |absolute_file_path| and | |
32 // returns back to |callback|. Returns empty path for failure. | |
33 void CreateManagedSnapshot(const base::FilePath& absolute_file_path, | |
34 const LocalPathCallback& callback); | |
35 | |
36 private: | |
37 // Part of CreateManagedSnapshot. | |
38 void OnCreateSnapshotFile( | |
39 const LocalPathCallback& callback, | |
40 base::File::Error result, | |
41 const base::File::Info& file_info, | |
42 const base::FilePath& platform_path, | |
43 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref); | |
44 | |
45 Profile* profile_; | |
46 std::vector<scoped_refptr<webkit_blob::ShareableFileReference> > file_refs_; | |
47 | |
48 // Note: This should remain the last member so it'll be destroyed and | |
49 // invalidate the weak pointers before any other memebers are destoryed. | |
50 base::WeakPtrFactory<SnapshotManager> weak_ptr_factory_; | |
51 DISALLOW_COPY_AND_ASSIGN(SnapshotManager); | |
52 }; | |
53 | |
54 } // namespace file_manager | |
55 | |
56 #endif // CHROME_BROWSER_CHROMEOS_FILE_MANAGER_SNAPSHOT_MANAGER_H_ | |
OLD | NEW |