summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjschuh@chromium.org <jschuh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-17 03:32:40 +0000
committerjschuh@chromium.org <jschuh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-17 03:32:40 +0000
commitcb15406554885da0c1e1030ade25d821b05ddac6 (patch)
treec7024916ab466deba405168655b3e84f51973be2
parent8c00ed7b6f62fd8db2f0c99446a01f447327878d (diff)
downloadchromium_src-cb15406554885da0c1e1030ade25d821b05ddac6.zip
chromium_src-cb15406554885da0c1e1030ade25d821b05ddac6.tar.gz
chromium_src-cb15406554885da0c1e1030ade25d821b05ddac6.tar.bz2
Refactor base/safe_numerics.h
* Move into base/numerics subdirectory. * Rename files for clarity. * Add owners. * Rename checked_numeric_cast to checked_cast. * Fixup callsites and include paths. BUG=332611 R=brettw@chromium.org, jam@chromium.org Review URL: https://codereview.chromium.org/141113003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245418 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/base.gyp2
-rw-r--r--base/base.gypi4
-rw-r--r--base/i18n/build_utf8_validator_tables.cc4
-rw-r--r--base/metrics/histogram_delta_serialization.cc4
-rw-r--r--base/numerics/OWNERS3
-rw-r--r--base/numerics/safe_conversions.h (renamed from base/safe_numerics.h)13
-rw-r--r--base/numerics/safe_conversions_impl.h (renamed from base/safe_numerics_impl.h)6
-rw-r--r--base/numerics/safe_numerics_unittest.cc (renamed from base/safe_numerics_unittest.cc)5
-rw-r--r--chrome/browser/extensions/api/media_galleries/media_galleries_apitest.cc4
-rw-r--r--chrome/browser/extensions/convert_web_app.cc4
-rw-r--r--chrome/browser/extensions/sandboxed_unpacker.cc8
-rw-r--r--chrome/browser/extensions/test_extension_dir.cc4
-rw-r--r--chrome/browser/media_galleries/linux/mtp_read_file_worker.cc6
-rw-r--r--chrome/browser/media_galleries/linux/snapshot_file_details.cc4
-rw-r--r--chrome/browser/media_galleries/win/mtp_device_operations_util.cc6
-rw-r--r--chrome/browser/net/crl_set_fetcher.cc6
-rw-r--r--chrome/browser/password_manager/password_manager_metrics_util.cc6
-rw-r--r--chrome/browser/password_manager/password_manager_util_win.cc1
-rw-r--r--chrome/browser/sync/glue/session_model_associator.cc1
-rw-r--r--chrome/installer/setup/install.cc4
-rw-r--r--chrome/renderer/pepper/ppb_pdf_impl.cc6
-rw-r--r--chrome/utility/extensions/unpacker.cc4
-rw-r--r--cloud_print/gcp20/prototype/printer_state.cc4
-rw-r--r--components/plugins/renderer/webview_plugin.cc8
-rw-r--r--components/policy/core/common/cloud/resource_cache.cc4
-rw-r--r--content/browser/fileapi/blob_url_request_job_unittest.cc4
-rw-r--r--content/browser/renderer_host/pepper/pepper_truetype_font_list_host.cc6
-rw-r--r--content/browser/speech/google_streaming_remote_engine_unittest.cc6
-rw-r--r--content/browser/vibration/vibration_message_filter.cc4
-rw-r--r--content/browser/vibration/vibration_provider_android.cc1
-rw-r--r--content/common/child_process_sandbox_support_impl_linux.cc10
-rw-r--r--content/common/gpu/media/video_encode_accelerator_unittest.cc4
-rw-r--r--content/renderer/media/rtc_video_decoder.cc4
-rw-r--r--content/renderer/pepper/content_decryptor_delegate.cc4
-rw-r--r--content/renderer/pepper/pepper_truetype_font_linux.cc4
-rw-r--r--content/renderer/pepper/pepper_video_source_host.cc6
-rw-r--r--content/renderer/renderer_webkitplatformsupport_impl.cc4
-rw-r--r--content/test/mock_google_streaming_server.cc6
-rw-r--r--gpu/command_buffer/common/gles2_cmd_format.h1
-rw-r--r--media/base/android/media_codec_bridge.cc14
-rw-r--r--media/base/audio_bus.cc4
-rw-r--r--net/websockets/websocket_basic_stream.cc6
-rw-r--r--net/websockets/websocket_channel.cc4
-rw-r--r--net/websockets/websocket_channel_test.cc1
-rw-r--r--ppapi/host/error_conversion.cc4
-rw-r--r--printing/image.cc6
-rw-r--r--printing/pdf_metafile_skia.cc6
-rw-r--r--printing/print_destination_win.cc4
-rw-r--r--tools/imagediff/image_diff.cc4
-rw-r--r--ui/base/clipboard/clipboard_win.cc8
-rw-r--r--ui/snapshot/snapshot_aura.cc4
-rw-r--r--win8/metro_driver/print_document_source.cc4
-rw-r--r--win8/metro_driver/print_handler.cc4
53 files changed, 129 insertions, 129 deletions
diff --git a/base/base.gyp b/base/base.gyp
index 63306cd..5893754 100644
--- a/base/base.gyp
+++ b/base/base.gyp
@@ -574,7 +574,7 @@
'process/process_util_unittest.cc',
'profiler/tracked_time_unittest.cc',
'rand_util_unittest.cc',
- 'safe_numerics_unittest.cc',
+ 'numerics/safe_numerics_unittest.cc',
'scoped_clear_errno_unittest.cc',
'scoped_native_library_unittest.cc',
'scoped_observer.h',
diff --git a/base/base.gypi b/base/base.gypi
index 1abf416..cb7c5c8 100644
--- a/base/base.gypi
+++ b/base/base.gypi
@@ -488,8 +488,8 @@
'rand_util_win.cc',
'run_loop.cc',
'run_loop.h',
- 'safe_numerics.h',
- 'safe_numerics_impl.h',
+ 'numerics/safe_conversions.h',
+ 'numerics/safe_conversions_impl.h',
'safe_strerror_posix.cc',
'safe_strerror_posix.h',
'scoped_native_library.cc',
diff --git a/base/i18n/build_utf8_validator_tables.cc b/base/i18n/build_utf8_validator_tables.cc
index de3aae6..34d3b99 100644
--- a/base/i18n/build_utf8_validator_tables.cc
+++ b/base/i18n/build_utf8_validator_tables.cc
@@ -40,7 +40,7 @@
#include "base/file_util.h"
#include "base/files/file_path.h"
#include "base/logging.h"
-#include "base/safe_numerics.h"
+#include "base/numerics/safe_conversions.h"
#include "base/strings/stringprintf.h"
#include "third_party/icu/source/common/unicode/utf8.h"
@@ -319,7 +319,7 @@ uint8 MakeState(const StringSet& set,
State(new_state_initializer,
new_state_initializer + arraysize(new_state_initializer)));
const uint8 new_state_number =
- base::checked_numeric_cast<uint8>(states->size() - 1);
+ base::checked_cast<uint8>(states->size() - 1);
CHECK(state_map->insert(std::make_pair(set, new_state_number)).second);
return new_state_number;
}
diff --git a/base/metrics/histogram_delta_serialization.cc b/base/metrics/histogram_delta_serialization.cc
index 924916d..e40a6b6 100644
--- a/base/metrics/histogram_delta_serialization.cc
+++ b/base/metrics/histogram_delta_serialization.cc
@@ -7,8 +7,8 @@
#include "base/logging.h"
#include "base/metrics/histogram_base.h"
#include "base/metrics/histogram_snapshot_manager.h"
+#include "base/numerics/safe_conversions.h"
#include "base/pickle.h"
-#include "base/safe_numerics.h"
#include "base/values.h"
namespace base {
@@ -75,7 +75,7 @@ void HistogramDeltaSerialization::DeserializeAndAddSamples(
const std::vector<std::string>& serialized_deltas) {
for (std::vector<std::string>::const_iterator it = serialized_deltas.begin();
it != serialized_deltas.end(); ++it) {
- Pickle pickle(it->data(), checked_numeric_cast<int>(it->size()));
+ Pickle pickle(it->data(), checked_cast<int>(it->size()));
PickleIterator iter(pickle);
DeserializeHistogramAndAddSamples(&iter);
}
diff --git a/base/numerics/OWNERS b/base/numerics/OWNERS
new file mode 100644
index 0000000..41f35fc
--- /dev/null
+++ b/base/numerics/OWNERS
@@ -0,0 +1,3 @@
+jschuh@chromium.org
+tsepez@chromium.org
+
diff --git a/base/safe_numerics.h b/base/numerics/safe_conversions.h
index 6fbd5bf..03ef96d 100644
--- a/base/safe_numerics.h
+++ b/base/numerics/safe_conversions.h
@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_SAFE_NUMERICS_H_
-#define BASE_SAFE_NUMERICS_H_
+#ifndef BASE_SAFE_CONVERSIONS_H_
+#define BASE_SAFE_CONVERSIONS_H_
#include <limits>
#include "base/logging.h"
-#include "base/safe_numerics_impl.h"
+#include "base/numerics/safe_conversions_impl.h"
namespace base {
@@ -19,11 +19,11 @@ inline bool IsValueInRangeForNumericType(Src value) {
return internal::RangeCheck<Dst>(value) == internal::TYPE_VALID;
}
-// checked_numeric_cast<> is analogous to static_cast<> for numeric types,
+// checked_cast<> is analogous to static_cast<> for numeric types,
// except that it CHECKs that the specified numeric conversion will not
// overflow or underflow. NaN source will always trigger a CHECK.
template <typename Dst, typename Src>
-inline Dst checked_numeric_cast(Src value) {
+inline Dst checked_cast(Src value) {
CHECK(IsValueInRangeForNumericType<Dst>(value));
return static_cast<Dst>(value);
}
@@ -59,4 +59,5 @@ inline Dst saturated_cast(Src value) {
} // namespace base
-#endif // BASE_SAFE_NUMERICS_H_
+#endif // BASE_SAFE_CONVERSIONS_H_
+
diff --git a/base/safe_numerics_impl.h b/base/numerics/safe_conversions_impl.h
index 6ca1e2b..8bc3021 100644
--- a/base/safe_numerics_impl.h
+++ b/base/numerics/safe_conversions_impl.h
@@ -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_SAFE_NUMERICS_IMPL_H_
-#define BASE_SAFE_NUMERICS_IMPL_H_
+#ifndef BASE_SAFE_CONVERSIONS_IMPL_H_
+#define BASE_SAFE_CONVERSIONS_IMPL_H_
#include <limits>
@@ -179,5 +179,5 @@ inline RangeCheckResult RangeCheck(Src value) {
} // namespace internal
} // namespace base
-#endif // BASE_SAFE_NUMERICS_IMPL_H_
+#endif // BASE_SAFE_CONVERSIONS_IMPL_H_
diff --git a/base/safe_numerics_unittest.cc b/base/numerics/safe_numerics_unittest.cc
index 1bcd38f..39eee0a 100644
--- a/base/safe_numerics_unittest.cc
+++ b/base/numerics/safe_numerics_unittest.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/safe_numerics.h"
+#include "base/numerics/safe_conversions.h"
#include <stdint.h>
@@ -258,7 +258,7 @@ TEST(SafeNumerics, CastTests) {
double double_infinity = std::numeric_limits<float>::infinity();
// Just test that the cast compiles, since the other tests cover logic.
- EXPECT_EQ(0, base::checked_numeric_cast<int>(static_cast<size_t>(0)));
+ EXPECT_EQ(0, base::checked_cast<int>(static_cast<size_t>(0)));
// Test various saturation corner cases.
EXPECT_EQ(saturated_cast<int>(small_negative),
@@ -277,3 +277,4 @@ TEST(SafeNumerics, CastTests) {
} // namespace internal
} // namespace base
+
diff --git a/chrome/browser/extensions/api/media_galleries/media_galleries_apitest.cc b/chrome/browser/extensions/api/media_galleries/media_galleries_apitest.cc
index 35d2913..299042e 100644
--- a/chrome/browser/extensions/api/media_galleries/media_galleries_apitest.cc
+++ b/chrome/browser/extensions/api/media_galleries/media_galleries_apitest.cc
@@ -6,8 +6,8 @@
#include "base/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/json/json_writer.h"
+#include "base/numerics/safe_conversions.h"
#include "base/path_service.h"
-#include "base/safe_numerics.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
@@ -62,7 +62,7 @@ class MediaGalleriesPlatformAppBrowserTest : public PlatformAppBrowserTest {
int64 file_size;
ASSERT_TRUE(base::GetFileSize(GetCommonDataDir().AppendASCII("test.jpg"),
&file_size));
- test_jpg_size_ = base::checked_numeric_cast<int>(file_size);
+ test_jpg_size_ = base::checked_cast<int>(file_size);
}
virtual void TearDownOnMainThread() OVERRIDE {
diff --git a/chrome/browser/extensions/convert_web_app.cc b/chrome/browser/extensions/convert_web_app.cc
index a324976..99a322b 100644
--- a/chrome/browser/extensions/convert_web_app.cc
+++ b/chrome/browser/extensions/convert_web_app.cc
@@ -15,8 +15,8 @@
#include "base/files/scoped_temp_dir.h"
#include "base/json/json_file_value_serializer.h"
#include "base/logging.h"
+#include "base/numerics/safe_conversions.h"
#include "base/path_service.h"
-#include "base/safe_numerics.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
@@ -173,7 +173,7 @@ scoped_refptr<Extension> ConvertWebAppToExtension(
}
const char* image_data_ptr = reinterpret_cast<const char*>(&image_data[0]);
- int size = base::checked_numeric_cast<int>(image_data.size());
+ int size = base::checked_cast<int>(image_data.size());
if (file_util::WriteFile(icon_file, image_data_ptr, size) != size) {
LOG(ERROR) << "Could not write icon file.";
return NULL;
diff --git a/chrome/browser/extensions/sandboxed_unpacker.cc b/chrome/browser/extensions/sandboxed_unpacker.cc
index 6647a8a..f7625e70 100644
--- a/chrome/browser/extensions/sandboxed_unpacker.cc
+++ b/chrome/browser/extensions/sandboxed_unpacker.cc
@@ -15,8 +15,8 @@
#include "base/memory/scoped_handle.h"
#include "base/message_loop/message_loop.h"
#include "base/metrics/histogram.h"
+#include "base/numerics/safe_conversions.h"
#include "base/path_service.h"
-#include "base/safe_numerics.h"
#include "base/sequenced_task_runner.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/sequenced_worker_pool.h"
@@ -628,7 +628,7 @@ base::DictionaryValue* SandboxedUnpacker::RewriteManifestFile(
base::FilePath manifest_path =
extension_root_.Append(kManifestFilename);
- int size = base::checked_numeric_cast<int>(manifest_json.size());
+ int size = base::checked_cast<int>(manifest_json.size());
if (file_util::WriteFile(manifest_path, manifest_json.data(), size) != size) {
// Error saving manifest.json.
ReportFailure(
@@ -741,7 +741,7 @@ bool SandboxedUnpacker::RewriteImageFiles(SkBitmap* install_icon) {
// Note: we're overwriting existing files that the utility process wrote,
// so we can be sure the directory exists.
const char* image_data_ptr = reinterpret_cast<const char*>(&image_data[0]);
- int size = base::checked_numeric_cast<int>(image_data.size());
+ int size = base::checked_cast<int>(image_data.size());
if (file_util::WriteFile(path, image_data_ptr, size) != size) {
// Error saving theme image.
ReportFailure(
@@ -810,7 +810,7 @@ bool SandboxedUnpacker::RewriteCatalogFiles() {
// Note: we're overwriting existing files that the utility process read,
// so we can be sure the directory exists.
- int size = base::checked_numeric_cast<int>(catalog_json.size());
+ int size = base::checked_cast<int>(catalog_json.size());
if (file_util::WriteFile(path, catalog_json.c_str(), size) != size) {
// Error saving catalog.
ReportFailure(
diff --git a/chrome/browser/extensions/test_extension_dir.cc b/chrome/browser/extensions/test_extension_dir.cc
index 039fbe8..a99e5be 100644
--- a/chrome/browser/extensions/test_extension_dir.cc
+++ b/chrome/browser/extensions/test_extension_dir.cc
@@ -6,7 +6,7 @@
#include "base/file_util.h"
#include "base/json/json_writer.h"
-#include "base/safe_numerics.h"
+#include "base/numerics/safe_conversions.h"
#include "base/test/values_test_util.h"
#include "chrome/browser/extensions/extension_creator.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -31,7 +31,7 @@ void TestExtensionDir::WriteManifest(base::StringPiece manifest) {
void TestExtensionDir::WriteFile(const base::FilePath::StringType& filename,
base::StringPiece contents) {
EXPECT_EQ(
- base::checked_numeric_cast<int>(contents.size()),
+ base::checked_cast<int>(contents.size()),
file_util::WriteFile(
dir_.path().Append(filename), contents.data(), contents.size()));
}
diff --git a/chrome/browser/media_galleries/linux/mtp_read_file_worker.cc b/chrome/browser/media_galleries/linux/mtp_read_file_worker.cc
index e991893..8c7eddb 100644
--- a/chrome/browser/media_galleries/linux/mtp_read_file_worker.cc
+++ b/chrome/browser/media_galleries/linux/mtp_read_file_worker.cc
@@ -7,7 +7,7 @@
#include "base/bind.h"
#include "base/file_util.h"
#include "base/files/file_path.h"
-#include "base/safe_numerics.h"
+#include "base/numerics/safe_conversions.h"
#include "chrome/browser/media_galleries/linux/snapshot_file_details.h"
#include "chrome/browser/storage_monitor/storage_monitor.h"
#include "content/public/browser/browser_thread.h"
@@ -28,9 +28,9 @@ uint32 WriteDataChunkIntoSnapshotFileOnFileThread(
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
int bytes_written =
file_util::AppendToFile(snapshot_file_path, data.data(),
- base::checked_numeric_cast<int>(data.size()));
+ base::checked_cast<int>(data.size()));
return (static_cast<int>(data.size()) == bytes_written) ?
- base::checked_numeric_cast<uint32>(bytes_written) : 0;
+ base::checked_cast<uint32>(bytes_written) : 0;
}
} // namespace
diff --git a/chrome/browser/media_galleries/linux/snapshot_file_details.cc b/chrome/browser/media_galleries/linux/snapshot_file_details.cc
index 4a4b67c..00995ca 100644
--- a/chrome/browser/media_galleries/linux/snapshot_file_details.cc
+++ b/chrome/browser/media_galleries/linux/snapshot_file_details.cc
@@ -4,7 +4,7 @@
#include "chrome/browser/media_galleries/linux/snapshot_file_details.h"
-#include "base/safe_numerics.h"
+#include "base/numerics/safe_conversions.h"
////////////////////////////////////////////////////////////////////////////////
// SnapshotRequestInfo //
@@ -64,5 +64,5 @@ uint32 SnapshotFileDetails::BytesToRead() const {
static const uint32 kReadChunkSize = 1024 * 1024;
return std::min(
kReadChunkSize,
- base::checked_numeric_cast<uint32>(file_info_.size) - bytes_written_);
+ base::checked_cast<uint32>(file_info_.size) - bytes_written_);
}
diff --git a/chrome/browser/media_galleries/win/mtp_device_operations_util.cc b/chrome/browser/media_galleries/win/mtp_device_operations_util.cc
index 178eb62..f2c681d 100644
--- a/chrome/browser/media_galleries/win/mtp_device_operations_util.cc
+++ b/chrome/browser/media_galleries/win/mtp_device_operations_util.cc
@@ -12,7 +12,7 @@
#include "base/file_util.h"
#include "base/files/file_path.h"
#include "base/logging.h"
-#include "base/safe_numerics.h"
+#include "base/numerics/safe_conversions.h"
#include "base/strings/string_util.h"
#include "base/threading/thread_restrictions.h"
#include "base/time/time.h"
@@ -385,9 +385,9 @@ DWORD CopyDataChunkToLocalFile(IStream* stream,
DCHECK_GT(bytes_read, 0U);
CHECK_LE(bytes_read, buffer.length());
int data_len =
- base::checked_numeric_cast<int>(
+ base::checked_cast<int>(
std::min(bytes_read,
- base::checked_numeric_cast<DWORD>(buffer.length())));
+ base::checked_cast<DWORD>(buffer.length())));
if (file_util::AppendToFile(local_path, buffer.c_str(), data_len) != data_len)
return 0U;
return data_len;
diff --git a/chrome/browser/net/crl_set_fetcher.cc b/chrome/browser/net/crl_set_fetcher.cc
index 0dca1ee..f610cad 100644
--- a/chrome/browser/net/crl_set_fetcher.cc
+++ b/chrome/browser/net/crl_set_fetcher.cc
@@ -6,9 +6,9 @@
#include "base/bind.h"
#include "base/file_util.h"
+#include "base/numerics/safe_conversions.h"
#include "base/path_service.h"
#include "base/rand_util.h"
-#include "base/safe_numerics.h"
#include "base/strings/string_number_conversions.h"
#include "base/time/time.h"
#include "chrome/browser/component_updater/component_updater_service.h"
@@ -168,7 +168,7 @@ bool CRLSetFetcher::Install(const base::DictionaryValue& manifest,
LOG(WARNING) << "Failed to parse CRL set from update CRX";
return false;
}
- int size = base::checked_numeric_cast<int>(crl_set_bytes.size());
+ int size = base::checked_cast<int>(crl_set_bytes.size());
if (file_util::WriteFile(save_to, crl_set_bytes.data(), size) != size) {
LOG(WARNING) << "Failed to save new CRL set to disk";
// We don't return false here because we can still use this CRL set. When
@@ -184,7 +184,7 @@ bool CRLSetFetcher::Install(const base::DictionaryValue& manifest,
VLOG(1) << "Applied CRL set delta #" << crl_set_->sequence()
<< "->#" << new_crl_set->sequence();
const std::string new_crl_set_bytes = new_crl_set->Serialize();
- int size = base::checked_numeric_cast<int>(new_crl_set_bytes.size());
+ int size = base::checked_cast<int>(new_crl_set_bytes.size());
if (file_util::WriteFile(save_to, new_crl_set_bytes.data(), size) != size) {
LOG(WARNING) << "Failed to save new CRL set to disk";
// We don't return false here because we can still use this CRL set. When
diff --git a/chrome/browser/password_manager/password_manager_metrics_util.cc b/chrome/browser/password_manager/password_manager_metrics_util.cc
index 2a41127..dbdcc93 100644
--- a/chrome/browser/password_manager/password_manager_metrics_util.cc
+++ b/chrome/browser/password_manager/password_manager_metrics_util.cc
@@ -6,10 +6,10 @@
#include "base/basictypes.h"
#include "base/metrics/histogram.h"
+#include "base/numerics/safe_conversions.h"
#include "base/prefs/pref_service.h"
#include "base/prefs/scoped_user_pref_update.h"
#include "base/rand_util.h"
-#include "base/safe_numerics.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/time/time.h"
@@ -65,10 +65,10 @@ size_t GetGroupIndex(size_t domain_index, PrefService* pref_service) {
pref_service, prefs::kPasswordManagerGroupsForDomains);
// This value has not been generated yet.
result =
- base::checked_numeric_cast<int>(base::RandGenerator(kGroupsPerDomain));
+ base::checked_cast<int>(base::RandGenerator(kGroupsPerDomain));
group_indices_updater->Set(domain_index, new FundamentalValue(result));
}
- return base::checked_numeric_cast<size_t>(result);
+ return base::checked_cast<size_t>(result);
}
} // namespace
diff --git a/chrome/browser/password_manager/password_manager_util_win.cc b/chrome/browser/password_manager/password_manager_util_win.cc
index fb3d085..b89df10 100644
--- a/chrome/browser/password_manager/password_manager_util_win.cc
+++ b/chrome/browser/password_manager/password_manager_util_win.cc
@@ -17,7 +17,6 @@
#include "base/prefs/pref_registry_simple.h"
#include "base/prefs/pref_service.h"
-#include "base/safe_numerics.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "chrome/browser/browser_process.h"
diff --git a/chrome/browser/sync/glue/session_model_associator.cc b/chrome/browser/sync/glue/session_model_associator.cc
index 9321542..910e702 100644
--- a/chrome/browser/sync/glue/session_model_associator.cc
+++ b/chrome/browser/sync/glue/session_model_associator.cc
@@ -11,7 +11,6 @@
#include "base/bind.h"
#include "base/location.h"
#include "base/logging.h"
-#include "base/safe_numerics.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/sequenced_worker_pool.h"
#include "chrome/browser/chrome_notification_types.h"
diff --git a/chrome/installer/setup/install.cc b/chrome/installer/setup/install.cc
index fb1bd37..3aed444 100644
--- a/chrome/installer/setup/install.cc
+++ b/chrome/installer/setup/install.cc
@@ -15,9 +15,9 @@
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
+#include "base/numerics/safe_conversions.h"
#include "base/path_service.h"
#include "base/process/launch.h"
-#include "base/safe_numerics.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
@@ -351,7 +351,7 @@ bool CreateVisualElementsManifest(const base::FilePath& src_path,
// Write the manifest to |src_path|.
const std::string manifest(UTF16ToUTF8(manifest16));
- int size = base::checked_numeric_cast<int>(manifest.size());
+ int size = base::checked_cast<int>(manifest.size());
if (file_util::WriteFile(
src_path.Append(installer::kVisualElementsManifest),
manifest.c_str(), size) == size) {
diff --git a/chrome/renderer/pepper/ppb_pdf_impl.cc b/chrome/renderer/pepper/ppb_pdf_impl.cc
index 3cd6bb2..0668585a 100644
--- a/chrome/renderer/pepper/ppb_pdf_impl.cc
+++ b/chrome/renderer/pepper/ppb_pdf_impl.cc
@@ -6,7 +6,7 @@
#include "base/command_line.h"
#include "base/metrics/histogram.h"
-#include "base/safe_numerics.h"
+#include "base/numerics/safe_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "chrome/common/chrome_switches.h"
@@ -26,13 +26,13 @@
#include "ppapi/shared_impl/resource.h"
#include "ppapi/shared_impl/resource_tracker.h"
#include "ppapi/shared_impl/var.h"
-#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/WebKit/public/web/WebDocument.h"
#include "third_party/WebKit/public/web/WebElement.h"
#include "third_party/WebKit/public/web/WebFrame.h"
#include "third_party/WebKit/public/web/WebPluginContainer.h"
#include "third_party/WebKit/public/web/WebView.h"
#include "third_party/icu/source/i18n/unicode/usearch.h"
+#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/layout.h"
#include "ui/base/resource/resource_bundle.h"
@@ -58,7 +58,7 @@ class PrivateFontFile : public ppapi::Resource {
size_t temp_size = static_cast<size_t>(*output_length);
bool rv = content::GetFontTable(
fd_, table, 0 /* offset */, static_cast<uint8_t*>(output), &temp_size);
- *output_length = base::checked_numeric_cast<uint32_t>(temp_size);
+ *output_length = base::checked_cast<uint32_t>(temp_size);
return rv;
}
diff --git a/chrome/utility/extensions/unpacker.cc b/chrome/utility/extensions/unpacker.cc
index 1119c91..f056fc3 100644
--- a/chrome/utility/extensions/unpacker.cc
+++ b/chrome/utility/extensions/unpacker.cc
@@ -12,7 +12,7 @@
#include "base/i18n/rtl.h"
#include "base/json/json_file_value_serializer.h"
#include "base/memory/scoped_handle.h"
-#include "base/safe_numerics.h"
+#include "base/numerics/safe_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread.h"
@@ -86,7 +86,7 @@ bool PathContainsParentDirectory(const base::FilePath& path) {
}
bool WritePickle(const IPC::Message& pickle, const base::FilePath& dest_path) {
- int size = base::checked_numeric_cast<int>(pickle.size());
+ int size = base::checked_cast<int>(pickle.size());
const char* data = static_cast<const char*>(pickle.data());
int bytes_written = file_util::WriteFile(dest_path, data, size);
return (bytes_written == size);
diff --git a/cloud_print/gcp20/prototype/printer_state.cc b/cloud_print/gcp20/prototype/printer_state.cc
index 156ebe4..0e12eee 100644
--- a/cloud_print/gcp20/prototype/printer_state.cc
+++ b/cloud_print/gcp20/prototype/printer_state.cc
@@ -8,7 +8,7 @@
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/logging.h"
-#include "base/safe_numerics.h"
+#include "base/numerics/safe_conversions.h"
#include "base/values.h"
namespace {
@@ -74,7 +74,7 @@ bool SaveToFile(const base::FilePath& path, const PrinterState& state) {
base::JSONWriter::WriteWithOptions(&json,
base::JSONWriter::OPTIONS_PRETTY_PRINT,
&json_str);
- int size = base::checked_numeric_cast<int>(json_str.size());
+ int size = base::checked_cast<int>(json_str.size());
return (file_util::WriteFile(path, json_str.data(), size) == size);
}
diff --git a/components/plugins/renderer/webview_plugin.cc b/components/plugins/renderer/webview_plugin.cc
index faf56e2..dfee291 100644
--- a/components/plugins/renderer/webview_plugin.cc
+++ b/components/plugins/renderer/webview_plugin.cc
@@ -6,7 +6,7 @@
#include "base/message_loop/message_loop.h"
#include "base/metrics/histogram.h"
-#include "base/safe_numerics.h"
+#include "base/numerics/safe_conversions.h"
#include "content/public/renderer/web_preferences.h"
#include "skia/ext/platform_canvas.h"
#include "third_party/WebKit/public/platform/WebSize.h"
@@ -74,15 +74,15 @@ void WebViewPlugin::ReplayReceivedData(WebPlugin* plugin) {
for (std::list<std::string>::iterator it = data_.begin(); it != data_.end();
++it) {
plugin->didReceiveData(
- it->c_str(), base::checked_numeric_cast<int, size_t>(it->length()));
+ it->c_str(), base::checked_cast<int, size_t>(it->length()));
total_bytes += it->length();
}
UMA_HISTOGRAM_MEMORY_KB(
"PluginDocument.Memory",
- (base::checked_numeric_cast<int, size_t>(total_bytes / 1024)));
+ (base::checked_cast<int, size_t>(total_bytes / 1024)));
UMA_HISTOGRAM_COUNTS(
"PluginDocument.NumChunks",
- (base::checked_numeric_cast<int, size_t>(data_.size())));
+ (base::checked_cast<int, size_t>(data_.size())));
}
if (finished_loading_) {
plugin->didFinishLoading();
diff --git a/components/policy/core/common/cloud/resource_cache.cc b/components/policy/core/common/cloud/resource_cache.cc
index 7b9e327..a68e66d 100644
--- a/components/policy/core/common/cloud/resource_cache.cc
+++ b/components/policy/core/common/cloud/resource_cache.cc
@@ -9,7 +9,7 @@
#include "base/file_util.h"
#include "base/files/file_enumerator.h"
#include "base/logging.h"
-#include "base/safe_numerics.h"
+#include "base/numerics/safe_conversions.h"
#include "base/sequenced_task_runner.h"
#include "base/strings/string_util.h"
@@ -82,7 +82,7 @@ bool ResourceCache::Store(const std::string& key,
// between these two calls. There is nothing in file_util that could be used
// to protect against such races, especially as the cache is cross-platform
// and therefore cannot use any POSIX-only tricks.
- int size = base::checked_numeric_cast<int>(data.size());
+ int size = base::checked_cast<int>(data.size());
return VerifyKeyPathAndGetSubkeyPath(key, true, subkey, &subkey_path) &&
base::DeleteFile(subkey_path, false) &&
(file_util::WriteFile(subkey_path, data.data(), size) == size);
diff --git a/content/browser/fileapi/blob_url_request_job_unittest.cc b/content/browser/fileapi/blob_url_request_job_unittest.cc
index e79b033..e5a3781 100644
--- a/content/browser/fileapi/blob_url_request_job_unittest.cc
+++ b/content/browser/fileapi/blob_url_request_job_unittest.cc
@@ -9,8 +9,8 @@
#include "base/files/scoped_temp_dir.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "base/numerics/safe_conversions.h"
#include "base/run_loop.h"
-#include "base/safe_numerics.h"
#include "base/time/time.h"
#include "content/public/test/test_file_system_context.h"
#include "net/base/io_buffer.h"
@@ -287,7 +287,7 @@ class BlobURLRequestJobTest : public testing::Test {
const std::vector<BlobData::Item>& items = blob_data_->items();
for (std::vector<BlobData::Item>::const_iterator it = items.begin();
it != items.end(); ++it) {
- int64 length = base::checked_numeric_cast<int64>(it->length());
+ int64 length = base::checked_cast<int64>(it->length());
CHECK(length <= kint64max - total);
total += length;
}
diff --git a/content/browser/renderer_host/pepper/pepper_truetype_font_list_host.cc b/content/browser/renderer_host/pepper/pepper_truetype_font_list_host.cc
index ceeb73e..af1717e 100644
--- a/content/browser/renderer_host/pepper/pepper_truetype_font_list_host.cc
+++ b/content/browser/renderer_host/pepper/pepper_truetype_font_list_host.cc
@@ -6,7 +6,7 @@
#include <algorithm>
-#include "base/safe_numerics.h"
+#include "base/numerics/safe_conversions.h"
#include "base/threading/sequenced_worker_pool.h"
#include "content/browser/renderer_host/pepper/pepper_truetype_font_list.h"
#include "content/common/font_list.h"
@@ -84,7 +84,7 @@ int32_t FontMessageFilter::OnHostMsgGetFontFamilies(
context->reply_msg =
PpapiPluginMsg_TrueTypeFontSingleton_GetFontFamiliesReply(font_families);
- return base::checked_numeric_cast<int32_t>(font_families.size());
+ return base::checked_cast<int32_t>(font_families.size());
}
int32_t FontMessageFilter::OnHostMsgGetFontsInFamily(
@@ -97,7 +97,7 @@ int32_t FontMessageFilter::OnHostMsgGetFontsInFamily(
context->reply_msg =
PpapiPluginMsg_TrueTypeFontSingleton_GetFontsInFamilyReply(
fonts_in_family);
- return base::checked_numeric_cast<int32_t>(fonts_in_family.size());
+ return base::checked_cast<int32_t>(fonts_in_family.size());
}
} // namespace
diff --git a/content/browser/speech/google_streaming_remote_engine_unittest.cc b/content/browser/speech/google_streaming_remote_engine_unittest.cc
index c484670..ab703d7 100644
--- a/content/browser/speech/google_streaming_remote_engine_unittest.cc
+++ b/content/browser/speech/google_streaming_remote_engine_unittest.cc
@@ -6,7 +6,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
-#include "base/safe_numerics.h"
+#include "base/numerics/safe_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/sys_byteorder.h"
#include "content/browser/speech/audio_buffer.h"
@@ -20,7 +20,7 @@
#include "testing/gtest/include/gtest/gtest.h"
using base::HostToNet32;
-using base::checked_numeric_cast;
+using base::checked_cast;
using net::URLRequestStatus;
using net::TestURLFetcher;
using net::TestURLFetcherFactory;
@@ -490,7 +490,7 @@ std::string GoogleStreamingRemoteEngineTest::SerializeProtobufResponse(
// Prepend 4 byte prefix length indication to the protobuf message as
// envisaged by the google streaming recognition webservice protocol.
- uint32 prefix = HostToNet32(checked_numeric_cast<uint32>(msg_string.size()));
+ uint32 prefix = HostToNet32(checked_cast<uint32>(msg_string.size()));
msg_string.insert(0, reinterpret_cast<char*>(&prefix), sizeof(prefix));
return msg_string;
diff --git a/content/browser/vibration/vibration_message_filter.cc b/content/browser/vibration/vibration_message_filter.cc
index 9a6ed0c..99811a97 100644
--- a/content/browser/vibration/vibration_message_filter.cc
+++ b/content/browser/vibration/vibration_message_filter.cc
@@ -6,7 +6,7 @@
#include <algorithm>
-#include "base/safe_numerics.h"
+#include "base/numerics/safe_conversions.h"
#include "content/common/view_messages.h"
#include "content/port/browser/vibration_provider.h"
#include "content/public/browser/content_browser_client.h"
@@ -48,7 +48,7 @@ void VibrationMessageFilter::OnVibrate(int64 milliseconds) {
// Though the Blink implementation already sanitizes vibration times, don't
// trust any values passed from the renderer.
milliseconds = std::max(kMinimumVibrationDurationMs, std::min(milliseconds,
- base::checked_numeric_cast<int64>(blink::kVibrationDurationMax)));
+ base::checked_cast<int64>(blink::kVibrationDurationMax)));
provider_->Vibrate(milliseconds);
}
diff --git a/content/browser/vibration/vibration_provider_android.cc b/content/browser/vibration/vibration_provider_android.cc
index ba62b15..4694f4e 100644
--- a/content/browser/vibration/vibration_provider_android.cc
+++ b/content/browser/vibration/vibration_provider_android.cc
@@ -6,7 +6,6 @@
#include <algorithm>
-#include "base/safe_numerics.h"
#include "content/browser/vibration/vibration_message_filter.h"
#include "content/common/view_messages.h"
#include "jni/VibrationProvider_jni.h"
diff --git a/content/common/child_process_sandbox_support_impl_linux.cc b/content/common/child_process_sandbox_support_impl_linux.cc
index 62124ae..de3e030 100644
--- a/content/common/child_process_sandbox_support_impl_linux.cc
+++ b/content/common/child_process_sandbox_support_impl_linux.cc
@@ -8,10 +8,10 @@
#include "base/debug/trace_event.h"
#include "base/memory/scoped_ptr.h"
+#include "base/numerics/safe_conversions.h"
#include "base/pickle.h"
#include "base/posix/eintr_wrapper.h"
#include "base/posix/unix_domain_socket_linux.h"
-#include "base/safe_numerics.h"
#include "base/sys_byteorder.h"
#include "content/common/sandbox_linux/sandbox_linux.h"
#include "third_party/WebKit/public/platform/linux/WebFontFamily.h"
@@ -117,7 +117,7 @@ bool GetFontTable(int fd, uint32_t table_tag, off_t offset,
struct stat st;
if (fstat(fd, &st) < 0)
return false;
- data_length = base::checked_numeric_cast<size_t>(st.st_size);
+ data_length = base::checked_cast<size_t>(st.st_size);
} else {
// Get a font table. Read the header to find its offset in the file.
uint16_t num_tables;
@@ -134,7 +134,7 @@ bool GetFontTable(int fd, uint32_t table_tag, off_t offset,
scoped_ptr<uint8_t[]> table_entries(new uint8_t[directory_size]);
n = HANDLE_EINTR(pread(fd, table_entries.get(), directory_size,
12 /* skip the SFNT header */));
- if (n != base::checked_numeric_cast<ssize_t>(directory_size))
+ if (n != base::checked_cast<ssize_t>(directory_size))
return false;
for (uint16_t i = 0; i < num_tables; ++i) {
@@ -155,7 +155,7 @@ bool GetFontTable(int fd, uint32_t table_tag, off_t offset,
return false;
// Clamp |offset| inside the allowable range. This allows the read to succeed
// but return 0 bytes.
- offset = std::min(offset, base::checked_numeric_cast<off_t>(data_length));
+ offset = std::min(offset, base::checked_cast<off_t>(data_length));
// Make sure it's safe to add the data offset and the caller's logical offset.
// Define the maximum positive offset on 32 bit systems.
static const off_t kMaxPositiveOffset32 = 0x7FFFFFFF; // 2 GB - 1.
@@ -169,7 +169,7 @@ bool GetFontTable(int fd, uint32_t table_tag, off_t offset,
// 'output_length' holds the maximum amount of data the caller can accept.
data_length = std::min(data_length, *output_length);
ssize_t n = HANDLE_EINTR(pread(fd, output, data_length, data_offset));
- if (n != base::checked_numeric_cast<ssize_t>(data_length))
+ if (n != base::checked_cast<ssize_t>(data_length))
return false;
}
*output_length = data_length;
diff --git a/content/common/gpu/media/video_encode_accelerator_unittest.cc b/content/common/gpu/media/video_encode_accelerator_unittest.cc
index 8ba6c78..701eae8 100644
--- a/content/common/gpu/media/video_encode_accelerator_unittest.cc
+++ b/content/common/gpu/media/video_encode_accelerator_unittest.cc
@@ -8,8 +8,8 @@
#include "base/file_util.h"
#include "base/files/memory_mapped_file.h"
#include "base/memory/scoped_vector.h"
+#include "base/numerics/safe_conversions.h"
#include "base/process/process.h"
-#include "base/safe_numerics.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "content/common/gpu/media/exynos_video_encode_accelerator.h"
@@ -495,7 +495,7 @@ void VEAClient::BitstreamBufferReady(int32 bitstream_buffer_id,
seen_keyframe_in_this_buffer_ = false;
if (save_to_file_) {
- int size = base::checked_numeric_cast<int>(payload_size);
+ int size = base::checked_cast<int>(payload_size);
EXPECT_EQ(file_util::AppendToFile(
base::FilePath::FromUTF8Unsafe(test_stream_.out_filename),
static_cast<char*>(shm->memory()),
diff --git a/content/renderer/media/rtc_video_decoder.cc b/content/renderer/media/rtc_video_decoder.cc
index 106f224..dd043c2 100644
--- a/content/renderer/media/rtc_video_decoder.cc
+++ b/content/renderer/media/rtc_video_decoder.cc
@@ -9,7 +9,7 @@
#include "base/memory/ref_counted.h"
#include "base/message_loop/message_loop_proxy.h"
#include "base/metrics/histogram.h"
-#include "base/safe_numerics.h"
+#include "base/numerics/safe_conversions.h"
#include "base/stl_util.h"
#include "base/task_runner_util.h"
#include "content/child/child_thread.h"
@@ -418,7 +418,7 @@ scoped_refptr<media::VideoFrame> RTCVideoDecoder::CreateVideoFrame(
DCHECK(decoder_texture_target_);
// Convert timestamp from 90KHz to ms.
base::TimeDelta timestamp_ms = base::TimeDelta::FromInternalValue(
- base::checked_numeric_cast<uint64_t>(timestamp) * 1000 / 90);
+ base::checked_cast<uint64_t>(timestamp) * 1000 / 90);
return media::VideoFrame::WrapNativeTexture(
make_scoped_ptr(new media::VideoFrame::MailboxHolder(
pb.texture_mailbox(),
diff --git a/content/renderer/pepper/content_decryptor_delegate.cc b/content/renderer/pepper/content_decryptor_delegate.cc
index 4fe5518..54815e3 100644
--- a/content/renderer/pepper/content_decryptor_delegate.cc
+++ b/content/renderer/pepper/content_decryptor_delegate.cc
@@ -7,7 +7,7 @@
#include "base/callback_helpers.h"
#include "base/debug/trace_event.h"
#include "base/message_loop/message_loop_proxy.h"
-#include "base/safe_numerics.h"
+#include "base/numerics/safe_conversions.h"
#include "content/renderer/pepper/ppb_buffer_impl.h"
#include "media/base/audio_buffer.h"
#include "media/base/audio_decoder_config.h"
@@ -998,7 +998,7 @@ bool ContentDecryptorDelegate::DeserializeAudioFrames(
// We should *not* have empty frames in the list.
if (frame_size <= 0 ||
- bytes_left < base::checked_numeric_cast<size_t>(frame_size)) {
+ bytes_left < base::checked_cast<size_t>(frame_size)) {
return false;
}
diff --git a/content/renderer/pepper/pepper_truetype_font_linux.cc b/content/renderer/pepper/pepper_truetype_font_linux.cc
index 53abf13..672154e 100644
--- a/content/renderer/pepper/pepper_truetype_font_linux.cc
+++ b/content/renderer/pepper/pepper_truetype_font_linux.cc
@@ -4,7 +4,7 @@
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
-#include "base/safe_numerics.h"
+#include "base/numerics/safe_conversions.h"
#include "base/sys_byteorder.h"
#include "content/public/common/child_process_sandbox_support_linux.h"
#include "content/renderer/pepper/pepper_truetype_font.h"
@@ -144,7 +144,7 @@ int32_t PepperTrueTypeFontLinux::GetTable(uint32_t table_tag,
&table_size))
return PP_ERROR_FAILED;
- return base::checked_numeric_cast<int32_t>(table_size);
+ return base::checked_cast<int32_t>(table_size);
}
} // namespace
diff --git a/content/renderer/pepper/pepper_video_source_host.cc b/content/renderer/pepper/pepper_video_source_host.cc
index 2a8bd93..c24057d 100644
--- a/content/renderer/pepper/pepper_video_source_host.cc
+++ b/content/renderer/pepper/pepper_video_source_host.cc
@@ -5,7 +5,7 @@
#include "content/renderer/pepper/pepper_video_source_host.h"
#include "base/bind.h"
-#include "base/safe_numerics.h"
+#include "base/numerics/safe_conversions.h"
#include "content/public/renderer/renderer_ppapi_host.h"
#include "content/renderer/pepper/ppb_image_data_impl.h"
#include "content/renderer/render_thread_impl.h"
@@ -134,8 +134,8 @@ void PepperVideoSourceHost::SendGetFrameReply() {
DCHECK(last_frame_.get());
scoped_ptr<cricket::VideoFrame> frame(last_frame_.release());
- int32_t width = base::checked_numeric_cast<int32_t>(frame->GetWidth());
- int32_t height = base::checked_numeric_cast<int32_t>(frame->GetHeight());
+ int32_t width = base::checked_cast<int32_t>(frame->GetWidth());
+ int32_t height = base::checked_cast<int32_t>(frame->GetHeight());
PP_ImageDataDesc image_desc;
IPC::PlatformFileForTransit image_handle;
uint32_t byte_count;
diff --git a/content/renderer/renderer_webkitplatformsupport_impl.cc b/content/renderer/renderer_webkitplatformsupport_impl.cc
index 8644a9c..86a2931 100644
--- a/content/renderer/renderer_webkitplatformsupport_impl.cc
+++ b/content/renderer/renderer_webkitplatformsupport_impl.cc
@@ -10,8 +10,8 @@
#include "base/memory/shared_memory.h"
#include "base/message_loop/message_loop_proxy.h"
#include "base/metrics/histogram.h"
+#include "base/numerics/safe_conversions.h"
#include "base/platform_file.h"
-#include "base/safe_numerics.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "content/child/database_util.h"
@@ -1057,7 +1057,7 @@ blink::WebCrypto* RendererWebKitPlatformSupportImpl::crypto() {
void RendererWebKitPlatformSupportImpl::vibrate(unsigned int milliseconds) {
RenderThread::Get()->Send(
- new ViewHostMsg_Vibrate(base::checked_numeric_cast<int64>(milliseconds)));
+ new ViewHostMsg_Vibrate(base::checked_cast<int64>(milliseconds)));
}
void RendererWebKitPlatformSupportImpl::cancelVibration() {
diff --git a/content/test/mock_google_streaming_server.cc b/content/test/mock_google_streaming_server.cc
index 4eae25c..5e13609 100644
--- a/content/test/mock_google_streaming_server.cc
+++ b/content/test/mock_google_streaming_server.cc
@@ -5,7 +5,7 @@
#include "content/test/mock_google_streaming_server.h"
#include "base/bind.h"
-#include "base/safe_numerics.h"
+#include "base/numerics/safe_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/sys_byteorder.h"
@@ -18,7 +18,7 @@
#include "net/url_request/url_request_status.h"
using base::HostToNet32;
-using base::checked_numeric_cast;
+using base::checked_cast;
namespace content {
@@ -101,7 +101,7 @@ void MockGoogleStreamingServer::SimulateResult(
// Prepend 4 byte prefix length indication to the protobuf message as
// envisaged by the google streaming recognition webservice protocol.
- uint32 prefix = HostToNet32(checked_numeric_cast<uint32>(msg_string.size()));
+ uint32 prefix = HostToNet32(checked_cast<uint32>(msg_string.size()));
msg_string.insert(0, reinterpret_cast<char*>(&prefix), sizeof(prefix));
SimulateServerResponse(true, msg_string);
diff --git a/gpu/command_buffer/common/gles2_cmd_format.h b/gpu/command_buffer/common/gles2_cmd_format.h
index d8e0694..252aafd 100644
--- a/gpu/command_buffer/common/gles2_cmd_format.h
+++ b/gpu/command_buffer/common/gles2_cmd_format.h
@@ -12,7 +12,6 @@
#include <string.h>
-#include "base/safe_numerics.h"
#include "gpu/command_buffer/common/bitfield_helpers.h"
#include "gpu/command_buffer/common/cmd_buffer_common.h"
#include "gpu/command_buffer/common/gles2_cmd_ids.h"
diff --git a/media/base/android/media_codec_bridge.cc b/media/base/android/media_codec_bridge.cc
index 6e7987f..b5ffb9b 100644
--- a/media/base/android/media_codec_bridge.cc
+++ b/media/base/android/media_codec_bridge.cc
@@ -14,7 +14,7 @@
#include "base/basictypes.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
-#include "base/safe_numerics.h"
+#include "base/numerics/safe_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "jni/MediaCodecBridge_jni.h"
@@ -225,7 +225,7 @@ MediaCodecStatus MediaCodecBridge::QueueInputBuffer(
size_t data_size,
const base::TimeDelta& presentation_time) {
DVLOG(3) << __PRETTY_FUNCTION__ << index << ": " << data_size;
- if (data_size > base::checked_numeric_cast<size_t>(kint32max))
+ if (data_size > base::checked_cast<size_t>(kint32max))
return MEDIA_CODEC_ERROR;
if (data && !FillInputBuffer(index, data, data_size))
return MEDIA_CODEC_ERROR;
@@ -252,7 +252,7 @@ MediaCodecStatus MediaCodecBridge::QueueSecureInputBuffer(
int subsamples_size,
const base::TimeDelta& presentation_time) {
DVLOG(3) << __PRETTY_FUNCTION__ << index << ": " << data_size;
- if (data_size > base::checked_numeric_cast<size_t>(kint32max))
+ if (data_size > base::checked_cast<size_t>(kint32max))
return MEDIA_CODEC_ERROR;
if (data && !FillInputBuffer(index, data, data_size))
return MEDIA_CODEC_ERROR;
@@ -349,9 +349,9 @@ MediaCodecStatus MediaCodecBridge::DequeueOutputBuffer(
Java_MediaCodecBridge_dequeueOutputBuffer(
env, j_media_codec_.obj(), timeout.InMicroseconds());
*index = Java_DequeueOutputResult_index(env, result.obj());
- *offset = base::checked_numeric_cast<size_t>(
+ *offset = base::checked_cast<size_t>(
Java_DequeueOutputResult_offset(env, result.obj()));
- *size = base::checked_numeric_cast<size_t>(
+ *size = base::checked_cast<size_t>(
Java_DequeueOutputResult_numBytes(env, result.obj()));
if (presentation_time) {
*presentation_time = base::TimeDelta::FromMicroseconds(
@@ -408,7 +408,7 @@ void MediaCodecBridge::GetInputBuffer(int input_buffer_index,
ScopedJavaLocalRef<jobject> j_buffer(Java_MediaCodecBridge_getInputBuffer(
env, j_media_codec_.obj(), input_buffer_index));
*data = static_cast<uint8*>(env->GetDirectBufferAddress(j_buffer.obj()));
- *capacity = base::checked_numeric_cast<size_t>(
+ *capacity = base::checked_cast<size_t>(
env->GetDirectBufferCapacity(j_buffer.obj()));
}
@@ -590,7 +590,7 @@ bool AudioCodecBridge::ConfigureMediaFormat(jobject j_format,
void AudioCodecBridge::PlayOutputBuffer(int index, size_t size) {
DCHECK_LE(0, index);
- int numBytes = base::checked_numeric_cast<int>(size);
+ int numBytes = base::checked_cast<int>(size);
JNIEnv* env = AttachCurrentThread();
ScopedJavaLocalRef<jobject> buf =
Java_MediaCodecBridge_getOutputBuffer(env, media_codec(), index);
diff --git a/media/base/audio_bus.cc b/media/base/audio_bus.cc
index c1123471..c61f2a2 100644
--- a/media/base/audio_bus.cc
+++ b/media/base/audio_bus.cc
@@ -5,7 +5,7 @@
#include "media/base/audio_bus.h"
#include "base/logging.h"
-#include "base/safe_numerics.h"
+#include "base/numerics/safe_conversions.h"
#include "media/audio/audio_parameters.h"
#include "media/base/limits.h"
#include "media/base/vector_math.h"
@@ -130,7 +130,7 @@ AudioBus::AudioBus(int frames, const std::vector<float*>& channel_data)
frames_(frames),
can_set_channel_data_(false) {
ValidateConfig(
- base::checked_numeric_cast<int>(channel_data_.size()), frames_);
+ base::checked_cast<int>(channel_data_.size()), frames_);
// Sanity check wrapped vector for alignment and channel count.
for (size_t i = 0; i < channel_data_.size(); ++i)
diff --git a/net/websockets/websocket_basic_stream.cc b/net/websockets/websocket_basic_stream.cc
index 12472b4..ea26fd8 100644
--- a/net/websockets/websocket_basic_stream.cc
+++ b/net/websockets/websocket_basic_stream.cc
@@ -12,7 +12,7 @@
#include "base/basictypes.h"
#include "base/bind.h"
#include "base/logging.h"
-#include "base/safe_numerics.h"
+#include "base/numerics/safe_conversions.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
#include "net/socket/client_socket_handle.h"
@@ -347,10 +347,10 @@ int WebSocketBasicStream::ConvertChunkToFrame(
// header. A check for exact equality can only be used when the whole frame
// arrives in one chunk.
DCHECK_GE(current_frame_header_->payload_length,
- base::checked_numeric_cast<uint64>(chunk_size));
+ base::checked_cast<uint64>(chunk_size));
DCHECK(!is_first_chunk || !is_final_chunk ||
current_frame_header_->payload_length ==
- base::checked_numeric_cast<uint64>(chunk_size));
+ base::checked_cast<uint64>(chunk_size));
// Convert the chunk to a complete frame.
*frame = CreateFrame(is_final_chunk, data_buffer);
diff --git a/net/websockets/websocket_channel.cc b/net/websockets/websocket_channel.cc
index 34c58b3..c9e6693 100644
--- a/net/websockets/websocket_channel.cc
+++ b/net/websockets/websocket_channel.cc
@@ -9,7 +9,7 @@
#include "base/basictypes.h" // for size_t
#include "base/bind.h"
#include "base/compiler_specific.h"
-#include "base/safe_numerics.h"
+#include "base/numerics/safe_conversions.h"
#include "base/strings/string_util.h"
#include "base/time/time.h"
#include "net/base/big_endian.h"
@@ -190,7 +190,7 @@ void WebSocketChannel::SendFrame(bool fin,
NOTREACHED() << "SendFrame() called in state " << state_;
return;
}
- if (data.size() > base::checked_numeric_cast<size_t>(current_send_quota_)) {
+ if (data.size() > base::checked_cast<size_t>(current_send_quota_)) {
AllowUnused(FailChannel(SEND_GOING_AWAY,
kWebSocketMuxErrorSendQuotaViolation,
"Send quota exceeded"));
diff --git a/net/websockets/websocket_channel_test.cc b/net/websockets/websocket_channel_test.cc
index 2e20f30..292d0b4 100644
--- a/net/websockets/websocket_channel_test.cc
+++ b/net/websockets/websocket_channel_test.cc
@@ -18,7 +18,6 @@
#include "base/memory/scoped_vector.h"
#include "base/memory/weak_ptr.h"
#include "base/message_loop/message_loop.h"
-#include "base/safe_numerics.h"
#include "base/strings/string_piece.h"
#include "net/base/net_errors.h"
#include "net/base/test_completion_callback.h"
diff --git a/ppapi/host/error_conversion.cc b/ppapi/host/error_conversion.cc
index da985d3..2b7d73c 100644
--- a/ppapi/host/error_conversion.cc
+++ b/ppapi/host/error_conversion.cc
@@ -4,7 +4,7 @@
#include "ppapi/host/error_conversion.h"
-#include "base/safe_numerics.h"
+#include "base/numerics/safe_conversions.h"
#include "net/base/net_errors.h"
#include "ppapi/c/pp_errors.h"
@@ -13,7 +13,7 @@ namespace host {
int32_t NetErrorToPepperError(int net_error) {
if (net_error > 0)
- return base::checked_numeric_cast<int32_t>(net_error);
+ return base::checked_cast<int32_t>(net_error);
switch (net_error) {
case net::OK:
diff --git a/printing/image.cc b/printing/image.cc
index b9c0010..1d65f28 100644
--- a/printing/image.cc
+++ b/printing/image.cc
@@ -8,7 +8,7 @@
#include "base/file_util.h"
#include "base/md5.h"
-#include "base/safe_numerics.h"
+#include "base/numerics/safe_conversions.h"
#include "base/strings/string_number_conversions.h"
#include "printing/metafile.h"
#include "printing/metafile_impl.h"
@@ -73,7 +73,7 @@ bool Image::SaveToPng(const base::FilePath& filepath) const {
int write_bytes = file_util::WriteFile(
filepath,
reinterpret_cast<char*>(&*compressed.begin()),
- base::checked_numeric_cast<int>(compressed.size()));
+ base::checked_cast<int>(compressed.size()));
success = (write_bytes == static_cast<int>(compressed.size()));
DCHECK(success);
}
@@ -152,7 +152,7 @@ bool Image::LoadMetafile(const std::string& data) {
DCHECK(!data.empty());
NativeMetafile metafile;
if (!metafile.InitFromData(data.data(),
- base::checked_numeric_cast<uint32>(data.size())))
+ base::checked_cast<uint32>(data.size())))
return false;
return LoadMetafile(metafile);
}
diff --git a/printing/pdf_metafile_skia.cc b/printing/pdf_metafile_skia.cc
index b386cf9..a92bb86 100644
--- a/printing/pdf_metafile_skia.cc
+++ b/printing/pdf_metafile_skia.cc
@@ -8,8 +8,8 @@
#include "base/file_descriptor_posix.h"
#include "base/file_util.h"
#include "base/metrics/histogram.h"
+#include "base/numerics/safe_conversions.h"
#include "base/posix/eintr_wrapper.h"
-#include "base/safe_numerics.h"
#include "skia/ext/refptr.h"
#include "skia/ext/vector_platform_device_skia.h"
#include "third_party/skia/include/core/SkData.h"
@@ -112,7 +112,7 @@ bool PdfMetafileSkia::FinishDocument() {
}
uint32 PdfMetafileSkia::GetDataSize() const {
- return base::checked_numeric_cast<uint32>(data_->pdf_stream_.getOffset());
+ return base::checked_cast<uint32>(data_->pdf_stream_.getOffset());
}
bool PdfMetafileSkia::GetData(void* dst_buffer,
@@ -241,7 +241,7 @@ PdfMetafileSkia* PdfMetafileSkia::GetMetafileForCurrentPage() {
PdfMetafileSkia* metafile = new PdfMetafileSkia;
metafile->InitFromData(data->bytes(),
- base::checked_numeric_cast<uint32>(data->size()));
+ base::checked_cast<uint32>(data->size()));
return metafile;
}
diff --git a/printing/print_destination_win.cc b/printing/print_destination_win.cc
index 6b98f4c..3c4ebc4 100644
--- a/printing/print_destination_win.cc
+++ b/printing/print_destination_win.cc
@@ -4,7 +4,7 @@
#include "printing/print_destination_interface.h"
-#include "base/safe_numerics.h"
+#include "base/numerics/safe_conversions.h"
#include "base/win/metro.h"
#include "win8/util/win8_util.h"
@@ -35,7 +35,7 @@ class PrintDestinationWin : public PrintDestinationInterface {
size_t content_size) {
if (metro_set_print_page_content_)
metro_set_print_page_content_(page_number - 1, content,
- base::checked_numeric_cast<UINT32>(content_size));
+ base::checked_cast<UINT32>(content_size));
}
private:
typedef void (*MetroSetPrintPageCount)(INT);
diff --git a/tools/imagediff/image_diff.cc b/tools/imagediff/image_diff.cc
index 740a397..47d86bb 100644
--- a/tools/imagediff/image_diff.cc
+++ b/tools/imagediff/image_diff.cc
@@ -20,8 +20,8 @@
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
+#include "base/numerics/safe_conversions.h"
#include "base/process/memory.h"
-#include "base/safe_numerics.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "tools/imagediff/image_diff_png.h"
@@ -386,7 +386,7 @@ int DiffImages(const base::FilePath& file1, const base::FilePath& file2,
diff_image.w() * 4, &png_encoding);
if (file_util::WriteFile(out_file,
reinterpret_cast<char*>(&png_encoding.front()),
- base::checked_numeric_cast<int>(png_encoding.size())) < 0)
+ base::checked_cast<int>(png_encoding.size())) < 0)
return kStatusError;
return kStatusDifferent;
diff --git a/ui/base/clipboard/clipboard_win.cc b/ui/base/clipboard/clipboard_win.cc
index 829b1c2b..8ad92ad 100644
--- a/ui/base/clipboard/clipboard_win.cc
+++ b/ui/base/clipboard/clipboard_win.cc
@@ -7,8 +7,8 @@
#include "ui/base/clipboard/clipboard.h"
-#include <shlobj.h>
#include <shellapi.h>
+#include <shlobj.h>
#include "base/basictypes.h"
#include "base/bind.h"
@@ -16,7 +16,7 @@
#include "base/logging.h"
#include "base/memory/shared_memory.h"
#include "base/message_loop/message_loop.h"
-#include "base/safe_numerics.h"
+#include "base/numerics/safe_conversions.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
@@ -518,8 +518,8 @@ void Clipboard::ReadHTML(ClipboardType type,
offsets.push_back(end_index - html_start);
markup->assign(base::UTF8ToUTF16AndAdjustOffsets(cf_html.data() + html_start,
&offsets));
- *fragment_start = base::checked_numeric_cast<uint32>(offsets[0]);
- *fragment_end = base::checked_numeric_cast<uint32>(offsets[1]);
+ *fragment_start = base::checked_cast<uint32>(offsets[0]);
+ *fragment_end = base::checked_cast<uint32>(offsets[1]);
}
void Clipboard::ReadRTF(ClipboardType type, std::string* result) const {
diff --git a/ui/snapshot/snapshot_aura.cc b/ui/snapshot/snapshot_aura.cc
index 94963f3..b926818 100644
--- a/ui/snapshot/snapshot_aura.cc
+++ b/ui/snapshot/snapshot_aura.cc
@@ -7,7 +7,7 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/logging.h"
-#include "base/safe_numerics.h"
+#include "base/numerics/safe_conversions.h"
#include "base/task_runner_util.h"
#include "cc/output/copy_output_request.h"
#include "cc/output/copy_output_result.h"
@@ -85,7 +85,7 @@ scoped_refptr<base::RefCountedBytes> ScaleRotateAndEncodeBitmap(
if (!gfx::PNGCodec::Encode(pixels,
gfx::PNGCodec::FORMAT_BGRA,
gfx::Size(bitmap.width(), bitmap.height()),
- base::checked_numeric_cast<int>(bitmap.rowBytes()),
+ base::checked_cast<int>(bitmap.rowBytes()),
true,
std::vector<gfx::PNGCodec::Comment>(),
&png_data->data())) {
diff --git a/win8/metro_driver/print_document_source.cc b/win8/metro_driver/print_document_source.cc
index 91842b7..34ce227 100644
--- a/win8/metro_driver/print_document_source.cc
+++ b/win8/metro_driver/print_document_source.cc
@@ -8,7 +8,7 @@
#include <windows.graphics.display.h>
#include "base/logging.h"
-#include "base/safe_numerics.h"
+#include "base/numerics/safe_conversions.h"
namespace {
@@ -253,7 +253,7 @@ STDMETHODIMP PrintDocumentSource::Paginate(uint32 page,
return S_FALSE;
hr = dxgi_preview_target_->SetJobPageCount(
PageCountType::FinalPageCount,
- base::checked_numeric_cast<UINT32>(page_count));
+ base::checked_cast<UINT32>(page_count));
if (FAILED(hr)) {
LOG(ERROR) << "Failed to SetJobPageCount " << std::hex << hr;
return hr;
diff --git a/win8/metro_driver/print_handler.cc b/win8/metro_driver/print_handler.cc
index 3539c9e..c409fcd 100644
--- a/win8/metro_driver/print_handler.cc
+++ b/win8/metro_driver/print_handler.cc
@@ -9,7 +9,7 @@
#include "base/bind.h"
#include "base/logging.h"
-#include "base/safe_numerics.h"
+#include "base/numerics/safe_conversions.h"
#include "chrome/app/chrome_command_ids.h"
#include "win8/metro_driver/chrome_app_view.h"
#include "win8/metro_driver/winrt_utils.h"
@@ -474,7 +474,7 @@ void MetroSetPrintPageContent(size_t page_number,
if (metafile_stream.Get() != NULL) {
ULONG bytes_written = 0;
hr = metafile_stream->Write(data,
- base::checked_numeric_cast<ULONG>(data_size),
+ base::checked_cast<ULONG>(data_size),
&bytes_written);
LOG_IF(ERROR, FAILED(hr)) << "Failed to Write to Stream " << std::hex << hr;
DCHECK(bytes_written == data_size);