| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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_DRIVE_FILE_SYSTEM_OPEN_FILE_OPERATION_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_OPEN_FILE_OPERATION_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_OPEN_FILE_OPERATION_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_OPEN_FILE_OPERATION_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 namespace internal { | 28 namespace internal { |
| 29 class ResourceMetadata; | 29 class ResourceMetadata; |
| 30 class FileCache; | 30 class FileCache; |
| 31 } // namespace internal | 31 } // namespace internal |
| 32 | 32 |
| 33 namespace file_system { | 33 namespace file_system { |
| 34 | 34 |
| 35 class CreateFileOperation; | 35 class CreateFileOperation; |
| 36 class DownloadOperation; | 36 class DownloadOperation; |
| 37 class OperationObserver; | 37 class OperationDelegate; |
| 38 | 38 |
| 39 class OpenFileOperation { | 39 class OpenFileOperation { |
| 40 public: | 40 public: |
| 41 OpenFileOperation(base::SequencedTaskRunner* blocking_task_runner, | 41 OpenFileOperation(base::SequencedTaskRunner* blocking_task_runner, |
| 42 OperationObserver* observer, | 42 OperationDelegate* delegate, |
| 43 JobScheduler* scheduler, | 43 JobScheduler* scheduler, |
| 44 internal::ResourceMetadata* metadata, | 44 internal::ResourceMetadata* metadata, |
| 45 internal::FileCache* cache, | 45 internal::FileCache* cache, |
| 46 const base::FilePath& temporary_file_directory); | 46 const base::FilePath& temporary_file_directory); |
| 47 ~OpenFileOperation(); | 47 ~OpenFileOperation(); |
| 48 | 48 |
| 49 // Opens the file at |file_path|. | 49 // Opens the file at |file_path|. |
| 50 // If the file is not actually downloaded, this method starts | 50 // If the file is not actually downloaded, this method starts |
| 51 // to download it to the cache, and then runs |callback| upon the | 51 // to download it to the cache, and then runs |callback| upon the |
| 52 // completion with the path to the local cache file. | 52 // completion with the path to the local cache file. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 77 const std::string& local_id, | 77 const std::string& local_id, |
| 78 const OpenFileCallback& callback, | 78 const OpenFileCallback& callback, |
| 79 scoped_ptr<base::ScopedClosureRunner>* file_closer, | 79 scoped_ptr<base::ScopedClosureRunner>* file_closer, |
| 80 FileError error); | 80 FileError error); |
| 81 | 81 |
| 82 // Closes the file with |local_id|. | 82 // Closes the file with |local_id|. |
| 83 void CloseFile(const std::string& local_id, | 83 void CloseFile(const std::string& local_id, |
| 84 scoped_ptr<base::ScopedClosureRunner> file_closer); | 84 scoped_ptr<base::ScopedClosureRunner> file_closer); |
| 85 | 85 |
| 86 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; | 86 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
| 87 OperationObserver* observer_; | 87 OperationDelegate* delegate_; |
| 88 internal::FileCache* cache_; | 88 internal::FileCache* cache_; |
| 89 | 89 |
| 90 scoped_ptr<CreateFileOperation> create_file_operation_; | 90 scoped_ptr<CreateFileOperation> create_file_operation_; |
| 91 scoped_ptr<DownloadOperation> download_operation_; | 91 scoped_ptr<DownloadOperation> download_operation_; |
| 92 | 92 |
| 93 // The map from local id for an opened file to the number how many times | 93 // The map from local id for an opened file to the number how many times |
| 94 // the file is opened. | 94 // the file is opened. |
| 95 std::map<std::string, int> open_files_; | 95 std::map<std::string, int> open_files_; |
| 96 | 96 |
| 97 // Note: This should remain the last member so it'll be destroyed and | 97 // Note: This should remain the last member so it'll be destroyed and |
| 98 // invalidate its weak pointers before any other members are destroyed. | 98 // invalidate its weak pointers before any other members are destroyed. |
| 99 base::WeakPtrFactory<OpenFileOperation> weak_ptr_factory_; | 99 base::WeakPtrFactory<OpenFileOperation> weak_ptr_factory_; |
| 100 DISALLOW_COPY_AND_ASSIGN(OpenFileOperation); | 100 DISALLOW_COPY_AND_ASSIGN(OpenFileOperation); |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 } // namespace file_system | 103 } // namespace file_system |
| 104 } // namespace drive | 104 } // namespace drive |
| 105 | 105 |
| 106 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_OPEN_FILE_OPERATION_H_ | 106 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_OPEN_FILE_OPERATION_H_ |
| OLD | NEW |