summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/saved_files_service.cc5
-rw-r--r--base/basictypes.h5
-rw-r--r--base/files/memory_mapped_file.cc15
-rw-r--r--base/files/memory_mapped_file.h20
-rw-r--r--base/files/memory_mapped_file_posix.cc21
-rw-r--r--base/files/memory_mapped_file_unittest.cc12
-rw-r--r--base/files/memory_mapped_file_win.cc24
-rw-r--r--base/json/string_escape.cc18
-rw-r--r--base/strings/string_util.cc22
-rw-r--r--chrome/browser/download/download_query_unittest.cc11
-rw-r--r--chrome/browser/extensions/api/messaging/message_service.cc8
-rw-r--r--chrome/browser/sync/test/integration/two_client_passwords_sync_test.cc8
-rw-r--r--chrome/browser/ui/panels/panel_drag_controller.cc6
-rw-r--r--chrome/common/cloud_print/cloud_print_helpers.cc8
-rw-r--r--chrome/utility/media_galleries/pmp_column_reader.cc6
-rw-r--r--cloud_print/gcp20/prototype/cloud_print_requester.cc8
-rw-r--r--content/browser/appcache/appcache_disk_cache.cc40
-rw-r--r--content/browser/appcache/appcache_disk_cache.h16
-rw-r--r--content/browser/appcache/appcache_response.cc48
-rw-r--r--content/browser/appcache/appcache_response.h63
-rw-r--r--content/browser/renderer_host/render_widget_host_view_mac.h1
-rw-r--r--content/browser/renderer_host/render_widget_host_view_mac.mm9
-rw-r--r--content/common/gpu/media/android_video_encode_accelerator.cc8
-rw-r--r--content/common/gpu/media/android_video_encode_accelerator.h14
-rw-r--r--content/common/mac/font_loader.h7
-rw-r--r--content/common/mac/font_loader.mm21
-rw-r--r--content/public/common/context_menu_params.cc2
-rw-r--r--content/public/common/context_menu_params.h8
-rw-r--r--content/renderer/dom_storage/dom_storage_cached_area.cc7
-rw-r--r--content/renderer/dom_storage/dom_storage_cached_area.h8
-rw-r--r--content/test/fileapi_test_file_set.cc5
-rw-r--r--media/base/android/media_codec_bridge.cc7
-rw-r--r--media/base/android/media_codec_bridge.h12
-rw-r--r--media/base/android/ndk_media_codec_bridge.cc24
-rw-r--r--media/base/android/ndk_media_codec_bridge.h7
-rw-r--r--media/base/android/sdk_media_codec_bridge.cc65
-rw-r--r--media/base/android/sdk_media_codec_bridge.h28
-rw-r--r--media/capture/video/mac/video_capture_device_mac.mm5
-rw-r--r--media/formats/mp4/box_reader.cc61
-rw-r--r--media/formats/mp4/box_reader.h63
-rw-r--r--net/disk_cache/blockfile/backend_worker_v3.cc6
-rw-r--r--net/disk_cache/blockfile/entry_impl.cc51
-rw-r--r--net/disk_cache/blockfile/entry_impl.h36
-rw-r--r--net/disk_cache/blockfile/entry_impl_v3.cc61
-rw-r--r--net/disk_cache/blockfile/entry_impl_v3.h24
-rw-r--r--net/disk_cache/blockfile/eviction.cc8
-rw-r--r--net/disk_cache/blockfile/eviction_v3.cc8
-rw-r--r--net/disk_cache/blockfile/index_table_v3.cc132
-rw-r--r--net/disk_cache/blockfile/index_table_v3.h59
-rw-r--r--net/disk_cache/blockfile/rankings.cc8
-rw-r--r--net/disk_cache/cache_util.cc18
-rw-r--r--net/disk_cache/cache_util.h5
-rw-r--r--net/disk_cache/simple/simple_synchronous_entry.cc136
-rw-r--r--net/disk_cache/simple/simple_synchronous_entry.h84
-rw-r--r--net/http/mock_http_cache.cc24
-rw-r--r--net/http/mock_http_cache.h14
-rw-r--r--net/http/partial_data.cc37
-rw-r--r--net/http/partial_data.h14
-rw-r--r--net/spdy/spdy_session.cc71
-rw-r--r--net/spdy/spdy_session.h41
-rw-r--r--net/spdy/spdy_stream_unittest.cc26
-rw-r--r--ppapi/shared_impl/id_assignment.cc4
-rw-r--r--ui/gfx/color_analysis.cc4
63 files changed, 889 insertions, 708 deletions
diff --git a/apps/saved_files_service.cc b/apps/saved_files_service.cc
index 49d9667..d166338 100644
--- a/apps/saved_files_service.cc
+++ b/apps/saved_files_service.cc
@@ -4,11 +4,12 @@
#include "apps/saved_files_service.h"
+#include <stdint.h>
+
#include <algorithm>
#include <map>
#include "apps/saved_files_service_factory.h"
-#include "base/basictypes.h"
#include "base/containers/scoped_ptr_hash_map.h"
#include "base/value_conversions.h"
#include "chrome/browser/chrome_notification_types.h"
@@ -46,7 +47,7 @@ const char kFileEntryIsDirectory[] = "is_directory";
const char kFileEntrySequenceNumber[] = "sequence_number";
const size_t kMaxSavedFileEntries = 500;
-const int kMaxSequenceNumber = kint32max;
+const int kMaxSequenceNumber = INT32_MAX;
// These might be different to the constant values in tests.
size_t g_max_saved_file_entries = kMaxSavedFileEntries;
diff --git a/base/basictypes.h b/base/basictypes.h
index 0d9d24c..eba9753 100644
--- a/base/basictypes.h
+++ b/base/basictypes.h
@@ -23,9 +23,4 @@ typedef uint32_t uint32;
typedef int64_t int64;
typedef uint64_t uint64;
-// DEPRECATED: Use std::numeric_limits (from <limits>) or
-// (U)INT{8,16,32,64}_{MIN,MAX} in case of globals (and include <stdint.h>).
-// http://crbug.com/138542
-const int32 kint32max = 0x7FFFFFFF;
-
#endif // BASE_BASICTYPES_H_
diff --git a/base/files/memory_mapped_file.cc b/base/files/memory_mapped_file.cc
index 227a41f..6c3f402 100644
--- a/base/files/memory_mapped_file.cc
+++ b/base/files/memory_mapped_file.cc
@@ -74,14 +74,15 @@ bool MemoryMappedFile::IsValid() const {
}
// static
-void MemoryMappedFile::CalculateVMAlignedBoundaries(int64 start,
- int64 size,
- int64* aligned_start,
- int64* aligned_size,
- int32* offset) {
+void MemoryMappedFile::CalculateVMAlignedBoundaries(int64_t start,
+ int64_t size,
+ int64_t* aligned_start,
+ int64_t* aligned_size,
+ int32_t* offset) {
// Sadly, on Windows, the mmap alignment is not just equal to the page size.
- const int64 mask = static_cast<int64>(SysInfo::VMAllocationGranularity()) - 1;
- DCHECK_LT(mask, std::numeric_limits<int32>::max());
+ const int64_t mask =
+ static_cast<int64_t>(SysInfo::VMAllocationGranularity()) - 1;
+ DCHECK_LT(mask, std::numeric_limits<int32_t>::max());
*offset = start & mask;
*aligned_start = start & ~mask;
*aligned_size = (size + *offset + mask) & ~mask;
diff --git a/base/files/memory_mapped_file.h b/base/files/memory_mapped_file.h
index 9ff29b9..fec09e9 100644
--- a/base/files/memory_mapped_file.h
+++ b/base/files/memory_mapped_file.h
@@ -6,8 +6,8 @@
#define BASE_FILES_MEMORY_MAPPED_FILE_H_
#include "base/base_export.h"
-#include "base/basictypes.h"
#include "base/files/file.h"
+#include "base/macros.h"
#include "build/build_config.h"
#if defined(OS_WIN)
@@ -32,10 +32,10 @@ class BASE_EXPORT MemoryMappedFile {
bool operator!=(const Region& other) const;
// Start of the region (measured in bytes from the beginning of the file).
- int64 offset;
+ int64_t offset;
// Length of the region in bytes.
- int64 size;
+ int64_t size;
};
// Opens an existing file and maps it into memory. Access is restricted to
@@ -58,7 +58,7 @@ class BASE_EXPORT MemoryMappedFile {
bool InitializeAsImageSection(const FilePath& file_name);
#endif // OS_WIN
- const uint8* data() const { return data_; }
+ const uint8_t* data() const { return data_; }
size_t length() const { return length_; }
// Is file_ a valid file handle that points to an open, memory mapped file?
@@ -71,11 +71,11 @@ class BASE_EXPORT MemoryMappedFile {
// - |aligned_start| is page aligned and <= |start|.
// - |aligned_size| is a multiple of the VM granularity and >= |size|.
// - |offset| is the displacement of |start| w.r.t |aligned_start|.
- static void CalculateVMAlignedBoundaries(int64 start,
- int64 size,
- int64* aligned_start,
- int64* aligned_size,
- int32* offset);
+ static void CalculateVMAlignedBoundaries(int64_t start,
+ int64_t size,
+ int64_t* aligned_start,
+ int64_t* aligned_size,
+ int32_t* offset);
// Map the file to memory, set data_ to that memory address. Return true on
// success, false on any kind of failure. This is a helper for Initialize().
@@ -85,7 +85,7 @@ class BASE_EXPORT MemoryMappedFile {
void CloseHandles();
File file_;
- uint8* data_;
+ uint8_t* data_;
size_t length_;
#if defined(OS_WIN)
diff --git a/base/files/memory_mapped_file_posix.cc b/base/files/memory_mapped_file_posix.cc
index 168da92..d9a7e90f 100644
--- a/base/files/memory_mapped_file_posix.cc
+++ b/base/files/memory_mapped_file_posix.cc
@@ -23,10 +23,10 @@ bool MemoryMappedFile::MapFileRegionToMemory(
off_t map_start = 0;
size_t map_size = 0;
- int32 data_offset = 0;
+ int32_t data_offset = 0;
if (region == MemoryMappedFile::Region::kWholeFile) {
- int64 file_len = file_.GetLength();
+ int64_t file_len = file_.GetLength();
if (file_len == -1) {
DPLOG(ERROR) << "fstat " << file_.GetPlatformFile();
return false;
@@ -38,8 +38,8 @@ bool MemoryMappedFile::MapFileRegionToMemory(
// start and size to be page-aligned. Hence, we map here the page-aligned
// outer region [|aligned_start|, |aligned_start| + |size|] which contains
// |region| and then add up the |data_offset| displacement.
- int64 aligned_start = 0;
- int64 aligned_size = 0;
+ int64_t aligned_start = 0;
+ int64_t aligned_size = 0;
CalculateVMAlignedBoundaries(region.offset,
region.size,
&aligned_start,
@@ -49,9 +49,10 @@ bool MemoryMappedFile::MapFileRegionToMemory(
// Ensure that the casts in the mmap call below are sane.
if (aligned_start < 0 || aligned_size < 0 ||
aligned_start > std::numeric_limits<off_t>::max() ||
- static_cast<uint64>(aligned_size) >
+ static_cast<uint64_t>(aligned_size) >
std::numeric_limits<size_t>::max() ||
- static_cast<uint64>(region.size) > std::numeric_limits<size_t>::max()) {
+ static_cast<uint64_t>(region.size) >
+ std::numeric_limits<size_t>::max()) {
DLOG(ERROR) << "Region bounds are not valid for mmap";
return false;
}
@@ -61,12 +62,8 @@ bool MemoryMappedFile::MapFileRegionToMemory(
length_ = static_cast<size_t>(region.size);
}
- data_ = static_cast<uint8*>(mmap(NULL,
- map_size,
- PROT_READ,
- MAP_SHARED,
- file_.GetPlatformFile(),
- map_start));
+ data_ = static_cast<uint8_t*>(mmap(NULL, map_size, PROT_READ, MAP_SHARED,
+ file_.GetPlatformFile(), map_start));
if (data_ == MAP_FAILED) {
DPLOG(ERROR) << "mmap " << file_.GetPlatformFile();
return false;
diff --git a/base/files/memory_mapped_file_unittest.cc b/base/files/memory_mapped_file_unittest.cc
index 1812d88..c865e27 100644
--- a/base/files/memory_mapped_file_unittest.cc
+++ b/base/files/memory_mapped_file_unittest.cc
@@ -14,16 +14,16 @@ namespace base {
namespace {
// Create a temporary buffer and fill it with a watermark sequence.
-scoped_ptr<uint8[]> CreateTestBuffer(size_t size, size_t offset) {
- scoped_ptr<uint8[]> buf(new uint8[size]);
+scoped_ptr<uint8_t[]> CreateTestBuffer(size_t size, size_t offset) {
+ scoped_ptr<uint8_t[]> buf(new uint8_t[size]);
for (size_t i = 0; i < size; ++i)
- buf.get()[i] = static_cast<uint8>((offset + i) % 253);
+ buf.get()[i] = static_cast<uint8_t>((offset + i) % 253);
return buf;
}
// Check that the watermark sequence is consistent with the |offset| provided.
-bool CheckBufferContents(const uint8* data, size_t size, size_t offset) {
- scoped_ptr<uint8[]> test_data(CreateTestBuffer(size, offset));
+bool CheckBufferContents(const uint8_t* data, size_t size, size_t offset) {
+ scoped_ptr<uint8_t[]> test_data(CreateTestBuffer(size, offset));
return memcmp(test_data.get(), data, size) == 0;
}
@@ -41,7 +41,7 @@ class MemoryMappedFileTest : public PlatformTest {
File::FLAG_CREATE_ALWAYS | File::FLAG_READ | File::FLAG_WRITE);
EXPECT_TRUE(file.IsValid());
- scoped_ptr<uint8[]> test_data(CreateTestBuffer(size, 0));
+ scoped_ptr<uint8_t[]> test_data(CreateTestBuffer(size, 0));
size_t bytes_written =
file.Write(0, reinterpret_cast<char*>(test_data.get()), size);
EXPECT_EQ(size, bytes_written);
diff --git a/base/files/memory_mapped_file_win.cc b/base/files/memory_mapped_file_win.cc
index 8585906..4d26d82 100644
--- a/base/files/memory_mapped_file_win.cc
+++ b/base/files/memory_mapped_file_win.cc
@@ -4,6 +4,8 @@
#include "base/files/memory_mapped_file.h"
+#include <limits>
+
#include "base/files/file_path.h"
#include "base/strings/string16.h"
#include "base/threading/thread_restrictions.h"
@@ -34,11 +36,11 @@ bool MemoryMappedFile::MapFileRegionToMemory(
LARGE_INTEGER map_start = {};
SIZE_T map_size = 0;
- int32 data_offset = 0;
+ int32_t data_offset = 0;
if (region == MemoryMappedFile::Region::kWholeFile) {
- int64 file_len = file_.GetLength();
- if (file_len <= 0 || file_len > kint32max)
+ int64_t file_len = file_.GetLength();
+ if (file_len <= 0 || file_len > std::numeric_limits<int32_t>::max())
return false;
length_ = static_cast<size_t>(file_len);
} else {
@@ -49,15 +51,15 @@ bool MemoryMappedFile::MapFileRegionToMemory(
// aligned and must be less than or equal the mapped file size.
// We map here the outer region [|aligned_start|, |aligned_start+size|]
// which contains |region| and then add up the |data_offset| displacement.
- int64 aligned_start = 0;
- int64 ignored = 0;
+ int64_t aligned_start = 0;
+ int64_t ignored = 0;
CalculateVMAlignedBoundaries(
region.offset, region.size, &aligned_start, &ignored, &data_offset);
- int64 size = region.size + data_offset;
+ int64_t size = region.size + data_offset;
// Ensure that the casts below in the MapViewOfFile call are sane.
if (aligned_start < 0 || size < 0 ||
- static_cast<uint64>(size) > std::numeric_limits<SIZE_T>::max()) {
+ static_cast<uint64_t>(size) > std::numeric_limits<SIZE_T>::max()) {
DLOG(ERROR) << "Region bounds are not valid for MapViewOfFile";
return false;
}
@@ -66,11 +68,9 @@ bool MemoryMappedFile::MapFileRegionToMemory(
length_ = static_cast<size_t>(region.size);
}
- data_ = static_cast<uint8*>(::MapViewOfFile(file_mapping_.Get(),
- FILE_MAP_READ,
- map_start.HighPart,
- map_start.LowPart,
- map_size));
+ data_ = static_cast<uint8_t*>(
+ ::MapViewOfFile(file_mapping_.Get(), FILE_MAP_READ, map_start.HighPart,
+ map_start.LowPart, map_size));
if (data_ == NULL)
return false;
data_ += data_offset;
diff --git a/base/json/string_escape.cc b/base/json/string_escape.cc
index 3221a3c..28b3ec6 100644
--- a/base/json/string_escape.cc
+++ b/base/json/string_escape.cc
@@ -4,6 +4,9 @@
#include "base/json/string_escape.h"
+#include <stdint.h>
+
+#include <limits>
#include <string>
#include "base/strings/string_util.h"
@@ -20,7 +23,7 @@ namespace {
const char kU16EscapeFormat[] = "\\u%04X";
// The code point to output for an invalid input code unit.
-const uint32 kReplacementCodePoint = 0xFFFD;
+const uint32_t kReplacementCodePoint = 0xFFFD;
// Used below in EscapeSpecialCodePoint().
static_assert('<' == 0x3C, "less than sign must be 0x3c");
@@ -28,7 +31,7 @@ static_assert('<' == 0x3C, "less than sign must be 0x3c");
// Try to escape the |code_point| if it is a known special character. If
// successful, returns true and appends the escape sequence to |dest|. This
// isn't required by the spec, but it's more readable by humans.
-bool EscapeSpecialCodePoint(uint32 code_point, std::string* dest) {
+bool EscapeSpecialCodePoint(uint32_t code_point, std::string* dest) {
// WARNING: if you add a new case here, you need to update the reader as well.
// Note: \v is in the reader, but not here since the JSON spec doesn't
// allow it.
@@ -80,12 +83,13 @@ bool EscapeJSONStringImpl(const S& str, bool put_in_quotes, std::string* dest) {
if (put_in_quotes)
dest->push_back('"');
- // Casting is necessary because ICU uses int32. Try and do so safely.
- CHECK_LE(str.length(), static_cast<size_t>(kint32max));
- const int32 length = static_cast<int32>(str.length());
+ // Casting is necessary because ICU uses int32_t. Try and do so safely.
+ CHECK_LE(str.length(),
+ static_cast<size_t>(std::numeric_limits<int32_t>::max()));
+ const int32_t length = static_cast<int32_t>(str.length());
- for (int32 i = 0; i < length; ++i) {
- uint32 code_point;
+ for (int32_t i = 0; i < length; ++i) {
+ uint32_t code_point;
if (!ReadUnicodeCharacter(str.data(), length, &i, &code_point)) {
code_point = kReplacementCodePoint;
did_replacement = true;
diff --git a/base/strings/string_util.cc b/base/strings/string_util.cc
index 72b8500..39cc6f5 100644
--- a/base/strings/string_util.cc
+++ b/base/strings/string_util.cc
@@ -8,6 +8,7 @@
#include <errno.h>
#include <math.h>
#include <stdarg.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -16,9 +17,9 @@
#include <wctype.h>
#include <algorithm>
+#include <limits>
#include <vector>
-#include "base/basictypes.h"
#include "base/logging.h"
#include "base/memory/singleton.h"
#include "base/strings/string_split.h"
@@ -354,10 +355,11 @@ void TruncateUTF8ToByteSize(const std::string& input,
*output = input;
return;
}
- DCHECK_LE(byte_size, static_cast<uint32>(kint32max));
- // Note: This cast is necessary because CBU8_NEXT uses int32s.
- int32 truncation_length = static_cast<int32>(byte_size);
- int32 char_index = truncation_length - 1;
+ DCHECK_LE(byte_size,
+ static_cast<uint32_t>(std::numeric_limits<int32_t>::max()));
+ // Note: This cast is necessary because CBU8_NEXT uses int32_ts.
+ int32_t truncation_length = static_cast<int32_t>(byte_size);
+ int32_t char_index = truncation_length - 1;
const char* data = input.data();
// Using CBU8, we will move backwards from the truncation point
@@ -365,7 +367,7 @@ void TruncateUTF8ToByteSize(const std::string& input,
// character. Once a full UTF8 character is found, we will
// truncate the string to the end of that character.
while (char_index >= 0) {
- int32 prev = char_index;
+ int32_t prev = char_index;
base_icu::UChar32 code_point = 0;
CBU8_NEXT(data, char_index, truncation_length, code_point);
if (!IsValidCharacter(code_point) ||
@@ -515,11 +517,11 @@ bool IsStringASCII(const std::wstring& str) {
bool IsStringUTF8(const StringPiece& str) {
const char *src = str.data();
- int32 src_len = static_cast<int32>(str.length());
- int32 char_index = 0;
+ int32_t src_len = static_cast<int32_t>(str.length());
+ int32_t char_index = 0;
while (char_index < src_len) {
- int32 code_point;
+ int32_t code_point;
CBU8_NEXT(src, char_index, src_len, code_point);
if (!IsValidCharacter(code_point))
return false;
@@ -672,7 +674,7 @@ static const char* const kByteStringsUnlocalized[] = {
" PB"
};
-string16 FormatBytesUnlocalized(int64 bytes) {
+string16 FormatBytesUnlocalized(int64_t bytes) {
double unit_amount = static_cast<double>(bytes);
size_t dimension = 0;
const int kKilo = 1024;
diff --git a/chrome/browser/download/download_query_unittest.cc b/chrome/browser/download/download_query_unittest.cc
index a5a9a1b..6947055 100644
--- a/chrome/browser/download/download_query_unittest.cc
+++ b/chrome/browser/download/download_query_unittest.cc
@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <stdint.h>
+
+#include <limits>
#include <string>
#include "base/bind.h"
@@ -31,7 +34,7 @@ static const int kSomeKnownTime = 1355864160;
static const char kSomeKnownTime8601[] = "2012-12-18T20:56:0";
static const char k8601Suffix[] = ".000Z";
-bool IdNotEqual(uint32 not_id, const DownloadItem& item) {
+bool IdNotEqual(uint32_t not_id, const DownloadItem& item) {
return item.GetId() != not_id;
}
@@ -157,9 +160,9 @@ TEST_F(DownloadQueryTest, DownloadQueryTest_ZeroItems) {
TEST_F(DownloadQueryTest, DownloadQueryTest_InvalidFilter) {
scoped_ptr<base::Value> value(new base::FundamentalValue(0));
- EXPECT_FALSE(query()->AddFilter(
- static_cast<DownloadQuery::FilterType>(kint32max),
- *value.get()));
+ EXPECT_FALSE(query()->AddFilter(static_cast<DownloadQuery::FilterType>(
+ std::numeric_limits<int32_t>::max()),
+ *value.get()));
}
TEST_F(DownloadQueryTest, DownloadQueryTest_EmptyQuery) {
diff --git a/chrome/browser/extensions/api/messaging/message_service.cc b/chrome/browser/extensions/api/messaging/message_service.cc
index 497bdb0..6cde9dc 100644
--- a/chrome/browser/extensions/api/messaging/message_service.cc
+++ b/chrome/browser/extensions/api/messaging/message_service.cc
@@ -4,6 +4,10 @@
#include "chrome/browser/extensions/api/messaging/message_service.h"
+#include <stdint.h>
+
+#include <limits>
+
#include "base/atomic_sequence_num.h"
#include "base/bind.h"
#include "base/callback.h"
@@ -200,8 +204,8 @@ content::RenderProcessHost*
void MessageService::AllocatePortIdPair(int* port1, int* port2) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
- unsigned channel_id =
- static_cast<unsigned>(g_next_channel_id.GetNext()) % (kint32max/2);
+ unsigned channel_id = static_cast<unsigned>(g_next_channel_id.GetNext()) %
+ (std::numeric_limits<int32_t>::max() / 2);
unsigned port1_id = channel_id * 2;
unsigned port2_id = channel_id * 2 + 1;
diff --git a/chrome/browser/sync/test/integration/two_client_passwords_sync_test.cc b/chrome/browser/sync/test/integration/two_client_passwords_sync_test.cc
index 36677a1..e1b6db0 100644
--- a/chrome/browser/sync/test/integration/two_client_passwords_sync_test.cc
+++ b/chrome/browser/sync/test/integration/two_client_passwords_sync_test.cc
@@ -2,6 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <stdint.h>
+
+#include <limits>
+
#include "base/guid.h"
#include "base/hash.h"
#include "base/rand_util.h"
@@ -219,8 +223,8 @@ IN_PROC_BROWSER_TEST_F(TwoClientPasswordsSyncTest, E2E_ONLY(TwoClientAddPass)) {
// Add one new password per profile. A unique form is created for each to
// prevent them from overwriting each other.
for (int i = 0; i < num_clients(); ++i) {
- AddLogin(GetPasswordStore(i),
- CreateTestPasswordForm(base::RandInt(0, kint32max)));
+ AddLogin(GetPasswordStore(i), CreateTestPasswordForm(base::RandInt(
+ 0, std::numeric_limits<int32_t>::max())));
}
// Blocks and waits for password forms in all profiles to match.
diff --git a/chrome/browser/ui/panels/panel_drag_controller.cc b/chrome/browser/ui/panels/panel_drag_controller.cc
index 0e19fdd..7919310 100644
--- a/chrome/browser/ui/panels/panel_drag_controller.cc
+++ b/chrome/browser/ui/panels/panel_drag_controller.cc
@@ -4,6 +4,10 @@
#include "chrome/browser/ui/panels/panel_drag_controller.h"
+#include <stdint.h>
+
+#include <limits>
+
#include "base/logging.h"
#include "chrome/browser/ui/panels/detached_panel_collection.h"
#include "chrome/browser/ui/panels/detached_panel_drag_handler.h"
@@ -649,7 +653,7 @@ Panel* PanelDragController::FindPanelToGlue(
GlueAction action,
gfx::Rect* target_bounds,
GlueEdge* target_edge) const {
- int best_distance = kint32max;
+ int best_distance = std::numeric_limits<int32_t>::max();
Panel* best_matching_panel = NULL;
// Compute the potential bounds for the dragging panel.
diff --git a/chrome/common/cloud_print/cloud_print_helpers.cc b/chrome/common/cloud_print/cloud_print_helpers.cc
index c2e1614..e11376c 100644
--- a/chrome/common/cloud_print/cloud_print_helpers.cc
+++ b/chrome/common/cloud_print/cloud_print_helpers.cc
@@ -4,6 +4,10 @@
#include "chrome/common/cloud_print/cloud_print_helpers.h"
+#include <stdint.h>
+
+#include <limits>
+
#include "base/json/json_reader.h"
#include "base/logging.h"
#include "base/md5.h"
@@ -205,8 +209,8 @@ std::string GetMultipartMimeType(const std::string& mime_boundary) {
// Create a MIME boundary marker (27 '-' characters followed by 16 hex digits).
void CreateMimeBoundaryForUpload(std::string* out) {
- int r1 = base::RandInt(0, kint32max);
- int r2 = base::RandInt(0, kint32max);
+ int r1 = base::RandInt(0, std::numeric_limits<int32_t>::max());
+ int r2 = base::RandInt(0, std::numeric_limits<int32_t>::max());
base::SStringPrintf(out, "---------------------------%08X%08X", r1, r2);
}
diff --git a/chrome/utility/media_galleries/pmp_column_reader.cc b/chrome/utility/media_galleries/pmp_column_reader.cc
index 56527e0..b85465d 100644
--- a/chrome/utility/media_galleries/pmp_column_reader.cc
+++ b/chrome/utility/media_galleries/pmp_column_reader.cc
@@ -4,7 +4,10 @@
#include "chrome/utility/media_galleries/pmp_column_reader.h"
+#include <stdint.h>
+
#include <cstring>
+#include <limits>
#include "base/files/file.h"
#include "base/files/file_util.h"
@@ -47,7 +50,8 @@ bool PmpColumnReader::ReadFile(base::File* file,
char* data_begin = reinterpret_cast<char*>(data_.get());
- DCHECK(length_ < kint32max); // ReadFile expects an int.
+ DCHECK(length_ <
+ std::numeric_limits<int32_t>::max()); // ReadFile expects an int.
bool success = file->Read(0, data_begin, length_) &&
ParseData(expected_type);
diff --git a/cloud_print/gcp20/prototype/cloud_print_requester.cc b/cloud_print/gcp20/prototype/cloud_print_requester.cc
index cbfdae4..9b94a38 100644
--- a/cloud_print/gcp20/prototype/cloud_print_requester.cc
+++ b/cloud_print/gcp20/prototype/cloud_print_requester.cc
@@ -4,6 +4,10 @@
#include "cloud_print/gcp20/prototype/cloud_print_requester.h"
+#include <stdint.h>
+
+#include <limits>
+
#include "base/bind.h"
#include "base/json/json_writer.h"
#include "base/md5.h"
@@ -122,8 +126,8 @@ void CloudPrintRequester::StartRegistration(const std::string& proxy_id,
const LocalSettings& settings,
const std::string& cdd) {
std::string mime_boundary;
- int r1 = base::RandInt(0, kint32max);
- int r2 = base::RandInt(0, kint32max);
+ int r1 = base::RandInt(0, std::numeric_limits<int32_t>::max());
+ int r2 = base::RandInt(0, std::numeric_limits<int32_t>::max());
base::SStringPrintf(&mime_boundary,
"---------------------------%08X%08X", r1, r2);
diff --git a/content/browser/appcache/appcache_disk_cache.cc b/content/browser/appcache/appcache_disk_cache.cc
index 8419e11..f7cbc58 100644
--- a/content/browser/appcache/appcache_disk_cache.cc
+++ b/content/browser/appcache/appcache_disk_cache.cc
@@ -4,6 +4,8 @@
#include "content/browser/appcache/appcache_disk_cache.h"
+#include <limits>
+
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/files/file_path.h"
@@ -61,11 +63,11 @@ class AppCacheDiskCache::EntryImpl : public Entry {
// Entry implementation.
int Read(int index,
- int64 offset,
+ int64_t offset,
net::IOBuffer* buf,
int buf_len,
const net::CompletionCallback& callback) override {
- if (offset < 0 || offset > kint32max)
+ if (offset < 0 || offset > std::numeric_limits<int32_t>::max())
return net::ERR_INVALID_ARGUMENT;
if (!disk_cache_entry_)
return net::ERR_ABORTED;
@@ -74,11 +76,11 @@ class AppCacheDiskCache::EntryImpl : public Entry {
}
int Write(int index,
- int64 offset,
+ int64_t offset,
net::IOBuffer* buf,
int buf_len,
const net::CompletionCallback& callback) override {
- if (offset < 0 || offset > kint32max)
+ if (offset < 0 || offset > std::numeric_limits<int32_t>::max())
return net::ERR_INVALID_ARGUMENT;
if (!disk_cache_entry_)
return net::ERR_ABORTED;
@@ -87,7 +89,7 @@ class AppCacheDiskCache::EntryImpl : public Entry {
index, static_cast<int>(offset), buf, buf_len, callback, kTruncate);
}
- int64 GetSize(int index) override {
+ int64_t GetSize(int index) override {
return disk_cache_entry_ ? disk_cache_entry_->GetDataSize(index) : 0L;
}
@@ -119,7 +121,8 @@ class AppCacheDiskCache::ActiveCall
: public base::RefCounted<AppCacheDiskCache::ActiveCall> {
public:
static int CreateEntry(const base::WeakPtr<AppCacheDiskCache>& owner,
- int64 key, Entry** entry,
+ int64_t key,
+ Entry** entry,
const net::CompletionCallback& callback) {
scoped_refptr<ActiveCall> active_call(
new ActiveCall(owner, entry, callback));
@@ -130,7 +133,8 @@ class AppCacheDiskCache::ActiveCall
}
static int OpenEntry(const base::WeakPtr<AppCacheDiskCache>& owner,
- int64 key, Entry** entry,
+ int64_t key,
+ Entry** entry,
const net::CompletionCallback& callback) {
scoped_refptr<ActiveCall> active_call(
new ActiveCall(owner, entry, callback));
@@ -141,7 +145,8 @@ class AppCacheDiskCache::ActiveCall
}
static int DoomEntry(const base::WeakPtr<AppCacheDiskCache>& owner,
- int64 key, const net::CompletionCallback& callback) {
+ int64_t key,
+ const net::CompletionCallback& callback) {
scoped_refptr<ActiveCall> active_call(
new ActiveCall(owner, nullptr, callback));
int rv = owner->disk_cache()->DoomEntry(
@@ -253,7 +258,8 @@ void AppCacheDiskCache::Disable() {
disk_cache_.reset();
}
-int AppCacheDiskCache::CreateEntry(int64 key, Entry** entry,
+int AppCacheDiskCache::CreateEntry(int64_t key,
+ Entry** entry,
const net::CompletionCallback& callback) {
DCHECK(entry);
DCHECK(!callback.is_null());
@@ -272,7 +278,8 @@ int AppCacheDiskCache::CreateEntry(int64 key, Entry** entry,
weak_factory_.GetWeakPtr(), key, entry, callback);
}
-int AppCacheDiskCache::OpenEntry(int64 key, Entry** entry,
+int AppCacheDiskCache::OpenEntry(int64_t key,
+ Entry** entry,
const net::CompletionCallback& callback) {
DCHECK(entry);
DCHECK(!callback.is_null());
@@ -291,7 +298,7 @@ int AppCacheDiskCache::OpenEntry(int64 key, Entry** entry,
weak_factory_.GetWeakPtr(), key, entry, callback);
}
-int AppCacheDiskCache::DoomEntry(int64 key,
+int AppCacheDiskCache::DoomEntry(int64_t key,
const net::CompletionCallback& callback) {
DCHECK(!callback.is_null());
if (is_disabled_)
@@ -321,15 +328,12 @@ AppCacheDiskCache::PendingCall::PendingCall()
entry(NULL) {
}
-AppCacheDiskCache::PendingCall::PendingCall(PendingCallType call_type,
- int64 key,
+AppCacheDiskCache::PendingCall::PendingCall(
+ PendingCallType call_type,
+ int64_t key,
Entry** entry,
const net::CompletionCallback& callback)
- : call_type(call_type),
- key(key),
- entry(entry),
- callback(callback) {
-}
+ : call_type(call_type), key(key), entry(entry), callback(callback) {}
AppCacheDiskCache::PendingCall::~PendingCall() {}
diff --git a/content/browser/appcache/appcache_disk_cache.h b/content/browser/appcache/appcache_disk_cache.h
index 98ac3c0..2b8c299 100644
--- a/content/browser/appcache/appcache_disk_cache.h
+++ b/content/browser/appcache/appcache_disk_cache.h
@@ -5,6 +5,8 @@
#ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_DISK_CACHE_H_
#define CONTENT_BROWSER_APPCACHE_APPCACHE_DISK_CACHE_H_
+#include <stdint.h>
+
#include <set>
#include <vector>
@@ -44,13 +46,13 @@ class CONTENT_EXPORT AppCacheDiskCache
void Disable();
bool is_disabled() const { return is_disabled_; }
- int CreateEntry(int64 key,
+ int CreateEntry(int64_t key,
Entry** entry,
const net::CompletionCallback& callback) override;
- int OpenEntry(int64 key,
+ int OpenEntry(int64_t key,
Entry** entry,
const net::CompletionCallback& callback) override;
- int DoomEntry(int64 key, const net::CompletionCallback& callback) override;
+ int DoomEntry(int64_t key, const net::CompletionCallback& callback) override;
void set_is_waiting_to_initialize(bool is_waiting_to_initialize) {
is_waiting_to_initialize_ = is_waiting_to_initialize;
@@ -76,14 +78,16 @@ class CONTENT_EXPORT AppCacheDiskCache
};
struct PendingCall {
PendingCallType call_type;
- int64 key;
+ int64_t key;
Entry** entry;
net::CompletionCallback callback;
PendingCall();
- PendingCall(PendingCallType call_type, int64 key,
- Entry** entry, const net::CompletionCallback& callback);
+ PendingCall(PendingCallType call_type,
+ int64_t key,
+ Entry** entry,
+ const net::CompletionCallback& callback);
~PendingCall();
};
diff --git a/content/browser/appcache/appcache_response.cc b/content/browser/appcache/appcache_response.cc
index 014ecfe..eef2454 100644
--- a/content/browser/appcache/appcache_response.cc
+++ b/content/browser/appcache/appcache_response.cc
@@ -47,12 +47,15 @@ class WrappedPickleIOBuffer : public net::WrappedIOBuffer {
// AppCacheResponseInfo ----------------------------------------------
-AppCacheResponseInfo::AppCacheResponseInfo(
- AppCacheStorage* storage, const GURL& manifest_url,
- int64 response_id, net::HttpResponseInfo* http_info,
- int64 response_data_size)
- : manifest_url_(manifest_url), response_id_(response_id),
- http_response_info_(http_info), response_data_size_(response_data_size),
+AppCacheResponseInfo::AppCacheResponseInfo(AppCacheStorage* storage,
+ const GURL& manifest_url,
+ int64_t response_id,
+ net::HttpResponseInfo* http_info,
+ int64_t response_data_size)
+ : manifest_url_(manifest_url),
+ response_id_(response_id),
+ http_response_info_(http_info),
+ response_data_size_(response_data_size),
storage_(storage) {
DCHECK(http_info);
DCHECK(response_id != kAppCacheNoResponseId);
@@ -75,15 +78,15 @@ HttpResponseInfoIOBuffer::~HttpResponseInfoIOBuffer() {}
// AppCacheResponseIO ----------------------------------------------
-AppCacheResponseIO::AppCacheResponseIO(
- int64 response_id, int64 group_id, AppCacheDiskCacheInterface* disk_cache)
+AppCacheResponseIO::AppCacheResponseIO(int64_t response_id,
+ int64_t group_id,
+ AppCacheDiskCacheInterface* disk_cache)
: response_id_(response_id),
group_id_(group_id),
disk_cache_(disk_cache),
entry_(NULL),
buffer_len_(0),
- weak_factory_(this) {
-}
+ weak_factory_(this) {}
AppCacheResponseIO::~AppCacheResponseIO() {
if (entry_)
@@ -170,16 +173,15 @@ void AppCacheResponseIO::OpenEntryCallback(
// AppCacheResponseReader ----------------------------------------------
AppCacheResponseReader::AppCacheResponseReader(
- int64 response_id,
- int64 group_id,
+ int64_t response_id,
+ int64_t group_id,
AppCacheDiskCacheInterface* disk_cache)
: AppCacheResponseIO(response_id, group_id, disk_cache),
range_offset_(0),
- range_length_(kint32max),
+ range_length_(std::numeric_limits<int32_t>::max()),
read_position_(0),
reading_metadata_size_(0),
- weak_factory_(this) {
-}
+ weak_factory_(this) {}
AppCacheResponseReader::~AppCacheResponseReader() {
}
@@ -266,7 +268,7 @@ void AppCacheResponseReader::OnIOComplete(int result) {
info_buffer_->response_data_size =
entry_->GetSize(kResponseContentIndex);
- int64 metadata_size = entry_->GetSize(kResponseMetadataIndex);
+ int64_t metadata_size = entry_->GetSize(kResponseMetadataIndex);
if (metadata_size > 0) {
reading_metadata_size_ = metadata_size;
info_buffer_->http_info->metadata = new net::IOBufferWithSize(
@@ -296,14 +298,15 @@ void AppCacheResponseReader::OnOpenEntryComplete() {
// AppCacheResponseWriter ----------------------------------------------
AppCacheResponseWriter::AppCacheResponseWriter(
- int64 response_id, int64 group_id, AppCacheDiskCacheInterface* disk_cache)
+ int64_t response_id,
+ int64_t group_id,
+ AppCacheDiskCacheInterface* disk_cache)
: AppCacheResponseIO(response_id, group_id, disk_cache),
info_size_(0),
write_position_(0),
write_amount_(0),
creation_phase_(INITIAL_ATTEMPT),
- weak_factory_(this) {
-}
+ weak_factory_(this) {}
AppCacheResponseWriter::~AppCacheResponseWriter() {
}
@@ -437,13 +440,12 @@ void AppCacheResponseWriter::OnCreateEntryComplete(
// AppCacheResponseMetadataWriter ----------------------------------------------
AppCacheResponseMetadataWriter::AppCacheResponseMetadataWriter(
- int64 response_id,
- int64 group_id,
+ int64_t response_id,
+ int64_t group_id,
AppCacheDiskCacheInterface* disk_cache)
: AppCacheResponseIO(response_id, group_id, disk_cache),
write_amount_(0),
- weak_factory_(this) {
-}
+ weak_factory_(this) {}
AppCacheResponseMetadataWriter::~AppCacheResponseMetadataWriter() {
}
diff --git a/content/browser/appcache/appcache_response.h b/content/browser/appcache/appcache_response.h
index a4c87db..8543b2b 100644
--- a/content/browser/appcache/appcache_response.h
+++ b/content/browser/appcache/appcache_response.h
@@ -5,6 +5,8 @@
#ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_RESPONSE_H_
#define CONTENT_BROWSER_APPCACHE_APPCACHE_RESPONSE_H_
+#include <stdint.h>
+
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
@@ -31,25 +33,27 @@ class CONTENT_EXPORT AppCacheResponseInfo
: public base::RefCounted<AppCacheResponseInfo> {
public:
// AppCacheResponseInfo takes ownership of the http_info.
- AppCacheResponseInfo(AppCacheStorage* storage, const GURL& manifest_url,
- int64 response_id, net::HttpResponseInfo* http_info,
- int64 response_data_size);
+ AppCacheResponseInfo(AppCacheStorage* storage,
+ const GURL& manifest_url,
+ int64_t response_id,
+ net::HttpResponseInfo* http_info,
+ int64_t response_data_size);
const GURL& manifest_url() const { return manifest_url_; }
- int64 response_id() const { return response_id_; }
+ int64_t response_id() const { return response_id_; }
const net::HttpResponseInfo* http_response_info() const {
return http_response_info_.get();
}
- int64 response_data_size() const { return response_data_size_; }
+ int64_t response_data_size() const { return response_data_size_; }
private:
friend class base::RefCounted<AppCacheResponseInfo>;
virtual ~AppCacheResponseInfo();
const GURL manifest_url_;
- const int64 response_id_;
+ const int64_t response_id_;
const scoped_ptr<net::HttpResponseInfo> http_response_info_;
- const int64 response_data_size_;
+ const int64_t response_data_size_;
AppCacheStorage* storage_;
};
@@ -73,21 +77,30 @@ class CONTENT_EXPORT AppCacheDiskCacheInterface {
public:
class Entry {
public:
- virtual int Read(int index, int64 offset, net::IOBuffer* buf, int buf_len,
+ virtual int Read(int index,
+ int64_t offset,
+ net::IOBuffer* buf,
+ int buf_len,
const net::CompletionCallback& callback) = 0;
- virtual int Write(int index, int64 offset, net::IOBuffer* buf, int buf_len,
+ virtual int Write(int index,
+ int64_t offset,
+ net::IOBuffer* buf,
+ int buf_len,
const net::CompletionCallback& callback) = 0;
- virtual int64 GetSize(int index) = 0;
+ virtual int64_t GetSize(int index) = 0;
virtual void Close() = 0;
protected:
virtual ~Entry() {}
};
- virtual int CreateEntry(int64 key, Entry** entry,
+ virtual int CreateEntry(int64_t key,
+ Entry** entry,
const net::CompletionCallback& callback) = 0;
- virtual int OpenEntry(int64 key, Entry** entry,
+ virtual int OpenEntry(int64_t key,
+ Entry** entry,
+ const net::CompletionCallback& callback) = 0;
+ virtual int DoomEntry(int64_t key,
const net::CompletionCallback& callback) = 0;
- virtual int DoomEntry(int64 key, const net::CompletionCallback& callback) = 0;
protected:
friend class base::RefCounted<AppCacheDiskCacheInterface>;
@@ -98,11 +111,11 @@ class CONTENT_EXPORT AppCacheDiskCacheInterface {
class CONTENT_EXPORT AppCacheResponseIO {
public:
virtual ~AppCacheResponseIO();
- int64 response_id() const { return response_id_; }
+ int64_t response_id() const { return response_id_; }
protected:
- AppCacheResponseIO(int64 response_id,
- int64 group_id,
+ AppCacheResponseIO(int64_t response_id,
+ int64_t group_id,
AppCacheDiskCacheInterface* disk_cache);
virtual void OnIOComplete(int result) = 0;
@@ -115,8 +128,8 @@ class CONTENT_EXPORT AppCacheResponseIO {
void WriteRaw(int index, int offset, net::IOBuffer* buf, int buf_len);
void OpenEntryIfNeeded();
- const int64 response_id_;
- const int64 group_id_;
+ const int64_t response_id_;
+ const int64_t group_id_;
AppCacheDiskCacheInterface* disk_cache_;
AppCacheDiskCacheInterface::Entry* entry_;
scoped_refptr<HttpResponseInfoIOBuffer> info_buffer_;
@@ -177,8 +190,8 @@ class CONTENT_EXPORT AppCacheResponseReader
friend class content::MockAppCacheStorage;
// Should only be constructed by the storage class and derivatives.
- AppCacheResponseReader(int64 response_id,
- int64 group_id,
+ AppCacheResponseReader(int64_t response_id,
+ int64_t group_id,
AppCacheDiskCacheInterface* disk_cache);
void OnIOComplete(int result) override;
@@ -230,12 +243,12 @@ class CONTENT_EXPORT AppCacheResponseWriter
bool IsWritePending() { return IsIOPending(); }
// Returns the amount written, info and data.
- int64 amount_written() { return info_size_ + write_position_; }
+ int64_t amount_written() { return info_size_ + write_position_; }
protected:
// Should only be constructed by the storage class and derivatives.
- AppCacheResponseWriter(int64 response_id,
- int64 group_id,
+ AppCacheResponseWriter(int64_t response_id,
+ int64_t group_id,
AppCacheDiskCacheInterface* disk_cache);
private:
@@ -292,8 +305,8 @@ class CONTENT_EXPORT AppCacheResponseMetadataWriter
friend class AppCacheStorageImpl;
friend class content::MockAppCacheStorage;
// Should only be constructed by the storage class and derivatives.
- AppCacheResponseMetadataWriter(int64 response_id,
- int64 group_id,
+ AppCacheResponseMetadataWriter(int64_t response_id,
+ int64_t group_id,
AppCacheDiskCacheInterface* disk_cache);
private:
diff --git a/content/browser/renderer_host/render_widget_host_view_mac.h b/content/browser/renderer_host/render_widget_host_view_mac.h
index 3e0eb39..ad80a2a 100644
--- a/content/browser/renderer_host/render_widget_host_view_mac.h
+++ b/content/browser/renderer_host/render_widget_host_view_mac.h
@@ -15,6 +15,7 @@
#include <vector>
#include "base/mac/scoped_nsobject.h"
+#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/time/time.h"
diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm
index be3ae94..6fda5e1 100644
--- a/content/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
@@ -7,9 +7,11 @@
#import <objc/runtime.h>
#include <OpenGL/gl.h>
#include <QuartzCore/QuartzCore.h>
+#include <stdint.h>
+
+#include <limits>
#include <utility>
-#include "base/basictypes.h"
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/command_line.h"
@@ -1331,7 +1333,7 @@ bool RenderWidgetHostViewMac::GetLineBreakIndex(
// TODO(nona): Bidi support.
const size_t loop_end_idx = std::min(bounds.size(), range.end());
int max_height = 0;
- int min_y_offset = kint32max;
+ int min_y_offset = std::numeric_limits<int32_t>::max();
for (size_t idx = range.start(); idx < loop_end_idx; ++idx) {
max_height = std::max(max_height, bounds[idx].height());
min_y_offset = std::min(min_y_offset, bounds[idx].y());
@@ -1465,7 +1467,8 @@ bool RenderWidgetHostViewMac::HasAcceleratedSurface(
}
void RenderWidgetHostViewMac::OnSwapCompositorFrame(
- uint32 output_surface_id, scoped_ptr<cc::CompositorFrame> frame) {
+ uint32_t output_surface_id,
+ scoped_ptr<cc::CompositorFrame> frame) {
TRACE_EVENT0("browser", "RenderWidgetHostViewMac::OnSwapCompositorFrame");
last_scroll_offset_ = frame->metadata.root_scroll_offset;
diff --git a/content/common/gpu/media/android_video_encode_accelerator.cc b/content/common/gpu/media/android_video_encode_accelerator.cc
index e439203..72689c9 100644
--- a/content/common/gpu/media/android_video_encode_accelerator.cc
+++ b/content/common/gpu/media/android_video_encode_accelerator.cc
@@ -145,7 +145,7 @@ bool AndroidVideoEncodeAccelerator::Initialize(
media::VideoPixelFormat format,
const gfx::Size& input_visible_size,
media::VideoCodecProfile output_profile,
- uint32 initial_bitrate,
+ uint32_t initial_bitrate,
Client* client) {
DVLOG(3) << __PRETTY_FUNCTION__ << " format: " << format
<< ", input_visible_size: " << input_visible_size.ToString()
@@ -268,8 +268,8 @@ void AndroidVideoEncodeAccelerator::UseOutputBitstreamBuffer(
}
void AndroidVideoEncodeAccelerator::RequestEncodingParametersChange(
- uint32 bitrate,
- uint32 framerate) {
+ uint32_t bitrate,
+ uint32_t framerate) {
DVLOG(3) << __PRETTY_FUNCTION__ << ": bitrate: " << bitrate
<< ", framerate: " << framerate;
DCHECK(thread_checker_.CalledOnValidThread());
@@ -393,7 +393,7 @@ void AndroidVideoEncodeAccelerator::DequeueOutput() {
return;
}
- int32 buf_index = 0;
+ int32_t buf_index = 0;
size_t offset = 0;
size_t size = 0;
bool key_frame = false;
diff --git a/content/common/gpu/media/android_video_encode_accelerator.h b/content/common/gpu/media/android_video_encode_accelerator.h
index 367ecf8..1528726 100644
--- a/content/common/gpu/media/android_video_encode_accelerator.h
+++ b/content/common/gpu/media/android_video_encode_accelerator.h
@@ -5,6 +5,8 @@
#ifndef CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_ENCODE_ACCELERATOR_H_
#define CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_ENCODE_ACCELERATOR_H_
+#include <stdint.h>
+
#include <list>
#include <queue>
#include <vector>
@@ -40,13 +42,13 @@ class CONTENT_EXPORT AndroidVideoEncodeAccelerator
bool Initialize(media::VideoPixelFormat format,
const gfx::Size& input_visible_size,
media::VideoCodecProfile output_profile,
- uint32 initial_bitrate,
+ uint32_t initial_bitrate,
Client* client) override;
void Encode(const scoped_refptr<media::VideoFrame>& frame,
bool force_keyframe) override;
void UseOutputBitstreamBuffer(const media::BitstreamBuffer& buffer) override;
- void RequestEncodingParametersChange(uint32 bitrate,
- uint32 framerate) override;
+ void RequestEncodingParametersChange(uint32_t bitrate,
+ uint32_t framerate) override;
void Destroy() override;
private:
@@ -54,7 +56,7 @@ class CONTENT_EXPORT AndroidVideoEncodeAccelerator
// Arbitrary choice.
INITIAL_FRAMERATE = 30,
// Until there are non-realtime users, no need for unrequested I-frames.
- IFRAME_INTERVAL = kint32max,
+ IFRAME_INTERVAL = INT32_MAX,
};
// Impedance-mismatch fixers: MediaCodec is a poll-based API but VEA is a
@@ -93,7 +95,7 @@ class CONTENT_EXPORT AndroidVideoEncodeAccelerator
base::RepeatingTimer io_timer_;
// The difference between number of buffers queued & dequeued at the codec.
- int32 num_buffers_at_codec_;
+ int32_t num_buffers_at_codec_;
// A monotonically-growing value, used as a fake timestamp just to keep things
// appearing to move forward.
@@ -103,7 +105,7 @@ class CONTENT_EXPORT AndroidVideoEncodeAccelerator
int num_output_buffers_; // -1 until RequireBitstreamBuffers.
size_t output_buffers_capacity_; // 0 until RequireBitstreamBuffers.
- uint32 last_set_bitrate_; // In bps.
+ uint32_t last_set_bitrate_; // In bps.
DISALLOW_COPY_AND_ASSIGN(AndroidVideoEncodeAccelerator);
};
diff --git a/content/common/mac/font_loader.h b/content/common/mac/font_loader.h
index 2f9f898..b4bbd47 100644
--- a/content/common/mac/font_loader.h
+++ b/content/common/mac/font_loader.h
@@ -6,6 +6,7 @@
#define CONTENT_COMMON_MAC_FONT_LOADER_H_
#include <ApplicationServices/ApplicationServices.h>
+#include <stdint.h>
#include "base/memory/shared_memory.h"
#include "content/common/content_export.h"
@@ -30,9 +31,9 @@ class FontLoader {
// LoadFont(), which should run on the file thread, then it is passed to a
// task which sends the result to the originating renderer.
struct Result {
- uint32 font_data_size;
+ uint32_t font_data_size;
base::SharedMemory font_data;
- uint32 font_id;
+ uint32_t font_id;
};
// Load a font specified by |font| into a shared memory buffer suitable for
// sending over IPC.
@@ -61,7 +62,7 @@ class FontLoader {
// when done.
CONTENT_EXPORT
static bool CGFontRefFromBuffer(base::SharedMemoryHandle font_data,
- uint32 font_data_size,
+ uint32_t font_data_size,
CGFontRef* out);
};
diff --git a/content/common/mac/font_loader.mm b/content/common/mac/font_loader.mm
index d829175..a533cf2 100644
--- a/content/common/mac/font_loader.mm
+++ b/content/common/mac/font_loader.mm
@@ -6,6 +6,8 @@
#import <Cocoa/Cocoa.h>
+#include <limits>
+
#include "base/basictypes.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
@@ -57,7 +59,7 @@ void _CTFontManagerUnregisterFontForData(NSUInteger, int) {
namespace {
-uint32 GetFontIDForFont(const base::FilePath& font_path) {
+uint32_t GetFontIDForFont(const base::FilePath& font_path) {
// content/common can't depend on content/browser, so this cannot call
// BrowserThread::CurrentlyOn(). Check this is always called on the same
// thread.
@@ -69,14 +71,14 @@ uint32 GetFontIDForFont(const base::FilePath& font_path) {
// ATS is deprecated and CTFont doesn't seem to have a obvious fixed id for a
// font. Since this function is only called from a single thread, use a static
// map to store ids.
- typedef std::map<base::FilePath, uint32> FontIdMap;
+ typedef std::map<base::FilePath, uint32_t> FontIdMap;
CR_DEFINE_STATIC_LOCAL(FontIdMap, font_ids, ());
auto it = font_ids.find(font_path);
if (it != font_ids.end())
return it->second;
- uint32 font_id = font_ids.size() + 1;
+ uint32_t font_id = font_ids.size() + 1;
font_ids[font_path] = font_id;
return font_id;
}
@@ -120,25 +122,26 @@ void FontLoader::LoadFont(const FontDescriptor& font,
base::FilePath font_path = base::mac::NSStringToFilePath([font_url path]);
// Load file into shared memory buffer.
- int64 font_file_size_64 = -1;
+ int64_t font_file_size_64 = -1;
if (!base::GetFileSize(font_path, &font_file_size_64)) {
DLOG(ERROR) << "Couldn't get font file size for " << font_path.value();
return;
}
- if (font_file_size_64 <= 0 || font_file_size_64 >= kint32max) {
+ if (font_file_size_64 <= 0 ||
+ font_file_size_64 >= std::numeric_limits<int32_t>::max()) {
DLOG(ERROR) << "Bad size for font file " << font_path.value();
return;
}
- int32 font_file_size_32 = static_cast<int32>(font_file_size_64);
+ int32_t font_file_size_32 = static_cast<int32_t>(font_file_size_64);
if (!result->font_data.CreateAndMapAnonymous(font_file_size_32)) {
DLOG(ERROR) << "Failed to create shmem area for " << font.font_name;
return;
}
- int32 amt_read = base::ReadFile(font_path,
- reinterpret_cast<char*>(result->font_data.memory()),
+ int32_t amt_read = base::ReadFile(
+ font_path, reinterpret_cast<char*>(result->font_data.memory()),
font_file_size_32);
if (amt_read != font_file_size_32) {
DLOG(ERROR) << "Failed to read font data for " << font_path.value();
@@ -151,7 +154,7 @@ void FontLoader::LoadFont(const FontDescriptor& font,
// static
bool FontLoader::CGFontRefFromBuffer(base::SharedMemoryHandle font_data,
- uint32 font_data_size,
+ uint32_t font_data_size,
CGFontRef* out) {
*out = NULL;
diff --git a/content/public/common/context_menu_params.cc b/content/public/common/context_menu_params.cc
index 9fc1d3d..ebd5455 100644
--- a/content/public/common/context_menu_params.cc
+++ b/content/public/common/context_menu_params.cc
@@ -6,7 +6,7 @@
namespace content {
-const int32 CustomContextMenuContext::kCurrentRenderWidget = kint32max;
+const int32_t CustomContextMenuContext::kCurrentRenderWidget = INT32_MAX;
CustomContextMenuContext::CustomContextMenuContext()
: is_pepper_menu(false),
diff --git a/content/public/common/context_menu_params.h b/content/public/common/context_menu_params.h
index 15b0598..f3d89c9 100644
--- a/content/public/common/context_menu_params.h
+++ b/content/public/common/context_menu_params.h
@@ -5,6 +5,8 @@
#ifndef CONTENT_PUBLIC_COMMON_CONTEXT_MENU_PARAMS_H_
#define CONTENT_PUBLIC_COMMON_CONTEXT_MENU_PARAMS_H_
+#include <stdint.h>
+
#include <map>
#include <string>
#include <vector>
@@ -27,7 +29,7 @@
namespace content {
struct CONTENT_EXPORT CustomContextMenuContext {
- static const int32 kCurrentRenderWidget;
+ static const int32_t kCurrentRenderWidget;
CustomContextMenuContext();
@@ -36,7 +38,7 @@ struct CONTENT_EXPORT CustomContextMenuContext {
// The routing ID of the render widget on which the context menu is shown.
// It could also be |kCurrentRenderWidget|, which means the render widget that
// the corresponding ViewHostMsg_ContextMenu is sent to.
- int32 render_widget_id;
+ int32_t render_widget_id;
// If the context menu was created for a link, and we navigated to that url,
// this will contain the url that was navigated. This field may not be set
@@ -118,7 +120,7 @@ struct CONTENT_EXPORT ContextMenuParams {
base::string16 misspelled_word;
// The identifier of the misspelling under the cursor, if any.
- uint32 misspelling_hash;
+ uint32_t misspelling_hash;
// Suggested replacements for a misspelled word under the cursor.
// This vector gets populated in the render process host
diff --git a/content/renderer/dom_storage/dom_storage_cached_area.cc b/content/renderer/dom_storage/dom_storage_cached_area.cc
index a01d3c6..23f3d35 100644
--- a/content/renderer/dom_storage/dom_storage_cached_area.cc
+++ b/content/renderer/dom_storage/dom_storage_cached_area.cc
@@ -4,7 +4,8 @@
#include "content/renderer/dom_storage/dom_storage_cached_area.h"
-#include "base/basictypes.h"
+#include <limits>
+
#include "base/metrics/histogram.h"
#include "base/time/time.h"
#include "content/common/dom_storage/dom_storage_map.h"
@@ -12,7 +13,7 @@
namespace content {
-DOMStorageCachedArea::DOMStorageCachedArea(int64 namespace_id,
+DOMStorageCachedArea::DOMStorageCachedArea(int64_t namespace_id,
const GURL& origin,
DOMStorageProxy* proxy)
: ignore_all_mutations_(false),
@@ -134,7 +135,7 @@ void DOMStorageCachedArea::ApplyMutation(
// We turn off quota checking here to accomodate the over budget
// allowance that's provided in the browser process.
base::NullableString16 unused;
- map_->set_quota(kint32max);
+ map_->set_quota(std::numeric_limits<int32_t>::max());
map_->SetItem(key.string(), new_value.string(), &unused);
map_->set_quota(kPerStorageAreaQuota);
}
diff --git a/content/renderer/dom_storage/dom_storage_cached_area.h b/content/renderer/dom_storage/dom_storage_cached_area.h
index b991038..cf345fa 100644
--- a/content/renderer/dom_storage/dom_storage_cached_area.h
+++ b/content/renderer/dom_storage/dom_storage_cached_area.h
@@ -5,6 +5,8 @@
#ifndef CONTENT_RENDERER_DOM_STORAGE_DOM_STORAGE_CACHED_AREA_H_
#define CONTENT_RENDERER_DOM_STORAGE_DOM_STORAGE_CACHED_AREA_H_
+#include <stdint.h>
+
#include <map>
#include "base/memory/ref_counted.h"
@@ -27,11 +29,11 @@ class DOMStorageProxy;
class CONTENT_EXPORT DOMStorageCachedArea
: public base::RefCounted<DOMStorageCachedArea> {
public:
- DOMStorageCachedArea(int64 namespace_id,
+ DOMStorageCachedArea(int64_t namespace_id,
const GURL& origin,
DOMStorageProxy* proxy);
- int64 namespace_id() const { return namespace_id_; }
+ int64_t namespace_id() const { return namespace_id_; }
const GURL& origin() const { return origin_; }
unsigned GetLength(int connection_id);
@@ -82,7 +84,7 @@ class CONTENT_EXPORT DOMStorageCachedArea
bool ignore_all_mutations_;
std::map<base::string16, int> ignore_key_mutations_;
- int64 namespace_id_;
+ int64_t namespace_id_;
GURL origin_;
scoped_refptr<DOMStorageMap> map_;
scoped_refptr<DOMStorageProxy> proxy_;
diff --git a/content/test/fileapi_test_file_set.cc b/content/test/fileapi_test_file_set.cc
index f8e14e6..8c2636a 100644
--- a/content/test/fileapi_test_file_set.cc
+++ b/content/test/fileapi_test_file_set.cc
@@ -4,6 +4,9 @@
#include "content/test/fileapi_test_file_set.h"
+#include <stdint.h>
+
+#include <limits>
#include <string>
#include "base/files/file.h"
@@ -50,7 +53,7 @@ void SetUpOneFileSystemTestCase(const base::FilePath& root_path,
ASSERT_TRUE(file.IsValid());
if (test_case.data_file_size) {
std::string content = base::RandBytesAsString(test_case.data_file_size);
- EXPECT_LE(test_case.data_file_size, kint32max);
+ EXPECT_LE(test_case.data_file_size, std::numeric_limits<int32_t>::max());
ASSERT_EQ(static_cast<int>(content.size()),
file.Write(0, content.data(), static_cast<int>(content.size())));
}
diff --git a/media/base/android/media_codec_bridge.cc b/media/base/android/media_codec_bridge.cc
index c242dba..6ca7e48 100644
--- a/media/base/android/media_codec_bridge.cc
+++ b/media/base/android/media_codec_bridge.cc
@@ -10,7 +10,6 @@
#include "base/android/jni_android.h"
#include "base/android/jni_array.h"
#include "base/android/jni_string.h"
-#include "base/basictypes.h"
#include "base/logging.h"
#include "base/strings/string_util.h"
#include "media/base/decrypt_config.h"
@@ -29,7 +28,7 @@ MediaCodecBridge::~MediaCodecBridge() {}
MediaCodecStatus MediaCodecBridge::QueueSecureInputBuffer(
int index,
- const uint8* data,
+ const uint8_t* data,
size_t data_size,
const std::string& key_id,
const std::string& iv,
@@ -51,9 +50,9 @@ size_t MediaCodecBridge::GetOutputBuffersCapacity() {
}
bool MediaCodecBridge::FillInputBuffer(int index,
- const uint8* data,
+ const uint8_t* data,
size_t size) {
- uint8* dst = nullptr;
+ uint8_t* dst = nullptr;
size_t capacity = 0;
GetInputBuffer(index, &dst, &capacity);
CHECK(dst);
diff --git a/media/base/android/media_codec_bridge.h b/media/base/android/media_codec_bridge.h
index 0719448..02a29f9 100644
--- a/media/base/android/media_codec_bridge.h
+++ b/media/base/android/media_codec_bridge.h
@@ -5,6 +5,8 @@
#ifndef MEDIA_BASE_ANDROID_MEDIA_CODEC_BRIDGE_H_
#define MEDIA_BASE_ANDROID_MEDIA_CODEC_BRIDGE_H_
+#include <stdint.h>
+
#include <set>
#include <string>
#include <vector>
@@ -74,7 +76,7 @@ class MEDIA_EXPORT MediaCodecBridge {
// |data_size| must be less than kint32max (because Java).
virtual MediaCodecStatus QueueInputBuffer(
int index,
- const uint8* data,
+ const uint8_t* data,
size_t data_size,
const base::TimeDelta& presentation_time) = 0;
@@ -84,7 +86,7 @@ class MEDIA_EXPORT MediaCodecBridge {
// |data_size|). |data_size| must be less than kint32max (because Java).
MediaCodecStatus QueueSecureInputBuffer(
int index,
- const uint8* data,
+ const uint8_t* data,
size_t data_size,
const std::string& key_id,
const std::string& iv,
@@ -97,7 +99,7 @@ class MEDIA_EXPORT MediaCodecBridge {
// switch to the Spitzer pipeline.
virtual MediaCodecStatus QueueSecureInputBuffer(
int index,
- const uint8* data,
+ const uint8_t* data,
size_t data_size,
const std::vector<char>& key_id,
const std::vector<char>& iv,
@@ -149,7 +151,7 @@ class MEDIA_EXPORT MediaCodecBridge {
// Returns an input buffer's base pointer and capacity.
virtual void GetInputBuffer(int input_buffer_index,
- uint8** data,
+ uint8_t** data,
size_t* capacity) = 0;
// Copy |dst_size| bytes from output buffer |index|'s |offset| onwards into
@@ -165,7 +167,7 @@ class MEDIA_EXPORT MediaCodecBridge {
// Fills a particular input buffer; returns false if |data_size| exceeds the
// input buffer's capacity (and doesn't touch the input buffer in that case).
bool FillInputBuffer(int index,
- const uint8* data,
+ const uint8_t* data,
size_t data_size) WARN_UNUSED_RESULT;
DISALLOW_COPY_AND_ASSIGN(MediaCodecBridge);
diff --git a/media/base/android/ndk_media_codec_bridge.cc b/media/base/android/ndk_media_codec_bridge.cc
index ae23aff..2ce2a0f 100644
--- a/media/base/android/ndk_media_codec_bridge.cc
+++ b/media/base/android/ndk_media_codec_bridge.cc
@@ -7,6 +7,8 @@
#include <media/NdkMediaError.h>
#include <media/NdkMediaFormat.h>
+#include <limits>
+
#include "base/strings/string_util.h"
#include "media/base/decrypt_config.h"
@@ -91,11 +93,13 @@ int NdkMediaCodecBridge::GetOutputSamplingRate() {
MediaCodecStatus NdkMediaCodecBridge::QueueInputBuffer(
int index,
- const uint8* data,
+ const uint8_t* data,
size_t data_size,
const base::TimeDelta& presentation_time) {
- if (data_size > base::checked_cast<size_t>(kint32max))
+ if (data_size >
+ base::checked_cast<size_t>(std::numeric_limits<int32_t>::max())) {
return MEDIA_CODEC_ERROR;
+ }
if (data && !FillInputBuffer(index, data, data_size))
return MEDIA_CODEC_ERROR;
@@ -107,15 +111,17 @@ MediaCodecStatus NdkMediaCodecBridge::QueueInputBuffer(
MediaCodecStatus NdkMediaCodecBridge::QueueSecureInputBuffer(
int index,
- const uint8* data,
+ const uint8_t* data,
size_t data_size,
const std::vector<char>& key_id,
const std::vector<char>& iv,
const SubsampleEntry* subsamples,
int subsamples_size,
const base::TimeDelta& presentation_time) {
- if (data_size > base::checked_cast<size_t>(kint32max))
+ if (data_size >
+ base::checked_cast<size_t>(std::numeric_limits<int32_t>::max())) {
return MEDIA_CODEC_ERROR;
+ }
if (key_id.size() > 16 || iv.size())
return MEDIA_CODEC_ERROR;
if (data && !FillInputBuffer(index, data, data_size))
@@ -131,9 +137,9 @@ MediaCodecStatus NdkMediaCodecBridge::QueueSecureInputBuffer(
DCHECK_GT(subsamples_size, 0);
DCHECK(subsamples);
for (int i = 0; i < subsamples_size; ++i) {
- DCHECK(subsamples[i].clear_bytes <= std::numeric_limits<uint16>::max());
+ DCHECK(subsamples[i].clear_bytes <= std::numeric_limits<uint16_t>::max());
if (subsamples[i].cypher_bytes >
- static_cast<uint32>(std::numeric_limits<int32>::max())) {
+ static_cast<uint32_t>(std::numeric_limits<int32_t>::max())) {
return MEDIA_CODEC_ERROR;
}
clear_data.push_back(subsamples[i].clear_bytes);
@@ -143,8 +149,8 @@ MediaCodecStatus NdkMediaCodecBridge::QueueSecureInputBuffer(
AMediaCodecCryptoInfo* crypto_info = AMediaCodecCryptoInfo_new(
new_subsamples_size,
- reinterpret_cast<uint8*>(const_cast<char*>(key_id.data())),
- reinterpret_cast<uint8*>(const_cast<char*>(iv.data())),
+ reinterpret_cast<uint8_t*>(const_cast<char*>(key_id.data())),
+ reinterpret_cast<uint8_t*>(const_cast<char*>(iv.data())),
AMEDIACODECRYPTOINFO_MODE_AES_CTR, clear_data.data(),
encrypted_data.data());
@@ -204,7 +210,7 @@ void NdkMediaCodecBridge::ReleaseOutputBuffer(int index, bool render) {
}
void NdkMediaCodecBridge::GetInputBuffer(int input_buffer_index,
- uint8** data,
+ uint8_t** data,
size_t* capacity) {
*data = AMediaCodec_getInputBuffer(media_codec_.get(), input_buffer_index,
capacity);
diff --git a/media/base/android/ndk_media_codec_bridge.h b/media/base/android/ndk_media_codec_bridge.h
index 75bada9..d16d6f8 100644
--- a/media/base/android/ndk_media_codec_bridge.h
+++ b/media/base/android/ndk_media_codec_bridge.h
@@ -6,6 +6,7 @@
#define MEDIA_BASE_ANDROID_NDK_MEDIA_CODEC_BRIDGE_H_
#include <media/NdkMediaCodec.h>
+#include <stdint.h>
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
@@ -27,13 +28,13 @@ class MEDIA_EXPORT NdkMediaCodecBridge : public MediaCodecBridge {
int GetOutputSamplingRate() override;
MediaCodecStatus QueueInputBuffer(
int index,
- const uint8* data,
+ const uint8_t* data,
size_t data_size,
const base::TimeDelta& presentation_time) override;
using MediaCodecBridge::QueueSecureInputBuffer;
MediaCodecStatus QueueSecureInputBuffer(
int index,
- const uint8* data,
+ const uint8_t* data,
size_t data_size,
const std::vector<char>& key_id,
const std::vector<char>& iv,
@@ -52,7 +53,7 @@ class MEDIA_EXPORT NdkMediaCodecBridge : public MediaCodecBridge {
bool* key_frame) override;
void ReleaseOutputBuffer(int index, bool render) override;
void GetInputBuffer(int input_buffer_index,
- uint8** data,
+ uint8_t** data,
size_t* capacity) override;
bool CopyFromOutputBuffer(int index,
size_t offset,
diff --git a/media/base/android/sdk_media_codec_bridge.cc b/media/base/android/sdk_media_codec_bridge.cc
index 01cfa3f..0c6e25f 100644
--- a/media/base/android/sdk_media_codec_bridge.cc
+++ b/media/base/android/sdk_media_codec_bridge.cc
@@ -5,6 +5,7 @@
#include "media/base/android/sdk_media_codec_bridge.h"
#include <algorithm>
+#include <limits>
#include "base/android/build_info.h"
#include "base/android/jni_android.h"
@@ -126,12 +127,14 @@ int SdkMediaCodecBridge::GetOutputSamplingRate() {
MediaCodecStatus SdkMediaCodecBridge::QueueInputBuffer(
int index,
- const uint8* data,
+ const uint8_t* data,
size_t data_size,
const base::TimeDelta& presentation_time) {
DVLOG(3) << __PRETTY_FUNCTION__ << index << ": " << data_size;
- if (data_size > base::checked_cast<size_t>(kint32max))
+ if (data_size >
+ base::checked_cast<size_t>(std::numeric_limits<int32_t>::max())) {
return MEDIA_CODEC_ERROR;
+ }
if (data && !FillInputBuffer(index, data, data_size))
return MEDIA_CODEC_ERROR;
JNIEnv* env = AttachCurrentThread();
@@ -144,7 +147,7 @@ MediaCodecStatus SdkMediaCodecBridge::QueueInputBuffer(
// interface after we switch to Spitzer pipeline.
MediaCodecStatus SdkMediaCodecBridge::QueueSecureInputBuffer(
int index,
- const uint8* data,
+ const uint8_t* data,
size_t data_size,
const std::vector<char>& key_id,
const std::vector<char>& iv,
@@ -152,16 +155,18 @@ MediaCodecStatus SdkMediaCodecBridge::QueueSecureInputBuffer(
int subsamples_size,
const base::TimeDelta& presentation_time) {
DVLOG(3) << __PRETTY_FUNCTION__ << index << ": " << data_size;
- if (data_size > base::checked_cast<size_t>(kint32max))
+ if (data_size >
+ base::checked_cast<size_t>(std::numeric_limits<int32_t>::max())) {
return MEDIA_CODEC_ERROR;
+ }
if (data && !FillInputBuffer(index, data, data_size))
return MEDIA_CODEC_ERROR;
JNIEnv* env = AttachCurrentThread();
ScopedJavaLocalRef<jbyteArray> j_key_id = base::android::ToJavaByteArray(
- env, reinterpret_cast<const uint8*>(key_id.data()), key_id.size());
+ env, reinterpret_cast<const uint8_t*>(key_id.data()), key_id.size());
ScopedJavaLocalRef<jbyteArray> j_iv = base::android::ToJavaByteArray(
- env, reinterpret_cast<const uint8*>(iv.data()), iv.size());
+ env, reinterpret_cast<const uint8_t*>(iv.data()), iv.size());
// MediaCodec.CryptoInfo documentations says passing NULL for |clear_array|
// to indicate that all data is encrypted. But it doesn't specify what
@@ -180,9 +185,9 @@ MediaCodecStatus SdkMediaCodecBridge::QueueSecureInputBuffer(
DCHECK_GT(subsamples_size, 0);
DCHECK(subsamples);
for (int i = 0; i < subsamples_size; ++i) {
- DCHECK(subsamples[i].clear_bytes <= std::numeric_limits<uint16>::max());
+ DCHECK(subsamples[i].clear_bytes <= std::numeric_limits<uint16_t>::max());
if (subsamples[i].cypher_bytes >
- static_cast<uint32>(std::numeric_limits<jint>::max())) {
+ static_cast<uint32_t>(std::numeric_limits<jint>::max())) {
return MEDIA_CODEC_ERROR;
}
@@ -281,12 +286,12 @@ size_t SdkMediaCodecBridge::GetOutputBuffersCapacity() {
}
void SdkMediaCodecBridge::GetInputBuffer(int input_buffer_index,
- uint8** data,
+ uint8_t** data,
size_t* capacity) {
JNIEnv* env = AttachCurrentThread();
ScopedJavaLocalRef<jobject> j_buffer(Java_MediaCodecBridge_getInputBuffer(
env, j_media_codec_.obj(), input_buffer_index));
- *data = static_cast<uint8*>(env->GetDirectBufferAddress(j_buffer.obj()));
+ *data = static_cast<uint8_t*>(env->GetDirectBufferAddress(j_buffer.obj()));
*capacity =
base::checked_cast<size_t>(env->GetDirectBufferCapacity(j_buffer.obj()));
}
@@ -301,7 +306,7 @@ bool SdkMediaCodecBridge::CopyFromOutputBuffer(int index,
src_capacity - offset < static_cast<size_t>(dst_size)) {
return false;
}
- memcpy(dst, static_cast<uint8*>(src_data) + offset, dst_size);
+ memcpy(dst, static_cast<uint8_t*>(src_data) + offset, dst_size);
return true;
}
@@ -312,7 +317,7 @@ int SdkMediaCodecBridge::GetOutputBufferAddress(int index,
ScopedJavaLocalRef<jobject> j_buffer(
Java_MediaCodecBridge_getOutputBuffer(env, j_media_codec_.obj(), index));
*addr =
- reinterpret_cast<uint8*>(env->GetDirectBufferAddress(j_buffer.obj())) +
+ reinterpret_cast<uint8_t*>(env->GetDirectBufferAddress(j_buffer.obj())) +
offset;
return env->GetDirectBufferCapacity(j_buffer.obj()) - offset;
}
@@ -345,10 +350,10 @@ AudioCodecBridge::AudioCodecBridge(const std::string& mime)
bool AudioCodecBridge::ConfigureAndStart(const AudioCodec& codec,
int sample_rate,
int channel_count,
- const uint8* extra_data,
+ const uint8_t* extra_data,
size_t extra_data_size,
- int64 codec_delay_ns,
- int64 seek_preroll_ns,
+ int64_t codec_delay_ns,
+ int64_t seek_preroll_ns,
bool play_audio,
jobject media_crypto) {
JNIEnv* env = AttachCurrentThread();
@@ -381,10 +386,10 @@ bool AudioCodecBridge::ConfigureAndStart(const AudioCodec& codec,
bool AudioCodecBridge::ConfigureMediaFormat(jobject j_format,
const AudioCodec& codec,
- const uint8* extra_data,
+ const uint8_t* extra_data,
size_t extra_data_size,
- int64 codec_delay_ns,
- int64 seek_preroll_ns) {
+ int64_t codec_delay_ns,
+ int64_t seek_preroll_ns) {
if (extra_data_size == 0 && codec != kCodecOpus)
return true;
@@ -401,7 +406,7 @@ bool AudioCodecBridge::ConfigureMediaFormat(jobject j_format,
// |total_length| keeps track of the total number of bytes before the last
// header.
size_t total_length = 1;
- const uint8* current_pos = extra_data;
+ const uint8_t* current_pos = extra_data;
// Calculate the length of the first 2 headers.
for (int i = 0; i < 2; ++i) {
header_length[i] = 0;
@@ -440,9 +445,9 @@ bool AudioCodecBridge::ConfigureMediaFormat(jobject j_format,
// The following code is copied from aac.cc
// TODO(qinmin): refactor the code in aac.cc to make it more reusable.
- uint8 profile = 0;
- uint8 frequency_index = 0;
- uint8 channel_config = 0;
+ uint8_t profile = 0;
+ uint8_t frequency_index = 0;
+ uint8_t channel_config = 0;
RETURN_ON_ERROR(reader.ReadBits(5, &profile));
RETURN_ON_ERROR(reader.ReadBits(4, &frequency_index));
@@ -464,7 +469,7 @@ bool AudioCodecBridge::ConfigureMediaFormat(jobject j_format,
return false;
}
const size_t kCsdLength = 2;
- uint8 csd[kCsdLength];
+ uint8_t csd[kCsdLength];
csd[0] = profile << 3 | frequency_index >> 1;
csd[1] = (frequency_index & 0x01) << 7 | channel_config << 3;
ScopedJavaLocalRef<jbyteArray> byte_array =
@@ -491,13 +496,13 @@ bool AudioCodecBridge::ConfigureMediaFormat(jobject j_format,
// csd1 - Codec Delay
ScopedJavaLocalRef<jbyteArray> csd1 = base::android::ToJavaByteArray(
- env, reinterpret_cast<const uint8*>(&codec_delay_ns),
+ env, reinterpret_cast<const uint8_t*>(&codec_delay_ns),
sizeof(int64_t));
Java_MediaCodecBridge_setCodecSpecificData(env, j_format, 1, csd1.obj());
// csd2 - Seek Preroll
ScopedJavaLocalRef<jbyteArray> csd2 = base::android::ToJavaByteArray(
- env, reinterpret_cast<const uint8*>(&seek_preroll_ns),
+ env, reinterpret_cast<const uint8_t*>(&seek_preroll_ns),
sizeof(int64_t));
Java_MediaCodecBridge_setCodecSpecificData(env, j_format, 2, csd2.obj());
break;
@@ -510,10 +515,10 @@ bool AudioCodecBridge::ConfigureMediaFormat(jobject j_format,
return true;
}
-int64 AudioCodecBridge::PlayOutputBuffer(int index,
- size_t size,
- size_t offset,
- bool postpone) {
+int64_t AudioCodecBridge::PlayOutputBuffer(int index,
+ size_t size,
+ size_t offset,
+ bool postpone) {
DCHECK_LE(0, index);
int numBytes = base::checked_cast<int>(size);
@@ -524,7 +529,7 @@ int64 AudioCodecBridge::PlayOutputBuffer(int index,
JNIEnv* env = AttachCurrentThread();
ScopedJavaLocalRef<jbyteArray> byte_array = base::android::ToJavaByteArray(
- env, static_cast<uint8*>(buffer), numBytes);
+ env, static_cast<uint8_t*>(buffer), numBytes);
return Java_MediaCodecBridge_playOutputBuffer(env, media_codec(),
byte_array.obj(), postpone);
}
diff --git a/media/base/android/sdk_media_codec_bridge.h b/media/base/android/sdk_media_codec_bridge.h
index 3518ad7..c495ffc9 100644
--- a/media/base/android/sdk_media_codec_bridge.h
+++ b/media/base/android/sdk_media_codec_bridge.h
@@ -6,6 +6,8 @@
#define MEDIA_BASE_ANDROID_SDK_MEDIA_CODEC_BRIDGE_H_
#include <jni.h>
+#include <stdint.h>
+
#include <set>
#include <string>
@@ -33,13 +35,13 @@ class MEDIA_EXPORT SdkMediaCodecBridge : public MediaCodecBridge {
int GetOutputSamplingRate() override;
MediaCodecStatus QueueInputBuffer(
int index,
- const uint8* data,
+ const uint8_t* data,
size_t data_size,
const base::TimeDelta& presentation_time) override;
using MediaCodecBridge::QueueSecureInputBuffer;
MediaCodecStatus QueueSecureInputBuffer(
int index,
- const uint8* data,
+ const uint8_t* data,
size_t data_size,
const std::vector<char>& key_id,
const std::vector<char>& iv,
@@ -60,7 +62,7 @@ class MEDIA_EXPORT SdkMediaCodecBridge : public MediaCodecBridge {
int GetOutputBuffersCount() override;
size_t GetOutputBuffersCapacity() override;
void GetInputBuffer(int input_buffer_index,
- uint8** data,
+ uint8_t** data,
size_t* capacity) override;
bool CopyFromOutputBuffer(int index,
size_t offset,
@@ -105,10 +107,10 @@ class MEDIA_EXPORT AudioCodecBridge : public SdkMediaCodecBridge {
bool ConfigureAndStart(const AudioCodec& codec,
int sample_rate,
int channel_count,
- const uint8* extra_data,
+ const uint8_t* extra_data,
size_t extra_data_size,
- int64 codec_delay_ns,
- int64 seek_preroll_ns,
+ int64_t codec_delay_ns,
+ int64_t seek_preroll_ns,
bool play_audio,
jobject media_crypto) WARN_UNUSED_RESULT;
@@ -120,10 +122,10 @@ class MEDIA_EXPORT AudioCodecBridge : public SdkMediaCodecBridge {
// When |postpone| is set to true, the next PlayOutputBuffer() should have
// postpone == false, and it will play two buffers: the postponed one and
// the one identified by |index|.
- int64 PlayOutputBuffer(int index,
- size_t size,
- size_t offset,
- bool postpone = false);
+ int64_t PlayOutputBuffer(int index,
+ size_t size,
+ size_t offset,
+ bool postpone = false);
// Set the volume of the audio output.
void SetVolume(double volume);
@@ -134,10 +136,10 @@ class MEDIA_EXPORT AudioCodecBridge : public SdkMediaCodecBridge {
// Configure the java MediaFormat object with the extra codec data passed in.
bool ConfigureMediaFormat(jobject j_format,
const AudioCodec& codec,
- const uint8* extra_data,
+ const uint8_t* extra_data,
size_t extra_data_size,
- int64 codec_delay_ns,
- int64 seek_preroll_ns);
+ int64_t codec_delay_ns,
+ int64_t seek_preroll_ns);
};
// Class for handling video encoding/decoding using android MediaCodec APIs.
diff --git a/media/capture/video/mac/video_capture_device_mac.mm b/media/capture/video/mac/video_capture_device_mac.mm
index 34c38f7..d96670b 100644
--- a/media/capture/video/mac/video_capture_device_mac.mm
+++ b/media/capture/video/mac/video_capture_device_mac.mm
@@ -7,6 +7,9 @@
#include <IOKit/IOCFPlugIn.h>
#include <IOKit/usb/IOUSBLib.h>
#include <IOKit/usb/USBSpec.h>
+#include <stdint.h>
+
+#include <limits>
#include "base/bind.h"
#include "base/location.h"
@@ -96,7 +99,7 @@ typedef struct IOUSBInterfaceDescriptor {
} IOUSBInterfaceDescriptor;
static void GetBestMatchSupportedResolution(gfx::Size* resolution) {
- int min_diff = kint32max;
+ int min_diff = std::numeric_limits<int32_t>::max();
const int desired_area = resolution->GetArea();
for (size_t i = 0; i < arraysize(kWellSupportedResolutions); ++i) {
const int area = kWellSupportedResolutions[i]->width *
diff --git a/media/formats/mp4/box_reader.cc b/media/formats/mp4/box_reader.cc
index 8200b19..4f32031 100644
--- a/media/formats/mp4/box_reader.cc
+++ b/media/formats/mp4/box_reader.cc
@@ -16,7 +16,7 @@ namespace mp4 {
Box::~Box() {}
-bool BufferReader::Read1(uint8* v) {
+bool BufferReader::Read1(uint8_t* v) {
RCHECK(HasBytes(1));
*v = buf_[pos_++];
return true;
@@ -35,18 +35,30 @@ template<typename T> bool BufferReader::Read(T* v) {
return true;
}
-bool BufferReader::Read2(uint16* v) { return Read(v); }
-bool BufferReader::Read2s(int16* v) { return Read(v); }
-bool BufferReader::Read4(uint32* v) { return Read(v); }
-bool BufferReader::Read4s(int32* v) { return Read(v); }
-bool BufferReader::Read8(uint64* v) { return Read(v); }
-bool BufferReader::Read8s(int64* v) { return Read(v); }
+bool BufferReader::Read2(uint16_t* v) {
+ return Read(v);
+}
+bool BufferReader::Read2s(int16_t* v) {
+ return Read(v);
+}
+bool BufferReader::Read4(uint32_t* v) {
+ return Read(v);
+}
+bool BufferReader::Read4s(int32_t* v) {
+ return Read(v);
+}
+bool BufferReader::Read8(uint64_t* v) {
+ return Read(v);
+}
+bool BufferReader::Read8s(int64_t* v) {
+ return Read(v);
+}
bool BufferReader::ReadFourCC(FourCC* v) {
- return Read4(reinterpret_cast<uint32*>(v));
+ return Read4(reinterpret_cast<uint32_t*>(v));
}
-bool BufferReader::ReadVec(std::vector<uint8>* vec, uint64 count) {
+bool BufferReader::ReadVec(std::vector<uint8_t>* vec, uint64_t count) {
RCHECK(HasBytes(count));
vec->clear();
vec->insert(vec->end(), buf_ + pos_, buf_ + pos_ + count);
@@ -54,28 +66,28 @@ bool BufferReader::ReadVec(std::vector<uint8>* vec, uint64 count) {
return true;
}
-bool BufferReader::SkipBytes(uint64 bytes) {
+bool BufferReader::SkipBytes(uint64_t bytes) {
RCHECK(HasBytes(bytes));
pos_ += bytes;
return true;
}
-bool BufferReader::Read4Into8(uint64* v) {
- uint32 tmp;
+bool BufferReader::Read4Into8(uint64_t* v) {
+ uint32_t tmp;
RCHECK(Read4(&tmp));
*v = tmp;
return true;
}
-bool BufferReader::Read4sInto8s(int64* v) {
+bool BufferReader::Read4sInto8s(int64_t* v) {
// Beware of the need for sign extension.
- int32 tmp;
+ int32_t tmp;
RCHECK(Read4s(&tmp));
*v = tmp;
return true;
}
-BoxReader::BoxReader(const uint8* buf,
+BoxReader::BoxReader(const uint8_t* buf,
const int size,
const scoped_refptr<MediaLog>& media_log,
bool is_EOS)
@@ -85,8 +97,7 @@ BoxReader::BoxReader(const uint8* buf,
version_(0),
flags_(0),
scanned_(false),
- is_EOS_(is_EOS) {
-}
+ is_EOS_(is_EOS) {}
BoxReader::~BoxReader() {
if (scanned_ && !children_.empty()) {
@@ -98,7 +109,7 @@ BoxReader::~BoxReader() {
}
// static
-BoxReader* BoxReader::ReadTopLevelBox(const uint8* buf,
+BoxReader* BoxReader::ReadTopLevelBox(const uint8_t* buf,
const int buf_size,
const scoped_refptr<MediaLog>& media_log,
bool* err) {
@@ -111,14 +122,14 @@ BoxReader* BoxReader::ReadTopLevelBox(const uint8* buf,
return NULL;
}
- if (reader->size() <= static_cast<uint64>(buf_size))
+ if (reader->size() <= static_cast<uint64_t>(buf_size))
return reader.release();
return NULL;
}
// static
-bool BoxReader::StartTopLevelBox(const uint8* buf,
+bool BoxReader::StartTopLevelBox(const uint8_t* buf,
const int buf_size,
const scoped_refptr<MediaLog>& media_log,
FourCC* type,
@@ -136,7 +147,7 @@ bool BoxReader::StartTopLevelBox(const uint8* buf,
}
// static
-BoxReader* BoxReader::ReadConcatentatedBoxes(const uint8* buf,
+BoxReader* BoxReader::ReadConcatentatedBoxes(const uint8_t* buf,
const int buf_size) {
return new BoxReader(buf, buf_size, new MediaLog(), true);
}
@@ -212,7 +223,7 @@ bool BoxReader::MaybeReadChild(Box* child) {
}
bool BoxReader::ReadFullBoxHeader() {
- uint32 vflags;
+ uint32_t vflags;
RCHECK(Read4(&vflags));
version_ = vflags >> 24;
flags_ = vflags & 0xffffff;
@@ -220,7 +231,7 @@ bool BoxReader::ReadFullBoxHeader() {
}
bool BoxReader::ReadHeader(bool* err) {
- uint64 size = 0;
+ uint64_t size = 0;
*err = false;
if (!HasBytes(8)) {
@@ -252,8 +263,8 @@ bool BoxReader::ReadHeader(bool* err) {
// Implementation-specific: support for boxes larger than 2^31 has been
// removed.
- if (size < static_cast<uint64>(pos_) ||
- size > static_cast<uint64>(kint32max)) {
+ if (size < static_cast<uint64_t>(pos_) ||
+ size > static_cast<uint64_t>(std::numeric_limits<int32_t>::max())) {
*err = true;
return false;
}
diff --git a/media/formats/mp4/box_reader.h b/media/formats/mp4/box_reader.h
index 957c287..3fff191 100644
--- a/media/formats/mp4/box_reader.h
+++ b/media/formats/mp4/box_reader.h
@@ -5,6 +5,9 @@
#ifndef MEDIA_FORMATS_MP4_BOX_READER_H_
#define MEDIA_FORMATS_MP4_BOX_READER_H_
+#include <stdint.h>
+
+#include <limits>
#include <map>
#include <vector>
@@ -32,53 +35,55 @@ struct MEDIA_EXPORT Box {
class MEDIA_EXPORT BufferReader {
public:
- BufferReader(const uint8* buf, const int size) : buf_(buf), pos_(0) {
+ BufferReader(const uint8_t* buf, const int size) : buf_(buf), pos_(0) {
CHECK(buf);
- size_ = base::checked_cast<uint64>(size);
+ size_ = base::checked_cast<uint64_t>(size);
}
- bool HasBytes(uint64 count) {
+ bool HasBytes(uint64_t count) {
// As the size of a box is implementation limited to 2^31, fail if
// attempting to check for too many bytes.
- return (pos_ <= size_ && count < static_cast<uint64>(kint32max) &&
+ return (pos_ <= size_ &&
+ count <
+ static_cast<uint64_t>(std::numeric_limits<int32_t>::max()) &&
size_ - pos_ >= count);
}
// Read a value from the stream, perfoming endian correction, and advance the
// stream pointer.
- bool Read1(uint8* v) WARN_UNUSED_RESULT;
- bool Read2(uint16* v) WARN_UNUSED_RESULT;
- bool Read2s(int16* v) WARN_UNUSED_RESULT;
- bool Read4(uint32* v) WARN_UNUSED_RESULT;
- bool Read4s(int32* v) WARN_UNUSED_RESULT;
- bool Read8(uint64* v) WARN_UNUSED_RESULT;
- bool Read8s(int64* v) WARN_UNUSED_RESULT;
+ bool Read1(uint8_t* v) WARN_UNUSED_RESULT;
+ bool Read2(uint16_t* v) WARN_UNUSED_RESULT;
+ bool Read2s(int16_t* v) WARN_UNUSED_RESULT;
+ bool Read4(uint32_t* v) WARN_UNUSED_RESULT;
+ bool Read4s(int32_t* v) WARN_UNUSED_RESULT;
+ bool Read8(uint64_t* v) WARN_UNUSED_RESULT;
+ bool Read8s(int64_t* v) WARN_UNUSED_RESULT;
bool ReadFourCC(FourCC* v) WARN_UNUSED_RESULT;
- bool ReadVec(std::vector<uint8>* t, uint64 count) WARN_UNUSED_RESULT;
+ bool ReadVec(std::vector<uint8_t>* t, uint64_t count) WARN_UNUSED_RESULT;
// These variants read a 4-byte integer of the corresponding signedness and
// store it in the 8-byte return type.
- bool Read4Into8(uint64* v) WARN_UNUSED_RESULT;
- bool Read4sInto8s(int64* v) WARN_UNUSED_RESULT;
+ bool Read4Into8(uint64_t* v) WARN_UNUSED_RESULT;
+ bool Read4sInto8s(int64_t* v) WARN_UNUSED_RESULT;
// Advance the stream by this many bytes.
- bool SkipBytes(uint64 nbytes) WARN_UNUSED_RESULT;
+ bool SkipBytes(uint64_t nbytes) WARN_UNUSED_RESULT;
- const uint8* data() const { return buf_; }
+ const uint8_t* data() const { return buf_; }
// This returns the size of the box as specified in the box header. Initially
// it is the buffer size until the header is read. Note that the size
// specified in the box header may be different than the number of bytes
// actually provided.
- uint64 size() const { return size_; }
- uint64 pos() const { return pos_; }
+ uint64_t size() const { return size_; }
+ uint64_t pos() const { return pos_; }
protected:
- const uint8* buf_;
- uint64 size_;
- uint64 pos_;
+ const uint8_t* buf_;
+ uint64_t size_;
+ uint64_t pos_;
template<typename T> bool Read(T* t) WARN_UNUSED_RESULT;
};
@@ -93,7 +98,7 @@ class MEDIA_EXPORT BoxReader : public BufferReader {
// values are only expected when insufficient data is available.
//
// |buf| is retained but not owned, and must outlive the BoxReader instance.
- static BoxReader* ReadTopLevelBox(const uint8* buf,
+ static BoxReader* ReadTopLevelBox(const uint8_t* buf,
const int buf_size,
const scoped_refptr<MediaLog>& media_log,
bool* err);
@@ -104,7 +109,7 @@ class MEDIA_EXPORT BoxReader : public BufferReader {
// true. The semantics of |*err| are the same as above.
//
// |buf| is not retained.
- static bool StartTopLevelBox(const uint8* buf,
+ static bool StartTopLevelBox(const uint8_t* buf,
const int buf_size,
const scoped_refptr<MediaLog>& media_log,
FourCC* type,
@@ -116,7 +121,7 @@ class MEDIA_EXPORT BoxReader : public BufferReader {
// with any type of box -- it does not have to be IsValidTopLevelBox().
//
// |buf| is retained but not owned, and must outlive the BoxReader instance.
- static BoxReader* ReadConcatentatedBoxes(const uint8* buf,
+ static BoxReader* ReadConcatentatedBoxes(const uint8_t* buf,
const int buf_size);
// Returns true if |type| is recognized to be a top-level box, false
@@ -169,15 +174,15 @@ class MEDIA_EXPORT BoxReader : public BufferReader {
bool ReadFullBoxHeader() WARN_UNUSED_RESULT;
FourCC type() const { return type_; }
- uint8 version() const { return version_; }
- uint32 flags() const { return flags_; }
+ uint8_t version() const { return version_; }
+ uint32_t flags() const { return flags_; }
const scoped_refptr<MediaLog>& media_log() const { return media_log_; }
private:
// Create a BoxReader from |buf|. |is_EOS| should be true if |buf| is
// complete stream (i.e. no additional data is expected to be appended).
- BoxReader(const uint8* buf,
+ BoxReader(const uint8_t* buf,
const int size,
const scoped_refptr<MediaLog>& media_log,
bool is_EOS);
@@ -200,8 +205,8 @@ class MEDIA_EXPORT BoxReader : public BufferReader {
scoped_refptr<MediaLog> media_log_;
FourCC type_;
- uint8 version_;
- uint32 flags_;
+ uint8_t version_;
+ uint32_t flags_;
typedef std::multimap<FourCC, BoxReader> ChildMap;
diff --git a/net/disk_cache/blockfile/backend_worker_v3.cc b/net/disk_cache/blockfile/backend_worker_v3.cc
index 9d2e6a6..2fddb9b 100644
--- a/net/disk_cache/blockfile/backend_worker_v3.cc
+++ b/net/disk_cache/blockfile/backend_worker_v3.cc
@@ -4,6 +4,10 @@
#include "net/disk_cache/blockfile/backend_worker_v3.h"
+#include <stdint.h>
+
+#include <limits>
+
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/files/file_path.h"
@@ -397,7 +401,7 @@ bool BackendImpl::CheckIndex() {
#if !defined(NET_BUILD_STRESS_CACHE)
if (data_->header.num_bytes < 0 ||
- (max_size_ < kint32max - kDefaultCacheSize &&
+ (max_size_ < std::numeric_limits<int32_t>::max() - kDefaultCacheSize &&
data_->header.num_bytes > max_size_ + kDefaultCacheSize)) {
LOG(ERROR) << "Invalid cache (current) size";
return false;
diff --git a/net/disk_cache/blockfile/entry_impl.cc b/net/disk_cache/blockfile/entry_impl.cc
index c26026e..1d86e08 100644
--- a/net/disk_cache/blockfile/entry_impl.cc
+++ b/net/disk_cache/blockfile/entry_impl.cc
@@ -4,6 +4,8 @@
#include "net/disk_cache/blockfile/entry_impl.h"
+#include <limits>
+
#include "base/hash.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/string_util.h"
@@ -350,7 +352,9 @@ int EntryImpl::WriteDataImpl(int index, int offset, IOBuffer* buf, int buf_len,
return result;
}
-int EntryImpl::ReadSparseDataImpl(int64 offset, IOBuffer* buf, int buf_len,
+int EntryImpl::ReadSparseDataImpl(int64_t offset,
+ IOBuffer* buf,
+ int buf_len,
const CompletionCallback& callback) {
DCHECK(node_.Data()->dirty || read_only_);
int result = InitSparseData();
@@ -364,7 +368,9 @@ int EntryImpl::ReadSparseDataImpl(int64 offset, IOBuffer* buf, int buf_len,
return result;
}
-int EntryImpl::WriteSparseDataImpl(int64 offset, IOBuffer* buf, int buf_len,
+int EntryImpl::WriteSparseDataImpl(int64_t offset,
+ IOBuffer* buf,
+ int buf_len,
const CompletionCallback& callback) {
DCHECK(node_.Data()->dirty || read_only_);
int result = InitSparseData();
@@ -378,7 +384,7 @@ int EntryImpl::WriteSparseDataImpl(int64 offset, IOBuffer* buf, int buf_len,
return result;
}
-int EntryImpl::GetAvailableRangeImpl(int64 offset, int len, int64* start) {
+int EntryImpl::GetAvailableRangeImpl(int64_t offset, int len, int64_t* start) {
int result = InitSparseData();
if (net::OK != result)
return result;
@@ -398,12 +404,13 @@ int EntryImpl::ReadyForSparseIOImpl(const CompletionCallback& callback) {
return sparse_->ReadyToUse(callback);
}
-uint32 EntryImpl::GetHash() {
+uint32_t EntryImpl::GetHash() {
return entry_.Data()->hash;
}
-bool EntryImpl::CreateEntry(Addr node_address, const std::string& key,
- uint32 hash) {
+bool EntryImpl::CreateEntry(Addr node_address,
+ const std::string& key,
+ uint32_t hash) {
Trace("Create entry In");
EntryStore* entry_store = entry_.Data();
RankingsNode* node = node_.Data();
@@ -417,7 +424,7 @@ bool EntryImpl::CreateEntry(Addr node_address, const std::string& key,
entry_store->hash = hash;
entry_store->creation_time = Time::Now().ToInternalValue();
- entry_store->key_len = static_cast<int32>(key.size());
+ entry_store->key_len = static_cast<int32_t>(key.size());
if (entry_store->key_len > kMaxInternalKeyLength) {
Addr address(0);
if (!CreateBlock(entry_store->key_len + 1, &address))
@@ -442,14 +449,14 @@ bool EntryImpl::CreateEntry(Addr node_address, const std::string& key,
memcpy(entry_store->key, key.data(), key.size());
entry_store->key[key.size()] = '\0';
}
- backend_->ModifyStorageSize(0, static_cast<int32>(key.size()));
- CACHE_UMA(COUNTS, "KeySize", 0, static_cast<int32>(key.size()));
+ backend_->ModifyStorageSize(0, static_cast<int32_t>(key.size()));
+ CACHE_UMA(COUNTS, "KeySize", 0, static_cast<int32_t>(key.size()));
node->dirty = backend_->GetCurrentEntryId();
Log("Create Entry ");
return true;
}
-bool EntryImpl::IsSameEntry(const std::string& key, uint32 hash) {
+bool EntryImpl::IsSameEntry(const std::string& key, uint32_t hash) {
if (entry_.Data()->hash != hash ||
static_cast<size_t>(entry_.Data()->key_len) != key.size())
return false;
@@ -546,7 +553,7 @@ bool EntryImpl::Update() {
return true;
}
-void EntryImpl::SetDirtyFlag(int32 current_id) {
+void EntryImpl::SetDirtyFlag(int32_t current_id) {
DCHECK(node_.HasData());
if (node_.Data()->dirty && current_id != node_.Data()->dirty)
dirty_ = true;
@@ -555,7 +562,7 @@ void EntryImpl::SetDirtyFlag(int32 current_id) {
dirty_ = true;
}
-void EntryImpl::SetPointerForInvalidEntry(int32 new_id) {
+void EntryImpl::SetPointerForInvalidEntry(int32_t new_id) {
node_.Data()->dirty = new_id;
node_.Store();
}
@@ -800,7 +807,7 @@ Time EntryImpl::GetLastModified() const {
return Time::FromInternalValue(node->Data()->last_modified);
}
-int32 EntryImpl::GetDataSize(int index) const {
+int32_t EntryImpl::GetDataSize(int index) const {
if (index < 0 || index >= kNumStreams)
return 0;
@@ -851,7 +858,9 @@ int EntryImpl::WriteData(int index, int offset, IOBuffer* buf, int buf_len,
return net::ERR_IO_PENDING;
}
-int EntryImpl::ReadSparseData(int64 offset, IOBuffer* buf, int buf_len,
+int EntryImpl::ReadSparseData(int64_t offset,
+ IOBuffer* buf,
+ int buf_len,
const CompletionCallback& callback) {
if (callback.is_null())
return ReadSparseDataImpl(offset, buf, buf_len, callback);
@@ -863,7 +872,9 @@ int EntryImpl::ReadSparseData(int64 offset, IOBuffer* buf, int buf_len,
return net::ERR_IO_PENDING;
}
-int EntryImpl::WriteSparseData(int64 offset, IOBuffer* buf, int buf_len,
+int EntryImpl::WriteSparseData(int64_t offset,
+ IOBuffer* buf,
+ int buf_len,
const CompletionCallback& callback) {
if (callback.is_null())
return WriteSparseDataImpl(offset, buf, buf_len, callback);
@@ -875,7 +886,9 @@ int EntryImpl::WriteSparseData(int64 offset, IOBuffer* buf, int buf_len,
return net::ERR_IO_PENDING;
}
-int EntryImpl::GetAvailableRange(int64 offset, int len, int64* start,
+int EntryImpl::GetAvailableRange(int64_t offset,
+ int len,
+ int64_t* start,
const CompletionCallback& callback) {
if (!background_queue_.get())
return net::ERR_UNEXPECTED;
@@ -1077,7 +1090,7 @@ int EntryImpl::InternalWriteData(int index, int offset,
offset + buf_len > max_file_size) {
int size = offset + buf_len;
if (size <= max_file_size)
- size = kint32max;
+ size = std::numeric_limits<int32_t>::max();
backend_->TooMuchStorageRequested(size);
return net::ERR_FAILED;
}
@@ -1499,12 +1512,12 @@ int EntryImpl::InitSparseData() {
return result;
}
-void EntryImpl::SetEntryFlags(uint32 flags) {
+void EntryImpl::SetEntryFlags(uint32_t flags) {
entry_.Data()->flags |= flags;
entry_.set_modified();
}
-uint32 EntryImpl::GetEntryFlags() {
+uint32_t EntryImpl::GetEntryFlags() {
return entry_.Data()->flags;
}
diff --git a/net/disk_cache/blockfile/entry_impl.h b/net/disk_cache/blockfile/entry_impl.h
index aafb59b..5a485e8 100644
--- a/net/disk_cache/blockfile/entry_impl.h
+++ b/net/disk_cache/blockfile/entry_impl.h
@@ -5,6 +5,8 @@
#ifndef NET_DISK_CACHE_BLOCKFILE_ENTRY_IMPL_H_
#define NET_DISK_CACHE_BLOCKFILE_ENTRY_IMPL_H_
+#include <stdint.h>
+
#include "base/memory/scoped_ptr.h"
#include "net/disk_cache/blockfile/disk_format.h"
#include "net/disk_cache/blockfile/storage_block-inl.h"
@@ -46,11 +48,15 @@ class NET_EXPORT_PRIVATE EntryImpl
const CompletionCallback& callback);
int WriteDataImpl(int index, int offset, IOBuffer* buf, int buf_len,
const CompletionCallback& callback, bool truncate);
- int ReadSparseDataImpl(int64 offset, IOBuffer* buf, int buf_len,
+ int ReadSparseDataImpl(int64_t offset,
+ IOBuffer* buf,
+ int buf_len,
const CompletionCallback& callback);
- int WriteSparseDataImpl(int64 offset, IOBuffer* buf, int buf_len,
+ int WriteSparseDataImpl(int64_t offset,
+ IOBuffer* buf,
+ int buf_len,
const CompletionCallback& callback);
- int GetAvailableRangeImpl(int64 offset, int len, int64* start);
+ int GetAvailableRangeImpl(int64_t offset, int len, int64_t* start);
void CancelSparseIOImpl();
int ReadyForSparseIOImpl(const CompletionCallback& callback);
@@ -62,14 +68,14 @@ class NET_EXPORT_PRIVATE EntryImpl
return &node_;
}
- uint32 GetHash();
+ uint32_t GetHash();
// Performs the initialization of a EntryImpl that will be added to the
// cache.
- bool CreateEntry(Addr node_address, const std::string& key, uint32 hash);
+ bool CreateEntry(Addr node_address, const std::string& key, uint32_t hash);
// Returns true if this entry matches the lookup arguments.
- bool IsSameEntry(const std::string& key, uint32 hash);
+ bool IsSameEntry(const std::string& key, uint32_t hash);
// Permamently destroys this entry.
void InternalDoom();
@@ -104,10 +110,10 @@ class NET_EXPORT_PRIVATE EntryImpl
// Marks this entry as dirty (in memory) if needed. This is intended only for
// entries that are being read from disk, to be called during loading.
- void SetDirtyFlag(int32 current_id);
+ void SetDirtyFlag(int32_t current_id);
// Fixes this entry so it can be treated as valid (to delete it).
- void SetPointerForInvalidEntry(int32 new_id);
+ void SetPointerForInvalidEntry(int32_t new_id);
// Returns true if this entry is so meesed up that not everything is going to
// be removed.
@@ -152,7 +158,7 @@ class NET_EXPORT_PRIVATE EntryImpl
std::string GetKey() const override;
base::Time GetLastUsed() const override;
base::Time GetLastModified() const override;
- int32 GetDataSize(int index) const override;
+ int32_t GetDataSize(int index) const override;
int ReadData(int index,
int offset,
IOBuffer* buf,
@@ -164,17 +170,17 @@ class NET_EXPORT_PRIVATE EntryImpl
int buf_len,
const CompletionCallback& callback,
bool truncate) override;
- int ReadSparseData(int64 offset,
+ int ReadSparseData(int64_t offset,
IOBuffer* buf,
int buf_len,
const CompletionCallback& callback) override;
- int WriteSparseData(int64 offset,
+ int WriteSparseData(int64_t offset,
IOBuffer* buf,
int buf_len,
const CompletionCallback& callback) override;
- int GetAvailableRange(int64 offset,
+ int GetAvailableRange(int64_t offset,
int len,
- int64* start,
+ int64_t* start,
const CompletionCallback& callback) override;
bool CouldBeSparse() const override;
void CancelSparseIO() override;
@@ -248,10 +254,10 @@ class NET_EXPORT_PRIVATE EntryImpl
int InitSparseData();
// Adds the provided |flags| to the current EntryFlags for this entry.
- void SetEntryFlags(uint32 flags);
+ void SetEntryFlags(uint32_t flags);
// Returns the current EntryFlags for this entry.
- uint32 GetEntryFlags();
+ uint32_t GetEntryFlags();
// Gets the data stored at the given index. If the information is in memory,
// a buffer will be allocated and the data will be copied to it (the caller
diff --git a/net/disk_cache/blockfile/entry_impl_v3.cc b/net/disk_cache/blockfile/entry_impl_v3.cc
index 7371936..f6e1531 100644
--- a/net/disk_cache/blockfile/entry_impl_v3.cc
+++ b/net/disk_cache/blockfile/entry_impl_v3.cc
@@ -4,6 +4,8 @@
#include "net/disk_cache/blockfile/entry_impl_v3.h"
+#include <limits>
+
#include "base/hash.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/string_util.h"
@@ -257,8 +259,9 @@ EntryImplV3::EntryImplV3(BackendImplV3* backend, Addr address, bool read_only)
#if defined(V3_NOT_JUST_YET_READY)
-bool EntryImplV3::CreateEntry(Addr node_address, const std::string& key,
- uint32 hash) {
+bool EntryImplV3::CreateEntry(Addr node_address,
+ const std::string& key,
+ uint32_t hash) {
Trace("Create entry In");
EntryStore* entry_store = entry_.Data();
RankingsNode* node = node_.Data();
@@ -272,7 +275,7 @@ bool EntryImplV3::CreateEntry(Addr node_address, const std::string& key,
entry_store->hash = hash;
entry_store->creation_time = Time::Now().ToInternalValue();
- entry_store->key_len = static_cast<int32>(key.size());
+ entry_store->key_len = static_cast<int32_t>(key.size());
if (entry_store->key_len > kMaxInternalKeyLength) {
Addr address(0);
if (!CreateBlock(entry_store->key_len + 1, &address))
@@ -297,18 +300,18 @@ bool EntryImplV3::CreateEntry(Addr node_address, const std::string& key,
memcpy(entry_store->key, key.data(), key.size());
entry_store->key[key.size()] = '\0';
}
- backend_->ModifyStorageSize(0, static_cast<int32>(key.size()));
- CACHE_UMA(COUNTS, "KeySize", 0, static_cast<int32>(key.size()));
+ backend_->ModifyStorageSize(0, static_cast<int32_t>(key.size()));
+ CACHE_UMA(COUNTS, "KeySize", 0, static_cast<int32_t>(key.size()));
node->dirty = backend_->GetCurrentEntryId();
Log("Create Entry ");
return true;
}
-uint32 EntryImplV3::GetHash() {
+uint32_t EntryImplV3::GetHash() {
return entry_.Data()->hash;
}
-bool EntryImplV3::IsSameEntry(const std::string& key, uint32 hash) {
+bool EntryImplV3::IsSameEntry(const std::string& key, uint32_t hash) {
if (entry_.Data()->hash != hash ||
static_cast<size_t>(entry_.Data()->key_len) != key.size())
return false;
@@ -513,7 +516,7 @@ Time EntryImplV3::GetLastModified() const {
return Time::FromInternalValue(node->Data()->last_modified);
}
-int32 EntryImplV3::GetDataSize(int index) const {
+int32_t EntryImplV3::GetDataSize(int index) const {
if (index < 0 || index >= kNumStreams)
return 0;
@@ -602,7 +605,9 @@ int EntryImpl::WriteDataImpl(int index, int offset, IOBuffer* buf, int buf_len,
return result;
}
-int EntryImplV3::ReadSparseData(int64 offset, IOBuffer* buf, int buf_len,
+int EntryImplV3::ReadSparseData(int64_t offset,
+ IOBuffer* buf,
+ int buf_len,
const CompletionCallback& callback) {
if (callback.is_null())
return ReadSparseDataImpl(offset, buf, buf_len, callback);
@@ -614,7 +619,9 @@ int EntryImplV3::ReadSparseData(int64 offset, IOBuffer* buf, int buf_len,
return net::ERR_IO_PENDING;
}
-int EntryImpl::ReadSparseDataImpl(int64 offset, IOBuffer* buf, int buf_len,
+int EntryImpl::ReadSparseDataImpl(int64_t offset,
+ IOBuffer* buf,
+ int buf_len,
const CompletionCallback& callback) {
DCHECK(node_.Data()->dirty || read_only_);
int result = InitSparseData();
@@ -628,7 +635,9 @@ int EntryImpl::ReadSparseDataImpl(int64 offset, IOBuffer* buf, int buf_len,
return result;
}
-int EntryImplV3::WriteSparseData(int64 offset, IOBuffer* buf, int buf_len,
+int EntryImplV3::WriteSparseData(int64_t offset,
+ IOBuffer* buf,
+ int buf_len,
const CompletionCallback& callback) {
if (callback.is_null())
return WriteSparseDataImpl(offset, buf, buf_len, callback);
@@ -640,7 +649,9 @@ int EntryImplV3::WriteSparseData(int64 offset, IOBuffer* buf, int buf_len,
return net::ERR_IO_PENDING;
}
-int EntryImpl::WriteSparseDataImpl(int64 offset, IOBuffer* buf, int buf_len,
+int EntryImpl::WriteSparseDataImpl(int64_t offset,
+ IOBuffer* buf,
+ int buf_len,
const CompletionCallback& callback) {
DCHECK(node_.Data()->dirty || read_only_);
int result = InitSparseData();
@@ -654,7 +665,9 @@ int EntryImpl::WriteSparseDataImpl(int64 offset, IOBuffer* buf, int buf_len,
return result;
}
-int EntryImplV3::GetAvailableRange(int64 offset, int len, int64* start,
+int EntryImplV3::GetAvailableRange(int64_t offset,
+ int len,
+ int64_t* start,
const CompletionCallback& callback) {
if (!background_queue_)
return net::ERR_UNEXPECTED;
@@ -663,7 +676,7 @@ int EntryImplV3::GetAvailableRange(int64 offset, int len, int64* start,
return net::ERR_IO_PENDING;
}
-int EntryImpl::GetAvailableRangeImpl(int64 offset, int len, int64* start) {
+int EntryImpl::GetAvailableRangeImpl(int64_t offset, int len, int64_t* start) {
int result = InitSparseData();
if (net::OK != result)
return result;
@@ -875,7 +888,7 @@ int EntryImpl::InternalWriteData(int index, int offset,
offset + buf_len > max_file_size) {
int size = offset + buf_len;
if (size <= max_file_size)
- size = kint32max;
+ size = std::numeric_limits<int32_t>::max();
backend_->TooMuchStorageRequested(size);
return net::ERR_FAILED;
}
@@ -1320,12 +1333,12 @@ int EntryImpl::InitSparseData() {
return result;
}
-void EntryImpl::SetEntryFlags(uint32 flags) {
+void EntryImpl::SetEntryFlags(uint32_t flags) {
entry_.Data()->flags |= flags;
entry_.set_modified();
}
-uint32 EntryImpl::GetEntryFlags() {
+uint32_t EntryImpl::GetEntryFlags() {
return entry_.Data()->flags;
}
@@ -1415,7 +1428,7 @@ Time EntryImplV3::GetLastModified() const {
return Time();
}
-int32 EntryImplV3::GetDataSize(int index) const {
+int32_t EntryImplV3::GetDataSize(int index) const {
return 0;
}
@@ -1429,17 +1442,23 @@ int EntryImplV3::WriteData(int index, int offset, IOBuffer* buf, int buf_len,
return net::ERR_FAILED;
}
-int EntryImplV3::ReadSparseData(int64 offset, IOBuffer* buf, int buf_len,
+int EntryImplV3::ReadSparseData(int64_t offset,
+ IOBuffer* buf,
+ int buf_len,
const CompletionCallback& callback) {
return net::ERR_FAILED;
}
-int EntryImplV3::WriteSparseData(int64 offset, IOBuffer* buf, int buf_len,
+int EntryImplV3::WriteSparseData(int64_t offset,
+ IOBuffer* buf,
+ int buf_len,
const CompletionCallback& callback) {
return net::ERR_FAILED;
}
-int EntryImplV3::GetAvailableRange(int64 offset, int len, int64* start,
+int EntryImplV3::GetAvailableRange(int64_t offset,
+ int len,
+ int64_t* start,
const CompletionCallback& callback) {
return net::ERR_FAILED;
}
diff --git a/net/disk_cache/blockfile/entry_impl_v3.h b/net/disk_cache/blockfile/entry_impl_v3.h
index e36834b..000362e 100644
--- a/net/disk_cache/blockfile/entry_impl_v3.h
+++ b/net/disk_cache/blockfile/entry_impl_v3.h
@@ -5,6 +5,8 @@
#ifndef NET_DISK_CACHE_BLOCKFILE_ENTRY_IMPL_V3_H_
#define NET_DISK_CACHE_BLOCKFILE_ENTRY_IMPL_V3_H_
+#include <stdint.h>
+
#include <string>
#include "base/memory/scoped_ptr.h"
@@ -40,11 +42,11 @@ class NET_EXPORT_PRIVATE EntryImplV3
// Performs the initialization of a EntryImplV3 that will be added to the
// cache.
- bool CreateEntry(Addr node_address, const std::string& key, uint32 hash);
+ bool CreateEntry(Addr node_address, const std::string& key, uint32_t hash);
- uint32 GetHash();
+ uint32_t GetHash();
- uint32 GetHash() const;
+ uint32_t GetHash() const;
Addr GetAddress() const;
int GetReuseCounter() const;
void SetReuseCounter(int count);
@@ -52,7 +54,7 @@ class NET_EXPORT_PRIVATE EntryImplV3
void SetRefetchCounter(int count);
// Returns true if this entry matches the lookup arguments.
- bool IsSameEntry(const std::string& key, uint32 hash);
+ bool IsSameEntry(const std::string& key, uint32_t hash);
// Permamently destroys this entry.
void InternalDoom();
@@ -82,7 +84,7 @@ class NET_EXPORT_PRIVATE EntryImplV3
std::string GetKey() const override;
base::Time GetLastUsed() const override;
base::Time GetLastModified() const override;
- int32 GetDataSize(int index) const override;
+ int32_t GetDataSize(int index) const override;
int ReadData(int index,
int offset,
IOBuffer* buf,
@@ -94,17 +96,17 @@ class NET_EXPORT_PRIVATE EntryImplV3
int buf_len,
const CompletionCallback& callback,
bool truncate) override;
- int ReadSparseData(int64 offset,
+ int ReadSparseData(int64_t offset,
IOBuffer* buf,
int buf_len,
const CompletionCallback& callback) override;
- int WriteSparseData(int64 offset,
+ int WriteSparseData(int64_t offset,
IOBuffer* buf,
int buf_len,
const CompletionCallback& callback) override;
- int GetAvailableRange(int64 offset,
+ int GetAvailableRange(int64_t offset,
int len,
- int64* start,
+ int64_t* start,
const CompletionCallback& callback) override;
bool CouldBeSparse() const override;
void CancelSparseIO() override;
@@ -176,10 +178,10 @@ class NET_EXPORT_PRIVATE EntryImplV3
int InitSparseData();
// Adds the provided |flags| to the current EntryFlags for this entry.
- void SetEntryFlags(uint32 flags);
+ void SetEntryFlags(uint32_t flags);
// Returns the current EntryFlags for this entry.
- uint32 GetEntryFlags();
+ uint32_t GetEntryFlags();
// Gets the data stored at the given index. If the information is in memory,
// a buffer will be allocated and the data will be copied to it (the caller
diff --git a/net/disk_cache/blockfile/eviction.cc b/net/disk_cache/blockfile/eviction.cc
index 46eb2d7..6e0dcd5 100644
--- a/net/disk_cache/blockfile/eviction.cc
+++ b/net/disk_cache/blockfile/eviction.cc
@@ -28,6 +28,10 @@
#include "net/disk_cache/blockfile/eviction.h"
+#include <stdint.h>
+
+#include <limits>
+
#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/location.h"
@@ -408,7 +412,7 @@ void Eviction::OnOpenEntryV2(EntryImpl* entry) {
EntryStore* info = entry->entry()->Data();
DCHECK_EQ(ENTRY_NORMAL, info->state);
- if (info->reuse_count < kint32max) {
+ if (info->reuse_count < std::numeric_limits<int32_t>::max()) {
info->reuse_count++;
entry->entry()->set_modified();
@@ -434,7 +438,7 @@ void Eviction::OnCreateEntryV2(EntryImpl* entry) {
break;
};
case ENTRY_EVICTED: {
- if (info->refetch_count < kint32max)
+ if (info->refetch_count < std::numeric_limits<int32_t>::max())
info->refetch_count++;
if (info->refetch_count > kHighUse && info->reuse_count < kHighUse) {
diff --git a/net/disk_cache/blockfile/eviction_v3.cc b/net/disk_cache/blockfile/eviction_v3.cc
index 9d404a9..c658a8e 100644
--- a/net/disk_cache/blockfile/eviction_v3.cc
+++ b/net/disk_cache/blockfile/eviction_v3.cc
@@ -28,6 +28,10 @@
#include "net/disk_cache/blockfile/eviction_v3.h"
+#include <stdint.h>
+
+#include <limits>
+
#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/logging.h"
@@ -174,7 +178,7 @@ void EvictionV3::OnOpenEntry(EntryImplV3* entry) {
EntryStore* info = entry->entry()->Data();
DCHECK_EQ(ENTRY_NORMAL, info->state);
- if (info->reuse_count < kint32max) {
+ if (info->reuse_count < std::numeric_limits<int32_t>::max()) {
info->reuse_count++;
entry->entry()->set_modified();
@@ -200,7 +204,7 @@ void EvictionV3::OnCreateEntry(EntryImplV3* entry) {
break;
};
case ENTRY_EVICTED: {
- if (info->refetch_count < kint32max)
+ if (info->refetch_count < std::numeric_limits<int32_t>::max())
info->refetch_count++;
if (info->refetch_count > kHighUse && info->reuse_count < kHighUse) {
diff --git a/net/disk_cache/blockfile/index_table_v3.cc b/net/disk_cache/blockfile/index_table_v3.cc
index 039cba7..426d683 100644
--- a/net/disk_cache/blockfile/index_table_v3.cc
+++ b/net/disk_cache/blockfile/index_table_v3.cc
@@ -5,6 +5,7 @@
#include "net/disk_cache/blockfile/index_table_v3.h"
#include <algorithm>
+#include <limits>
#include <set>
#include <utility>
@@ -24,16 +25,16 @@ namespace {
// The following constants describe the bitfields of an IndexCell so they are
// implicitly synchronized with the descrption of IndexCell on file_format_v3.h.
-const uint64 kCellLocationMask = (1 << 22) - 1;
-const uint64 kCellIdMask = (1 << 18) - 1;
-const uint64 kCellTimestampMask = (1 << 20) - 1;
-const uint64 kCellReuseMask = (1 << 4) - 1;
-const uint8 kCellStateMask = (1 << 3) - 1;
-const uint8 kCellGroupMask = (1 << 3) - 1;
-const uint8 kCellSumMask = (1 << 2) - 1;
+const uint64_t kCellLocationMask = (1 << 22) - 1;
+const uint64_t kCellIdMask = (1 << 18) - 1;
+const uint64_t kCellTimestampMask = (1 << 20) - 1;
+const uint64_t kCellReuseMask = (1 << 4) - 1;
+const uint8_t kCellStateMask = (1 << 3) - 1;
+const uint8_t kCellGroupMask = (1 << 3) - 1;
+const uint8_t kCellSumMask = (1 << 2) - 1;
-const uint64 kCellSmallTableLocationMask = (1 << 16) - 1;
-const uint64 kCellSmallTableIdMask = (1 << 24) - 1;
+const uint64_t kCellSmallTableLocationMask = (1 << 16) - 1;
+const uint64_t kCellSmallTableIdMask = (1 << 24) - 1;
const int kCellIdOffset = 22;
const int kCellTimestampOffset = 40;
@@ -60,19 +61,19 @@ const int kEvictedEntriesFile = disk_cache::BLOCK_EVICTED - 1;
const int kMaxLocation = 1 << 22;
const int kMinFileNumber = 1 << 16;
-uint32 GetCellLocation(const IndexCell& cell) {
+uint32_t GetCellLocation(const IndexCell& cell) {
return cell.first_part & kCellLocationMask;
}
-uint32 GetCellSmallTableLocation(const IndexCell& cell) {
+uint32_t GetCellSmallTableLocation(const IndexCell& cell) {
return cell.first_part & kCellSmallTableLocationMask;
}
-uint32 GetCellId(const IndexCell& cell) {
+uint32_t GetCellId(const IndexCell& cell) {
return (cell.first_part >> kCellIdOffset) & kCellIdMask;
}
-uint32 GetCellSmallTableId(const IndexCell& cell) {
+uint32_t GetCellSmallTableId(const IndexCell& cell) {
return (cell.first_part >> kCellSmallTableIdOffset) &
kCellSmallTableIdMask;
}
@@ -97,42 +98,42 @@ int GetCellSum(const IndexCell& cell) {
return (cell.last_part >> kCellSumOffset) & kCellSumMask;
}
-void SetCellLocation(IndexCell* cell, uint32 address) {
- DCHECK_LE(address, static_cast<uint32>(kCellLocationMask));
+void SetCellLocation(IndexCell* cell, uint32_t address) {
+ DCHECK_LE(address, static_cast<uint32_t>(kCellLocationMask));
cell->first_part &= ~kCellLocationMask;
cell->first_part |= address;
}
-void SetCellSmallTableLocation(IndexCell* cell, uint32 address) {
- DCHECK_LE(address, static_cast<uint32>(kCellSmallTableLocationMask));
+void SetCellSmallTableLocation(IndexCell* cell, uint32_t address) {
+ DCHECK_LE(address, static_cast<uint32_t>(kCellSmallTableLocationMask));
cell->first_part &= ~kCellSmallTableLocationMask;
cell->first_part |= address;
}
-void SetCellId(IndexCell* cell, uint32 hash) {
- DCHECK_LE(hash, static_cast<uint32>(kCellIdMask));
+void SetCellId(IndexCell* cell, uint32_t hash) {
+ DCHECK_LE(hash, static_cast<uint32_t>(kCellIdMask));
cell->first_part &= ~(kCellIdMask << kCellIdOffset);
- cell->first_part |= static_cast<int64>(hash) << kCellIdOffset;
+ cell->first_part |= static_cast<int64_t>(hash) << kCellIdOffset;
}
-void SetCellSmallTableId(IndexCell* cell, uint32 hash) {
- DCHECK_LE(hash, static_cast<uint32>(kCellSmallTableIdMask));
+void SetCellSmallTableId(IndexCell* cell, uint32_t hash) {
+ DCHECK_LE(hash, static_cast<uint32_t>(kCellSmallTableIdMask));
cell->first_part &= ~(kCellSmallTableIdMask << kCellSmallTableIdOffset);
- cell->first_part |= static_cast<int64>(hash) << kCellSmallTableIdOffset;
+ cell->first_part |= static_cast<int64_t>(hash) << kCellSmallTableIdOffset;
}
void SetCellTimestamp(IndexCell* cell, int timestamp) {
DCHECK_LT(timestamp, 1 << 20);
DCHECK_GE(timestamp, 0);
cell->first_part &= ~(kCellTimestampMask << kCellTimestampOffset);
- cell->first_part |= static_cast<int64>(timestamp) << kCellTimestampOffset;
+ cell->first_part |= static_cast<int64_t>(timestamp) << kCellTimestampOffset;
}
void SetCellReuse(IndexCell* cell, int count) {
DCHECK_LT(count, 16);
DCHECK_GE(count, 0);
cell->first_part &= ~(kCellReuseMask << kCellReuseOffset);
- cell->first_part |= static_cast<int64>(count) << kCellReuseOffset;
+ cell->first_part |= static_cast<int64_t>(count) << kCellReuseOffset;
}
void SetCellState(IndexCell* cell, disk_cache::EntryState state) {
@@ -155,9 +156,9 @@ void SetCellSum(IndexCell* cell, int sum) {
// This is a very particular way to calculate the sum, so it will not match if
// compared a gainst a pure 2 bit, modulo 2 sum.
int CalculateCellSum(const IndexCell& cell) {
- uint32* words = bit_cast<uint32*>(&cell);
- uint8* bytes = bit_cast<uint8*>(&cell);
- uint32 result = words[0] + words[1];
+ uint32_t* words = bit_cast<uint32_t*>(&cell);
+ uint8_t* bytes = bit_cast<uint8_t*>(&cell);
+ uint32_t result = words[0] + words[1];
result += result >> 16;
result += (result >> 8) + (bytes[8] & 0x3f);
result += result >> 4;
@@ -252,7 +253,8 @@ void UpdateIterator(const disk_cache::EntryCell& cell,
void InitIterator(IndexIterator* iterator) {
iterator->cells.clear();
- iterator->timestamp = iterator->forward ? kint32max : 0;
+ iterator->timestamp =
+ iterator->forward ? std::numeric_limits<int32_t>::max() : 0;
}
} // namespace
@@ -271,7 +273,7 @@ bool EntryCell::IsValid() const {
// in the case of small tables. See also the comment by the definition of
// kEntriesFile.
Addr EntryCell::GetAddress() const {
- uint32 location = GetLocation();
+ uint32_t location = GetLocation();
int file_number = FileNumberFromLocation(location);
if (small_table_) {
DCHECK_EQ(0, file_number);
@@ -317,8 +319,8 @@ void EntryCell::SetTimestamp(int timestamp) {
}
// Static.
-EntryCell EntryCell::GetEntryCellForTest(int32 cell_num,
- uint32 hash,
+EntryCell EntryCell::GetEntryCellForTest(int32_t cell_num,
+ uint32_t hash,
Addr address,
IndexCell* cell,
bool small_table) {
@@ -339,13 +341,11 @@ EntryCell::EntryCell() : cell_num_(0), hash_(0), small_table_(false) {
cell_.Clear();
}
-EntryCell::EntryCell(int32 cell_num,
- uint32 hash,
+EntryCell::EntryCell(int32_t cell_num,
+ uint32_t hash,
Addr address,
bool small_table)
- : cell_num_(cell_num),
- hash_(hash),
- small_table_(small_table) {
+ : cell_num_(cell_num), hash_(hash), small_table_(small_table) {
DCHECK(IsValidAddress(address) || !address.value());
cell_.Clear();
@@ -357,34 +357,33 @@ EntryCell::EntryCell(int32 cell_num,
SetCellSmallTableLocation(&cell_, address.start_block());
SetCellSmallTableId(&cell_, hash >> kSmallTableHashShift);
} else {
- uint32 location = address.FileNumber() << 16 | address.start_block();
+ uint32_t location = address.FileNumber() << 16 | address.start_block();
SetCellLocation(&cell_, location);
SetCellId(&cell_, hash >> kHashShift);
}
}
-EntryCell::EntryCell(int32 cell_num,
- uint32 hash,
+EntryCell::EntryCell(int32_t cell_num,
+ uint32_t hash,
const IndexCell& cell,
bool small_table)
: cell_num_(cell_num),
hash_(hash),
cell_(cell),
- small_table_(small_table) {
-}
+ small_table_(small_table) {}
void EntryCell::FixSum() {
SetCellSum(&cell_, CalculateCellSum(cell_));
}
-uint32 EntryCell::GetLocation() const {
+uint32_t EntryCell::GetLocation() const {
if (small_table_)
return GetCellSmallTableLocation(cell_);
return GetCellLocation(cell_);
}
-uint32 EntryCell::RecomputeHash() {
+uint32_t EntryCell::RecomputeHash() {
if (small_table_) {
hash_ &= (1 << kSmallTableHashShift) - 1;
hash_ |= GetCellSmallTableId(cell_) << kSmallTableHashShift;
@@ -512,13 +511,13 @@ void IndexTable::Init(IndexTableInitData* params) {
int old_main_table_bit_words = ((mask_ >> 1) + 1) * kCellsPerBucket / 32;
DCHECK_GT(num_words, old_main_table_bit_words);
memset(params->index_bitmap->bitmap + old_main_table_bit_words, 0,
- (num_words - old_main_table_bit_words) * sizeof(int32));
+ (num_words - old_main_table_bit_words) * sizeof(int32_t));
DCHECK(growing);
int old_num_words = (backup_header_.get()->table_len + 31) / 32;
DCHECK_GT(old_num_words, old_main_table_bit_words);
memset(backup_bitmap_storage_.get() + old_main_table_bit_words, 0,
- (old_num_words - old_main_table_bit_words) * sizeof(int32));
+ (old_num_words - old_main_table_bit_words) * sizeof(int32_t));
}
bitmap_.reset(new Bitmap(params->index_bitmap->bitmap, header_->table_len,
num_words));
@@ -526,11 +525,11 @@ void IndexTable::Init(IndexTableInitData* params) {
if (growing) {
int old_num_words = (backup_header_.get()->table_len + 31) / 32;
DCHECK_GE(num_words, old_num_words);
- scoped_ptr<uint32[]> storage(new uint32[num_words]);
+ scoped_ptr<uint32_t[]> storage(new uint32_t[num_words]);
memcpy(storage.get(), backup_bitmap_storage_.get(),
- old_num_words * sizeof(int32));
+ old_num_words * sizeof(int32_t));
memset(storage.get() + old_num_words, 0,
- (num_words - old_num_words) * sizeof(int32));
+ (num_words - old_num_words) * sizeof(int32_t));
backup_bitmap_storage_.swap(storage);
backup_header_->table_len = header_->table_len;
@@ -574,7 +573,7 @@ void IndexTable::Shutdown() {
//
// One consequence of this pattern is that we never start looking at buckets in
// the extra table, unless we are following a link from the main table.
-EntrySet IndexTable::LookupEntries(uint32 hash) {
+EntrySet IndexTable::LookupEntries(uint32_t hash) {
EntrySet entries;
int bucket_num = static_cast<int>(hash & mask_);
IndexBucket* bucket = &main_table_[bucket_num];
@@ -611,7 +610,7 @@ EntrySet IndexTable::LookupEntries(uint32 hash) {
return entries;
}
-EntryCell IndexTable::CreateEntryCell(uint32 hash, Addr address) {
+EntryCell IndexTable::CreateEntryCell(uint32_t hash, Addr address) {
DCHECK(IsValidAddress(address));
DCHECK(address.FileNumber() || address.start_block());
@@ -665,7 +664,7 @@ EntryCell IndexTable::CreateEntryCell(uint32 hash, Addr address) {
return entry_cell;
}
-EntryCell IndexTable::FindEntryCell(uint32 hash, Addr address) {
+EntryCell IndexTable::FindEntryCell(uint32_t hash, Addr address) {
return FindEntryCellImpl(hash, address, false);
}
@@ -679,7 +678,7 @@ base::Time IndexTable::TimeFromTimestamp(int timestamp) {
TimeDelta::FromMinutes(timestamp);
}
-void IndexTable::SetSate(uint32 hash, Addr address, EntryState state) {
+void IndexTable::SetSate(uint32_t hash, Addr address, EntryState state) {
EntryCell cell = FindEntryCellImpl(hash, address, state == ENTRY_FREE);
if (!cell.IsValid()) {
NOTREACHED();
@@ -727,7 +726,7 @@ void IndexTable::SetSate(uint32 hash, Addr address, EntryState state) {
Save(&cell);
}
-void IndexTable::UpdateTime(uint32 hash, Addr address, base::Time current) {
+void IndexTable::UpdateTime(uint32_t hash, Addr address, base::Time current) {
EntryCell cell = FindEntryCell(hash, address);
if (!cell.IsValid())
return;
@@ -792,7 +791,8 @@ void IndexTable::OnBackupTimer() {
// -----------------------------------------------------------------------
-EntryCell IndexTable::FindEntryCellImpl(uint32 hash, Addr address,
+EntryCell IndexTable::FindEntryCellImpl(uint32_t hash,
+ Addr address,
bool allow_deleted) {
int bucket_num = static_cast<int>(hash & mask_);
IndexBucket* bucket = &main_table_[bucket_num];
@@ -847,7 +847,7 @@ void IndexTable::CheckState(const EntryCell& cell) {
void IndexTable::Write(const EntryCell& cell) {
IndexBucket* bucket = NULL;
int bucket_num = cell.cell_num() / kCellsPerBucket;
- if (bucket_num < static_cast<int32>(mask_ + 1)) {
+ if (bucket_num < static_cast<int32_t>(mask_ + 1)) {
bucket = &main_table_[bucket_num];
} else {
DCHECK_LE(bucket_num, header()->max_bucket);
@@ -888,7 +888,7 @@ void IndexTable::WalkTables(int limit_time,
header_->num_high_use_entries = 0;
header_->num_evicted_entries = 0;
- for (int i = 0; i < static_cast<int32>(mask_ + 1); i++) {
+ for (int i = 0; i < static_cast<int32_t>(mask_ + 1); i++) {
int bucket_num = i;
IndexBucket* bucket = &main_table_[i];
do {
@@ -957,7 +957,7 @@ void IndexTable::MoveCells(IndexBucket* old_extra_table) {
// (h >> 14). If the table is say 8 times the original size (growing from 4x),
// the bit that we are interested in would be the 3rd bit of the stored value,
// in other words 'multiplier' >> 1.
- uint32 new_bit = (1 << extra_bits_) >> 1;
+ uint32_t new_bit = (1 << extra_bits_) >> 1;
scoped_ptr<IndexBucket[]> old_main_table;
IndexBucket* source_table = main_table_;
@@ -1016,7 +1016,7 @@ void IndexTable::MoveCells(IndexBucket* old_extra_table) {
void IndexTable::MoveSingleCell(IndexCell* current_cell, int cell_num,
int main_table_index, bool growing) {
- uint32 hash = GetFullHash(*current_cell, main_table_index);
+ uint32_t hash = GetFullHash(*current_cell, main_table_index);
EntryCell old_cell(cell_num, hash, *current_cell, small_table_);
// This method may be called when moving entries from a small table to a
@@ -1070,7 +1070,7 @@ void IndexTable::HandleMisplacedCell(IndexCell* current_cell, int cell_num,
NOTREACHED(); // No unit tests yet.
// The cell may be misplaced, or a duplicate cell exists with this data.
- uint32 hash = GetFullHash(*current_cell, main_table_index);
+ uint32_t hash = GetFullHash(*current_cell, main_table_index);
MoveSingleCell(current_cell, cell_num, main_table_index, false);
// Now look for a duplicate cell.
@@ -1108,21 +1108,21 @@ void IndexTable::CheckBucketList(int bucket_num) {
} while (bucket_num);
}
-uint32 IndexTable::GetLocation(const IndexCell& cell) {
+uint32_t IndexTable::GetLocation(const IndexCell& cell) {
if (small_table_)
return GetCellSmallTableLocation(cell);
return GetCellLocation(cell);
}
-uint32 IndexTable::GetHashValue(const IndexCell& cell) {
+uint32_t IndexTable::GetHashValue(const IndexCell& cell) {
if (small_table_)
return GetCellSmallTableId(cell);
return GetCellId(cell);
}
-uint32 IndexTable::GetFullHash(const IndexCell& cell, uint32 lower_part) {
+uint32_t IndexTable::GetFullHash(const IndexCell& cell, uint32_t lower_part) {
// It is OK for the high order bits of lower_part to overlap with the stored
// part of the hash.
if (small_table_)
@@ -1132,16 +1132,16 @@ uint32 IndexTable::GetFullHash(const IndexCell& cell, uint32 lower_part) {
}
// All the bits stored in the cell should match the provided hash.
-bool IndexTable::IsHashMatch(const IndexCell& cell, uint32 hash) {
+bool IndexTable::IsHashMatch(const IndexCell& cell, uint32_t hash) {
hash = small_table_ ? hash >> kSmallTableHashShift : hash >> kHashShift;
return GetHashValue(cell) == hash;
}
-bool IndexTable::MisplacedHash(const IndexCell& cell, uint32 hash) {
+bool IndexTable::MisplacedHash(const IndexCell& cell, uint32_t hash) {
if (!extra_bits_)
return false;
- uint32 mask = (1 << extra_bits_) - 1;
+ uint32_t mask = (1 << extra_bits_) - 1;
hash = small_table_ ? hash >> kSmallTableHashShift : hash >> kHashShift;
return (GetHashValue(cell) & mask) != (hash & mask);
}
diff --git a/net/disk_cache/blockfile/index_table_v3.h b/net/disk_cache/blockfile/index_table_v3.h
index 598aeec..3a9a3e2 100644
--- a/net/disk_cache/blockfile/index_table_v3.h
+++ b/net/disk_cache/blockfile/index_table_v3.h
@@ -18,9 +18,11 @@
// re-initialized with the new structures. Note that the IndexTable instance is
// still functional while the backend performs file IO.
+#include <stdint.h>
+
#include <vector>
-#include "base/basictypes.h"
+#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/time/time.h"
@@ -54,8 +56,8 @@ class NET_EXPORT_PRIVATE EntryCell {
bool IsValid() const;
- int32 cell_num() const { return cell_num_; }
- uint32 hash() const { return hash_; }
+ int32_t cell_num() const { return cell_num_; }
+ uint32_t hash() const { return hash_; }
Addr GetAddress() const;
EntryState GetState() const;
@@ -68,8 +70,8 @@ class NET_EXPORT_PRIVATE EntryCell {
void SetReuse(int count);
void SetTimestamp(int timestamp);
- static EntryCell GetEntryCellForTest(int32 cell_num,
- uint32 hash,
+ static EntryCell GetEntryCellForTest(int32_t cell_num,
+ uint32_t hash,
Addr address,
IndexCell* cell,
bool small_table);
@@ -80,9 +82,9 @@ class NET_EXPORT_PRIVATE EntryCell {
friend class CacheDumperHelper;
EntryCell();
- EntryCell(int32 cell_num, uint32 hash, Addr address, bool small_table);
- EntryCell(int32 cell_num,
- uint32 hash,
+ EntryCell(int32_t cell_num, uint32_t hash, Addr address, bool small_table);
+ EntryCell(int32_t cell_num,
+ uint32_t hash,
const IndexCell& cell,
bool small_table);
@@ -90,16 +92,16 @@ class NET_EXPORT_PRIVATE EntryCell {
void FixSum();
// Returns the raw value stored on the index table.
- uint32 GetLocation() const;
+ uint32_t GetLocation() const;
// Recalculates hash_ assuming that only the low order bits are valid and the
// rest come from cell_.
- uint32 RecomputeHash();
+ uint32_t RecomputeHash();
void Serialize(IndexCell* destination) const;
- int32 cell_num_;
- uint32 hash_;
+ int32_t cell_num_;
+ uint32_t hash_;
IndexCell cell_;
bool small_table_;
};
@@ -116,7 +118,10 @@ struct NET_EXPORT_PRIVATE EntrySet {
// A given entity referenced by the index table is uniquely identified by the
// combination of hash and address.
-struct CellInfo { uint32 hash; Addr address; };
+struct CellInfo {
+ uint32_t hash;
+ Addr address;
+};
typedef std::vector<CellInfo> CellList;
// An index iterator is used to get a group of cells that share the same
@@ -160,7 +165,7 @@ struct NET_EXPORT_PRIVATE IndexTableInitData {
IndexBucket* main_table;
IndexBucket* extra_table;
scoped_ptr<IndexHeaderV3> backup_header;
- scoped_ptr<uint32[]> backup_bitmap;
+ scoped_ptr<uint32_t[]> backup_bitmap;
};
// See the description at the top of this file.
@@ -182,16 +187,16 @@ class NET_EXPORT_PRIVATE IndexTable {
// Locates a resouce on the index. Returns a list of all resources that match
// the provided hash.
- EntrySet LookupEntries(uint32 hash);
+ EntrySet LookupEntries(uint32_t hash);
// Creates a new cell to store a new resource.
- EntryCell CreateEntryCell(uint32 hash, Addr address);
+ EntryCell CreateEntryCell(uint32_t hash, Addr address);
// Locates a particular cell. This method allows a caller to perform slow
// operations with some entries while the index evolves, by returning the
// current state of a cell. If the desired cell cannot be located, the return
// object will be invalid.
- EntryCell FindEntryCell(uint32 hash, Addr address);
+ EntryCell FindEntryCell(uint32_t hash, Addr address);
// Returns an IndexTable timestamp for a given absolute time. The actual
// resolution of the timestamp should be considered an implementation detail,
@@ -203,8 +208,8 @@ class NET_EXPORT_PRIVATE IndexTable {
base::Time TimeFromTimestamp(int timestamp);
// Updates a particular cell.
- void SetSate(uint32 hash, Addr address, EntryState state);
- void UpdateTime(uint32 hash, Addr address, base::Time current);
+ void SetSate(uint32_t hash, Addr address, EntryState state);
+ void UpdateTime(uint32_t hash, Addr address, base::Time current);
// Saves the contents of |cell| to the table.
void Save(EntryCell* cell);
@@ -232,7 +237,7 @@ class NET_EXPORT_PRIVATE IndexTable {
const IndexHeaderV3* header() const { return header_; }
private:
- EntryCell FindEntryCellImpl(uint32 hash, Addr address, bool allow_deleted);
+ EntryCell FindEntryCellImpl(uint32_t hash, Addr address, bool allow_deleted);
void CheckState(const EntryCell& cell);
void Write(const EntryCell& cell);
int NewExtraBucket();
@@ -252,21 +257,21 @@ class NET_EXPORT_PRIVATE IndexTable {
int main_table_index);
void CheckBucketList(int bucket_id);
- uint32 GetLocation(const IndexCell& cell);
- uint32 GetHashValue(const IndexCell& cell);
- uint32 GetFullHash(const IndexCell& cell, uint32 lower_part);
- bool IsHashMatch(const IndexCell& cell, uint32 hash);
- bool MisplacedHash(const IndexCell& cell, uint32 hash);
+ uint32_t GetLocation(const IndexCell& cell);
+ uint32_t GetHashValue(const IndexCell& cell);
+ uint32_t GetFullHash(const IndexCell& cell, uint32_t lower_part);
+ bool IsHashMatch(const IndexCell& cell, uint32_t hash);
+ bool MisplacedHash(const IndexCell& cell, uint32_t hash);
IndexTableBackend* backend_;
IndexHeaderV3* header_;
scoped_ptr<Bitmap> bitmap_;
scoped_ptr<Bitmap> backup_bitmap_;
- scoped_ptr<uint32[]> backup_bitmap_storage_;
+ scoped_ptr<uint32_t[]> backup_bitmap_storage_;
scoped_ptr<IndexHeaderV3> backup_header_;
IndexBucket* main_table_;
IndexBucket* extra_table_;
- uint32 mask_; // Binary mask to map a hash to the hash table.
+ uint32_t mask_; // Binary mask to map a hash to the hash table.
int extra_bits_; // How many bits are in mask_ above the default value.
bool modified_;
bool small_table_;
diff --git a/net/disk_cache/blockfile/rankings.cc b/net/disk_cache/blockfile/rankings.cc
index 6ea7909..0f06141 100644
--- a/net/disk_cache/blockfile/rankings.cc
+++ b/net/disk_cache/blockfile/rankings.cc
@@ -4,6 +4,10 @@
#include "net/disk_cache/blockfile/rankings.h"
+#include <stdint.h>
+
+#include <limits>
+
#include "net/disk_cache/blockfile/backend_impl.h"
#include "net/disk_cache/blockfile/disk_format.h"
#include "net/disk_cache/blockfile/entry_impl.h"
@@ -907,8 +911,8 @@ void Rankings::IncrementCounter(List list) {
if (!count_lists_)
return;
- DCHECK(control_data_->sizes[list] < kint32max);
- if (control_data_->sizes[list] < kint32max)
+ DCHECK(control_data_->sizes[list] < std::numeric_limits<int32_t>::max());
+ if (control_data_->sizes[list] < std::numeric_limits<int32_t>::max())
control_data_->sizes[list]++;
}
diff --git a/net/disk_cache/cache_util.cc b/net/disk_cache/cache_util.cc
index 1671138..51ec95b 100644
--- a/net/disk_cache/cache_util.cc
+++ b/net/disk_cache/cache_util.cc
@@ -4,6 +4,8 @@
#include "net/disk_cache/cache_util.h"
+#include <limits>
+
#include "base/files/file_enumerator.h"
#include "base/files/file_util.h"
#include "base/location.h"
@@ -49,7 +51,7 @@ base::FilePath GetTempCacheName(const base::FilePath& path,
return base::FilePath();
}
-int64 PreferredCacheSizeInternal(int64 available) {
+int64_t PreferredCacheSizeInternal(int64_t available) {
using disk_cache::kDefaultCacheSize;
// Return 80% of the available space if there is not enough space to use
// kDefaultCacheSize.
@@ -62,12 +64,12 @@ int64 PreferredCacheSizeInternal(int64 available) {
// Return 10% of the available space if the target size
// (2.5 * kDefaultCacheSize) is more than 10%.
- if (available < static_cast<int64>(kDefaultCacheSize) * 25)
+ if (available < static_cast<int64_t>(kDefaultCacheSize) * 25)
return available / 10;
// Return the target size (2.5 * kDefaultCacheSize) if it uses 10% to 1%
// of the available space.
- if (available < static_cast<int64>(kDefaultCacheSize) * 250)
+ if (available < static_cast<int64_t>(kDefaultCacheSize) * 250)
return kDefaultCacheSize * 5 / 2;
// Return 1% of the available space.
@@ -141,16 +143,16 @@ bool DelayedCacheCleanup(const base::FilePath& full_path) {
// Returns the preferred maximum number of bytes for the cache given the
// number of available bytes.
-int PreferredCacheSize(int64 available) {
+int PreferredCacheSize(int64_t available) {
if (available < 0)
return kDefaultCacheSize;
// Limit cache size to somewhat less than kint32max to avoid potential
// integer overflows in cache backend implementations.
- DCHECK_LT(kDefaultCacheSize * 4, kint32max);
- return static_cast<int32>(std::min(
- PreferredCacheSizeInternal(available),
- static_cast<int64>(kDefaultCacheSize * 4)));
+ DCHECK_LT(kDefaultCacheSize * 4, std::numeric_limits<int32_t>::max());
+ return static_cast<int32_t>(
+ std::min(PreferredCacheSizeInternal(available),
+ static_cast<int64_t>(kDefaultCacheSize * 4)));
}
} // namespace disk_cache
diff --git a/net/disk_cache/cache_util.h b/net/disk_cache/cache_util.h
index c4baa2d..2594012 100644
--- a/net/disk_cache/cache_util.h
+++ b/net/disk_cache/cache_util.h
@@ -5,7 +5,8 @@
#ifndef NET_DISK_CACHE_CACHE_UTIL_H_
#define NET_DISK_CACHE_CACHE_UTIL_H_
-#include "base/basictypes.h"
+#include <stdint.h>
+
#include "net/base/net_export.h"
#include "net/disk_cache/disk_cache.h"
@@ -37,7 +38,7 @@ NET_EXPORT_PRIVATE bool DeleteCacheFile(const base::FilePath& name);
bool DelayedCacheCleanup(const base::FilePath& full_path);
// Returns the preferred max cache size given the available disk space.
-NET_EXPORT_PRIVATE int PreferredCacheSize(int64 available);
+NET_EXPORT_PRIVATE int PreferredCacheSize(int64_t available);
// The default cache size should not ideally be exposed, but the blockfile
// backend uses it for reasons that include testing.
diff --git a/net/disk_cache/simple/simple_synchronous_entry.cc b/net/disk_cache/simple/simple_synchronous_entry.cc
index 584efa6..bf3a3ab 100644
--- a/net/disk_cache/simple/simple_synchronous_entry.cc
+++ b/net/disk_cache/simple/simple_synchronous_entry.cc
@@ -125,8 +125,8 @@ using simple_util::GetFileIndexFromStreamIndex;
SimpleEntryStat::SimpleEntryStat(base::Time last_used,
base::Time last_modified,
- const int32 data_size[],
- const int32 sparse_data_size)
+ const int32_t data_size[],
+ const int32_t sparse_data_size)
: last_used_(last_used),
last_modified_(last_modified),
sparse_data_size_(sparse_data_size) {
@@ -156,9 +156,9 @@ int SimpleEntryStat::GetLastEOFOffsetInFile(const std::string& key,
return GetOffsetInFile(key, eof_data_offset, stream_index);
}
-int64 SimpleEntryStat::GetFileSize(const std::string& key,
- int file_index) const {
- const int32 total_data_size =
+int64_t SimpleEntryStat::GetFileSize(const std::string& key,
+ int file_index) const {
+ const int32_t total_data_size =
file_index == 0 ? data_size_[0] + data_size_[1] + sizeof(SimpleFileEOF)
: data_size_[2];
return GetFileSizeFromKeyAndDataSize(key, total_data_size);
@@ -182,10 +182,8 @@ SimpleSynchronousEntry::CRCRecord::CRCRecord() : index(-1),
SimpleSynchronousEntry::CRCRecord::CRCRecord(int index_p,
bool has_crc32_p,
- uint32 data_crc32_p)
- : index(index_p),
- has_crc32(has_crc32_p),
- data_crc32(data_crc32_p) {}
+ uint32_t data_crc32_p)
+ : index(index_p), has_crc32(has_crc32_p), data_crc32(data_crc32_p) {}
SimpleSynchronousEntry::EntryOperationData::EntryOperationData(int index_p,
int offset_p,
@@ -206,18 +204,17 @@ SimpleSynchronousEntry::EntryOperationData::EntryOperationData(int index_p,
doomed(doomed_p) {}
SimpleSynchronousEntry::EntryOperationData::EntryOperationData(
- int64 sparse_offset_p,
+ int64_t sparse_offset_p,
int buf_len_p)
- : sparse_offset(sparse_offset_p),
- buf_len(buf_len_p) {}
+ : sparse_offset(sparse_offset_p), buf_len(buf_len_p) {}
// static
void SimpleSynchronousEntry::OpenEntry(
net::CacheType cache_type,
const FilePath& path,
- const uint64 entry_hash,
+ const uint64_t entry_hash,
bool had_index,
- SimpleEntryCreationResults *out_results) {
+ SimpleEntryCreationResults* out_results) {
base::ElapsedTimer open_time;
SimpleSynchronousEntry* sync_entry =
new SimpleSynchronousEntry(cache_type, path, "", entry_hash);
@@ -242,9 +239,9 @@ void SimpleSynchronousEntry::CreateEntry(
net::CacheType cache_type,
const FilePath& path,
const std::string& key,
- const uint64 entry_hash,
+ const uint64_t entry_hash,
bool had_index,
- SimpleEntryCreationResults *out_results) {
+ SimpleEntryCreationResults* out_results) {
DCHECK_EQ(entry_hash, GetEntryHashKey(key));
SimpleSynchronousEntry* sync_entry =
new SimpleSynchronousEntry(cache_type, path, key, entry_hash);
@@ -261,19 +258,19 @@ void SimpleSynchronousEntry::CreateEntry(
}
// static
-int SimpleSynchronousEntry::DoomEntry(
- const FilePath& path,
- uint64 entry_hash) {
+int SimpleSynchronousEntry::DoomEntry(const FilePath& path,
+ uint64_t entry_hash) {
const bool deleted_well = DeleteFilesForEntryHash(path, entry_hash);
return deleted_well ? net::OK : net::ERR_FAILED;
}
// static
int SimpleSynchronousEntry::DoomEntrySet(
- const std::vector<uint64>* key_hashes,
+ const std::vector<uint64_t>* key_hashes,
const FilePath& path) {
const size_t did_delete_count = std::count_if(
- key_hashes->begin(), key_hashes->end(), [&path](const uint64& key_hash) {
+ key_hashes->begin(), key_hashes->end(),
+ [&path](const uint64_t& key_hash) {
return SimpleSynchronousEntry::DeleteFilesForEntryHash(path, key_hash);
});
return (did_delete_count == key_hashes->size()) ? net::OK : net::ERR_FAILED;
@@ -281,12 +278,12 @@ int SimpleSynchronousEntry::DoomEntrySet(
void SimpleSynchronousEntry::ReadData(const EntryOperationData& in_entry_op,
net::IOBuffer* out_buf,
- uint32* out_crc32,
+ uint32_t* out_crc32,
SimpleEntryStat* entry_stat,
int* out_result) const {
DCHECK(initialized_);
DCHECK_NE(0, in_entry_op.index);
- const int64 file_offset =
+ const int64_t file_offset =
entry_stat->GetOffsetInFile(key_, in_entry_op.offset, in_entry_op.index);
int file_index = GetFileIndexFromStreamIndex(in_entry_op.index);
// Zero-length reads and reads to the empty streams of omitted files should
@@ -322,7 +319,7 @@ void SimpleSynchronousEntry::WriteData(const EntryOperationData& in_entry_op,
int buf_len = in_entry_op.buf_len;
bool truncate = in_entry_op.truncate;
bool doomed = in_entry_op.doomed;
- const int64 file_offset = out_entry_stat->GetOffsetInFile(
+ const int64_t file_offset = out_entry_stat->GetOffsetInFile(
key_, in_entry_op.offset, in_entry_op.index);
bool extending_by_write = offset + buf_len > out_entry_stat->data_size(index);
@@ -355,7 +352,7 @@ void SimpleSynchronousEntry::WriteData(const EntryOperationData& in_entry_op,
if (extending_by_write) {
// The EOF record and the eventual stream afterward need to be zeroed out.
- const int64 file_eof_offset =
+ const int64_t file_eof_offset =
out_entry_stat->GetEOFOffsetInFile(key_, index);
if (!files_[file_index].SetLength(file_eof_offset)) {
RecordWriteResult(cache_type_, WRITE_RESULT_PRETRUNCATE_FAILURE);
@@ -400,7 +397,7 @@ void SimpleSynchronousEntry::ReadSparseData(
base::Time* out_last_used,
int* out_result) {
DCHECK(initialized_);
- int64 offset = in_entry_op.sparse_offset;
+ int64_t offset = in_entry_op.sparse_offset;
int buf_len = in_entry_op.buf_len;
char* buf = out_buf->data();
@@ -416,9 +413,10 @@ void SimpleSynchronousEntry::ReadSparseData(
DCHECK_EQ(it->first, found_range->offset);
if (found_range->offset + found_range->length > offset) {
DCHECK_GE(found_range->length, 0);
- DCHECK_LE(found_range->length, kint32max);
+ DCHECK_LE(found_range->length, std::numeric_limits<int32_t>::max());
DCHECK_GE(offset - found_range->offset, 0);
- DCHECK_LE(offset - found_range->offset, kint32max);
+ DCHECK_LE(offset - found_range->offset,
+ std::numeric_limits<int32_t>::max());
int net_offset = static_cast<int>(offset - found_range->offset);
int range_len_after_offset =
static_cast<int>(found_range->length - net_offset);
@@ -457,11 +455,11 @@ void SimpleSynchronousEntry::ReadSparseData(
void SimpleSynchronousEntry::WriteSparseData(
const EntryOperationData& in_entry_op,
net::IOBuffer* in_buf,
- uint64 max_sparse_data_size,
+ uint64_t max_sparse_data_size,
SimpleEntryStat* out_entry_stat,
int* out_result) {
DCHECK(initialized_);
- int64 offset = in_entry_op.sparse_offset;
+ int64_t offset = in_entry_op.sparse_offset;
int buf_len = in_entry_op.buf_len;
const char* buf = in_buf->data();
@@ -473,7 +471,7 @@ void SimpleSynchronousEntry::WriteSparseData(
return;
}
- uint64 sparse_data_size = out_entry_stat->sparse_data_size();
+ uint64_t sparse_data_size = out_entry_stat->sparse_data_size();
// This is a pessimistic estimate; it assumes the entire buffer is going to
// be appended as a new range, not written over existing ranges.
if (sparse_data_size + buf_len > max_sparse_data_size) {
@@ -490,9 +488,10 @@ void SimpleSynchronousEntry::WriteSparseData(
SparseRange* found_range = &it->second;
if (found_range->offset + found_range->length > offset) {
DCHECK_GE(found_range->length, 0);
- DCHECK_LE(found_range->length, kint32max);
+ DCHECK_LE(found_range->length, std::numeric_limits<int32_t>::max());
DCHECK_GE(offset - found_range->offset, 0);
- DCHECK_LE(offset - found_range->offset, kint32max);
+ DCHECK_LE(offset - found_range->offset,
+ std::numeric_limits<int32_t>::max());
int net_offset = static_cast<int>(offset - found_range->offset);
int range_len_after_offset =
static_cast<int>(found_range->length - net_offset);
@@ -554,23 +553,23 @@ void SimpleSynchronousEntry::WriteSparseData(
base::Time modification_time = Time::Now();
out_entry_stat->set_last_used(modification_time);
out_entry_stat->set_last_modified(modification_time);
- int32 old_sparse_data_size = out_entry_stat->sparse_data_size();
+ int32_t old_sparse_data_size = out_entry_stat->sparse_data_size();
out_entry_stat->set_sparse_data_size(old_sparse_data_size + appended_so_far);
*out_result = written_so_far;
}
void SimpleSynchronousEntry::GetAvailableRange(
const EntryOperationData& in_entry_op,
- int64* out_start,
+ int64_t* out_start,
int* out_result) {
DCHECK(initialized_);
- int64 offset = in_entry_op.sparse_offset;
+ int64_t offset = in_entry_op.sparse_offset;
int len = in_entry_op.buf_len;
SparseRangeIterator it = sparse_ranges_.lower_bound(offset);
- int64 start = offset;
- int64 avail_so_far = 0;
+ int64_t start = offset;
+ int64_t avail_so_far = 0;
if (it != sparse_ranges_.end() && it->second.offset < offset + len)
start = it->second.offset;
@@ -592,17 +591,17 @@ void SimpleSynchronousEntry::GetAvailableRange(
++it;
}
- int64 len_from_start = len - (start - offset);
+ int64_t len_from_start = len - (start - offset);
*out_start = start;
*out_result = static_cast<int>(std::min(avail_so_far, len_from_start));
}
void SimpleSynchronousEntry::CheckEOFRecord(int index,
const SimpleEntryStat& entry_stat,
- uint32 expected_crc32,
+ uint32_t expected_crc32,
int* out_result) const {
DCHECK(initialized_);
- uint32 crc32;
+ uint32_t crc32;
bool has_crc32;
int stream_size;
*out_result =
@@ -676,11 +675,11 @@ void SimpleSynchronousEntry::Close(
continue;
files_[i].Close();
- const int64 file_size = entry_stat.GetFileSize(key_, i);
+ const int64_t file_size = entry_stat.GetFileSize(key_, i);
SIMPLE_CACHE_UMA(CUSTOM_COUNTS,
"LastClusterSize", cache_type_,
file_size % 4096, 0, 4097, 50);
- const int64 cluster_loss = file_size % 4096 ? 4096 - file_size % 4096 : 0;
+ const int64_t cluster_loss = file_size % 4096 ? 4096 - file_size % 4096 : 0;
SIMPLE_CACHE_UMA(PERCENTAGE,
"LastClusterLossPercent", cache_type_,
static_cast<base::HistogramBase::Sample>(
@@ -703,7 +702,7 @@ void SimpleSynchronousEntry::Close(
SimpleSynchronousEntry::SimpleSynchronousEntry(net::CacheType cache_type,
const FilePath& path,
const std::string& key,
- const uint64 entry_hash)
+ const uint64_t entry_hash)
: cache_type_(cache_type),
path_(path),
entry_hash_(entry_hash),
@@ -904,7 +903,7 @@ int SimpleSynchronousEntry::InitializeForOpen(
bool had_index,
SimpleEntryStat* out_entry_stat,
scoped_refptr<net::GrowableIOBuffer>* stream_0_data,
- uint32* out_stream_0_crc32) {
+ uint32_t* out_stream_0_crc32) {
DCHECK(!initialized_);
if (!OpenFiles(had_index, out_entry_stat)) {
DLOG(WARNING) << "Could not open platform files for entry.";
@@ -973,7 +972,7 @@ int SimpleSynchronousEntry::InitializeForOpen(
}
}
- int32 sparse_data_size = 0;
+ int32_t sparse_data_size = 0;
if (!OpenSparseFileIfExists(&sparse_data_size)) {
RecordSyncOpenResult(
cache_type_, OPEN_ENTRY_SPARSE_OPEN_FAILED, had_index);
@@ -1055,14 +1054,14 @@ int SimpleSynchronousEntry::ReadAndValidateStream0(
int total_data_size,
SimpleEntryStat* out_entry_stat,
scoped_refptr<net::GrowableIOBuffer>* stream_0_data,
- uint32* out_stream_0_crc32) const {
+ uint32_t* out_stream_0_crc32) const {
// Temporarily assign all the data size to stream 1 in order to read the
// EOF record for stream 0, which contains the size of stream 0.
out_entry_stat->set_data_size(0, 0);
out_entry_stat->set_data_size(1, total_data_size - sizeof(SimpleFileEOF));
bool has_crc32;
- uint32 read_crc32;
+ uint32_t read_crc32;
int stream_0_size;
int ret_value_crc32 = GetEOFRecordData(
0, *out_entry_stat, &has_crc32, &read_crc32, &stream_0_size);
@@ -1088,7 +1087,7 @@ int SimpleSynchronousEntry::ReadAndValidateStream0(
return net::ERR_FAILED;
// Check the CRC32.
- uint32 expected_crc32 =
+ uint32_t expected_crc32 =
stream_0_size == 0
? crc32(0, Z_NULL, 0)
: crc32(crc32(0, Z_NULL, 0),
@@ -1107,7 +1106,7 @@ int SimpleSynchronousEntry::ReadAndValidateStream0(
int SimpleSynchronousEntry::GetEOFRecordData(int index,
const SimpleEntryStat& entry_stat,
bool* out_has_crc32,
- uint32* out_crc32,
+ uint32_t* out_crc32,
int* out_data_size) const {
SimpleFileEOF eof_record;
int file_offset = entry_stat.GetEOFOffsetInFile(key_, index);
@@ -1139,10 +1138,9 @@ void SimpleSynchronousEntry::Doom() const {
}
// static
-bool SimpleSynchronousEntry::DeleteFileForEntryHash(
- const FilePath& path,
- const uint64 entry_hash,
- const int file_index) {
+bool SimpleSynchronousEntry::DeleteFileForEntryHash(const FilePath& path,
+ const uint64_t entry_hash,
+ const int file_index) {
FilePath to_delete = path.AppendASCII(
GetFilenameFromEntryHashAndFileIndex(entry_hash, file_index));
return simple_util::SimpleCacheDeleteFile(to_delete);
@@ -1151,7 +1149,7 @@ bool SimpleSynchronousEntry::DeleteFileForEntryHash(
// static
bool SimpleSynchronousEntry::DeleteFilesForEntryHash(
const FilePath& path,
- const uint64 entry_hash) {
+ const uint64_t entry_hash) {
bool result = true;
for (int i = 0; i < kSimpleEntryFileCount; ++i) {
if (!DeleteFileForEntryHash(path, entry_hash, i) && !CanOmitEmptyFile(i))
@@ -1185,7 +1183,7 @@ FilePath SimpleSynchronousEntry::GetFilenameFromFileIndex(int file_index) {
}
bool SimpleSynchronousEntry::OpenSparseFileIfExists(
- int32* out_sparse_data_size) {
+ int32_t* out_sparse_data_size) {
DCHECK(!sparse_file_open());
FilePath filename = path_.AppendASCII(
@@ -1221,7 +1219,7 @@ void SimpleSynchronousEntry::CloseSparseFile() {
bool SimpleSynchronousEntry::TruncateSparseFile() {
DCHECK(sparse_file_open());
- int64 header_and_key_length = sizeof(SimpleFileHeader) + key_.size();
+ int64_t header_and_key_length = sizeof(SimpleFileHeader) + key_.size();
if (!sparse_file_.SetLength(header_and_key_length)) {
DLOG(WARNING) << "Could not truncate sparse file";
return false;
@@ -1262,10 +1260,10 @@ bool SimpleSynchronousEntry::InitializeSparseFile() {
return true;
}
-bool SimpleSynchronousEntry::ScanSparseFile(int32* out_sparse_data_size) {
+bool SimpleSynchronousEntry::ScanSparseFile(int32_t* out_sparse_data_size) {
DCHECK(sparse_file_open());
- int64 sparse_data_size = 0;
+ int64_t sparse_data_size = 0;
SimpleFileHeader header;
int header_read_result =
@@ -1287,7 +1285,7 @@ bool SimpleSynchronousEntry::ScanSparseFile(int32* out_sparse_data_size) {
sparse_ranges_.clear();
- int64 range_header_offset = sizeof(header) + key_.size();
+ int64_t range_header_offset = sizeof(header) + key_.size();
while (1) {
SimpleFileSparseRangeHeader range_header;
int range_header_read_result =
@@ -1320,7 +1318,7 @@ bool SimpleSynchronousEntry::ScanSparseFile(int32* out_sparse_data_size) {
sparse_data_size += range.length;
}
- *out_sparse_data_size = static_cast<int32>(sparse_data_size);
+ *out_sparse_data_size = static_cast<int32_t>(sparse_data_size);
sparse_tail_offset_ = range_header_offset;
return true;
@@ -1341,9 +1339,8 @@ bool SimpleSynchronousEntry::ReadSparseRange(const SparseRange* range,
// If we read the whole range and we have a crc32, check it.
if (offset == 0 && len == range->length && range->data_crc32 != 0) {
- uint32 actual_crc32 = crc32(crc32(0L, Z_NULL, 0),
- reinterpret_cast<const Bytef*>(buf),
- len);
+ uint32_t actual_crc32 =
+ crc32(crc32(0L, Z_NULL, 0), reinterpret_cast<const Bytef*>(buf), len);
if (actual_crc32 != range->data_crc32) {
DLOG(WARNING) << "Sparse range crc32 mismatch.";
return false;
@@ -1362,7 +1359,7 @@ bool SimpleSynchronousEntry::WriteSparseRange(SparseRange* range,
DCHECK_LE(offset, range->length);
DCHECK_LE(offset + len, range->length);
- uint32 new_crc32 = 0;
+ uint32_t new_crc32 = 0;
if (offset == 0 && len == range->length) {
new_crc32 = crc32(crc32(0L, Z_NULL, 0),
reinterpret_cast<const Bytef*>(buf),
@@ -1396,16 +1393,15 @@ bool SimpleSynchronousEntry::WriteSparseRange(SparseRange* range,
return true;
}
-bool SimpleSynchronousEntry::AppendSparseRange(int64 offset,
+bool SimpleSynchronousEntry::AppendSparseRange(int64_t offset,
int len,
const char* buf) {
DCHECK_GE(offset, 0);
DCHECK_GT(len, 0);
DCHECK(buf);
- uint32 data_crc32 = crc32(crc32(0L, Z_NULL, 0),
- reinterpret_cast<const Bytef*>(buf),
- len);
+ uint32_t data_crc32 =
+ crc32(crc32(0L, Z_NULL, 0), reinterpret_cast<const Bytef*>(buf), len);
SimpleFileSparseRangeHeader header;
header.sparse_range_magic_number = kSimpleSparseRangeMagicNumber;
@@ -1427,7 +1423,7 @@ bool SimpleSynchronousEntry::AppendSparseRange(int64 offset,
DLOG(WARNING) << "Could not append sparse range data.";
return false;
}
- int64 data_file_offset = sparse_tail_offset_;
+ int64_t data_file_offset = sparse_tail_offset_;
sparse_tail_offset_ += bytes_written;
SparseRange range;
diff --git a/net/disk_cache/simple/simple_synchronous_entry.h b/net/disk_cache/simple/simple_synchronous_entry.h
index 7f98b21..6386a45 100644
--- a/net/disk_cache/simple/simple_synchronous_entry.h
+++ b/net/disk_cache/simple/simple_synchronous_entry.h
@@ -5,6 +5,8 @@
#ifndef NET_DISK_CACHE_SIMPLE_SIMPLE_SYNCHRONOUS_ENTRY_H_
#define NET_DISK_CACHE_SIMPLE_SIMPLE_SYNCHRONOUS_ENTRY_H_
+#include <stdint.h>
+
#include <algorithm>
#include <map>
#include <string>
@@ -36,15 +38,15 @@ class NET_EXPORT_PRIVATE SimpleEntryStat {
public:
SimpleEntryStat(base::Time last_used,
base::Time last_modified,
- const int32 data_size[],
- const int32 sparse_data_size);
+ const int32_t data_size[],
+ const int32_t sparse_data_size);
int GetOffsetInFile(const std::string& key,
int offset,
int stream_index) const;
int GetEOFOffsetInFile(const std::string& key, int stream_index) const;
int GetLastEOFOffsetInFile(const std::string& key, int file_index) const;
- int64 GetFileSize(const std::string& key, int file_index) const;
+ int64_t GetFileSize(const std::string& key, int file_index) const;
base::Time last_used() const { return last_used_; }
base::Time last_modified() const { return last_modified_; }
@@ -53,21 +55,21 @@ class NET_EXPORT_PRIVATE SimpleEntryStat {
last_modified_ = last_modified;
}
- int32 data_size(int stream_index) const { return data_size_[stream_index]; }
+ int32_t data_size(int stream_index) const { return data_size_[stream_index]; }
void set_data_size(int stream_index, int data_size) {
data_size_[stream_index] = data_size;
}
- int32 sparse_data_size() const { return sparse_data_size_; }
- void set_sparse_data_size(int32 sparse_data_size) {
+ int32_t sparse_data_size() const { return sparse_data_size_; }
+ void set_sparse_data_size(int32_t sparse_data_size) {
sparse_data_size_ = sparse_data_size;
}
private:
base::Time last_used_;
base::Time last_modified_;
- int32 data_size_[kSimpleEntryStreamCount];
- int32 sparse_data_size_;
+ int32_t data_size_[kSimpleEntryStreamCount];
+ int32_t sparse_data_size_;
};
struct SimpleEntryCreationResults {
@@ -77,7 +79,7 @@ struct SimpleEntryCreationResults {
SimpleSynchronousEntry* sync_entry;
scoped_refptr<net::GrowableIOBuffer> stream_0_data;
SimpleEntryStat entry_stat;
- uint32 stream_0_crc32;
+ uint32_t stream_0_crc32;
int result;
};
@@ -88,11 +90,11 @@ class SimpleSynchronousEntry {
public:
struct CRCRecord {
CRCRecord();
- CRCRecord(int index_p, bool has_crc32_p, uint32 data_crc32_p);
+ CRCRecord(int index_p, bool has_crc32_p, uint32_t data_crc32_p);
int index;
bool has_crc32;
- uint32 data_crc32;
+ uint32_t data_crc32;
};
struct EntryOperationData {
@@ -102,11 +104,11 @@ class SimpleSynchronousEntry {
int buf_len_p,
bool truncate_p,
bool doomed_p);
- EntryOperationData(int64 sparse_offset_p, int buf_len_p);
+ EntryOperationData(int64_t sparse_offset_p, int buf_len_p);
int index;
int offset;
- int64 sparse_offset;
+ int64_t sparse_offset;
int buf_len;
bool truncate;
bool doomed;
@@ -114,33 +116,32 @@ class SimpleSynchronousEntry {
static void OpenEntry(net::CacheType cache_type,
const base::FilePath& path,
- uint64 entry_hash,
+ uint64_t entry_hash,
bool had_index,
SimpleEntryCreationResults* out_results);
static void CreateEntry(net::CacheType cache_type,
const base::FilePath& path,
const std::string& key,
- uint64 entry_hash,
+ uint64_t entry_hash,
bool had_index,
SimpleEntryCreationResults* out_results);
// Deletes an entry from the file system without affecting the state of the
// corresponding instance, if any (allowing operations to continue to be
// executed through that instance). Returns a net error code.
- static int DoomEntry(const base::FilePath& path,
- uint64 entry_hash);
+ static int DoomEntry(const base::FilePath& path, uint64_t entry_hash);
// Like |DoomEntry()| above. Deletes all entries corresponding to the
// |key_hashes|. Succeeds only when all entries are deleted. Returns a net
// error code.
- static int DoomEntrySet(const std::vector<uint64>* key_hashes,
+ static int DoomEntrySet(const std::vector<uint64_t>* key_hashes,
const base::FilePath& path);
// N.B. ReadData(), WriteData(), CheckEOFRecord() and Close() may block on IO.
void ReadData(const EntryOperationData& in_entry_op,
net::IOBuffer* out_buf,
- uint32* out_crc32,
+ uint32_t* out_crc32,
SimpleEntryStat* entry_stat,
int* out_result) const;
void WriteData(const EntryOperationData& in_entry_op,
@@ -149,7 +150,7 @@ class SimpleSynchronousEntry {
int* out_result);
void CheckEOFRecord(int index,
const SimpleEntryStat& entry_stat,
- uint32 expected_crc32,
+ uint32_t expected_crc32,
int* out_result) const;
void ReadSparseData(const EntryOperationData& in_entry_op,
@@ -158,11 +159,11 @@ class SimpleSynchronousEntry {
int* out_result);
void WriteSparseData(const EntryOperationData& in_entry_op,
net::IOBuffer* in_buf,
- uint64 max_sparse_data_size,
+ uint64_t max_sparse_data_size,
SimpleEntryStat* out_entry_stat,
int* out_result);
void GetAvailableRange(const EntryOperationData& in_entry_op,
- int64* out_start,
+ int64_t* out_start,
int* out_result);
// Close all streams, and add write EOF records to streams indicated by the
@@ -189,21 +190,20 @@ class SimpleSynchronousEntry {
};
struct SparseRange {
- int64 offset;
- int64 length;
- uint32 data_crc32;
- int64 file_offset;
+ int64_t offset;
+ int64_t length;
+ uint32_t data_crc32;
+ int64_t file_offset;
bool operator<(const SparseRange& other) const {
return offset < other.offset;
}
};
- SimpleSynchronousEntry(
- net::CacheType cache_type,
- const base::FilePath& path,
- const std::string& key,
- uint64 entry_hash);
+ SimpleSynchronousEntry(net::CacheType cache_type,
+ const base::FilePath& path,
+ const std::string& key,
+ uint64_t entry_hash);
// Like Entry, the SimpleSynchronousEntry self releases when Close() is
// called.
@@ -233,7 +233,7 @@ class SimpleSynchronousEntry {
int InitializeForOpen(bool had_index,
SimpleEntryStat* out_entry_stat,
scoped_refptr<net::GrowableIOBuffer>* stream_0_data,
- uint32* out_stream_0_crc32);
+ uint32_t* out_stream_0_crc32);
// Writes the header and key to a newly-created stream file. |index| is the
// index of the stream. Returns true on success; returns false and sets
@@ -252,17 +252,17 @@ class SimpleSynchronousEntry {
int total_data_size,
SimpleEntryStat* out_entry_stat,
scoped_refptr<net::GrowableIOBuffer>* stream_0_data,
- uint32* out_stream_0_crc32) const;
+ uint32_t* out_stream_0_crc32) const;
int GetEOFRecordData(int index,
const SimpleEntryStat& entry_stat,
bool* out_has_crc32,
- uint32* out_crc32,
+ uint32_t* out_crc32,
int* out_data_size) const;
void Doom() const;
// Opens the sparse data file and scans it if it exists.
- bool OpenSparseFileIfExists(int32* out_sparse_data_size);
+ bool OpenSparseFileIfExists(int32_t* out_sparse_data_size);
// Creates and initializes the sparse data file.
bool CreateSparseFile();
@@ -279,7 +279,7 @@ class SimpleSynchronousEntry {
// Scans the existing ranges in the sparse file. Populates |sparse_ranges_|
// and sets |*out_sparse_data_size| to the total size of all the ranges (not
// including headers).
- bool ScanSparseFile(int32* out_sparse_data_size);
+ bool ScanSparseFile(int32_t* out_sparse_data_size);
// Reads from a single sparse range. If asked to read the entire range, also
// verifies the CRC32.
@@ -292,13 +292,13 @@ class SimpleSynchronousEntry {
int offset, int len, const char* buf);
// Appends a new sparse range to the sparse data file.
- bool AppendSparseRange(int64 offset, int len, const char* buf);
+ bool AppendSparseRange(int64_t offset, int len, const char* buf);
static bool DeleteFileForEntryHash(const base::FilePath& path,
- uint64 entry_hash,
+ uint64_t entry_hash,
int file_index);
static bool DeleteFilesForEntryHash(const base::FilePath& path,
- uint64 entry_hash);
+ uint64_t entry_hash);
void RecordSyncCreateResult(CreateEntryResult result, bool had_index);
@@ -310,7 +310,7 @@ class SimpleSynchronousEntry {
const net::CacheType cache_type_;
const base::FilePath path_;
- const uint64 entry_hash_;
+ const uint64_t entry_hash_;
std::string key_;
bool have_open_files_;
@@ -322,13 +322,13 @@ class SimpleSynchronousEntry {
// was created to store it.
bool empty_file_omitted_[kSimpleEntryFileCount];
- typedef std::map<int64, SparseRange> SparseRangeOffsetMap;
+ typedef std::map<int64_t, SparseRange> SparseRangeOffsetMap;
typedef SparseRangeOffsetMap::iterator SparseRangeIterator;
SparseRangeOffsetMap sparse_ranges_;
base::File sparse_file_;
// Offset of the end of the sparse file (where the next sparse range will be
// written).
- int64 sparse_tail_offset_;
+ int64_t sparse_tail_offset_;
// True if the entry was created, or false if it was opened. Used to log
// SimpleCache.*.EntryCreatedWithStream2Omitted only for created entries.
diff --git a/net/http/mock_http_cache.cc b/net/http/mock_http_cache.cc
index 184270a..e5496b1 100644
--- a/net/http/mock_http_cache.cc
+++ b/net/http/mock_http_cache.cc
@@ -4,6 +4,8 @@
#include "net/http/mock_http_cache.h"
+#include <limits>
+
#include "base/bind.h"
#include "base/location.h"
#include "base/single_thread_task_runner.h"
@@ -86,9 +88,9 @@ base::Time MockDiskEntry::GetLastModified() const {
return base::Time::FromInternalValue(0);
}
-int32 MockDiskEntry::GetDataSize(int index) const {
+int32_t MockDiskEntry::GetDataSize(int index) const {
DCHECK(index >= 0 && index < kNumCacheEntryDataIndices);
- return static_cast<int32>(data_[index].size());
+ return static_cast<int32_t>(data_[index].size());
}
int MockDiskEntry::ReadData(int index,
@@ -146,7 +148,7 @@ int MockDiskEntry::WriteData(int index,
return ERR_IO_PENDING;
}
-int MockDiskEntry::ReadSparseData(int64 offset,
+int MockDiskEntry::ReadSparseData(int64_t offset,
IOBuffer* buf,
int buf_len,
const CompletionCallback& callback) {
@@ -161,7 +163,7 @@ int MockDiskEntry::ReadSparseData(int64 offset,
if (fail_requests_)
return ERR_CACHE_READ_FAILURE;
- DCHECK(offset < kint32max);
+ DCHECK(offset < std::numeric_limits<int32_t>::max());
int real_offset = static_cast<int>(offset);
if (!buf_len)
return 0;
@@ -179,7 +181,7 @@ int MockDiskEntry::ReadSparseData(int64 offset,
return ERR_IO_PENDING;
}
-int MockDiskEntry::WriteSparseData(int64 offset,
+int MockDiskEntry::WriteSparseData(int64_t offset,
IOBuffer* buf,
int buf_len,
const CompletionCallback& callback) {
@@ -201,7 +203,7 @@ int MockDiskEntry::WriteSparseData(int64 offset,
if (fail_requests_)
return ERR_CACHE_READ_FAILURE;
- DCHECK(offset < kint32max);
+ DCHECK(offset < std::numeric_limits<int32_t>::max());
int real_offset = static_cast<int>(offset);
if (static_cast<int>(data_[1].size()) < real_offset + buf_len)
@@ -215,9 +217,9 @@ int MockDiskEntry::WriteSparseData(int64 offset,
return ERR_IO_PENDING;
}
-int MockDiskEntry::GetAvailableRange(int64 offset,
+int MockDiskEntry::GetAvailableRange(int64_t offset,
int len,
- int64* start,
+ int64_t* start,
const CompletionCallback& callback) {
DCHECK(!callback.is_null());
if (!sparse_ || busy_ || cancel_)
@@ -229,7 +231,7 @@ int MockDiskEntry::GetAvailableRange(int64 offset,
return ERR_CACHE_READ_FAILURE;
*start = offset;
- DCHECK(offset < kint32max);
+ DCHECK(offset < std::numeric_limits<int32_t>::max());
int real_offset = static_cast<int>(offset);
if (static_cast<int>(data_[1].size()) < real_offset)
return 0;
@@ -368,8 +370,8 @@ CacheType MockDiskCache::GetCacheType() const {
return DISK_CACHE;
}
-int32 MockDiskCache::GetEntryCount() const {
- return static_cast<int32>(entries_.size());
+int32_t MockDiskCache::GetEntryCount() const {
+ return static_cast<int32_t>(entries_.size());
}
int MockDiskCache::OpenEntry(const std::string& key,
diff --git a/net/http/mock_http_cache.h b/net/http/mock_http_cache.h
index e0b8e71..86b8e51 100644
--- a/net/http/mock_http_cache.h
+++ b/net/http/mock_http_cache.h
@@ -10,6 +10,8 @@
#ifndef NET_HTTP_MOCK_HTTP_CACHE_H_
#define NET_HTTP_MOCK_HTTP_CACHE_H_
+#include <stdint.h>
+
#include "base/containers/hash_tables.h"
#include "base/strings/string_split.h"
#include "net/disk_cache/disk_cache.h"
@@ -33,7 +35,7 @@ class MockDiskEntry : public disk_cache::Entry,
std::string GetKey() const override;
base::Time GetLastUsed() const override;
base::Time GetLastModified() const override;
- int32 GetDataSize(int index) const override;
+ int32_t GetDataSize(int index) const override;
int ReadData(int index,
int offset,
IOBuffer* buf,
@@ -45,17 +47,17 @@ class MockDiskEntry : public disk_cache::Entry,
int buf_len,
const CompletionCallback& callback,
bool truncate) override;
- int ReadSparseData(int64 offset,
+ int ReadSparseData(int64_t offset,
IOBuffer* buf,
int buf_len,
const CompletionCallback& callback) override;
- int WriteSparseData(int64 offset,
+ int WriteSparseData(int64_t offset,
IOBuffer* buf,
int buf_len,
const CompletionCallback& callback) override;
- int GetAvailableRange(int64 offset,
+ int GetAvailableRange(int64_t offset,
int len,
- int64* start,
+ int64_t* start,
const CompletionCallback& callback) override;
bool CouldBeSparse() const override;
void CancelSparseIO() override;
@@ -112,7 +114,7 @@ class MockDiskCache : public disk_cache::Backend {
~MockDiskCache() override;
CacheType GetCacheType() const override;
- int32 GetEntryCount() const override;
+ int32_t GetEntryCount() const override;
int OpenEntry(const std::string& key,
disk_cache::Entry** entry,
const CompletionCallback& callback) override;
diff --git a/net/http/partial_data.cc b/net/http/partial_data.cc
index 8e1eb0a..915aaa4 100644
--- a/net/http/partial_data.cc
+++ b/net/http/partial_data.cc
@@ -4,6 +4,8 @@
#include "net/http/partial_data.h"
+#include <limits>
+
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/format_macros.h"
@@ -72,8 +74,9 @@ void PartialData::SetHeaders(const HttpRequestHeaders& headers) {
void PartialData::RestoreHeaders(HttpRequestHeaders* headers) const {
DCHECK(current_range_start_ >= 0 || byte_range_.IsSuffixByteRange());
- int64 end = byte_range_.IsSuffixByteRange() ?
- byte_range_.suffix_length() : byte_range_.last_byte_position();
+ int64_t end = byte_range_.IsSuffixByteRange()
+ ? byte_range_.suffix_length()
+ : byte_range_.last_byte_position();
headers->CopyFrom(extra_headers_);
if (truncated_ || !byte_range_.IsValid())
@@ -102,7 +105,7 @@ int PartialData::ShouldValidateCache(disk_cache::Entry* entry,
if (sparse_entry_) {
DCHECK(callback_.is_null());
- int64* start = new int64;
+ int64_t* start = new int64_t;
// This callback now owns "start". We make sure to keep it
// in a local variable since we want to use it later.
CompletionCallback cb =
@@ -193,7 +196,7 @@ bool PartialData::UpdateFromStoredHeaders(const HttpResponseHeaders* headers,
// Now we avoid resume if there is no content length, but that was not
// always the case so double check here.
- int64 total_length = headers->GetContentLength();
+ int64_t total_length = headers->GetContentLength();
if (total_length <= 0)
return false;
@@ -220,7 +223,7 @@ bool PartialData::UpdateFromStoredHeaders(const HttpResponseHeaders* headers,
if (!headers->HasStrongValidators())
return false;
- int64 length_value = headers->GetContentLength();
+ int64_t length_value = headers->GetContentLength();
if (length_value <= 0)
return false; // We must have stored the resource length.
@@ -270,7 +273,7 @@ bool PartialData::ResponseHeadersOK(const HttpResponseHeaders* headers) {
byte_range_.HasLastBytePosition();
}
- int64 start, end, total_length;
+ int64_t start, end, total_length;
if (!headers->GetContentRange(&start, &end, &total_length))
return false;
if (total_length <= 0)
@@ -280,7 +283,7 @@ bool PartialData::ResponseHeadersOK(const HttpResponseHeaders* headers) {
// A server should return a valid content length with a 206 (per the standard)
// but relax the requirement because some servers don't do that.
- int64 content_length = headers->GetContentLength();
+ int64_t content_length = headers->GetContentLength();
if (content_length > 0 && content_length != end - start + 1)
return false;
@@ -374,7 +377,7 @@ int PartialData::CacheRead(disk_cache::Entry* entry,
rv = entry->ReadSparseData(current_range_start_, data, read_len,
callback);
} else {
- if (current_range_start_ > kint32max)
+ if (current_range_start_ > std::numeric_limits<int32_t>::max())
return ERR_INVALID_ARGUMENT;
rv = entry->ReadData(kDataStream, static_cast<int>(current_range_start_),
@@ -392,7 +395,7 @@ int PartialData::CacheWrite(disk_cache::Entry* entry,
return entry->WriteSparseData(
current_range_start_, data, data_len, callback);
} else {
- if (current_range_start_ > kint32max)
+ if (current_range_start_ > std::numeric_limits<int32_t>::max())
return ERR_INVALID_ARGUMENT;
return entry->WriteData(kDataStream, static_cast<int>(current_range_start_),
@@ -415,16 +418,16 @@ void PartialData::OnNetworkReadCompleted(int result) {
}
int PartialData::GetNextRangeLen() {
- int64 range_len =
- byte_range_.HasLastBytePosition() ?
- byte_range_.last_byte_position() - current_range_start_ + 1 :
- kint32max;
- if (range_len > kint32max)
- range_len = kint32max;
- return static_cast<int32>(range_len);
+ int64_t range_len =
+ byte_range_.HasLastBytePosition()
+ ? byte_range_.last_byte_position() - current_range_start_ + 1
+ : std::numeric_limits<int32_t>::max();
+ if (range_len > std::numeric_limits<int32_t>::max())
+ range_len = std::numeric_limits<int32_t>::max();
+ return static_cast<int32_t>(range_len);
}
-void PartialData::GetAvailableRangeCompleted(int64* start, int result) {
+void PartialData::GetAvailableRangeCompleted(int64_t* start, int result) {
DCHECK(!callback_.is_null());
DCHECK_NE(ERR_IO_PENDING, result);
diff --git a/net/http/partial_data.h b/net/http/partial_data.h
index 649d462..29ccbb3 100644
--- a/net/http/partial_data.h
+++ b/net/http/partial_data.h
@@ -5,7 +5,9 @@
#ifndef NET_HTTP_PARTIAL_DATA_H_
#define NET_HTTP_PARTIAL_DATA_H_
-#include "base/basictypes.h"
+#include <stdint.h>
+
+#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "net/base/completion_callback.h"
#include "net/http/http_byte_range.h"
@@ -124,12 +126,12 @@ class PartialData {
int GetNextRangeLen();
// Completion routine for our callback.
- void GetAvailableRangeCompleted(int64* start, int result);
+ void GetAvailableRangeCompleted(int64_t* start, int result);
- int64 current_range_start_;
- int64 current_range_end_;
- int64 cached_start_;
- int64 resource_size_;
+ int64_t current_range_start_;
+ int64_t current_range_end_;
+ int64_t cached_start_;
+ int64_t resource_size_;
int cached_min_len_;
HttpByteRange byte_range_; // The range requested by the user.
// The clean set of extra headers (no ranges).
diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc
index 3810928..50428ff 100644
--- a/net/spdy/spdy_session.cc
+++ b/net/spdy/spdy_session.cc
@@ -5,6 +5,7 @@
#include "net/spdy/spdy_session.h"
#include <algorithm>
+#include <limits>
#include <map>
#include "base/basictypes.h"
@@ -173,7 +174,7 @@ scoped_ptr<base::Value> NetLogSpdySettingCallback(
SpdySettingsIds id,
const SpdyMajorVersion protocol_version,
SpdySettingsFlags flags,
- uint32 value,
+ uint32_t value,
NetLogCaptureMode /* capture_mode */) {
scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
dict->SetInteger("id",
@@ -193,7 +194,7 @@ scoped_ptr<base::Value> NetLogSpdySendSettingsCallback(
it != settings->end(); ++it) {
const SpdySettingsIds id = it->first;
const SpdySettingsFlags flags = it->second.first;
- const uint32 value = it->second.second;
+ const uint32_t value = it->second.second;
settings_list->Append(new base::StringValue(base::StringPrintf(
"[id:%u flags:%u value:%u]",
SpdyConstants::SerializeSettingId(protocol_version, id),
@@ -206,7 +207,7 @@ scoped_ptr<base::Value> NetLogSpdySendSettingsCallback(
scoped_ptr<base::Value> NetLogSpdyWindowUpdateFrameCallback(
SpdyStreamId stream_id,
- uint32 delta,
+ uint32_t delta,
NetLogCaptureMode /* capture_mode */) {
scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
dict->SetInteger("stream_id", static_cast<int>(stream_id));
@@ -215,8 +216,8 @@ scoped_ptr<base::Value> NetLogSpdyWindowUpdateFrameCallback(
}
scoped_ptr<base::Value> NetLogSpdySessionWindowUpdateCallback(
- int32 delta,
- int32 window_size,
+ int32_t delta,
+ int32_t window_size,
NetLogCaptureMode /* capture_mode */) {
scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
dict->SetInteger("delta", delta);
@@ -1264,10 +1265,8 @@ scoped_ptr<SpdyBuffer> SpdySession::CreateDataBuffer(SpdyStreamId stream_id,
// TODO(mbelshe): reduce memory copies here.
DCHECK(buffered_spdy_framer_.get());
- scoped_ptr<SpdyFrame> frame(
- buffered_spdy_framer_->CreateDataFrame(
- stream_id, data->data(),
- static_cast<uint32>(effective_len), flags));
+ scoped_ptr<SpdyFrame> frame(buffered_spdy_framer_->CreateDataFrame(
+ stream_id, data->data(), static_cast<uint32_t>(effective_len), flags));
scoped_ptr<SpdyBuffer> data_buffer(new SpdyBuffer(frame.Pass()));
@@ -1275,7 +1274,7 @@ scoped_ptr<SpdyBuffer> SpdySession::CreateDataBuffer(SpdyStreamId stream_id,
// just a FIN with no payload.
if (flow_control_state_ == FLOW_CONTROL_STREAM_AND_SESSION &&
effective_len != 0) {
- DecreaseSendWindowSize(static_cast<int32>(effective_len));
+ DecreaseSendWindowSize(static_cast<int32_t>(effective_len));
data_buffer->AddConsumeCallback(
base::Bind(&SpdySession::OnWriteBufferConsumed,
weak_factory_.GetWeakPtr(),
@@ -1512,7 +1511,8 @@ int SpdySession::DoReadComplete(int result) {
DCHECK(buffered_spdy_framer_.get());
char* data = read_buffer_->data();
while (result > 0) {
- uint32 bytes_processed = buffered_spdy_framer_->ProcessInput(data, result);
+ uint32_t bytes_processed =
+ buffered_spdy_framer_->ProcessInput(data, result);
result -= bytes_processed;
data += bytes_processed;
@@ -2125,7 +2125,7 @@ void SpdySession::OnStreamFrameData(SpdyStreamId stream_id,
buffer.reset(new SpdyBuffer(data, len));
if (flow_control_state_ == FLOW_CONTROL_STREAM_AND_SESSION) {
- DecreaseRecvWindowSize(static_cast<int32>(len));
+ DecreaseRecvWindowSize(static_cast<int32_t>(len));
buffer->AddConsumeCallback(
base::Bind(&SpdySession::OnReadBufferConsumed,
weak_factory_.GetWeakPtr()));
@@ -2165,8 +2165,8 @@ void SpdySession::OnStreamPadding(SpdyStreamId stream_id, size_t len) {
// Increase window size because padding bytes are consumed (by discarding).
// Net result: |session_unacked_recv_window_bytes_| increases by |len|,
// |session_recv_window_size_| does not change.
- DecreaseRecvWindowSize(static_cast<int32>(len));
- IncreaseRecvWindowSize(static_cast<int32>(len));
+ DecreaseRecvWindowSize(static_cast<int32_t>(len));
+ IncreaseRecvWindowSize(static_cast<int32_t>(len));
ActiveStreamMap::iterator it = active_streams_.find(stream_id);
if (it == active_streams_.end())
@@ -2208,9 +2208,7 @@ void SpdySession::OnSettings(bool clear_persisted) {
}
}
-void SpdySession::OnSetting(SpdySettingsIds id,
- uint8 flags,
- uint32 value) {
+void SpdySession::OnSetting(SpdySettingsIds id, uint8_t flags, uint32_t value) {
CHECK(in_io_loop_);
HandleSetting(id, value);
@@ -2817,7 +2815,7 @@ void SpdySession::OnPushPromise(SpdyStreamId stream_id,
}
void SpdySession::SendStreamWindowUpdate(SpdyStreamId stream_id,
- uint32 delta_window_size) {
+ uint32_t delta_window_size) {
CHECK_GE(flow_control_state_, FLOW_CONTROL_STREAM);
ActiveStreamMap::const_iterator it = active_streams_.find(stream_id);
CHECK(it != active_streams_.end());
@@ -2880,13 +2878,13 @@ void SpdySession::SendInitialData() {
SettingsMap::const_iterator it =
server_settings_map.find(SETTINGS_CURRENT_CWND);
- uint32 cwnd = (it != server_settings_map.end()) ? it->second.second : 0;
+ uint32_t cwnd = (it != server_settings_map.end()) ? it->second.second : 0;
UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdySettingsCwndSent", cwnd, 1, 200, 100);
for (SettingsMap::const_iterator it = server_settings_map.begin();
it != server_settings_map.end(); ++it) {
const SpdySettingsIds new_id = it->first;
- const uint32 new_val = it->second.second;
+ const uint32_t new_val = it->second.second;
HandleSetting(new_id, new_val);
}
@@ -2908,7 +2906,7 @@ void SpdySession::SendSettings(const SettingsMap& settings) {
EnqueueSessionWrite(HIGHEST, SETTINGS, settings_frame.Pass());
}
-void SpdySession::HandleSetting(uint32 id, uint32 value) {
+void SpdySession::HandleSetting(uint32_t id, uint32_t value) {
switch (id) {
case SETTINGS_MAX_CONCURRENT_STREAMS:
max_concurrent_streams_ = std::min(static_cast<size_t>(value),
@@ -2922,7 +2920,7 @@ void SpdySession::HandleSetting(uint32 id, uint32 value) {
return;
}
- if (value > static_cast<uint32>(kint32max)) {
+ if (value > static_cast<uint32_t>(std::numeric_limits<int32_t>::max())) {
net_log().AddEvent(
NetLog::TYPE_HTTP2_SESSION_INITIAL_WINDOW_SIZE_OUT_OF_RANGE,
NetLog::IntCallback("initial_window_size", value));
@@ -2930,9 +2928,9 @@ void SpdySession::HandleSetting(uint32 id, uint32 value) {
}
// SETTINGS_INITIAL_WINDOW_SIZE updates initial_send_window_size_ only.
- int32 delta_window_size =
- static_cast<int32>(value) - stream_initial_send_window_size_;
- stream_initial_send_window_size_ = static_cast<int32>(value);
+ int32_t delta_window_size =
+ static_cast<int32_t>(value) - stream_initial_send_window_size_;
+ stream_initial_send_window_size_ = static_cast<int32_t>(value);
UpdateStreamsSendWindowSize(delta_window_size);
net_log().AddEvent(
NetLog::TYPE_HTTP2_SESSION_UPDATE_STREAMS_SEND_WINDOW_SIZE,
@@ -2942,7 +2940,7 @@ void SpdySession::HandleSetting(uint32 id, uint32 value) {
}
}
-void SpdySession::UpdateStreamsSendWindowSize(int32 delta_window_size) {
+void SpdySession::UpdateStreamsSendWindowSize(int32_t delta_window_size) {
DCHECK_GE(flow_control_state_, FLOW_CONTROL_STREAM);
for (ActiveStreamMap::iterator it = active_streams_.begin();
it != active_streams_.end(); ++it) {
@@ -2970,7 +2968,7 @@ void SpdySession::SendPrefacePing() {
}
void SpdySession::SendWindowUpdateFrame(SpdyStreamId stream_id,
- uint32 delta_window_size,
+ uint32_t delta_window_size,
RequestPriority priority) {
CHECK_GE(flow_control_state_, FLOW_CONTROL_STREAM);
ActiveStreamMap::const_iterator it = active_streams_.find(stream_id);
@@ -3095,7 +3093,7 @@ void SpdySession::RecordHistograms() {
SettingsMap::const_iterator it;
for (it = settings_map.begin(); it != settings_map.end(); ++it) {
const SpdySettingsIds id = it->first;
- const uint32 val = it->second.second;
+ const uint32_t val = it->second.second;
switch (id) {
case SETTINGS_CURRENT_CWND:
// Record several different histograms to see if cwnd converges
@@ -3185,7 +3183,8 @@ void SpdySession::IncreaseSendWindowSize(int delta_window_size) {
DCHECK_GE(delta_window_size, 1);
// Check for overflow.
- int32 max_delta_window_size = kint32max - session_send_window_size_;
+ int32_t max_delta_window_size =
+ std::numeric_limits<int32_t>::max() - session_send_window_size_;
if (delta_window_size > max_delta_window_size) {
RecordProtocolErrorHistogram(PROTOCOL_ERROR_INVALID_WINDOW_UPDATE_SIZE);
DoDrainSession(
@@ -3207,7 +3206,7 @@ void SpdySession::IncreaseSendWindowSize(int delta_window_size) {
ResumeSendStalledStreams();
}
-void SpdySession::DecreaseSendWindowSize(int32 delta_window_size) {
+void SpdySession::DecreaseSendWindowSize(int32_t delta_window_size) {
DCHECK_EQ(flow_control_state_, FLOW_CONTROL_STREAM_AND_SESSION);
// We only call this method when sending a frame. Therefore,
@@ -3234,18 +3233,20 @@ void SpdySession::OnReadBufferConsumed(
DCHECK_EQ(flow_control_state_, FLOW_CONTROL_STREAM_AND_SESSION);
DCHECK_GE(consume_size, 1u);
- DCHECK_LE(consume_size, static_cast<size_t>(kint32max));
+ DCHECK_LE(consume_size,
+ static_cast<size_t>(std::numeric_limits<int32_t>::max()));
- IncreaseRecvWindowSize(static_cast<int32>(consume_size));
+ IncreaseRecvWindowSize(static_cast<int32_t>(consume_size));
}
-void SpdySession::IncreaseRecvWindowSize(int32 delta_window_size) {
+void SpdySession::IncreaseRecvWindowSize(int32_t delta_window_size) {
DCHECK_EQ(flow_control_state_, FLOW_CONTROL_STREAM_AND_SESSION);
DCHECK_GE(session_unacked_recv_window_bytes_, 0);
DCHECK_GE(session_recv_window_size_, session_unacked_recv_window_bytes_);
DCHECK_GE(delta_window_size, 1);
// Check for overflow.
- DCHECK_LE(delta_window_size, kint32max - session_recv_window_size_);
+ DCHECK_LE(delta_window_size,
+ std::numeric_limits<int32_t>::max() - session_recv_window_size_);
session_recv_window_size_ += delta_window_size;
net_log_.AddEvent(NetLog::TYPE_HTTP2_STREAM_UPDATE_RECV_WINDOW,
@@ -3261,7 +3262,7 @@ void SpdySession::IncreaseRecvWindowSize(int32 delta_window_size) {
}
}
-void SpdySession::DecreaseRecvWindowSize(int32 delta_window_size) {
+void SpdySession::DecreaseRecvWindowSize(int32_t delta_window_size) {
CHECK(in_io_loop_);
DCHECK_EQ(flow_control_state_, FLOW_CONTROL_STREAM_AND_SESSION);
DCHECK_GE(delta_window_size, 1);
diff --git a/net/spdy/spdy_session.h b/net/spdy/spdy_session.h
index d0cbd3f2b..4fb7f98 100644
--- a/net/spdy/spdy_session.h
+++ b/net/spdy/spdy_session.h
@@ -5,13 +5,15 @@
#ifndef NET_SPDY_SPDY_SESSION_H_
#define NET_SPDY_SPDY_SESSION_H_
+#include <stdint.h>
+
#include <deque>
#include <map>
#include <set>
#include <string>
-#include "base/basictypes.h"
#include "base/gtest_prod_util.h"
+#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
@@ -364,7 +366,7 @@ class NET_EXPORT SpdySession : public BufferedSpdyFramerVisitorInterface,
// Send a WINDOW_UPDATE frame for a stream. Called by a stream
// whenever receive window size is increased.
void SendStreamWindowUpdate(SpdyStreamId stream_id,
- uint32 delta_window_size);
+ uint32_t delta_window_size);
// Accessors for the session's availability state.
bool IsAvailable() const { return availability_state_ == STATE_AVAILABLE; }
@@ -455,7 +457,7 @@ class NET_EXPORT SpdySession : public BufferedSpdyFramerVisitorInterface,
}
// Returns the current |stream_initial_send_window_size_|.
- int32 stream_initial_send_window_size() const {
+ int32_t stream_initial_send_window_size() const {
return stream_initial_send_window_size_;
}
@@ -504,7 +506,7 @@ class NET_EXPORT SpdySession : public BufferedSpdyFramerVisitorInterface,
// Default value of SETTINGS_INITIAL_WINDOW_SIZE per protocol specification.
// A session is always created with this initial window size.
- static int32 GetDefaultInitialWindowSize(NextProto protocol) {
+ static int32_t GetDefaultInitialWindowSize(NextProto protocol) {
return protocol < kProtoHTTP2 ? 65536 : 65535;
}
@@ -718,10 +720,10 @@ class NET_EXPORT SpdySession : public BufferedSpdyFramerVisitorInterface,
// Handle SETTING. Either when we send settings, or when we receive a
// SETTINGS control frame, update our SpdySession accordingly.
- void HandleSetting(uint32 id, uint32 value);
+ void HandleSetting(uint32_t id, uint32_t value);
// Adjust the send window size of all ActiveStreams and PendingStreamRequests.
- void UpdateStreamsSendWindowSize(int32 delta_window_size);
+ void UpdateStreamsSendWindowSize(int32_t delta_window_size);
// Send the PING (preface-PING) frame.
void SendPrefacePingIfNoneInFlight();
@@ -730,7 +732,8 @@ class NET_EXPORT SpdySession : public BufferedSpdyFramerVisitorInterface,
void SendPrefacePing();
// Send a single WINDOW_UPDATE frame.
- void SendWindowUpdateFrame(SpdyStreamId stream_id, uint32 delta_window_size,
+ void SendWindowUpdateFrame(SpdyStreamId stream_id,
+ uint32_t delta_window_size,
RequestPriority priority);
// Send the PING frame.
@@ -844,7 +847,7 @@ class NET_EXPORT SpdySession : public BufferedSpdyFramerVisitorInterface,
SpdyStreamId stream_id) override;
void OnHeaderFrameEnd(SpdyStreamId stream_id, bool end_headers) override;
void OnSettings(bool clear_persisted) override;
- void OnSetting(SpdySettingsIds id, uint8 flags, uint32 value) override;
+ void OnSetting(SpdySettingsIds id, uint8_t flags, uint32_t value) override;
void OnWindowUpdate(SpdyStreamId stream_id, int delta_window_size) override;
void OnPushPromise(SpdyStreamId stream_id,
SpdyStreamId promised_stream_id,
@@ -902,7 +905,7 @@ class NET_EXPORT SpdySession : public BufferedSpdyFramerVisitorInterface,
// cause this session's send window size to go negative.
//
// If session flow control is turned off, this must not be called.
- void DecreaseSendWindowSize(int32 delta_window_size);
+ void DecreaseSendWindowSize(int32_t delta_window_size);
// Called when bytes are consumed by the delegate from a SpdyBuffer
// containing received data. Increases the receive window size
@@ -919,7 +922,7 @@ class NET_EXPORT SpdySession : public BufferedSpdyFramerVisitorInterface,
// initialization to set the initial receive window size.
//
// If session flow control is turned off, this must not be called.
- void IncreaseRecvWindowSize(int32 delta_window_size);
+ void IncreaseRecvWindowSize(int32_t delta_window_size);
// Called by OnStreamFrameData (which is in turn called by the
// framer) to decrease this session's receive window size by
@@ -927,7 +930,7 @@ class NET_EXPORT SpdySession : public BufferedSpdyFramerVisitorInterface,
// this session's receive window size to go negative.
//
// If session flow control is turned off, this must not be called.
- void DecreaseRecvWindowSize(int32 delta_window_size);
+ void DecreaseRecvWindowSize(int32_t delta_window_size);
// Queue a send-stalled stream for possibly resuming once we're not
// send-stalled anymore.
@@ -957,7 +960,7 @@ class NET_EXPORT SpdySession : public BufferedSpdyFramerVisitorInterface,
max_concurrent_pushed_streams_ = value;
}
- int64 pings_in_flight() const { return pings_in_flight_; }
+ int64_t pings_in_flight() const { return pings_in_flight_; }
SpdyPingId next_ping_id() const { return next_ping_id_; }
@@ -1100,7 +1103,7 @@ class NET_EXPORT SpdySession : public BufferedSpdyFramerVisitorInterface,
int stalled_streams_; // Count of streams that were ever stalled.
// Count of all pings on the wire, for which we have not gotten a response.
- int64 pings_in_flight_;
+ int64_t pings_in_flight_;
// This is the next ping_id (unique_id) to be sent in PING frame.
SpdyPingId next_ping_id_;
@@ -1129,35 +1132,35 @@ class NET_EXPORT SpdySession : public BufferedSpdyFramerVisitorInterface,
FlowControlState flow_control_state_;
// Current send window size. Zero unless session flow control is turned on.
- int32 session_send_window_size_;
+ int32_t session_send_window_size_;
// Maximum receive window size. Each time a WINDOW_UPDATE is sent, it
// restores the receive window size to this value. Zero unless session flow
// control is turned on.
- int32 session_max_recv_window_size_;
+ int32_t session_max_recv_window_size_;
// Sum of |session_unacked_recv_window_bytes_| and current receive window
// size. Zero unless session flow control is turned on.
// TODO(bnc): Rename or change semantics so that |window_size_| is actual
// window size.
- int32 session_recv_window_size_;
+ int32_t session_recv_window_size_;
// When bytes are consumed, SpdyIOBuffer destructor calls back to SpdySession,
// and this member keeps count of them until the corresponding WINDOW_UPDATEs
// are sent. Zero unless session flow control is turned on.
- int32 session_unacked_recv_window_bytes_;
+ int32_t session_unacked_recv_window_bytes_;
// Initial send window size for this session's streams. Can be
// changed by an arriving SETTINGS frame. Newly created streams use
// this value for the initial send window size.
- int32 stream_initial_send_window_size_;
+ int32_t stream_initial_send_window_size_;
// Initial receive window size for this session's streams. There are
// plans to add a command line switch that would cause a SETTINGS
// frame with window size announcement to be sent on startup. Newly
// created streams will use this value for the initial receive
// window size.
- int32 stream_max_recv_window_size_;
+ int32_t stream_max_recv_window_size_;
// A queue of stream IDs that have been send-stalled at some point
// in the past.
diff --git a/net/spdy/spdy_stream_unittest.cc b/net/spdy/spdy_stream_unittest.cc
index c9e387e..a75d88e 100644
--- a/net/spdy/spdy_stream_unittest.cc
+++ b/net/spdy/spdy_stream_unittest.cc
@@ -2,7 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <stdint.h>
+
#include <cstddef>
+#include <limits>
#include <string>
#include <vector>
@@ -58,7 +61,7 @@ class SpdyStreamTest : public ::testing::Test,
protected:
// A function that takes a SpdyStream and the number of bytes which
// will unstall the next frame completely.
- typedef base::Callback<void(const base::WeakPtr<SpdyStream>&, int32)>
+ typedef base::Callback<void(const base::WeakPtr<SpdyStream>&, int32_t)>
UnstallFunction;
SpdyStreamTest()
@@ -830,7 +833,7 @@ TEST_P(SpdyStreamTest, DuplicateHeaders) {
// The tests below are only for SPDY/3 and above.
// Call IncreaseSendWindowSize on a stream with a large enough delta
-// to overflow an int32. The SpdyStream should handle that case
+// to overflow an int32_t. The SpdyStream should handle that case
// gracefully.
TEST_P(SpdyStreamTest, IncreaseSendWindowSizeOverflow) {
session_ =
@@ -877,9 +880,10 @@ TEST_P(SpdyStreamTest, IncreaseSendWindowSizeOverflow) {
data.RunFor(1);
- int32 old_send_window_size = stream->send_window_size();
+ int32_t old_send_window_size = stream->send_window_size();
ASSERT_GT(old_send_window_size, 0);
- int32 delta_window_size = kint32max - old_send_window_size + 1;
+ int32_t delta_window_size =
+ std::numeric_limits<int32_t>::max() - old_send_window_size + 1;
stream->IncreaseSendWindowSize(delta_window_size);
EXPECT_EQ(NULL, stream.get());
@@ -900,14 +904,14 @@ void StallStream(const base::WeakPtr<SpdyStream>& stream) {
}
void IncreaseStreamSendWindowSize(const base::WeakPtr<SpdyStream>& stream,
- int32 delta_window_size) {
+ int32_t delta_window_size) {
EXPECT_TRUE(stream->send_stalled_by_flow_control());
stream->IncreaseSendWindowSize(delta_window_size);
EXPECT_FALSE(stream->send_stalled_by_flow_control());
}
void AdjustStreamSendWindowSize(const base::WeakPtr<SpdyStream>& stream,
- int32 delta_window_size) {
+ int32_t delta_window_size) {
// Make sure that negative adjustments are handled properly.
EXPECT_TRUE(stream->send_stalled_by_flow_control());
stream->AdjustSendWindowSize(-delta_window_size);
@@ -1135,11 +1139,11 @@ TEST_P(SpdyStreamTest, ReceivedBytes) {
EXPECT_TRUE(stream->HasUrlFromHeaders());
EXPECT_EQ(kStreamUrl, stream->GetUrlFromHeaders().spec());
- int64 reply_frame_len = reply->size();
- int64 data_header_len = spdy_util_.CreateFramer(false)
- ->GetDataFrameMinimumSize();
- int64 data_frame_len = data_header_len + kPostBodyLength;
- int64 response_len = reply_frame_len + data_frame_len;
+ int64_t reply_frame_len = reply->size();
+ int64_t data_header_len =
+ spdy_util_.CreateFramer(false)->GetDataFrameMinimumSize();
+ int64_t data_frame_len = data_header_len + kPostBodyLength;
+ int64_t response_len = reply_frame_len + data_frame_len;
EXPECT_EQ(0, stream->raw_received_bytes());
data.RunFor(1); // SYN
diff --git a/ppapi/shared_impl/id_assignment.cc b/ppapi/shared_impl/id_assignment.cc
index 5c5aed6..b1120e9 100644
--- a/ppapi/shared_impl/id_assignment.cc
+++ b/ppapi/shared_impl/id_assignment.cc
@@ -4,13 +4,13 @@
#include "ppapi/shared_impl/id_assignment.h"
-#include "base/basictypes.h"
+#include <stdint.h>
namespace ppapi {
const unsigned int kPPIdTypeBits = 2;
-const int32 kMaxPPId = kint32max >> kPPIdTypeBits;
+const int32_t kMaxPPId = INT32_MAX >> kPPIdTypeBits;
static_assert(PP_ID_TYPE_COUNT <= (1 << kPPIdTypeBits),
"kPPIdTypeBits is too small for all id types");
diff --git a/ui/gfx/color_analysis.cc b/ui/gfx/color_analysis.cc
index 16695c9..94eac52 100644
--- a/ui/gfx/color_analysis.cc
+++ b/ui/gfx/color_analysis.cc
@@ -4,6 +4,8 @@
#include "ui/gfx/color_analysis.h"
+#include <stdint.h>
+
#include <algorithm>
#include <limits>
#include <vector>
@@ -186,7 +188,7 @@ SkColor FindClosestColor(const uint8_t* image,
uint8_t in_g = SkColorGetG(color);
uint8_t in_b = SkColorGetB(color);
// Search using distance-squared to avoid expensive sqrt() operations.
- int best_distance_squared = kint32max;
+ int best_distance_squared = std::numeric_limits<int32_t>::max();
SkColor best_color = color;
const uint8_t* byte = image;
for (int i = 0; i < width * height; ++i) {