| 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 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MEDIA_PATH_FILTER_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MEDIA_PATH_FILTER_H_ |
| 6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MEDIA_PATH_FILTER_H_ | 6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MEDIA_PATH_FILTER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <map> |
| 10 #include <string> | 11 #include <string> |
| 11 #include <vector> | 12 #include <vector> |
| 12 | 13 |
| 13 #include "base/containers/hash_tables.h" | |
| 14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/sequence_checker.h" | 16 #include "base/sequence_checker.h" |
| 17 | 17 |
| 18 enum MediaGalleryFileType { | 18 enum MediaGalleryFileType { |
| 19 MEDIA_GALLERY_FILE_TYPE_UNKNOWN = 0, | 19 MEDIA_GALLERY_FILE_TYPE_UNKNOWN = 0, |
| 20 MEDIA_GALLERY_FILE_TYPE_AUDIO = 1 << 0, | 20 MEDIA_GALLERY_FILE_TYPE_AUDIO = 1 << 0, |
| 21 MEDIA_GALLERY_FILE_TYPE_IMAGE = 1 << 1, | 21 MEDIA_GALLERY_FILE_TYPE_IMAGE = 1 << 1, |
| 22 MEDIA_GALLERY_FILE_TYPE_VIDEO = 1 << 2, | 22 MEDIA_GALLERY_FILE_TYPE_VIDEO = 1 << 2, |
| 23 }; | 23 }; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 // Returns the type of |path| or MEDIA_GALLERY_FILE_TYPE_UNKNOWN if it | 39 // Returns the type of |path| or MEDIA_GALLERY_FILE_TYPE_UNKNOWN if it |
| 40 // is not a media file. | 40 // is not a media file. |
| 41 MediaGalleryFileType GetType(const base::FilePath& path); | 41 MediaGalleryFileType GetType(const base::FilePath& path); |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 typedef std::vector<base::FilePath::StringType> MediaFileExtensionList; | 44 typedef std::vector<base::FilePath::StringType> MediaFileExtensionList; |
| 45 | 45 |
| 46 // Key: .extension | 46 // Key: .extension |
| 47 // Value: MediaGalleryFileType, but stored as an int to allow "|=" | 47 // Value: MediaGalleryFileType, but stored as an int to allow "|=" |
| 48 typedef base::hash_map<base::FilePath::StringType, int> MediaFileExtensionMap; | 48 using MediaFileExtensionMap = std::map<base::FilePath::StringType, int>; |
| 49 | 49 |
| 50 void EnsureInitialized(); | 50 void EnsureInitialized(); |
| 51 | 51 |
| 52 void AddExtensionsToMediaFileExtensionMap( | 52 void AddExtensionsToMediaFileExtensionMap( |
| 53 const MediaFileExtensionList& extensions_list, | 53 const MediaFileExtensionList& extensions_list, |
| 54 MediaGalleryFileType type); | 54 MediaGalleryFileType type); |
| 55 void AddAdditionalExtensionsToMediaFileExtensionMap( | 55 void AddAdditionalExtensionsToMediaFileExtensionMap( |
| 56 const base::FilePath::CharType* const* extensions_list, | 56 const base::FilePath::CharType* const* extensions_list, |
| 57 size_t extensions_list_size, | 57 size_t extensions_list_size, |
| 58 MediaGalleryFileType type); | 58 MediaGalleryFileType type); |
| 59 void AddExtensionToMediaFileExtensionMap( | 59 void AddExtensionToMediaFileExtensionMap( |
| 60 const base::FilePath::CharType* extension, | 60 const base::FilePath::CharType* extension, |
| 61 MediaGalleryFileType type); | 61 MediaGalleryFileType type); |
| 62 | 62 |
| 63 // Checks |initialized_| is only accessed on one sequence. | 63 // Checks |initialized_| is only accessed on one sequence. |
| 64 base::SequenceChecker sequence_checker_; | 64 base::SequenceChecker sequence_checker_; |
| 65 bool initialized_; | 65 bool initialized_; |
| 66 MediaFileExtensionMap media_file_extensions_map_; | 66 MediaFileExtensionMap media_file_extensions_map_; |
| 67 | 67 |
| 68 DISALLOW_COPY_AND_ASSIGN(MediaPathFilter); | 68 DISALLOW_COPY_AND_ASSIGN(MediaPathFilter); |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MEDIA_PATH_FILTER_H_ | 71 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_MEDIA_PATH_FILTER_H_ |
| OLD | NEW |