Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(533)

Side by Side Diff: base/string_util.cc

Issue 192065: Merge 25487 - Strip .plugin off of Mac plugin names when showing the crash in... (Closed) Base URL: svn://chrome-svn/chrome/branches/195/src/
Patch Set: Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/string_util.h ('k') | base/string_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:mergeinfo
Merged /branches/chrome_webkit_merge_branch/base/string_util.cc:r69-2775
Merged /trunk/src/base/string_util.cc:r25487
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/string_util.h" 5 #include "base/string_util.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #include <ctype.h> 9 #include <ctype.h>
10 #include <errno.h> 10 #include <errno.h>
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 if (case_sensitive) 737 if (case_sensitive)
738 return str.compare(0, search.length(), search) == 0; 738 return str.compare(0, search.length(), search) == 0;
739 else { 739 else {
740 if (search.size() > str.size()) 740 if (search.size() > str.size())
741 return false; 741 return false;
742 return std::equal(search.begin(), search.end(), str.begin(), 742 return std::equal(search.begin(), search.end(), str.begin(),
743 CaseInsensitiveCompare<wchar_t>()); 743 CaseInsensitiveCompare<wchar_t>());
744 } 744 }
745 } 745 }
746 746
747 bool EndsWith(const std::wstring& str,
748 const std::wstring& search,
749 bool case_sensitive) {
750 std::wstring::size_type str_length = str.length();
751 std::wstring::size_type search_length = search.length();
752 if (search_length > str_length)
753 return false;
754 if (case_sensitive) {
755 return str.compare(str_length - search_length, search_length, search) == 0;
756 } else {
757 return std::equal(search.begin(), search.end(),
758 str.begin() + (str_length - search_length),
759 CaseInsensitiveCompare<wchar_t>());
760 }
761 }
762
747 DataUnits GetByteDisplayUnits(int64 bytes) { 763 DataUnits GetByteDisplayUnits(int64 bytes) {
748 // The byte thresholds at which we display amounts. A byte count is displayed 764 // The byte thresholds at which we display amounts. A byte count is displayed
749 // in unit U when kUnitThresholds[U] <= bytes < kUnitThresholds[U+1]. 765 // in unit U when kUnitThresholds[U] <= bytes < kUnitThresholds[U+1].
750 // This must match the DataUnits enum. 766 // This must match the DataUnits enum.
751 static const int64 kUnitThresholds[] = { 767 static const int64 kUnitThresholds[] = {
752 0, // DATA_UNITS_BYTE, 768 0, // DATA_UNITS_BYTE,
753 3*1024, // DATA_UNITS_KILOBYTE, 769 3*1024, // DATA_UNITS_KILOBYTE,
754 2*1024*1024, // DATA_UNITS_MEGABYTE, 770 2*1024*1024, // DATA_UNITS_MEGABYTE,
755 1024*1024*1024 // DATA_UNITS_GIGABYTE, 771 1024*1024*1024 // DATA_UNITS_GIGABYTE,
756 }; 772 };
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after
1649 // Each input byte creates two output hex characters. 1665 // Each input byte creates two output hex characters.
1650 std::string ret(size * 2, '\0'); 1666 std::string ret(size * 2, '\0');
1651 1667
1652 for (size_t i = 0; i < size; ++i) { 1668 for (size_t i = 0; i < size; ++i) {
1653 char b = reinterpret_cast<const char*>(bytes)[i]; 1669 char b = reinterpret_cast<const char*>(bytes)[i];
1654 ret[(i * 2)] = kHexChars[(b >> 4) & 0xf]; 1670 ret[(i * 2)] = kHexChars[(b >> 4) & 0xf];
1655 ret[(i * 2) + 1] = kHexChars[b & 0xf]; 1671 ret[(i * 2) + 1] = kHexChars[b & 0xf];
1656 } 1672 }
1657 return ret; 1673 return ret;
1658 } 1674 }
OLDNEW
« no previous file with comments | « base/string_util.h ('k') | base/string_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698