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" | 11 #include "webkit/fileapi/file_system_file_util.h" |
12 #include "webkit/fileapi/file_system_types.h" | 12 #include "webkit/fileapi/file_system_types.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 FileSystemFileUtil* 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(FileSystemFileUtil* 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 FileSystemFileUtil* 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(FileSystemFileUtil* 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 FileSystemFileUtil* 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 24 matching lines...) Expand all Loading... |
82 void set_allowed_bytes_growth(const int64& allowed_bytes_growth) { | 81 void set_allowed_bytes_growth(const int64& allowed_bytes_growth) { |
83 allowed_bytes_growth_ = allowed_bytes_growth; | 82 allowed_bytes_growth_ = allowed_bytes_growth; |
84 } | 83 } |
85 | 84 |
86 int64 allowed_bytes_growth() const { return allowed_bytes_growth_; } | 85 int64 allowed_bytes_growth() const { return allowed_bytes_growth_; } |
87 | 86 |
88 FileSystemOperationContext* CreateInheritedContextForDest() const; | 87 FileSystemOperationContext* CreateInheritedContextForDest() const; |
89 | 88 |
90 private: | 89 private: |
91 scoped_refptr<FileSystemContext> file_system_context_; | 90 scoped_refptr<FileSystemContext> file_system_context_; |
92 // These *_file_system_file_util_ are not "owned" by | 91 // These *_file_util_ are not "owned" by FileSystemOperationContext. They |
93 // FileSystemOperationContext. They are supposed to be pointers to objects | 92 // are supposed to be pointers to objects that will outlive us. |
94 // that will outlive us. | 93 FileSystemFileUtil* src_file_util_; |
95 FileSystemFileUtil* src_file_system_file_util_; | 94 FileSystemFileUtil* dest_file_util_; |
96 FileSystemFileUtil* dest_file_system_file_util_; | |
97 | 95 |
98 GURL src_origin_url_; // Also used for any single-path operation. | 96 GURL src_origin_url_; // Also used for any single-path operation. |
99 GURL dest_origin_url_; | 97 GURL dest_origin_url_; |
100 FileSystemType src_type_; // Also used for any single-path operation. | 98 FileSystemType src_type_; // Also used for any single-path operation. |
101 FileSystemType dest_type_; | 99 FileSystemType dest_type_; |
102 int64 allowed_bytes_growth_; | 100 int64 allowed_bytes_growth_; |
103 | 101 |
104 // Used for delayed operation by quota. | 102 // Used for delayed operation by quota. |
105 FilePath src_virtual_path_; // Also used for any single-path operation. | 103 FilePath src_virtual_path_; // Also used for any single-path operation. |
106 FilePath dest_virtual_path_; | 104 FilePath dest_virtual_path_; |
107 }; | 105 }; |
108 | 106 |
109 } // namespace fileapi | 107 } // namespace fileapi |
110 | 108 |
111 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_CONTEXT_H_ | 109 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_OPERATION_CONTEXT_H_ |
OLD | NEW |