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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 virtual ~ObfuscatedFileEnumerator() {} |
134 | 134 |
135 virtual base::FilePath Next() OVERRIDE { | 135 virtual 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 virtual int64 Size() override { |
162 return current_platform_file_info_.size; | 162 return current_platform_file_info_.size; |
163 } | 163 } |
164 | 164 |
165 virtual base::Time LastModifiedTime() OVERRIDE { | 165 virtual base::Time LastModifiedTime() override { |
166 return current_platform_file_info_.last_modified; | 166 return current_platform_file_info_.last_modified; |
167 } | 167 } |
168 | 168 |
169 virtual bool IsDirectory() OVERRIDE { | 169 virtual bool IsDirectory() override { |
170 return current_platform_file_info_.is_directory; | 170 return current_platform_file_info_.is_directory; |
171 } | 171 } |
172 | 172 |
173 private: | 173 private: |
174 typedef SandboxDirectoryDatabase::FileId FileId; | 174 typedef SandboxDirectoryDatabase::FileId FileId; |
175 typedef SandboxDirectoryDatabase::FileInfo FileInfo; | 175 typedef SandboxDirectoryDatabase::FileInfo FileInfo; |
176 | 176 |
177 struct FileRecord { | 177 struct FileRecord { |
178 FileId file_id; | 178 FileId file_id; |
179 base::FilePath virtual_path; | 179 base::FilePath virtual_path; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 SandboxOriginDatabaseInterface* origin_database, | 213 SandboxOriginDatabaseInterface* origin_database, |
214 const base::FilePath& base_file_path) | 214 const base::FilePath& base_file_path) |
215 : base_file_path_(base_file_path) { | 215 : base_file_path_(base_file_path) { |
216 if (origin_database) | 216 if (origin_database) |
217 origin_database->ListAllOrigins(&origins_); | 217 origin_database->ListAllOrigins(&origins_); |
218 } | 218 } |
219 | 219 |
220 virtual ~ObfuscatedOriginEnumerator() {} | 220 virtual ~ObfuscatedOriginEnumerator() {} |
221 | 221 |
222 // Returns the next origin. Returns empty if there are no more origins. | 222 // Returns the next origin. Returns empty if there are no more origins. |
223 virtual GURL Next() OVERRIDE { | 223 virtual GURL Next() override { |
224 OriginRecord record; | 224 OriginRecord record; |
225 if (!origins_.empty()) { | 225 if (!origins_.empty()) { |
226 record = origins_.back(); | 226 record = origins_.back(); |
227 origins_.pop_back(); | 227 origins_.pop_back(); |
228 } | 228 } |
229 current_ = record; | 229 current_ = record; |
230 return storage::GetOriginFromIdentifier(record.origin); | 230 return storage::GetOriginFromIdentifier(record.origin); |
231 } | 231 } |
232 | 232 |
233 // Returns the current origin's information. | 233 // Returns the current origin's information. |
234 virtual bool HasTypeDirectory(const std::string& type_string) const OVERRIDE { | 234 virtual bool HasTypeDirectory(const std::string& type_string) const override { |
235 if (current_.path.empty()) | 235 if (current_.path.empty()) |
236 return false; | 236 return false; |
237 if (type_string.empty()) { | 237 if (type_string.empty()) { |
238 NOTREACHED(); | 238 NOTREACHED(); |
239 return false; | 239 return false; |
240 } | 240 } |
241 base::FilePath path = | 241 base::FilePath path = |
242 base_file_path_.Append(current_.path).AppendASCII(type_string); | 242 base_file_path_.Append(current_.path).AppendASCII(type_string); |
243 return base::DirectoryExists(path); | 243 return base::DirectoryExists(path); |
244 } | 244 } |
(...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1408 } | 1408 } |
1409 return file.Pass(); | 1409 return file.Pass(); |
1410 } | 1410 } |
1411 | 1411 |
1412 bool ObfuscatedFileUtil::HasIsolatedStorage(const GURL& origin) { | 1412 bool ObfuscatedFileUtil::HasIsolatedStorage(const GURL& origin) { |
1413 return special_storage_policy_.get() && | 1413 return special_storage_policy_.get() && |
1414 special_storage_policy_->HasIsolatedStorage(origin); | 1414 special_storage_policy_->HasIsolatedStorage(origin); |
1415 } | 1415 } |
1416 | 1416 |
1417 } // namespace storage | 1417 } // namespace storage |
OLD | NEW |