OLD | NEW |
| (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_CHROMEOS_DRIVE_FILE_SYSTEM_CLOSE_FILE_OPERATION_H_ | |
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_CLOSE_FILE_OPERATION_H_ | |
7 | |
8 #include <map> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "base/memory/ref_counted.h" | |
12 #include "base/memory/weak_ptr.h" | |
13 #include "chrome/browser/chromeos/drive/file_errors.h" | |
14 | |
15 namespace base { | |
16 class FilePath; | |
17 class SequencedTaskRunner; | |
18 } // namespace base | |
19 | |
20 namespace drive { | |
21 | |
22 class ResourceEntry; | |
23 | |
24 namespace internal { | |
25 class ResourceMetadata; | |
26 } // namespace internal | |
27 | |
28 namespace file_system { | |
29 | |
30 class OperationObserver; | |
31 | |
32 class CloseFileOperation { | |
33 public: | |
34 CloseFileOperation(base::SequencedTaskRunner* blocking_task_runner, | |
35 OperationObserver* observer, | |
36 internal::ResourceMetadata* metadata, | |
37 std::map<base::FilePath, int>* open_files); | |
38 ~CloseFileOperation(); | |
39 | |
40 // Closes the currently opened file |file_path|. | |
41 // |callback| must not be null. | |
42 void CloseFile(const base::FilePath& file_path, | |
43 const FileOperationCallback& callback); | |
44 | |
45 private: | |
46 // Part of CloseFile(). Called after ResourceMetadata::GetResourceEntry(). | |
47 void CloseFileAfterGetResourceEntry(const base::FilePath& file_path, | |
48 const FileOperationCallback& callback, | |
49 const ResourceEntry* entry, | |
50 FileError error); | |
51 | |
52 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; | |
53 OperationObserver* observer_; | |
54 internal::ResourceMetadata* metadata_; | |
55 | |
56 // The map from paths for opened file to the number how many the file is | |
57 // opened. The instance is owned by FileSystem and shared with | |
58 // OpenFileOperation. | |
59 std::map<base::FilePath, int>* open_files_; | |
60 | |
61 // Note: This should remain the last member so it'll be destroyed and | |
62 // invalidate its weak pointers before any other members are destroyed. | |
63 base::WeakPtrFactory<CloseFileOperation> weak_ptr_factory_; | |
64 DISALLOW_COPY_AND_ASSIGN(CloseFileOperation); | |
65 }; | |
66 | |
67 } // namespace file_system | |
68 } // namespace drive | |
69 | |
70 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_CLOSE_FILE_OPERATION_H_ | |
OLD | NEW |