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 #include "webkit/fileapi/file_system_test_helper.h" | 5 #include "webkit/fileapi/file_system_test_helper.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
11 #include "webkit/fileapi/file_system_context.h" | 11 #include "webkit/fileapi/file_system_context.h" |
12 #include "webkit/fileapi/file_system_operation.h" | 12 #include "webkit/fileapi/file_system_operation.h" |
13 #include "webkit/fileapi/file_system_operation_context.h" | 13 #include "webkit/fileapi/file_system_operation_context.h" |
14 #include "webkit/fileapi/file_system_usage_cache.h" | 14 #include "webkit/fileapi/file_system_usage_cache.h" |
15 #include "webkit/fileapi/file_system_util.h" | 15 #include "webkit/fileapi/file_system_util.h" |
16 #include "webkit/fileapi/sandbox_mount_point_provider.h" | 16 #include "webkit/fileapi/sandbox_mount_point_provider.h" |
17 #include "webkit/quota/special_storage_policy.h" | 17 #include "webkit/quota/mock_special_storage_policy.h" |
18 | 18 |
19 namespace fileapi { | 19 namespace fileapi { |
20 namespace { | |
21 | |
22 class TestSpecialStoragePolicy : public quota::SpecialStoragePolicy { | |
23 public: | |
24 explicit TestSpecialStoragePolicy(bool unlimited_quota) | |
25 : unlimited_quota_(unlimited_quota) {} | |
26 | |
27 virtual bool IsStorageProtected(const GURL& origin) { | |
28 return false; | |
29 } | |
30 | |
31 virtual bool IsStorageUnlimited(const GURL& origin) { | |
32 return unlimited_quota_; | |
33 } | |
34 | |
35 virtual bool IsFileHandler(const std::string& extension_id) { | |
36 return true; | |
37 } | |
38 | |
39 private: | |
40 bool unlimited_quota_; | |
41 }; | |
42 | |
43 } // anonymous namespace | |
44 | 20 |
45 FileSystemTestOriginHelper::FileSystemTestOriginHelper( | 21 FileSystemTestOriginHelper::FileSystemTestOriginHelper( |
46 const GURL& origin, FileSystemType type) | 22 const GURL& origin, FileSystemType type) |
47 : origin_(origin), type_(type), file_util_(NULL) { | 23 : origin_(origin), type_(type), file_util_(NULL) { |
48 } | 24 } |
49 | 25 |
50 FileSystemTestOriginHelper::FileSystemTestOriginHelper() | 26 FileSystemTestOriginHelper::FileSystemTestOriginHelper() |
51 : origin_(GURL("http://foo.com")), | 27 : origin_(GURL("http://foo.com")), |
52 type_(kFileSystemTypeTemporary), | 28 type_(kFileSystemTypeTemporary), |
53 file_util_(NULL) { | 29 file_util_(NULL) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 } | 62 } |
87 | 63 |
88 void FileSystemTestOriginHelper::SetUp( | 64 void FileSystemTestOriginHelper::SetUp( |
89 const FilePath& base_dir, | 65 const FilePath& base_dir, |
90 bool incognito_mode, | 66 bool incognito_mode, |
91 bool unlimited_quota, | 67 bool unlimited_quota, |
92 quota::QuotaManagerProxy* quota_manager_proxy, | 68 quota::QuotaManagerProxy* quota_manager_proxy, |
93 FileSystemFileUtil* file_util) { | 69 FileSystemFileUtil* file_util) { |
94 file_util_ = file_util; | 70 file_util_ = file_util; |
95 DCHECK(file_util_); | 71 DCHECK(file_util_); |
| 72 scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy = |
| 73 new quota::MockSpecialStoragePolicy; |
| 74 special_storage_policy->SetAllUnlimited(unlimited_quota); |
96 file_system_context_ = new FileSystemContext( | 75 file_system_context_ = new FileSystemContext( |
97 base::MessageLoopProxy::current(), | 76 base::MessageLoopProxy::current(), |
98 base::MessageLoopProxy::current(), | 77 base::MessageLoopProxy::current(), |
99 new TestSpecialStoragePolicy(unlimited_quota), | 78 special_storage_policy, |
100 quota_manager_proxy, | 79 quota_manager_proxy, |
101 base_dir, | 80 base_dir, |
102 incognito_mode, | 81 incognito_mode, |
103 true /* allow_file_access_from_files */, | 82 true /* allow_file_access_from_files */, |
104 unlimited_quota, | 83 unlimited_quota, |
105 NULL); | 84 NULL); |
106 | 85 |
107 DCHECK(file_system_context_->path_manager()); | 86 DCHECK(file_system_context_->path_manager()); |
108 DCHECK(file_system_context_->path_manager()->sandbox_provider()); | 87 DCHECK(file_system_context_->path_manager()->sandbox_provider()); |
109 | 88 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 void FileSystemTestOriginHelper::InitializeOperationContext( | 181 void FileSystemTestOriginHelper::InitializeOperationContext( |
203 FileSystemOperationContext* context) { | 182 FileSystemOperationContext* context) { |
204 DCHECK(context); | 183 DCHECK(context); |
205 context->set_src_origin_url(origin_); | 184 context->set_src_origin_url(origin_); |
206 context->set_src_type(type_); | 185 context->set_src_type(type_); |
207 context->set_dest_origin_url(origin_); | 186 context->set_dest_origin_url(origin_); |
208 context->set_dest_type(type_); | 187 context->set_dest_type(type_); |
209 } | 188 } |
210 | 189 |
211 } // namespace fileapi | 190 } // namespace fileapi |
OLD | NEW |