| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_CONTEXT_H_ | 5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_CONTEXT_H_ |
| 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_CONTEXT_H_ | 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_CONTEXT_H_ |
| 7 | 7 |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
| 11 #include "webkit/fileapi/file_system_file_util.h" | |
| 12 #include "webkit/fileapi/file_system_types.h" | 11 #include "webkit/fileapi/file_system_types.h" |
| 12 #include "webkit/fileapi/fileapi_file_util.h" |
| 13 | 13 |
| 14 namespace fileapi { | 14 namespace fileapi { |
| 15 | 15 |
| 16 class FileSystemContext; | 16 class FileSystemContext; |
| 17 | 17 |
| 18 class FileSystemOperationContext { | 18 class FileSystemOperationContext { |
| 19 public: | 19 public: |
| 20 // The |file_system_file_util| parameter is so that unit tests can force their | 20 // The |file_util| parameter is so that unit tests can force their own |
| 21 // own preferred class in for both src and dest FSFU; in general these will | 21 // preferred class in for both src and dest FSFU; in general these will get |
| 22 // get set later by the FileSystemOperation. | 22 // set later by the FileSystemOperation. |
| 23 FileSystemOperationContext( | 23 FileSystemOperationContext(FileSystemContext* context, FileUtil* file_util); |
| 24 FileSystemContext* context, | |
| 25 FileSystemFileUtil* file_system_file_util); | |
| 26 ~FileSystemOperationContext(); | 24 ~FileSystemOperationContext(); |
| 27 | 25 |
| 28 FileSystemContext* file_system_context() const { | 26 FileSystemContext* file_system_context() const { |
| 29 return file_system_context_.get(); | 27 return file_system_context_.get(); |
| 30 } | 28 } |
| 31 | 29 |
| 32 void set_src_file_system_file_util(FileSystemFileUtil* util) { | 30 void set_src_file_util(FileUtil* util) { |
| 33 DCHECK(!src_file_system_file_util_); | 31 DCHECK(!src_file_util_); |
| 34 src_file_system_file_util_ = util; | 32 src_file_util_ = util; |
| 35 } | 33 } |
| 36 | 34 |
| 37 FileSystemFileUtil* src_file_system_file_util() const { | 35 FileUtil* src_file_util() const { |
| 38 return src_file_system_file_util_; | 36 return src_file_util_; |
| 39 } | 37 } |
| 40 | 38 |
| 41 void set_dest_file_system_file_util(FileSystemFileUtil* util) { | 39 void set_dest_file_util(FileUtil* util) { |
| 42 DCHECK(!dest_file_system_file_util_); | 40 DCHECK(!dest_file_util_); |
| 43 dest_file_system_file_util_ = util; | 41 dest_file_util_ = util; |
| 44 } | 42 } |
| 45 | 43 |
| 46 FileSystemFileUtil* dest_file_system_file_util() const { | 44 FileUtil* dest_file_util() const { |
| 47 return dest_file_system_file_util_; | 45 return dest_file_util_; |
| 48 } | 46 } |
| 49 | 47 |
| 50 void set_src_origin_url(const GURL& url) { | 48 void set_src_origin_url(const GURL& url) { |
| 51 src_origin_url_ = url; | 49 src_origin_url_ = url; |
| 52 } | 50 } |
| 53 | 51 |
| 54 const GURL& src_origin_url() const { | 52 const GURL& src_origin_url() const { |
| 55 return src_origin_url_; | 53 return src_origin_url_; |
| 56 } | 54 } |
| 57 | 55 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 } | 113 } |
| 116 | 114 |
| 117 FileSystemOperationContext* CreateInheritedContextForDest() const; | 115 FileSystemOperationContext* CreateInheritedContextForDest() const; |
| 118 FileSystemOperationContext* CreateInheritedContextWithNewVirtualPaths( | 116 FileSystemOperationContext* CreateInheritedContextWithNewVirtualPaths( |
| 119 const FilePath& new_src_virtual_path, | 117 const FilePath& new_src_virtual_path, |
| 120 const FilePath& new_dest_virtual_path) const; | 118 const FilePath& new_dest_virtual_path) const; |
| 121 void ImportAllowedBytesGrowth(const FileSystemOperationContext& other); | 119 void ImportAllowedBytesGrowth(const FileSystemOperationContext& other); |
| 122 | 120 |
| 123 private: | 121 private: |
| 124 scoped_refptr<FileSystemContext> file_system_context_; | 122 scoped_refptr<FileSystemContext> file_system_context_; |
| 125 // These *_file_system_file_util_ are not "owned" by | 123 // These *_file_util_ are not "owned" by FileSystemOperationContext. They |
| 126 // FileSystemOperationContext. They are supposed to be pointers to objects | 124 // are supposed to be pointers to objects that will outlive us. |
| 127 // that will outlive us. | 125 FileUtil* src_file_util_; |
| 128 FileSystemFileUtil* src_file_system_file_util_; | 126 FileUtil* dest_file_util_; |
| 129 FileSystemFileUtil* dest_file_system_file_util_; | |
| 130 | 127 |
| 131 GURL src_origin_url_; // Also used for any single-path operation. | 128 GURL src_origin_url_; // Also used for any single-path operation. |
| 132 GURL dest_origin_url_; | 129 GURL dest_origin_url_; |
| 133 FileSystemType src_type_; // Also used for any single-path operation. | 130 FileSystemType src_type_; // Also used for any single-path operation. |
| 134 FileSystemType dest_type_; | 131 FileSystemType dest_type_; |
| 135 int64 allowed_bytes_growth_; | 132 int64 allowed_bytes_growth_; |
| 136 bool do_not_write_actually_; | 133 bool do_not_write_actually_; |
| 137 | 134 |
| 138 // Used for delayed operation by quota. | 135 // Used for delayed operation by quota. |
| 139 FilePath src_virtual_path_; // Also used for any single-path operation. | 136 FilePath src_virtual_path_; // Also used for any single-path operation. |
| 140 FilePath dest_virtual_path_; | 137 FilePath dest_virtual_path_; |
| 141 }; | 138 }; |
| 142 | 139 |
| 143 } // namespace fileapi | 140 } // namespace fileapi |
| 144 | 141 |
| 145 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_CONTEXT_H_ | 142 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_CONTEXT_H_ |
| OLD | NEW |