OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "storage/browser/fileapi/obfuscated_file_util.h" | 5 #include "storage/browser/fileapi/obfuscated_file_util.h" |
6 | 6 |
7 #include <queue> | 7 #include <queue> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 base::FilePath root_virtual_path = root_url.path(); | 123 base::FilePath root_virtual_path = root_url.path(); |
124 FileId file_id; | 124 FileId file_id; |
125 | 125 |
126 if (!db_->GetFileWithPath(root_virtual_path, &file_id)) | 126 if (!db_->GetFileWithPath(root_virtual_path, &file_id)) |
127 return; | 127 return; |
128 | 128 |
129 FileRecord record = { file_id, root_virtual_path }; | 129 FileRecord record = { file_id, root_virtual_path }; |
130 recurse_queue_.push(record); | 130 recurse_queue_.push(record); |
131 } | 131 } |
132 | 132 |
133 virtual ~ObfuscatedFileEnumerator() {} | 133 ~ObfuscatedFileEnumerator() override {} |
134 | 134 |
135 virtual base::FilePath Next() override { | 135 base::FilePath Next() override { |
136 ProcessRecurseQueue(); | 136 ProcessRecurseQueue(); |
137 if (display_stack_.empty()) | 137 if (display_stack_.empty()) |
138 return base::FilePath(); | 138 return base::FilePath(); |
139 | 139 |
140 current_file_id_ = display_stack_.back(); | 140 current_file_id_ = display_stack_.back(); |
141 display_stack_.pop_back(); | 141 display_stack_.pop_back(); |
142 | 142 |
143 FileInfo file_info; | 143 FileInfo file_info; |
144 base::FilePath platform_file_path; | 144 base::FilePath platform_file_path; |
145 base::File::Error error = | 145 base::File::Error error = |
146 obfuscated_file_util_->GetFileInfoInternal( | 146 obfuscated_file_util_->GetFileInfoInternal( |
147 db_, context_, root_url_, current_file_id_, | 147 db_, context_, root_url_, current_file_id_, |
148 &file_info, ¤t_platform_file_info_, &platform_file_path); | 148 &file_info, ¤t_platform_file_info_, &platform_file_path); |
149 if (error != base::File::FILE_OK) | 149 if (error != base::File::FILE_OK) |
150 return Next(); | 150 return Next(); |
151 | 151 |
152 base::FilePath virtual_path = | 152 base::FilePath virtual_path = |
153 current_parent_virtual_path_.Append(file_info.name); | 153 current_parent_virtual_path_.Append(file_info.name); |
154 if (recursive_ && file_info.is_directory()) { | 154 if (recursive_ && file_info.is_directory()) { |
155 FileRecord record = { current_file_id_, virtual_path }; | 155 FileRecord record = { current_file_id_, virtual_path }; |
156 recurse_queue_.push(record); | 156 recurse_queue_.push(record); |
157 } | 157 } |
158 return virtual_path; | 158 return virtual_path; |
159 } | 159 } |
160 | 160 |
161 virtual int64 Size() override { | 161 int64 Size() override { return current_platform_file_info_.size; } |
162 return current_platform_file_info_.size; | |
163 } | |
164 | 162 |
165 virtual base::Time LastModifiedTime() override { | 163 base::Time LastModifiedTime() override { |
166 return current_platform_file_info_.last_modified; | 164 return current_platform_file_info_.last_modified; |
167 } | 165 } |
168 | 166 |
169 virtual bool IsDirectory() override { | 167 bool IsDirectory() override { |
170 return current_platform_file_info_.is_directory; | 168 return current_platform_file_info_.is_directory; |
171 } | 169 } |
172 | 170 |
173 private: | 171 private: |
174 typedef SandboxDirectoryDatabase::FileId FileId; | 172 typedef SandboxDirectoryDatabase::FileId FileId; |
175 typedef SandboxDirectoryDatabase::FileInfo FileInfo; | 173 typedef SandboxDirectoryDatabase::FileInfo FileInfo; |
176 | 174 |
177 struct FileRecord { | 175 struct FileRecord { |
178 FileId file_id; | 176 FileId file_id; |
179 base::FilePath virtual_path; | 177 base::FilePath virtual_path; |
(...skipping 30 matching lines...) Expand all Loading... |
210 public: | 208 public: |
211 typedef SandboxOriginDatabase::OriginRecord OriginRecord; | 209 typedef SandboxOriginDatabase::OriginRecord OriginRecord; |
212 ObfuscatedOriginEnumerator( | 210 ObfuscatedOriginEnumerator( |
213 SandboxOriginDatabaseInterface* origin_database, | 211 SandboxOriginDatabaseInterface* origin_database, |
214 const base::FilePath& base_file_path) | 212 const base::FilePath& base_file_path) |
215 : base_file_path_(base_file_path) { | 213 : base_file_path_(base_file_path) { |
216 if (origin_database) | 214 if (origin_database) |
217 origin_database->ListAllOrigins(&origins_); | 215 origin_database->ListAllOrigins(&origins_); |
218 } | 216 } |
219 | 217 |
220 virtual ~ObfuscatedOriginEnumerator() {} | 218 ~ObfuscatedOriginEnumerator() override {} |
221 | 219 |
222 // Returns the next origin. Returns empty if there are no more origins. | 220 // Returns the next origin. Returns empty if there are no more origins. |
223 virtual GURL Next() override { | 221 GURL Next() override { |
224 OriginRecord record; | 222 OriginRecord record; |
225 if (!origins_.empty()) { | 223 if (!origins_.empty()) { |
226 record = origins_.back(); | 224 record = origins_.back(); |
227 origins_.pop_back(); | 225 origins_.pop_back(); |
228 } | 226 } |
229 current_ = record; | 227 current_ = record; |
230 return storage::GetOriginFromIdentifier(record.origin); | 228 return storage::GetOriginFromIdentifier(record.origin); |
231 } | 229 } |
232 | 230 |
233 // Returns the current origin's information. | 231 // Returns the current origin's information. |
234 virtual bool HasTypeDirectory(const std::string& type_string) const override { | 232 bool HasTypeDirectory(const std::string& type_string) const override { |
235 if (current_.path.empty()) | 233 if (current_.path.empty()) |
236 return false; | 234 return false; |
237 if (type_string.empty()) { | 235 if (type_string.empty()) { |
238 NOTREACHED(); | 236 NOTREACHED(); |
239 return false; | 237 return false; |
240 } | 238 } |
241 base::FilePath path = | 239 base::FilePath path = |
242 base_file_path_.Append(current_.path).AppendASCII(type_string); | 240 base_file_path_.Append(current_.path).AppendASCII(type_string); |
243 return base::DirectoryExists(path); | 241 return base::DirectoryExists(path); |
244 } | 242 } |
(...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1408 } | 1406 } |
1409 return file.Pass(); | 1407 return file.Pass(); |
1410 } | 1408 } |
1411 | 1409 |
1412 bool ObfuscatedFileUtil::HasIsolatedStorage(const GURL& origin) { | 1410 bool ObfuscatedFileUtil::HasIsolatedStorage(const GURL& origin) { |
1413 return special_storage_policy_.get() && | 1411 return special_storage_policy_.get() && |
1414 special_storage_policy_->HasIsolatedStorage(origin); | 1412 special_storage_policy_->HasIsolatedStorage(origin); |
1415 } | 1413 } |
1416 | 1414 |
1417 } // namespace storage | 1415 } // namespace storage |
OLD | NEW |