Skip to content

Commit

Permalink
Linux: Move base/mime_util* to base/nix. It's not used on any other p…
Browse files Browse the repository at this point in the history
…latform.

BUG=none
TEST=none
Review URL: http://codereview.chromium.org/8538008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109685 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
thestig@chromium.org committed Nov 11, 2011
1 parent 7e98f94 commit e528589
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 30 deletions.
4 changes: 2 additions & 2 deletions base/base.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,6 @@
'metrics/stats_counters.h',
'metrics/stats_table.cc',
'metrics/stats_table.h',
'mime_util.h',
'mime_util_xdg.cc',
'native_library.h',
'native_library_linux.cc',
'native_library_mac.mm',
Expand Down Expand Up @@ -360,6 +358,8 @@
'version.h',
'vlog.cc',
'vlog.h',
'nix/mime_util_xdg.cc',
'nix/mime_util_xdg.h',
'nix/xdg_util.cc',
'nix/xdg_util.h',
'win/event_trace_consumer.h',
Expand Down
14 changes: 8 additions & 6 deletions base/mime_util_xdg.cc → base/nix/mime_util_xdg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/mime_util.h"

#include "base/nix/mime_util_xdg.h"

#include <cstdlib>
#include <list>
Expand All @@ -16,7 +15,6 @@
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
#include "base/message_loop.h"
#include "base/nix/xdg_util.h"
#include "base/string_split.h"
#include "base/string_util.h"
Expand All @@ -26,7 +24,9 @@
#include "base/time.h"

#if defined(TOOLKIT_USES_GTK)
#include <gtk/gtk.h>
#include <gtk/gtk.h> // NOLINT

#include "base/message_loop.h"
#endif

namespace {
Expand Down Expand Up @@ -585,7 +585,8 @@ MimeUtilConstants::~MimeUtilConstants() {

} // namespace

namespace mime_util {
namespace base {
namespace nix {

std::string GetFileMimeType(const FilePath& filepath) {
base::ThreadRestrictions::AssertIOAllowed();
Expand Down Expand Up @@ -672,4 +673,5 @@ FilePath GetMimeIcon(const std::string& mime_type, size_t size) {
return FilePath();
}

} // namespace mime_util
} // namespace nix
} // namespace base
12 changes: 7 additions & 5 deletions base/mime_util.h → base/nix/mime_util_xdg.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef BASE_MIME_UTIL_H_
#define BASE_MIME_UTIL_H_
#ifndef BASE_NIX_MIME_UTIL_XDG_H_
#define BASE_NIX_MIME_UTIL_XDG_H_
#pragma once

#include <string>
Expand All @@ -13,7 +13,8 @@

class FilePath;

namespace mime_util {
namespace base {
namespace nix {

// Gets the mime type for a file based on its filename. The file path does not
// have to exist. Please note because it doesn't touch the disk, this does not
Expand All @@ -37,6 +38,7 @@ BASE_EXPORT void DetectGtkTheme();
// then a generic icon, and finally an empty FilePath if all else fails.
BASE_EXPORT FilePath GetMimeIcon(const std::string& mime_type, size_t size);

} // namespace mime_util
} // namespace nix
} // namespace base

#endif // BASE_MIME_UTIL_H_
#endif // BASE_NIX_MIME_UTIL_XDG_H_
4 changes: 2 additions & 2 deletions chrome/browser/icon_loader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "third_party/skia/include/core/SkBitmap.h"

#if defined(TOOLKIT_USES_GTK)
#include "base/mime_util.h"
#include "base/nix/mime_util_xdg.h"
#endif

using content::BrowserThread;
Expand All @@ -31,7 +31,7 @@ void IconLoader::Start() {

#if defined(TOOLKIT_USES_GTK)
// This call must happen on the UI thread before we can start loading icons.
mime_util::DetectGtkTheme();
base::nix::DetectGtkTheme();
#endif

BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/icon_loader_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "base/file_util.h"
#include "base/logging.h"
#include "base/message_loop.h"
#include "base/mime_util.h"
#include "base/nix/mime_util_xdg.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "webkit/glue/image_decoder.h"

Expand All @@ -31,7 +31,7 @@ void IconLoader::ReadIcon() {
NOTREACHED();
}

FilePath filename = mime_util::GetMimeIcon(group_, size_pixels);
FilePath filename = base::nix::GetMimeIcon(group_, size_pixels);
string icon_data;
file_util::ReadFileToString(filename, &icon_data);

Expand Down
6 changes: 3 additions & 3 deletions chrome/browser/icon_manager_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

#include "chrome/browser/icon_manager.h"

#include "base/mime_util.h"
#include "base/nix/mime_util_xdg.h"
#include "base/threading/thread_restrictions.h"

IconGroupID IconManager::GetGroupIDFromFilepath(const FilePath& filepath) {
// It turns out the call to mime_util::GetFileMimeType below does IO, but
// It turns out the call to base::nix::GetFileMimeType below does IO, but
// callers of GetGroupIDFromFilepath assume it does not do IO (the Windows
// and Mac implementations do not). We should fix this by either not doing IO
// in this method, or reworking callers to avoid calling it on the UI thread.
// See crbug.com/72740.
base::ThreadRestrictions::ScopedAllowIO allow_io;

return mime_util::GetFileMimeType(filepath);
return base::nix::GetFileMimeType(filepath);
}
6 changes: 3 additions & 3 deletions chrome/browser/ui/gtk/dialogs_gtk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "base/file_util.h"
#include "base/logging.h"
#include "base/message_loop.h"
#include "base/mime_util.h"
#include "base/nix/mime_util_xdg.h"
#include "base/sys_string_conversions.h"
#include "base/threading/thread.h"
#include "base/threading/thread_restrictions.h"
Expand Down Expand Up @@ -228,7 +228,7 @@ void SelectFileDialogImplGTK::AddFilters(GtkFileChooser* chooser) {

// Allow IO in the file dialog. http://crbug.com/72637
base::ThreadRestrictions::ScopedAllowIO allow_io;
std::string mime_type = mime_util::GetFileMimeType(
std::string mime_type = base::nix::GetFileMimeType(
FilePath("name").ReplaceExtension(file_types_.extensions[i][j]));
gtk_file_filter_add_mime_type(filter, mime_type.c_str());
}
Expand All @@ -247,7 +247,7 @@ void SelectFileDialogImplGTK::AddFilters(GtkFileChooser* chooser) {
base::ThreadRestrictions::ScopedAllowIO allow_io;
// There is no system default filter description so we use
// the MIME type itself if the description is blank.
std::string mime_type = mime_util::GetFileMimeType(
std::string mime_type = base::nix::GetFileMimeType(
FilePath("name").ReplaceExtension(file_types_.extensions[i][0]));
gtk_file_filter_set_name(filter, mime_type.c_str());
}
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/gtk/dialogs_kde.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "base/bind_helpers.h"
#include "base/command_line.h"
#include "base/logging.h"
#include "base/mime_util.h"
#include "base/nix/mime_util_xdg.h"
#include "base/nix/xdg_util.h"
#include "base/process_util.h"
#include "base/string_number_conversions.h"
Expand Down Expand Up @@ -194,7 +194,7 @@ std::string SelectFileDialogImplKDE::GetMimeTypeFilterString() {
for (size_t i = 0; i < file_types_.extensions.size(); ++i) {
for (size_t j = 0; j < file_types_.extensions[i].size(); ++j) {
if (!file_types_.extensions[i][j].empty()) {
std::string mime_type = mime_util::GetFileMimeType(
std::string mime_type = base::nix::GetFileMimeType(
FilePath("name").ReplaceExtension(file_types_.extensions[i][j]));
filter_set.insert(mime_type);
}
Expand Down
4 changes: 2 additions & 2 deletions content/browser/tab_contents/web_drag_source_gtk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <string>

#include "base/file_util.h"
#include "base/mime_util.h"
#include "base/nix/mime_util_xdg.h"
#include "base/threading/thread_restrictions.h"
#include "base/utf_string_conversions.h"
#include "content/browser/download/drag_download_file.h"
Expand Down Expand Up @@ -114,7 +114,7 @@ void WebDragSourceGtk::StartDragging(const WebDropData& drop_data,
// Looking up the mime type can hit the disk. http://crbug.com/84896
base::ThreadRestrictions::ScopedAllowIO allow_io;
drag_file_mime_type_ = gdk_atom_intern(
mime_util::GetDataMimeType(drop_data.file_contents).c_str(), FALSE);
base::nix::GetDataMimeType(drop_data.file_contents).c_str(), FALSE);
gtk_target_list_add(list, drag_file_mime_type_,
0, ui::CHROME_WEBDROP_FILE_CONTENTS);
}
Expand Down
4 changes: 2 additions & 2 deletions net/base/platform_mime_util_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#if defined(OS_ANDROID)
#include "net/android/network_library.h"
#else
#include "base/mime_util.h"
#include "base/nix/mime_util_xdg.h"
#endif

namespace net {
Expand All @@ -33,7 +33,7 @@ bool PlatformMimeUtil::GetPlatformMimeTypeFromExtension(
return false;

FilePath dummy_path("foo." + ext);
std::string out = mime_util::GetFileMimeType(dummy_path);
std::string out = base::nix::GetFileMimeType(dummy_path);

// GetFileMimeType likes to return application/octet-stream
// for everything it doesn't know - ignore that.
Expand Down
2 changes: 1 addition & 1 deletion tools/valgrind/memcheck/suppressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4378,7 +4378,7 @@
...
fun:xdg_mime_init
fun:xdg_mime_get_mime_type_from_file_name
fun:_ZN9mime_util15GetFileMimeTypeERK8FilePath
fun:*GetFileMimeTypeERK8FilePath
fun:_ZNK3net16PlatformMimeUtil32GetPlatformMimeTypeFromExtensionERKSsPSs
fun:_ZNK3net8MimeUtil30GetMimeTypeFromExtensionHelperERKSsbPSs
fun:_ZNK3net8MimeUtil24GetMimeTypeFromExtensionERKSsPSs
Expand Down

0 comments on commit e528589

Please sign in to comment.