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 "base/nix/mime_util_xdg.h" | 5 #include "base/nix/mime_util_xdg.h" |
6 | 6 |
7 #include <cstdlib> | 7 #include <cstdlib> |
8 #include <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 #include <vector> | 10 #include <vector> |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "base/third_party/xdg_mime/xdgmime.h" | 22 #include "base/third_party/xdg_mime/xdgmime.h" |
23 #include "base/threading/thread_restrictions.h" | 23 #include "base/threading/thread_restrictions.h" |
24 #include "base/time.h" | 24 #include "base/time.h" |
25 | 25 |
26 #if defined(TOOLKIT_GTK) | 26 #if defined(TOOLKIT_GTK) |
27 #include <gtk/gtk.h> // NOLINT | 27 #include <gtk/gtk.h> // NOLINT |
28 | 28 |
29 #include "base/message_loop.h" | 29 #include "base/message_loop.h" |
30 #endif | 30 #endif |
31 | 31 |
32 namespace base { | |
33 namespace nix { | |
34 | |
35 namespace { | 32 namespace { |
36 | 33 |
37 class IconTheme; | 34 class IconTheme; |
38 | 35 |
39 // None of the XDG stuff is thread-safe, so serialize all access under | 36 // None of the XDG stuff is thread-safe, so serialize all access under |
40 // this lock. | 37 // this lock. |
41 base::LazyInstance<base::Lock>::Leaky | 38 base::LazyInstance<base::Lock>::Leaky |
42 g_mime_util_xdg_lock = LAZY_INSTANCE_INITIALIZER; | 39 g_mime_util_xdg_lock = LAZY_INSTANCE_INITIALIZER; |
43 | 40 |
44 class MimeUtilConstants { | 41 class MimeUtilConstants { |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 return LookupFallbackIcon(icon_name); | 576 return LookupFallbackIcon(icon_name); |
580 } | 577 } |
581 | 578 |
582 MimeUtilConstants::~MimeUtilConstants() { | 579 MimeUtilConstants::~MimeUtilConstants() { |
583 for (size_t i = 0; i < kDefaultThemeNum; i++) | 580 for (size_t i = 0; i < kDefaultThemeNum; i++) |
584 delete default_themes_[i]; | 581 delete default_themes_[i]; |
585 } | 582 } |
586 | 583 |
587 } // namespace | 584 } // namespace |
588 | 585 |
| 586 namespace base { |
| 587 namespace nix { |
| 588 |
589 std::string GetFileMimeType(const FilePath& filepath) { | 589 std::string GetFileMimeType(const FilePath& filepath) { |
590 if (filepath.empty()) | 590 if (filepath.empty()) |
591 return std::string(); | 591 return std::string(); |
592 base::ThreadRestrictions::AssertIOAllowed(); | 592 base::ThreadRestrictions::AssertIOAllowed(); |
593 base::AutoLock scoped_lock(g_mime_util_xdg_lock.Get()); | 593 base::AutoLock scoped_lock(g_mime_util_xdg_lock.Get()); |
594 return xdg_mime_get_mime_type_from_file_name(filepath.value().c_str()); | 594 return xdg_mime_get_mime_type_from_file_name(filepath.value().c_str()); |
595 } | 595 } |
596 | 596 |
597 std::string GetDataMimeType(const std::string& data) { | 597 std::string GetDataMimeType(const std::string& data) { |
598 base::ThreadRestrictions::AssertIOAllowed(); | 598 base::ThreadRestrictions::AssertIOAllowed(); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 icon_file = LookupIconInDefaultTheme(icon_names[i], size); | 668 icon_file = LookupIconInDefaultTheme(icon_names[i], size); |
669 if (!icon_file.empty()) | 669 if (!icon_file.empty()) |
670 return icon_file; | 670 return icon_file; |
671 } | 671 } |
672 } | 672 } |
673 return FilePath(); | 673 return FilePath(); |
674 } | 674 } |
675 | 675 |
676 } // namespace nix | 676 } // namespace nix |
677 } // namespace base | 677 } // namespace base |
OLD | NEW |