OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/media_galleries/fileapi/iphoto_data_provider.h" | 5 #include "chrome/browser/media_galleries/fileapi/iphoto_data_provider.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 const parser::Library& library) { | 41 const parser::Library& library) { |
42 DCHECK(MediaFileSystemBackend::CurrentlyOnMediaTaskRunnerThread()); | 42 DCHECK(MediaFileSystemBackend::CurrentlyOnMediaTaskRunnerThread()); |
43 set_valid(result); | 43 set_valid(result); |
44 if (valid()) | 44 if (valid()) |
45 BuildIndices(library); | 45 BuildIndices(library); |
46 ready_callback.Run(valid()); | 46 ready_callback.Run(valid()); |
47 } | 47 } |
48 | 48 |
49 void IPhotoDataProvider::BuildIndices(const parser::Library& library) { | 49 void IPhotoDataProvider::BuildIndices(const parser::Library& library) { |
50 typedef base::hash_map<uint64, const base::FilePath*> IdIndex; | 50 typedef base::hash_map<uint64, const base::FilePath*> IdIndex; |
51 typedef base::hash_map<uint64, std::string> IdFileNameIndex; | |
52 | 51 |
53 IdIndex photo_id_index; | 52 IdIndex photo_id_index; |
54 IdIndex originals_id_index; | 53 IdIndex originals_id_index; |
55 for (std::set<parser::Photo>::const_iterator photo_it = | 54 for (std::set<parser::Photo>::const_iterator photo_it = |
56 library.all_photos.begin(); | 55 library.all_photos.begin(); |
57 photo_it != library.all_photos.end(); photo_it++) { | 56 photo_it != library.all_photos.end(); photo_it++) { |
58 photo_id_index[photo_it->id] = &(photo_it->location); | 57 photo_id_index[photo_it->id] = &(photo_it->location); |
59 if (!photo_it->original_location.empty()) | 58 if (!photo_it->original_location.empty()) |
60 originals_id_index[photo_it->id] = &(photo_it->original_location); | 59 originals_id_index[photo_it->id] = &(photo_it->original_location); |
61 } | 60 } |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 DirIndex::const_iterator originals_it = originals_index_.find(album); | 177 DirIndex::const_iterator originals_it = originals_index_.find(album); |
179 if (originals_it == originals_index_.end()) | 178 if (originals_it == originals_index_.end()) |
180 return base::FilePath(); | 179 return base::FilePath(); |
181 FileIndex::const_iterator file_it = originals_it->second.find(filename); | 180 FileIndex::const_iterator file_it = originals_it->second.find(filename); |
182 if (file_it == originals_it->second.end()) | 181 if (file_it == originals_it->second.end()) |
183 return base::FilePath(); | 182 return base::FilePath(); |
184 return file_it->second; | 183 return file_it->second; |
185 } | 184 } |
186 | 185 |
187 } // namespace iphoto | 186 } // namespace iphoto |
OLD | NEW |