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/iapps_finder_impl.h" | 5 #include "chrome/browser/media_galleries/fileapi/iapps_finder_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #import "base/mac/foundation_util.h" | 10 #import "base/mac/foundation_util.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 // Find the most recently used database from the list of database paths. Most | 50 // Find the most recently used database from the list of database paths. Most |
51 // of the time |plist| has a size of 1. | 51 // of the time |plist| has a size of 1. |
52 base::Time most_recent_db_time; | 52 base::Time most_recent_db_time; |
53 base::FilePath most_recent_db_path; | 53 base::FilePath most_recent_db_path; |
54 for (NSString* path_ns in plist.get()) { | 54 for (NSString* path_ns in plist.get()) { |
55 base::FilePath db_path = path_extractor.Run(path_ns); | 55 base::FilePath db_path = path_extractor.Run(path_ns); |
56 if (db_path.empty()) | 56 if (db_path.empty()) |
57 continue; | 57 continue; |
58 | 58 |
59 base::PlatformFileInfo file_info; | 59 base::File::Info file_info; |
60 if (!base::GetFileInfo(db_path, &file_info)) | 60 if (!base::GetFileInfo(db_path, &file_info)) |
61 continue; | 61 continue; |
62 | 62 |
63 // In case of two databases with the same modified time, tie breaker goes | 63 // In case of two databases with the same modified time, tie breaker goes |
64 // to the first one on the list. | 64 // to the first one on the list. |
65 if (file_info.last_modified <= most_recent_db_time) | 65 if (file_info.last_modified <= most_recent_db_time) |
66 continue; | 66 continue; |
67 | 67 |
68 most_recent_db_time = file_info.last_modified; | 68 most_recent_db_time = file_info.last_modified; |
69 most_recent_db_path = db_path; | 69 most_recent_db_path = db_path; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 base::scoped_nsobject<NSString>(kITunesRecentDatabasePathsKey), | 106 base::scoped_nsobject<NSString>(kITunesRecentDatabasePathsKey), |
107 base::Bind(&ExtractITunesPath)), | 107 base::Bind(&ExtractITunesPath)), |
108 callback); | 108 callback); |
109 } | 109 } |
110 | 110 |
111 void SetMacPreferencesForTesting(MacPreferences* preferences) { | 111 void SetMacPreferencesForTesting(MacPreferences* preferences) { |
112 g_test_mac_preferences = preferences; | 112 g_test_mac_preferences = preferences; |
113 } | 113 } |
114 | 114 |
115 } // namespace iapps | 115 } // namespace iapps |
OLD | NEW |