diff options
author | munjal@chromium.org <munjal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-24 01:10:35 +0000 |
---|---|---|
committer | munjal@chromium.org <munjal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-24 01:10:35 +0000 |
commit | 43c6dae7c9d9dc3cf639a4ada168d880b800e34b (patch) | |
tree | 3a59983e36763bee8846cd3d1209812587ef0836 /chrome/browser/sync/util | |
parent | 64f9baa2bb3cc42f4fed901f2171409f9a890f71 (diff) | |
download | chromium_src-43c6dae7c9d9dc3cf639a4ada168d880b800e34b.zip chromium_src-43c6dae7c9d9dc3cf639a4ada168d880b800e34b.tar.gz chromium_src-43c6dae7c9d9dc3cf639a4ada168d880b800e34b.tar.bz2 |
Final part of PathString cleanup.
BUG=26342
TEST+exist
Review URL: http://codereview.chromium.org/429003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32894 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync/util')
-rw-r--r-- | chrome/browser/sync/util/character_set_converters.cc | 47 | ||||
-rw-r--r-- | chrome/browser/sync/util/character_set_converters.h | 2 | ||||
-rw-r--r-- | chrome/browser/sync/util/character_set_converters_unittest.cc | 32 | ||||
-rw-r--r-- | chrome/browser/sync/util/query_helpers.h | 2 | ||||
-rw-r--r-- | chrome/browser/sync/util/sync_types.h | 15 |
5 files changed, 1 insertions, 97 deletions
diff --git a/chrome/browser/sync/util/character_set_converters.cc b/chrome/browser/sync/util/character_set_converters.cc deleted file mode 100644 index 551ca2b..0000000 --- a/chrome/browser/sync/util/character_set_converters.cc +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/sync/util/character_set_converters.h" - -namespace browser_sync { - -void TrimPathStringToValidCharacter(std::string* string) { - // Constants from http://en.wikipedia.org/wiki/UTF-8 - CHECK(string); - if (string->empty()) - return; - if (0 == (string->at(string->length() - 1) & 0x080)) - return; - size_t partial_enc_bytes = 0; - for (partial_enc_bytes = 0 ; true ; ++partial_enc_bytes) { - if (4 == partial_enc_bytes || partial_enc_bytes == string->length()) { - // original string was broken, garbage in, garbage out. - return; - } - PathChar c = string->at(string->length() - 1 - partial_enc_bytes); - if ((c & 0x0c0) == 0x080) // utf continuation char; - continue; - if ((c & 0x0e0) == 0x0e0) { // 2-byte encoded char. - if (1 == partial_enc_bytes) - return; - else - break; - } - if ((c & 0x0f0) == 0xc0) { // 3-byte encoded char. - if (2 == partial_enc_bytes) - return; - else - break; - } - if ((c & 0x0f8) == 0x0f0) { // 4-byte encoded char. - if (3 == partial_enc_bytes) - return; - else - break; - } - } - string->resize(string->length() - 1 - partial_enc_bytes); -} - -} // namespace browser_sync diff --git a/chrome/browser/sync/util/character_set_converters.h b/chrome/browser/sync/util/character_set_converters.h index b486f04..cbb44d6 100644 --- a/chrome/browser/sync/util/character_set_converters.h +++ b/chrome/browser/sync/util/character_set_converters.h @@ -23,8 +23,6 @@ std::string FilePathToUTF8(const FilePath& file_path); // Returns FilePath from the given UTF8 string. FilePath UTF8ToFilePath(const std::string& utf8); -void TrimPathStringToValidCharacter(std::string* string); - } // namespace browser_sync #endif // CHROME_BROWSER_SYNC_UTIL_CHARACTER_SET_CONVERTERS_H_ diff --git a/chrome/browser/sync/util/character_set_converters_unittest.cc b/chrome/browser/sync/util/character_set_converters_unittest.cc deleted file mode 100644 index aa8fa89..0000000 --- a/chrome/browser/sync/util/character_set_converters_unittest.cc +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/sync/util/character_set_converters.h" - -#include <string> - -#include "testing/gtest/include/gtest/gtest.h" - -using std::string; - -class CharacterSetConverterTest : public testing::Test { -}; - -TEST(NameTruncation, WindowsNameTruncation) { - using browser_sync::TrimPathStringToValidCharacter; - char array[] = {'1', '2', '\xc0', '\xe0', '3', '4', '\0'}; - std::string message(array); - ASSERT_EQ(message.length(), arraysize(array) - 1); - string::size_type old_length = message.length(); - while (old_length != 0) { - TrimPathStringToValidCharacter(&message); - if (old_length == 4) - EXPECT_EQ(3u, message.length()); - else - EXPECT_EQ(old_length, message.length()); - message.resize(message.length() - 1); - old_length = message.length(); - } - TrimPathStringToValidCharacter(&message); -} diff --git a/chrome/browser/sync/util/query_helpers.h b/chrome/browser/sync/util/query_helpers.h index 66b1d81..c44e635 100644 --- a/chrome/browser/sync/util/query_helpers.h +++ b/chrome/browser/sync/util/query_helpers.h @@ -49,7 +49,7 @@ bool DoesTableExist(sqlite3* dbhandle, const std::string& tablename); // passed inside of the Vector. // Example: // -// vector<PathString> v; +// vector<std::string> v; // v.push_back("abc"); // v.push_back("123"); // PrepareQuery(dbhandle, "SELECT * FROM table", "column_name", v.begin(), diff --git a/chrome/browser/sync/util/sync_types.h b/chrome/browser/sync/util/sync_types.h index 429033b..14addd0 100644 --- a/chrome/browser/sync/util/sync_types.h +++ b/chrome/browser/sync/util/sync_types.h @@ -12,10 +12,6 @@ #include "base/string_util.h" #include "build/build_config.h" -#define PSTR(s) s -#define PSTR_CHAR char -typedef std::string PathString; - #if !defined(OS_WIN) // Mac OS X typedef's BOOL to signed char, so we do that on Linux too. typedef signed char BOOL; @@ -33,21 +29,10 @@ const BOOL FALSE = 0; #endif #endif -typedef PathString::value_type PathChar; - -inline size_t CountBytes(const std::wstring& s) { - return s.size() * sizeof(std::wstring::value_type); -} - inline size_t CountBytes(const std::string &s) { return s.size() * sizeof(std::string::value_type); } -inline PathString IntToPathString(int digit) { - std::string tmp = StringPrintf("%d", digit); - return PathString(tmp.begin(), tmp.end()); -} - const size_t kSyncProtocolMaxNameLengthBytes = 255; #endif // CHROME_BROWSER_SYNC_UTIL_SYNC_TYPES_H_ |