| 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_directory_database.h" | 5 #include "webkit/fileapi/file_system_directory_database.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/pickle.h" | 10 #include "base/pickle.h" |
| 11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/sys_string_conversions.h" | 13 #include "base/sys_string_conversions.h" |
| 14 #include "third_party/leveldatabase/src/include/leveldb/iterator.h" | 14 #include "third_party/leveldatabase/src/include/leveldb/iterator.h" |
| 15 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h" | 15 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h" |
| 16 #include "webkit/fileapi/file_system_util.h" |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| 19 bool PickleFromFileInfo( | 20 bool PickleFromFileInfo( |
| 20 const fileapi::FileSystemDirectoryDatabase::FileInfo& info, | 21 const fileapi::FileSystemDirectoryDatabase::FileInfo& info, |
| 21 Pickle* pickle) { | 22 Pickle* pickle) { |
| 22 DCHECK(pickle); | 23 DCHECK(pickle); |
| 23 std::string data_path; | 24 std::string data_path; |
| 24 // Round off here to match the behavior of the filesystem on real files. | 25 // Round off here to match the behavior of the filesystem on real files. |
| 25 base::Time time = | 26 base::Time time = |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 } | 146 } |
| 146 return true; | 147 return true; |
| 147 } | 148 } |
| 148 HandleError(FROM_HERE, status); | 149 HandleError(FROM_HERE, status); |
| 149 return false; | 150 return false; |
| 150 } | 151 } |
| 151 | 152 |
| 152 bool FileSystemDirectoryDatabase::GetFileWithPath( | 153 bool FileSystemDirectoryDatabase::GetFileWithPath( |
| 153 const FilePath& path, FileId* file_id) { | 154 const FilePath& path, FileId* file_id) { |
| 154 std::vector<FilePath::StringType> components; | 155 std::vector<FilePath::StringType> components; |
| 155 path.GetComponents(&components); | 156 VirtualPath::GetComponents(path, &components); |
| 156 FileId local_id = 0; | 157 FileId local_id = 0; |
| 157 std::vector<FilePath::StringType>::iterator iter; | 158 std::vector<FilePath::StringType>::iterator iter; |
| 158 for (iter = components.begin(); iter != components.end(); ++iter) { | 159 for (iter = components.begin(); iter != components.end(); ++iter) { |
| 159 FilePath::StringType name; | 160 FilePath::StringType name; |
| 160 name = *iter; | 161 name = *iter; |
| 161 if (name == FILE_PATH_LITERAL("/")) | 162 if (name == FILE_PATH_LITERAL("/")) |
| 162 continue; | 163 continue; |
| 163 if (!GetChildWithName(local_id, name, &local_id)) | 164 if (!GetChildWithName(local_id, name, &local_id)) |
| 164 return false; | 165 return false; |
| 165 } | 166 } |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 | 539 |
| 539 void FileSystemDirectoryDatabase::HandleError( | 540 void FileSystemDirectoryDatabase::HandleError( |
| 540 const tracked_objects::Location& from_here, | 541 const tracked_objects::Location& from_here, |
| 541 leveldb::Status status) { | 542 leveldb::Status status) { |
| 542 LOG(ERROR) << "FileSystemDirectoryDatabase failed at: " | 543 LOG(ERROR) << "FileSystemDirectoryDatabase failed at: " |
| 543 << from_here.ToString() << " with error: " << status.ToString(); | 544 << from_here.ToString() << " with error: " << status.ToString(); |
| 544 db_.reset(); | 545 db_.reset(); |
| 545 } | 546 } |
| 546 | 547 |
| 547 } // namespace fileapi | 548 } // namespace fileapi |
| OLD | NEW |