| 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, |
| 24 FileSystemContext* context, | 24 FileApiFileUtil* file_util); |
| 25 FileSystemFileUtil* file_system_file_util); | |
| 26 ~FileSystemOperationContext(); | 25 ~FileSystemOperationContext(); |
| 27 | 26 |
| 28 FileSystemContext* file_system_context() const { | 27 FileSystemContext* file_system_context() const { |
| 29 return file_system_context_.get(); | 28 return file_system_context_.get(); |
| 30 } | 29 } |
| 31 | 30 |
| 32 void set_src_file_system_file_util(FileSystemFileUtil* util) { | 31 void set_src_file_util(FileApiFileUtil* util) { |
| 33 DCHECK(!src_file_system_file_util_); | 32 DCHECK(!src_file_util_); |
| 34 src_file_system_file_util_ = util; | 33 src_file_util_ = util; |
| 35 } | 34 } |
| 36 | 35 |
| 37 FileSystemFileUtil* src_file_system_file_util() const { | 36 FileApiFileUtil* src_file_util() const { |
| 38 return src_file_system_file_util_; | 37 return src_file_util_; |
| 39 } | 38 } |
| 40 | 39 |
| 41 void set_dest_file_system_file_util(FileSystemFileUtil* util) { | 40 void set_dest_file_util(FileApiFileUtil* util) { |
| 42 DCHECK(!dest_file_system_file_util_); | 41 DCHECK(!dest_file_util_); |
| 43 dest_file_system_file_util_ = util; | 42 dest_file_util_ = util; |
| 44 } | 43 } |
| 45 | 44 |
| 46 FileSystemFileUtil* dest_file_system_file_util() const { | 45 FileApiFileUtil* dest_file_util() const { |
| 47 return dest_file_system_file_util_; | 46 return dest_file_util_; |
| 48 } | 47 } |
| 49 | 48 |
| 50 void set_src_origin_url(const GURL& url) { | 49 void set_src_origin_url(const GURL& url) { |
| 51 src_origin_url_ = url; | 50 src_origin_url_ = url; |
| 52 } | 51 } |
| 53 | 52 |
| 54 const GURL& src_origin_url() const { | 53 const GURL& src_origin_url() const { |
| 55 return src_origin_url_; | 54 return src_origin_url_; |
| 56 } | 55 } |
| 57 | 56 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 } | 114 } |
| 116 | 115 |
| 117 FileSystemOperationContext* CreateInheritedContextForDest() const; | 116 FileSystemOperationContext* CreateInheritedContextForDest() const; |
| 118 FileSystemOperationContext* CreateInheritedContextWithNewVirtualPaths( | 117 FileSystemOperationContext* CreateInheritedContextWithNewVirtualPaths( |
| 119 const FilePath& new_src_virtual_path, | 118 const FilePath& new_src_virtual_path, |
| 120 const FilePath& new_dest_virtual_path) const; | 119 const FilePath& new_dest_virtual_path) const; |
| 121 void ImportAllowedBytesGrowth(const FileSystemOperationContext& other); | 120 void ImportAllowedBytesGrowth(const FileSystemOperationContext& other); |
| 122 | 121 |
| 123 private: | 122 private: |
| 124 scoped_refptr<FileSystemContext> file_system_context_; | 123 scoped_refptr<FileSystemContext> file_system_context_; |
| 125 // These *_file_system_file_util_ are not "owned" by | 124 // These *_file_util_ are not "owned" by FileSystemOperationContext. They |
| 126 // FileSystemOperationContext. They are supposed to be pointers to objects | 125 // are supposed to be pointers to objects that will outlive us. |
| 127 // that will outlive us. | 126 FileApiFileUtil* src_file_util_; |
| 128 FileSystemFileUtil* src_file_system_file_util_; | 127 FileApiFileUtil* dest_file_util_; |
| 129 FileSystemFileUtil* dest_file_system_file_util_; | |
| 130 | 128 |
| 131 GURL src_origin_url_; // Also used for any single-path operation. | 129 GURL src_origin_url_; // Also used for any single-path operation. |
| 132 GURL dest_origin_url_; | 130 GURL dest_origin_url_; |
| 133 FileSystemType src_type_; // Also used for any single-path operation. | 131 FileSystemType src_type_; // Also used for any single-path operation. |
| 134 FileSystemType dest_type_; | 132 FileSystemType dest_type_; |
| 135 int64 allowed_bytes_growth_; | 133 int64 allowed_bytes_growth_; |
| 136 bool do_not_write_actually_; | 134 bool do_not_write_actually_; |
| 137 | 135 |
| 138 // Used for delayed operation by quota. | 136 // Used for delayed operation by quota. |
| 139 FilePath src_virtual_path_; // Also used for any single-path operation. | 137 FilePath src_virtual_path_; // Also used for any single-path operation. |
| 140 FilePath dest_virtual_path_; | 138 FilePath dest_virtual_path_; |
| 141 }; | 139 }; |
| 142 | 140 |
| 143 } // namespace fileapi | 141 } // namespace fileapi |
| 144 | 142 |
| 145 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_CONTEXT_H_ | 143 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_CONTEXT_H_ |
| OLD | NEW |