summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-31 17:18:50 +0000
committerbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-31 17:18:50 +0000
commita8e2058011129cbef38bf89834ee01715556b392 (patch)
tree00cb892894c52145a66d23048acf2a81f0eed61d /base
parenta1fa87c8042ed2a3f9edd74ad2f313c84b1e407a (diff)
downloadchromium_src-a8e2058011129cbef38bf89834ee01715556b392.zip
chromium_src-a8e2058011129cbef38bf89834ee01715556b392.tar.gz
chromium_src-a8e2058011129cbef38bf89834ee01715556b392.tar.bz2
Move base/win_util to the base/win directory and use the base::win namespace.
Fix up includes, many files including base/win_util don't actually need it. TEST=it compiles BUG=none git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70341 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/base.gyp2
-rw-r--r--base/base.gypi4
-rw-r--r--base/file_util_win.cc6
-rw-r--r--base/linux_util.h3
-rw-r--r--base/win/win_util.cc (renamed from base/win_util.cc)8
-rw-r--r--base/win/win_util.h (renamed from base/win_util.h)29
-rw-r--r--base/win/win_util_unittest.cc (renamed from base/win_util_unittest.cc)50
7 files changed, 64 insertions, 38 deletions
diff --git a/base/base.gyp b/base/base.gyp
index 1c82964..56f4e99 100644
--- a/base/base.gyp
+++ b/base/base.gyp
@@ -163,7 +163,6 @@
'waitable_event_unittest.cc',
'waitable_event_watcher_unittest.cc',
'weak_ptr_unittest.cc',
- 'win_util_unittest.cc',
'win/event_trace_consumer_unittest.cc',
'win/event_trace_controller_unittest.cc',
'win/event_trace_provider_unittest.cc',
@@ -173,6 +172,7 @@
'win/scoped_bstr_unittest.cc',
'win/scoped_comptr_unittest.cc',
'win/scoped_variant_unittest.cc',
+ 'win/win_util_unittest.cc',
],
'dependencies': [
'base',
diff --git a/base/base.gypi b/base/base.gypi
index 7b6d50b..b73b6b1 100644
--- a/base/base.gypi
+++ b/base/base.gypi
@@ -317,10 +317,10 @@
'win/scoped_hglobal.h',
'win/scoped_variant.cc',
'win/scoped_variant.h',
+ 'win/win_util.cc',
+ 'win/win_util.h',
'win/windows_version.cc',
'win/windows_version.h',
- 'win_util.cc',
- 'win_util.h',
'nix/xdg_util.h',
'nix/xdg_util.cc',
],
diff --git a/base/file_util_win.cc b/base/file_util_win.cc
index 2644803..c302d77 100644
--- a/base/file_util_win.cc
+++ b/base/file_util_win.cc
@@ -22,8 +22,8 @@
#include "base/thread_restrictions.h"
#include "base/time.h"
#include "base/utf_string_conversions.h"
-#include "base/win_util.h"
#include "base/win/scoped_comptr.h"
+#include "base/win/win_util.h"
#include "base/win/windows_version.h"
namespace file_util {
@@ -447,7 +447,7 @@ bool CreateShortcutLink(const wchar_t *source, const wchar_t *destination,
if (FAILED(property_store.QueryFrom(i_shell_link)))
return false;
- if (!win_util::SetAppIdForPropertyStore(property_store, app_id))
+ if (!base::win::SetAppIdForPropertyStore(property_store, app_id))
return false;
}
@@ -499,7 +499,7 @@ bool UpdateShortcutLink(const wchar_t *source, const wchar_t *destination,
if (FAILED(property_store.QueryFrom(i_shell_link)))
return false;
- if (!win_util::SetAppIdForPropertyStore(property_store, app_id))
+ if (!base::win::SetAppIdForPropertyStore(property_store, app_id))
return false;
}
diff --git a/base/linux_util.h b/base/linux_util.h
index 0d2f20e..c1135ce 100644
--- a/base/linux_util.h
+++ b/base/linux_util.h
@@ -19,8 +19,7 @@ static const char kFindInodeSwitch[] = "--find-inode";
// in compromised context without going through the standard library.
extern char g_linux_distro[];
-// Get the Linux Distro if we can, or return "Unknown", similar to
-// GetWinVersion() in base/win_util.h.
+// Get the Linux Distro if we can, or return "Unknown".
std::string GetLinuxDistro();
// Set the Linux Distro string.
diff --git a/base/win_util.cc b/base/win/win_util.cc
index b7d5cd7..cce3d9c 100644
--- a/base/win_util.cc
+++ b/base/win/win_util.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/win_util.h"
+#include "base/win/win_util.h"
#include <aclapi.h>
#include <shobjidl.h> // Must be before propkey.
@@ -20,7 +20,8 @@
#include "base/thread_restrictions.h"
#include "base/win/windows_version.h"
-namespace win_util {
+namespace base {
+namespace win {
#define SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(struct_name, member) \
offsetof(struct_name, member) + \
@@ -135,7 +136,8 @@ bool RemoveCommandFromAutoRun(HKEY root_key, const string16& name) {
return autorun_key.DeleteValue(name.c_str());
}
-} // namespace win_util
+} // namespace win
+} // namespace base
#ifdef _MSC_VER
//
diff --git a/base/win_util.h b/base/win/win_util.h
index c06e9c7..187e42d 100644
--- a/base/win_util.h
+++ b/base/win/win_util.h
@@ -2,8 +2,25 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_WIN_UTIL_H_
-#define BASE_WIN_UTIL_H_
+// =============================================================================
+// PLEASE READ
+//
+// In general, you should not be adding stuff to this file.
+//
+// - If your thing is only used in one place, just put it in a reasonable
+// location in or near that one place. It's nice you want people to be able
+// to re-use your function, but realistically, if it hasn't been necessary
+// before after so many years of development, it's probably not going to be
+// used in other places in the future unless you know of them now.
+//
+// - If your thing is used by multiple callers and is UI-related, it should
+// probably be in app/win/ instead. Try to put it in the most specific file
+// possible (avoiding the *_util files when practical).
+//
+// =============================================================================
+
+#ifndef BASE_WIN_WIN_UTIL_H_
+#define BASE_WIN_WIN_UTIL_H_
#pragma once
#include <windows.h>
@@ -16,7 +33,8 @@ struct IPropertyStore;
struct _tagpropertykey;
typedef _tagpropertykey PROPERTYKEY;
-namespace win_util {
+namespace base {
+namespace win {
void GetNonClientMetrics(NONCLIENTMETRICS* metrics);
@@ -54,6 +72,7 @@ bool AddCommandToAutoRun(HKEY root_key, const string16& name,
// could be HKCU or HKLM or the root of any user hive.
bool RemoveCommandFromAutoRun(HKEY root_key, const string16& name);
-} // namespace win_util
+} // namespace win
+} // namespace base
-#endif // BASE_WIN_UTIL_H_
+#endif // BASE_WIN_WIN_UTIL_H_
diff --git a/base/win_util_unittest.cc b/base/win/win_util_unittest.cc
index b0aeb8e..b79ed56 100644
--- a/base/win_util_unittest.cc
+++ b/base/win/win_util_unittest.cc
@@ -6,47 +6,53 @@
#include "base/basictypes.h"
#include "base/string_util.h"
-#include "base/win_util.h"
+#include "base/win/win_util.h"
#include "base/win/windows_version.h"
#include "testing/gtest/include/gtest/gtest.h"
+namespace base {
+namespace win {
+
+namespace {
+
+// Saves the current thread's locale ID when initialized, and restores it when
+// the instance is going out of scope.
+class ThreadLocaleSaver {
+ public:
+ ThreadLocaleSaver() : original_locale_id_(GetThreadLocale()) {}
+ ~ThreadLocaleSaver() { SetThreadLocale(original_locale_id_); }
+
+ private:
+ LCID original_locale_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(ThreadLocaleSaver);
+};
+
+} // namespace
+
// The test is somewhat silly, because the Vista bots some have UAC enabled
// and some have it disabled. At least we check that it does not crash.
TEST(BaseWinUtilTest, TestIsUACEnabled) {
- if (base::win::GetVersion() >= base::win::VERSION_VISTA) {
- win_util::UserAccountControlIsEnabled();
+ if (GetVersion() >= base::win::VERSION_VISTA) {
+ UserAccountControlIsEnabled();
} else {
- EXPECT_TRUE(win_util::UserAccountControlIsEnabled());
+ EXPECT_TRUE(UserAccountControlIsEnabled());
}
}
TEST(BaseWinUtilTest, TestGetUserSidString) {
std::wstring user_sid;
- EXPECT_TRUE(win_util::GetUserSidString(&user_sid));
+ EXPECT_TRUE(GetUserSidString(&user_sid));
EXPECT_TRUE(!user_sid.empty());
}
TEST(BaseWinUtilTest, TestGetNonClientMetrics) {
NONCLIENTMETRICS metrics = {0};
- win_util::GetNonClientMetrics(&metrics);
+ GetNonClientMetrics(&metrics);
EXPECT_TRUE(metrics.cbSize > 0);
EXPECT_TRUE(metrics.iScrollWidth > 0);
EXPECT_TRUE(metrics.iScrollHeight > 0);
}
-namespace {
-
-// Saves the current thread's locale ID when initialized, and restores it when
-// the instance is going out of scope.
-class ThreadLocaleSaver {
- public:
- ThreadLocaleSaver() : original_locale_id_(GetThreadLocale()) {}
- ~ThreadLocaleSaver() { SetThreadLocale(original_locale_id_); }
-
- private:
- LCID original_locale_id_;
-
- DISALLOW_COPY_AND_ASSIGN(ThreadLocaleSaver);
-};
-
-} // namespace
+} // namespace win
+} // namespace base