Bug 787933 - Stop using stdin types in IPC code; r=bsmedberg+cjones sr=cjones

This commit is contained in:
Ms2ger 2012-09-17 10:37:20 +02:00
parent 0e621fbc2c
commit 10ec580e54
158 changed files with 823 additions and 846 deletions

View File

@ -1392,7 +1392,7 @@ GetAllKeysHelper::GetSuccessResult(JSContext* aCx,
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
for (uint32 index = 0, count = keys.Length(); index < count; index++) {
for (uint32_t index = 0, count = keys.Length(); index < count; index++) {
const Key& key = keys[index];
NS_ASSERTION(!key.IsUnset(), "Bad key!");

View File

@ -488,7 +488,7 @@ ContentParent::MarkAsDead()
}
void
ContentParent::OnChannelConnected(int32 pid)
ContentParent::OnChannelConnected(int32_t pid)
{
ProcessHandle handle;
if (!base::OpenPrivilegedProcessHandle(pid, &handle)) {

View File

@ -120,7 +120,7 @@ public:
void KillHard();
protected:
void OnChannelConnected(int32 pid);
void OnChannelConnected(int32_t pid);
virtual void ActorDestroy(ActorDestroyReason why);
private:

View File

@ -28,7 +28,7 @@ bool ReadRemoteEvent(const IPC::Message* aMsg, void** aIter,
typedef CrashReporter::ThreadId NativeThreadId;
#else
// unused in this case
typedef int32 NativeThreadId;
typedef int32_t NativeThreadId;
#endif
}

View File

@ -549,7 +549,7 @@ PluginInstanceChild::NPN_SetValue(NPPVariable aVar, void* aValue)
case NPPVpluginDrawingModel: {
NPError rv;
int drawingModel = (int16) (intptr_t) aValue;
int drawingModel = (int16_t) (intptr_t) aValue;
if (!PluginModuleChild::current()->AsyncDrawingAllowed() &&
IsDrawingModelAsync(drawingModel)) {
@ -586,7 +586,7 @@ PluginInstanceChild::NPN_SetValue(NPPVariable aVar, void* aValue)
#ifdef XP_MACOSX
case NPPVpluginEventModel: {
NPError rv;
int eventModel = (int16) (intptr_t) aValue;
int eventModel = (int16_t) (intptr_t) aValue;
if (!CallNPN_SetValue_NPPVpluginEventModel(eventModel, &rv))
return NPERR_GENERIC_ERROR;

View File

@ -316,12 +316,12 @@ struct ParamTraits<NPWindowType>
static void Write(Message* aMsg, const paramType& aParam)
{
aMsg->WriteInt16(int16(aParam));
aMsg->WriteInt16(int16_t(aParam));
}
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
{
int16 result;
int16_t result;
if (aMsg->ReadInt16(aIter, &result)) {
*aResult = paramType(result);
return true;
@ -331,7 +331,7 @@ struct ParamTraits<NPWindowType>
static void Log(const paramType& aParam, std::wstring* aLog)
{
aLog->append(StringPrintf(L"%d", int16(aParam)));
aLog->append(StringPrintf(L"%d", int16_t(aParam)));
}
};
@ -342,12 +342,12 @@ struct ParamTraits<NPImageFormat>
static void Write(Message* aMsg, const paramType& aParam)
{
aMsg->WriteInt16(int16(aParam));
aMsg->WriteInt16(int16_t(aParam));
}
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
{
int16 result;
int16_t result;
if (aMsg->ReadInt16(aIter, &result)) {
*aResult = paramType(result);
return true;
@ -357,7 +357,7 @@ struct ParamTraits<NPImageFormat>
static void Log(const paramType& aParam, std::wstring* aLog)
{
aLog->append(StringPrintf(L"%d", int16(aParam)));
aLog->append(StringPrintf(L"%d", int16_t(aParam)));
}
};
@ -386,7 +386,7 @@ struct ParamTraits<mozilla::plugins::NPRemoteWindow>
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
{
uint64 window;
uint64_t window;
int32_t x, y;
uint32_t width, height;
NPRect clipRect;
@ -712,7 +712,7 @@ struct ParamTraits<NPVariant>
} break;
case 3: {
int32 value;
int32_t value;
if (ReadParam(aMsg, aIter, &value)) {
INT32_TO_NPVARIANT(value, *aResult);
return true;
@ -856,12 +856,12 @@ struct ParamTraits<NPCoordinateSpace>
static void Write(Message* aMsg, const paramType& aParam)
{
WriteParam(aMsg, int32(aParam));
WriteParam(aMsg, int32_t(aParam));
}
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
{
int32 intval;
int32_t intval;
if (ReadParam(aMsg, aIter, &intval)) {
switch (intval) {
case NPCoordinateSpacePlugin:

View File

@ -203,7 +203,7 @@ PluginModuleParent::TimeoutChanged(const char* aPref, void* aModule)
if (!strcmp(aPref, kChildTimeoutPref)) {
// The timeout value used by the parent for children
int32_t timeoutSecs = Preferences::GetInt(kChildTimeoutPref, 0);
int32 timeoutMs = (timeoutSecs > 0) ? (1000 * timeoutSecs) :
int32_t timeoutMs = (timeoutSecs > 0) ? (1000 * timeoutSecs) :
SyncChannel::kNoTimeout;
static_cast<PluginModuleParent*>(aModule)->SetReplyTimeoutMs(timeoutMs);
} else if (!strcmp(aPref, kParentTimeoutPref)) {

View File

@ -41,9 +41,9 @@ bool
PluginProcessParent::Launch(int32_t timeoutMs)
{
ProcessArchitecture currentArchitecture = base::GetCurrentProcessArchitecture();
uint32 containerArchitectures = GetSupportedArchitecturesForProcessType(GeckoProcessType_Plugin);
uint32_t containerArchitectures = GetSupportedArchitecturesForProcessType(GeckoProcessType_Plugin);
uint32 pluginLibArchitectures = currentArchitecture;
uint32_t pluginLibArchitectures = currentArchitecture;
#ifdef XP_MACOSX
nsresult rv = GetArchitecturesForBinary(mPluginFilePath.c_str(), &pluginLibArchitectures);
if (NS_FAILED(rv)) {

View File

@ -54,14 +54,14 @@ struct ParamTraits<mozilla::gl::TextureImage::TextureShareType>
static void Write(Message* msg, const paramType& param)
{
MOZ_STATIC_ASSERT(sizeof(paramType) <= sizeof(int32),
"TextureShareType assumes to be int32");
WriteParam(msg, int32(param));
MOZ_STATIC_ASSERT(sizeof(paramType) <= sizeof(int32_t),
"TextureShareType assumes to be int32_t");
WriteParam(msg, int32_t(param));
}
static bool Read(const Message* msg, void** iter, paramType* result)
{
int32 type;
int32_t type;
if (!ReadParam(msg, iter, &type))
return false;

View File

@ -112,7 +112,7 @@ parent:
sync GetScreenBrightness() returns (double brightness);
SetScreenBrightness(double brightness);
AdjustSystemClock(int32 aDeltaMilliseconds);
AdjustSystemClock(int32_t aDeltaMilliseconds);
SetTimezone(nsCString aTimezoneSpec);
sync GetTimezone()
returns (nsCString aTimezoneSpec);

View File

@ -38,18 +38,22 @@ namespace subtle {
#ifndef OS_WIN
#define __w64
#endif
typedef __w64 int32 Atomic32;
typedef __w64 int32_t Atomic32;
#ifdef ARCH_CPU_64_BITS
typedef int64 Atomic64;
typedef int64_t Atomic64;
#endif
// Use AtomicWord for a machine-sized pointer. It will use the Atomic32 or
// Atomic64 routines below, depending on your architecture.
#if defined(OS_OPENBSD) && !defined(ARCH_CPU_64_BITS)
#ifdef OS_OPENBSD
#ifdef ARCH_CPU_64_BITS
typedef Atomic64 AtomicWord;
#else
typedef Atomic32 AtomicWord;
#endif // ARCH_CPU_64_BITS
#else
typedef intptr_t AtomicWord;
#endif
#endif // OS_OPENBSD
// Atomically execute:
// result = *ptr;

View File

@ -45,10 +45,10 @@ struct AtomicOps_x86CPUFeatureStruct AtomicOps_Internalx86CPUFeatures = {
// Initialize the AtomicOps_Internalx86CPUFeatures struct.
static void AtomicOps_Internalx86CPUFeaturesInit() {
uint32 eax;
uint32 ebx;
uint32 ecx;
uint32 edx;
uint32_t eax;
uint32_t ebx;
uint32_t ecx;
uint32_t edx;
// Get vendor string (issue CPUID with eax = 0)
cpuid(eax, ebx, ecx, edx, 0);

View File

@ -11,7 +11,7 @@
///////////////////////////////////////////////////////////////////////////////
IDropTargetHelper* BaseDropTarget::cached_drop_target_helper_ = NULL;
int32 BaseDropTarget::drag_identity_ = 0;
int32_t BaseDropTarget::drag_identity_ = 0;
BaseDropTarget::BaseDropTarget(HWND hwnd)
: hwnd_(hwnd),

View File

@ -86,7 +86,7 @@ class BaseDropTarget : public IDropTarget {
DWORD effect);
// Return the drag identity.
static int32 GetDragIdentity() { return drag_identity_; }
static int32_t GetDragIdentity() { return drag_identity_; }
private:
// Returns the cached drop helper, creating one if necessary. The returned
@ -110,9 +110,9 @@ class BaseDropTarget : public IDropTarget {
// moves over the HWND in a DnD session (OnDragEnter). 0 is reserved to mean
// the "no/unknown" identity, and is used for initialization. The identity is
// sent to the renderer in drag enter notifications. Note: the identity value
// is passed over the renderer NPAPI interface to gears, so use int32 instead
// is passed over the renderer NPAPI interface to gears, so use int32_t instead
// of int here.
static int32 drag_identity_;
static int32_t drag_identity_;
// The HWND of the source. This HWND is used to determine coordinates for
// mouse events that are sent to the renderer notifying various drag states.

View File

@ -24,47 +24,32 @@
#undef NO_NSPR_10_SUPPORT
#endif
#ifdef _WIN32
#undef _WIN32
#define _WIN32_SAVE
#endif
#include "obsolete/protypes.h"
#ifdef _WIN32_SAVE
#undef _WIN32_SAVE
#define _WIN32
#endif
#include <limits.h> // So we can set the bounds of our types
#include <stddef.h> // For size_t
#include <string.h> // for memcpy
#include "base/port.h" // Types that only need exist on certain systems
#ifndef COMPILER_MSVC
// stdint.h is part of C99 but MSVC doesn't have it.
#include <stdint.h> // For intptr_t.
#endif
#include "mozilla/StandardInteger.h"
// A type to represent a Unicode code-point value. As of Unicode 4.0,
// such values require up to 21 bits.
// (For type-checking on pointers, make this explicitly signed,
// and it should always be the signed version of whatever int32 is.)
// and it should always be the signed version of whatever int32_t is.)
typedef signed int char32;
const uint8 kuint8max = (( uint8) 0xFF);
const uint16 kuint16max = ((uint16) 0xFFFF);
const uint32 kuint32max = ((uint32) 0xFFFFFFFF);
const uint64 kuint64max = ((uint64) GG_LONGLONG(0xFFFFFFFFFFFFFFFF));
const int8 kint8min = (( int8) 0x80);
const int8 kint8max = (( int8) 0x7F);
const int16 kint16min = (( int16) 0x8000);
const int16 kint16max = (( int16) 0x7FFF);
const int32 kint32min = (( int32) 0x80000000);
const int32 kint32max = (( int32) 0x7FFFFFFF);
const int64 kint64min = (( int64) GG_LONGLONG(0x8000000000000000));
const int64 kint64max = (( int64) GG_LONGLONG(0x7FFFFFFFFFFFFFFF));
const uint8_t kuint8max = (( uint8_t) 0xFF);
const uint16_t kuint16max = ((uint16_t) 0xFFFF);
const uint32_t kuint32max = ((uint32_t) 0xFFFFFFFF);
const uint64_t kuint64max = ((uint64_t) GG_LONGLONG(0xFFFFFFFFFFFFFFFF));
const int8_t kint8min = (( int8_t) 0x80);
const int8_t kint8max = (( int8_t) 0x7F);
const int16_t kint16min = (( int16_t) 0x8000);
const int16_t kint16max = (( int16_t) 0x7FFF);
const int32_t kint32min = (( int32_t) 0x80000000);
const int32_t kint32max = (( int32_t) 0x7FFFFFFF);
const int64_t kint64min = (( int64_t) GG_LONGLONG(0x8000000000000000));
const int64_t kint64max = (( int64_t) GG_LONGLONG(0x7FFFFFFFFFFFFFFF));
// Platform- and hardware-dependent printf specifiers
# if defined(OS_POSIX)
@ -259,7 +244,7 @@ struct CompileAssert {
// MetatagId refers to metatag-id that we assign to
// each metatag <name, value> pair..
typedef uint32 MetatagId;
typedef uint32_t MetatagId;
// Argument type used in interfaces that can optionally take ownership
// of a passed in argument. If TAKE_OWNERSHIP is passed, the called
@ -275,7 +260,7 @@ enum Ownership {
// support.
//
// float f = 3.14159265358979;
// int i = bit_cast<int32>(f);
// int i = bit_cast<int32_t>(f);
// // i = 0x40490fdb
//
// The classical address-casting method is:

View File

@ -32,7 +32,7 @@ void ConditionVariable::Wait() {
}
void ConditionVariable::TimedWait(const TimeDelta& max_time) {
int64 usecs = max_time.InMicroseconds();
int64_t usecs = max_time.InMicroseconds();
// The timeout argument to pthread_cond_timedwait is in absolute time.
struct timeval now;

View File

@ -51,15 +51,15 @@ class SignatureVerifier {
// SubjectPublicKeyInfo ::= SEQUENCE {
// algorithm AlgorithmIdentifier,
// subjectPublicKey BIT STRING }
bool VerifyInit(const uint8* signature_algorithm,
bool VerifyInit(const uint8_t* signature_algorithm,
int signature_algorithm_len,
const uint8* signature,
const uint8_t* signature,
int signature_len,
const uint8* public_key_info,
const uint8_t* public_key_info,
int public_key_info_len);
// Feeds a piece of the data to the signature verifier.
void VerifyUpdate(const uint8* data_part, int data_part_len);
void VerifyUpdate(const uint8_t* data_part, int data_part_len);
// Concludes a signature verification operation. Returns true if the
// signature is valid. Returns false if the signature is invalid or an
@ -67,24 +67,24 @@ class SignatureVerifier {
bool VerifyFinal();
// Note: we can provide a one-shot interface if there is interest:
// bool Verify(const uint8* data,
// bool Verify(const uint8_t* data,
// int data_len,
// const uint8* signature_algorithm,
// const uint8_t* signature_algorithm,
// int signature_algorithm_len,
// const uint8* signature,
// const uint8_t* signature,
// int signature_len,
// const uint8* public_key_info,
// const uint8_t* public_key_info,
// int public_key_info_len);
private:
void Reset();
std::vector<uint8> signature_;
std::vector<uint8_t> signature_;
#if defined(OS_LINUX)
VFYContext* vfy_context_;
#elif defined(OS_MACOSX)
std::vector<uint8> public_key_info_;
std::vector<uint8_t> public_key_info_;
CSSM_CSP_HANDLE csp_handle_;

View File

@ -23,7 +23,7 @@ void* AppRealloc(void* ptr, CSSM_SIZE size, void* alloc_ref) {
return realloc(ptr, size);
}
void* AppCalloc(uint32 num, CSSM_SIZE size, void* alloc_ref) {
void* AppCalloc(uint32_t num, CSSM_SIZE size, void* alloc_ref) {
return calloc(num, size);
}
@ -58,11 +58,11 @@ SignatureVerifier::~SignatureVerifier() {
}
}
bool SignatureVerifier::VerifyInit(const uint8* signature_algorithm,
bool SignatureVerifier::VerifyInit(const uint8_t* signature_algorithm,
int signature_algorithm_len,
const uint8* signature,
const uint8_t* signature,
int signature_len,
const uint8* public_key_info,
const uint8_t* public_key_info,
int public_key_info_len) {
signature_.assign(signature, signature + signature_len);
public_key_info_.assign(public_key_info,
@ -71,7 +71,7 @@ bool SignatureVerifier::VerifyInit(const uint8* signature_algorithm,
CSSM_ALGORITHMS key_alg = CSSM_ALGID_RSA; // TODO(wtc): hardcoded.
memset(&public_key_, 0, sizeof(public_key_));
public_key_.KeyData.Data = const_cast<uint8*>(&public_key_info_[0]);
public_key_.KeyData.Data = const_cast<uint8_t*>(&public_key_info_[0]);
public_key_.KeyData.Length = public_key_info_.size();
public_key_.KeyHeader.HeaderVersion = CSSM_KEYHEADER_VERSION;
public_key_.KeyHeader.BlobType = CSSM_KEYBLOB_RAW;
@ -106,10 +106,10 @@ bool SignatureVerifier::VerifyInit(const uint8* signature_algorithm,
return true;
}
void SignatureVerifier::VerifyUpdate(const uint8* data_part,
void SignatureVerifier::VerifyUpdate(const uint8_t* data_part,
int data_part_len) {
CSSM_DATA data;
data.Data = const_cast<uint8*>(data_part);
data.Data = const_cast<uint8_t*>(data_part);
data.Length = data_part_len;
CSSM_RETURN crtn = CSSM_VerifyDataUpdate(sig_handle_, &data, 1);
DCHECK(crtn == CSSM_OK);
@ -117,7 +117,7 @@ void SignatureVerifier::VerifyUpdate(const uint8* data_part,
bool SignatureVerifier::VerifyFinal() {
CSSM_DATA sig;
sig.Data = const_cast<uint8*>(&signature_[0]);
sig.Data = const_cast<uint8_t*>(&signature_[0]);
sig.Length = signature_.size();
CSSM_RETURN crtn = CSSM_VerifyDataFinal(sig_handle_, &sig);
Reset();

View File

@ -21,18 +21,18 @@ SignatureVerifier::~SignatureVerifier() {
Reset();
}
bool SignatureVerifier::VerifyInit(const uint8* signature_algorithm,
bool SignatureVerifier::VerifyInit(const uint8_t* signature_algorithm,
int signature_algorithm_len,
const uint8* signature,
const uint8_t* signature,
int signature_len,
const uint8* public_key_info,
const uint8_t* public_key_info,
int public_key_info_len) {
signature_.assign(signature, signature + signature_len);
CERTSubjectPublicKeyInfo* spki = NULL;
SECItem spki_der;
spki_der.type = siBuffer;
spki_der.data = const_cast<uint8*>(public_key_info);
spki_der.data = const_cast<uint8_t*>(public_key_info);
spki_der.len = public_key_info_len;
spki = SECKEY_DecodeDERSubjectPublicKeyInfo(&spki_der);
if (!spki)
@ -50,7 +50,7 @@ bool SignatureVerifier::VerifyInit(const uint8* signature_algorithm,
SECItem sig_alg_der;
sig_alg_der.type = siBuffer;
sig_alg_der.data = const_cast<uint8*>(signature_algorithm);
sig_alg_der.data = const_cast<uint8_t*>(signature_algorithm);
sig_alg_der.len = signature_algorithm_len;
SECAlgorithmID sig_alg_id;
SECStatus rv;
@ -64,7 +64,7 @@ bool SignatureVerifier::VerifyInit(const uint8* signature_algorithm,
SECItem sig;
sig.type = siBuffer;
sig.data = const_cast<uint8*>(signature);
sig.data = const_cast<uint8_t*>(signature);
sig.len = signature_len;
SECOidTag hash_alg_tag;
vfy_context_ = VFY_CreateContextWithAlgorithmID(public_key, &sig,
@ -87,7 +87,7 @@ bool SignatureVerifier::VerifyInit(const uint8* signature_algorithm,
return true;
}
void SignatureVerifier::VerifyUpdate(const uint8* data_part,
void SignatureVerifier::VerifyUpdate(const uint8_t* data_part,
int data_part_len) {
SECStatus rv = VFY_Update(vfy_context_, data_part, data_part_len);
DCHECK(rv == SECSuccess);

View File

@ -22,7 +22,7 @@ TEST(SignatureVerifierTest, BasicTest) {
// TBSCertificate ::= SEQUENCE {
// ... -- omitted, not important
// }
const uint8 tbs_certificate[1017] = {
const uint8_t tbs_certificate[1017] = {
0x30, 0x82, 0x03, 0xf5, // a SEQUENCE of length 1013 (0x3f5)
0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x03, 0x43, 0xdd, 0x63, 0x30, 0x0d,
0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05,
@ -116,7 +116,7 @@ TEST(SignatureVerifierTest, BasicTest) {
// algorithm OBJECT IDENTIFIER,
// parameters ANY DEFINED BY algorithm OPTIONAL }
//
const uint8 signature_algorithm[15] = {
const uint8_t signature_algorithm[15] = {
0x30, 0x0d, // a SEQUENCE of length 13 (0xd)
0x06, 0x09, // an OBJECT IDENTIFIER of length 9
// 1.2.840.113549.1.1.5 - sha1WithRSAEncryption
@ -125,7 +125,7 @@ TEST(SignatureVerifierTest, BasicTest) {
};
// RSA signature, a big integer in the big-endian byte order.
const uint8 signature[256] = {
const uint8_t signature[256] = {
0x1e, 0x6a, 0xe7, 0xe0, 0x4f, 0xe7, 0x4d, 0xd0, 0x69, 0x7c, 0xf8, 0x8f,
0x99, 0xb4, 0x18, 0x95, 0x36, 0x24, 0x0f, 0x0e, 0xa3, 0xea, 0x34, 0x37,
0xf4, 0x7d, 0xd5, 0x92, 0x35, 0x53, 0x72, 0x76, 0x3f, 0x69, 0xf0, 0x82,
@ -154,7 +154,7 @@ TEST(SignatureVerifierTest, BasicTest) {
// SubjectPublicKeyInfo ::= SEQUENCE {
// algorithm AlgorithmIdentifier,
// subjectPublicKey BIT STRING }
const uint8 public_key_info[294] = {
const uint8_t public_key_info[294] = {
0x30, 0x82, 0x01, 0x22, // a SEQUENCE of length 290 (0x122)
// algorithm
0x30, 0x0d, // a SEQUENCE of length 13
@ -228,7 +228,7 @@ TEST(SignatureVerifierTest, BasicTest) {
EXPECT_TRUE(ok);
// Test 3: verify the signature with incorrect data.
uint8 bad_tbs_certificate[sizeof(tbs_certificate)];
uint8_t bad_tbs_certificate[sizeof(tbs_certificate)];
memcpy(bad_tbs_certificate, tbs_certificate, sizeof(tbs_certificate));
bad_tbs_certificate[10] += 1; // Corrupt one byte of the data.
ok = verifier.VerifyInit(signature_algorithm,
@ -248,7 +248,7 @@ TEST(SignatureVerifierTest, BasicTest) {
#endif
// Test 4: verify a bad signature.
uint8 bad_signature[sizeof(signature)];
uint8_t bad_signature[sizeof(signature)];
memcpy(bad_signature, signature, sizeof(signature));
bad_signature[10] += 1; // Corrupt one byte of the signature.
ok = verifier.VerifyInit(signature_algorithm,

View File

@ -38,11 +38,11 @@ SignatureVerifier::~SignatureVerifier() {
}
}
bool SignatureVerifier::VerifyInit(const uint8* signature_algorithm,
bool SignatureVerifier::VerifyInit(const uint8_t* signature_algorithm,
int signature_algorithm_len,
const uint8* signature,
const uint8_t* signature,
int signature_len,
const uint8* public_key_info,
const uint8_t* public_key_info,
int public_key_info_len) {
signature_.reserve(signature_len);
// CryptoAPI uses big integers in the little-endian byte order, so we need
@ -114,7 +114,7 @@ bool SignatureVerifier::VerifyInit(const uint8* signature_algorithm,
return true;
}
void SignatureVerifier::VerifyUpdate(const uint8* data_part,
void SignatureVerifier::VerifyUpdate(const uint8_t* data_part,
int data_part_len) {
BOOL ok = CryptHashData(hash_object_, data_part, data_part_len, 0);
DCHECK(ok) << "CryptHashData failed: " << GetLastError();

View File

@ -54,8 +54,8 @@ bool DataPack::Load(const FilePath& path) {
// Parse the header of the file.
// First uint32_t: version; second: resource count.
const uint32* ptr = reinterpret_cast<const uint32_t*>(mmap_->data());
uint32 version = ptr[0];
const uint32_t* ptr = reinterpret_cast<const uint32_t*>(mmap_->data());
uint32_t version = ptr[0];
if (version != kFileFormatVersion) {
LOG(ERROR) << "Bad data pack version: got " << version << ", expected "
<< kFileFormatVersion;

View File

@ -199,7 +199,7 @@ FILE* CreateAndOpenTemporaryFile(FilePath* path) {
return CreateAndOpenTemporaryFileInDir(directory, path);
}
bool GetFileSize(const FilePath& file_path, int64* file_size) {
bool GetFileSize(const FilePath& file_path, int64_t* file_size) {
FileInfo info;
if (!GetFileInfo(file_path, &info))
return false;
@ -379,7 +379,7 @@ std::wstring GetFilenameFromPath(const std::wstring& path) {
return FilePath::FromWStringHack(path).BaseName().ToWStringHack();
}
bool GetFileSize(const std::wstring& file_path, int64* file_size) {
bool GetFileSize(const std::wstring& file_path, int64_t* file_size) {
return GetFileSize(FilePath::FromWStringHack(file_path), file_size);
}
bool GetTempDir(std::wstring* path_str) {

View File

@ -325,14 +325,14 @@ bool CreateDirectory(const FilePath& full_path);
bool CreateDirectory(const std::wstring& full_path);
// Returns the file size. Returns true on success.
bool GetFileSize(const FilePath& file_path, int64* file_size);
bool GetFileSize(const FilePath& file_path, int64_t* file_size);
// Deprecated temporary compatibility function.
bool GetFileSize(const std::wstring& file_path, int64* file_size);
bool GetFileSize(const std::wstring& file_path, int64_t* file_size);
// Used to hold information about a given file path. See GetFileInfo below.
struct FileInfo {
// The size of the file in bytes. Undefined when is_directory is true.
int64 size;
int64_t size;
// True if the file corresponds to a directory.
bool is_directory;
@ -489,7 +489,7 @@ class MemoryMappedFile {
// Later we may want to allow the user to specify access.
bool Initialize(const FilePath& file_name);
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?
@ -510,7 +510,7 @@ class MemoryMappedFile {
// The file descriptor.
int file_;
#endif
uint8* data_;
uint8_t* data_;
size_t length_;
DISALLOW_COPY_AND_ASSIGN(MemoryMappedFile);

View File

@ -718,7 +718,7 @@ bool MemoryMappedFile::MapFileToMemory(const FilePath& file_name) {
return false;
length_ = file_stat.st_size;
data_ = static_cast<uint8*>(
data_ = static_cast<uint8_t*>(
mmap(NULL, length_, PROT_READ, MAP_SHARED, file_, 0));
if (data_ == MAP_FAILED)
data_ = NULL;

View File

@ -107,7 +107,7 @@ std::wstring ReadTextFile(const FilePath& filename) {
}
#if defined(OS_WIN)
uint64 FileTimeAsUint64(const FILETIME& ft) {
uint64_t FileTimeAsUint64(const FILETIME& ft) {
ULARGE_INTEGER u;
u.LowPart = ft.dwLowDateTime;
u.HighPart = ft.dwHighDateTime;

View File

@ -488,7 +488,7 @@ bool CreateNewTempDirectory(const FilePath::StringType& prefix,
return false;
FilePath path_to_create;
srand(static_cast<uint32>(time(NULL)));
srand(static_cast<uint32_t>(time(NULL)));
int count = 0;
while (count < 50) {
@ -779,7 +779,7 @@ bool MemoryMappedFile::MapFileToMemory(const FilePath& file_name) {
if (file_mapping_ == INVALID_HANDLE_VALUE)
return false;
data_ = static_cast<uint8*>(
data_ = static_cast<uint8_t*>(
::MapViewOfFile(file_mapping_, FILE_MAP_READ, 0, 0, length_));
return data_ != NULL;
}

View File

@ -57,7 +57,7 @@ FileVersionInfo* FileVersionInfo::CreateFileVersionInfo(
}
LanguageAndCodePage* translate = NULL;
uint32 page_count;
uint32_t page_count;
BOOL query_result = VerQueryValue(data, L"\\VarFileInfo\\Translation",
(void**) &translate, &page_count);
@ -166,7 +166,7 @@ bool FileVersionInfo::GetValue(const wchar_t* name, std::wstring* value_str) {
_snwprintf_s(sub_block, MAX_PATH, MAX_PATH,
L"\\StringFileInfo\\%04x%04x\\%ls", language, code_page, name);
LPVOID value = NULL;
uint32 size;
uint32_t size;
BOOL r = ::VerQueryValue(data_.get(), sub_block, &value, &size);
if (r && value) {
value_str->assign(static_cast<wchar_t*>(value));

View File

@ -28,7 +28,7 @@ typedef ::Lock Lock;
typedef ::AutoLock AutoLock;
// Static table of checksums for all possible 8 bit bytes.
const uint32 Histogram::kCrcTable[256] = {0x0, 0x77073096L, 0xee0e612cL,
const uint32_t Histogram::kCrcTable[256] = {0x0, 0x77073096L, 0xee0e612cL,
0x990951baL, 0x76dc419L, 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0xedb8832L,
0x79dcb8a4L, 0xe0d5e91eL, 0x97d2d988L, 0x9b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, 0x1adad47dL,
@ -202,8 +202,8 @@ void Histogram::WriteAscii(bool graph_it, const std::string& newline,
}
}
int64 remaining = sample_count;
int64 past = 0;
int64_t remaining = sample_count;
int64_t past = 0;
// Output the actual histogram graph.
for (size_t i = 0; i < bucket_count(); ++i) {
Count current = snapshot.counts(i);
@ -261,7 +261,7 @@ bool Histogram::DeserializeHistogramInfo(const std::string& histogram_info) {
int declared_min;
int declared_max;
size_t bucket_count;
uint32 range_checksum;
uint32_t range_checksum;
int histogram_type;
int pickle_flags;
SampleSet sample;
@ -332,7 +332,7 @@ Histogram::Inconsistencies Histogram::FindCorruption(
const SampleSet& snapshot) const {
int inconsistencies = NO_INCONSISTENCIES;
Sample previous_range = -1; // Bottom range is always 0.
int64 count = 0;
int64_t count = 0;
for (size_t index = 0; index < bucket_count(); ++index) {
count += snapshot.counts(index);
int new_range = ranges(index);
@ -344,7 +344,7 @@ Histogram::Inconsistencies Histogram::FindCorruption(
if (!HasValidRangeChecksum())
inconsistencies |= RANGE_CHECKSUM_ERROR;
int64 delta64 = snapshot.redundant_count() - count;
int64_t delta64 = snapshot.redundant_count() - count;
if (delta64 != 0) {
int delta = static_cast<int>(delta64);
if (delta != delta64)
@ -559,9 +559,9 @@ bool Histogram::ValidateBucketRanges() const {
return true;
}
uint32 Histogram::CalculateRangeChecksum() const {
uint32_t Histogram::CalculateRangeChecksum() const {
DCHECK_EQ(ranges_.size(), bucket_count() + 1);
uint32 checksum = static_cast<uint32>(ranges_.size()); // Seed checksum.
uint32_t checksum = static_cast<uint32_t>(ranges_.size()); // Seed checksum.
for (size_t index = 0; index < bucket_count(); ++index)
checksum = Crc32(checksum, ranges(index));
return checksum;
@ -584,14 +584,14 @@ void Histogram::Initialize() {
// We generate the CRC-32 using the low order bits to select whether to XOR in
// the reversed polynomial 0xedb88320L. This is nice and simple, and allows us
// to keep the quotient in a uint32. Since we're not concerned about the nature
// to keep the quotient in a uint32_t. Since we're not concerned about the nature
// of corruptions (i.e., we don't care about bit sequencing, since we are
// handling memory changes, which are more grotesque) so we don't bother to
// get the CRC correct for big-endian vs little-ending calculations. All we
// need is a nice hash, that tends to depend on all the bits of the sample, with
// very little chance of changes in one place impacting changes in another
// place.
uint32 Histogram::Crc32(uint32 sum, Histogram::Sample range) {
uint32_t Histogram::Crc32(uint32_t sum, Histogram::Sample range) {
const bool kUseRealCrc = true; // TODO(jar): Switch to false and watch stats.
if (kUseRealCrc) {
union {
@ -607,12 +607,12 @@ uint32 Histogram::Crc32(uint32 sum, Histogram::Sample range) {
// and we don't care about edge cases since we have an even number of bytes.
union {
Histogram::Sample range;
uint16 ints[sizeof(Histogram::Sample) / 2];
uint16_t ints[sizeof(Histogram::Sample) / 2];
} converter;
DCHECK_EQ(sizeof(Histogram::Sample), sizeof(converter));
converter.range = range;
sum += converter.ints[0];
sum = (sum << 16) ^ sum ^ (static_cast<uint32>(converter.ints[1]) << 11);
sum = (sum << 16) ^ sum ^ (static_cast<uint32_t>(converter.ints[1]) << 11);
sum += sum >> 11;
}
return sum;
@ -649,9 +649,9 @@ void Histogram::WriteAsciiHeader(const SampleSet& snapshot,
StringAppendF(output, " (flags = 0x%x)", flags_ & ~kHexRangePrintingFlag);
}
void Histogram::WriteAsciiBucketContext(const int64 past,
void Histogram::WriteAsciiBucketContext(const int64_t past,
const Count current,
const int64 remaining,
const int64_t remaining,
const size_t i,
std::string* output) const {
double scaled_sum = (past + current + remaining) / 100.0;

View File

@ -334,8 +334,8 @@ class Histogram {
// Accessor methods.
Count counts(size_t i) const { return counts_[i]; }
Count TotalCount() const;
int64 sum() const { return sum_; }
int64 redundant_count() const { return redundant_count_; }
int64_t sum() const { return sum_; }
int64_t redundant_count() const { return redundant_count_; }
size_t size() const { return counts_.size(); }
// Arithmetic manipulation of corresponding elements of the set.
@ -352,7 +352,7 @@ class Histogram {
// Save simple stats locally. Note that this MIGHT get done in base class
// without shared memory at some point.
int64 sum_; // sum of samples.
int64_t sum_; // sum of samples.
private:
// Allow tests to corrupt our innards for testing purposes.
@ -365,7 +365,7 @@ class Histogram {
// updated on several threads simultaneously), the tallies might mismatch,
// and also the snapshotting code may asynchronously get a mismatch (though
// generally either race based mismatch cause is VERY rare).
int64 redundant_count_;
int64_t redundant_count_;
};
//----------------------------------------------------------------------------
@ -442,7 +442,7 @@ class Histogram {
Sample declared_min() const { return declared_min_; }
Sample declared_max() const { return declared_max_; }
virtual Sample ranges(size_t i) const;
uint32 range_checksum() const { return range_checksum_; }
uint32_t range_checksum() const { return range_checksum_; }
virtual size_t bucket_count() const;
// Snapshot the current complete set of sample data.
// Override with atomic/locked snapshot if needed.
@ -502,7 +502,7 @@ class Histogram {
// values relate properly to the declared_min_ and declared_max_)..
bool ValidateBucketRanges() const;
virtual uint32 CalculateRangeChecksum() const;
virtual uint32_t CalculateRangeChecksum() const;
private:
// Allow tests to corrupt our innards for testing purposes.
@ -517,7 +517,7 @@ class Histogram {
void Initialize();
// Checksum function for accumulating range values into a checksum.
static uint32 Crc32(uint32 sum, Sample range);
static uint32_t Crc32(uint32_t sum, Sample range);
//----------------------------------------------------------------------------
// Helpers for emitting Ascii graphic. Each method appends data to output.
@ -531,8 +531,8 @@ class Histogram {
// Write information about previous, current, and next buckets.
// Information such as cumulative percentage, etc.
void WriteAsciiBucketContext(const int64 past, const Count current,
const int64 remaining, const size_t i,
void WriteAsciiBucketContext(const int64_t past, const Count current,
const int64_t remaining, const size_t i,
std::string* output) const;
// Write textual description of the bucket contents (relative to histogram).
@ -546,7 +546,7 @@ class Histogram {
//----------------------------------------------------------------------------
// Table for generating Crc32 values.
static const uint32 kCrcTable[256];
static const uint32_t kCrcTable[256];
//----------------------------------------------------------------------------
// Invariant values set at/near construction time
@ -569,7 +569,7 @@ class Histogram {
// For redundancy, we store a checksum of all the sample ranges when ranges
// are generated. If ever there is ever a difference, then the histogram must
// have been corrupted.
uint32 range_checksum_;
uint32_t range_checksum_;
// Finally, provide the state that changes with the addition of each new
// sample.

View File

@ -387,9 +387,9 @@ TEST(HistogramTest, CorruptBucketBounds) {
// http://www.w3.org/TR/PNG/#D-CRCAppendix.
TEST(HistogramTest, Crc32TableTest) {
for (int i = 0; i < 256; ++i) {
uint32 checksum = i;
uint32_t checksum = i;
for (int j = 0; j < 8; ++j) {
const uint32 kReversedPolynomial = 0xedb88320L;
const uint32_t kReversedPolynomial = 0xedb88320L;
if (checksum & 1)
checksum = kReversedPolynomial ^ (checksum >> 1);
else

View File

@ -20,7 +20,7 @@
template<class T>
class IDMap {
private:
typedef base::hash_map<int32, T*> HashTable;
typedef base::hash_map<int32_t, T*> HashTable;
typedef typename HashTable::iterator iterator;
public:
@ -42,8 +42,8 @@ class IDMap {
}
// Adds a view with an automatically generated unique ID. See AddWithID.
int32 Add(T* data) {
int32 this_id = next_id_;
int32_t Add(T* data) {
int32_t this_id = next_id_;
DCHECK(data_.find(this_id) == data_.end()) << "Inserting duplicate item";
data_[this_id] = data;
next_id_++;
@ -54,12 +54,12 @@ class IDMap {
// the list. The caller either must generate all unique IDs itself and use
// this function, or allow this object to generate IDs and call Add. These
// two methods may not be mixed, or duplicate IDs may be generated
void AddWithID(T* data, int32 id) {
void AddWithID(T* data, int32_t id) {
DCHECK(data_.find(id) == data_.end()) << "Inserting duplicate item";
data_[id] = data;
}
void Remove(int32 id) {
void Remove(int32_t id) {
iterator i = data_.find(id);
if (i == data_.end()) {
NOTREACHED() << "Attempting to remove an item not in the list";
@ -84,7 +84,7 @@ class IDMap {
return false;
}
T* Lookup(int32 id) const {
T* Lookup(int32_t id) const {
const_iterator i = data_.find(id);
if (i == data_.end())
return NULL;
@ -97,7 +97,7 @@ class IDMap {
protected:
// The next ID that we will return from Add()
int32 next_id_;
int32_t next_id_;
HashTable data_;
};

View File

@ -28,18 +28,18 @@
namespace base {
#if defined(OS_WIN)
bool OSIdleTimeSource(int32 *milliseconds_interval_since_last_event) {
bool OSIdleTimeSource(int32_t *milliseconds_interval_since_last_event) {
LASTINPUTINFO lastInputInfo;
lastInputInfo.cbSize = sizeof(lastInputInfo);
if (GetLastInputInfo(&lastInputInfo) == 0) {
return false;
}
int32 last_input_time = lastInputInfo.dwTime;
int32_t last_input_time = lastInputInfo.dwTime;
// Note: On Windows GetLastInputInfo returns a 32bit value which rolls over
// ~49days.
int32 current_time = GetTickCount();
int32 delta = current_time - last_input_time;
int32_t current_time = GetTickCount();
int32_t delta = current_time - last_input_time;
// delta will go negative if we've been idle for 2GB of ticks.
if (delta < 0)
delta = -delta;
@ -47,7 +47,7 @@ bool OSIdleTimeSource(int32 *milliseconds_interval_since_last_event) {
return true;
}
#elif defined(OS_MACOSX)
bool OSIdleTimeSource(int32 *milliseconds_interval_since_last_event) {
bool OSIdleTimeSource(int32_t *milliseconds_interval_since_last_event) {
*milliseconds_interval_since_last_event =
CGEventSourceSecondsSinceLastEventType(
kCGEventSourceStateCombinedSessionState,
@ -72,7 +72,7 @@ class IdleState {
}
}
int32 IdleTime() {
int32_t IdleTime() {
if (have_idle_info_ && idle_info_.Get()) {
XScreenSaverQueryInfo(GDK_DISPLAY(), GDK_ROOT_WINDOW(),
idle_info_.Get());
@ -88,10 +88,10 @@ class IdleState {
DISALLOW_COPY_AND_ASSIGN(IdleState);
};
bool OSIdleTimeSource(int32* milliseconds_interval_since_last_event) {
bool OSIdleTimeSource(int32_t* milliseconds_interval_since_last_event) {
static LazyInstance<IdleState> state_instance(base::LINKER_INITIALIZED);
IdleState* state = state_instance.Pointer();
int32 idle_time = state->IdleTime();
int32_t idle_time = state->IdleTime();
if (0 < idle_time) {
*milliseconds_interval_since_last_event = idle_time;
return true;
@ -139,7 +139,7 @@ void IdleTimer::StartTimer() {
}
TimeDelta IdleTimer::CurrentIdleTime() {
int32 interval = 0;
int32_t interval = 0;
if (idle_time_source_(&interval)) {
return TimeDelta::FromMilliseconds(interval);
}

View File

@ -40,7 +40,7 @@ namespace base {
// Function prototype - Get the number of milliseconds that the user has been
// idle.
typedef bool (*IdleTimeSource)(int32 *milliseconds_interval_since_last_event);
typedef bool (*IdleTimeSource)(int32_t *milliseconds_interval_since_last_event);
class IdleTimer {
public:

View File

@ -23,10 +23,10 @@ namespace {
// the time stored here.
static Time mock_timer_started;
bool MockIdleTimeSource(int32 *milliseconds_interval_since_last_event) {
bool MockIdleTimeSource(int32_t *milliseconds_interval_since_last_event) {
TimeDelta delta = Time::Now() - mock_timer_started;
*milliseconds_interval_since_last_event =
static_cast<int32>(delta.InMilliseconds());
static_cast<int32_t>(delta.InMilliseconds());
return true;
}

View File

@ -100,7 +100,7 @@ class LazyInstance : public LazyInstanceHelper {
}
private:
int8 buf_[sizeof(Type)]; // Preallocate the space for the Type instance.
int8_t buf_[sizeof(Type)]; // Preallocate the space for the Type instance.
DISALLOW_COPY_AND_ASSIGN(LazyInstance);
};

View File

@ -66,7 +66,7 @@ class LockImpl {
// All private data is implicitly protected by lock_.
// Be VERY careful to only access members under that lock.
PlatformThreadId owning_thread_id_;
int32 recursion_count_shadow_;
int32_t recursion_count_shadow_;
bool recursion_used_; // Allow debugging to continued after a DCHECK().
#endif // NDEBUG

View File

@ -25,8 +25,8 @@
#include "base/basictypes.h"
struct Context {
uint32 buf[4];
uint32 bits[2];
uint32_t buf[4];
uint32_t bits[2];
unsigned char in[64];
};
@ -34,11 +34,11 @@ struct Context {
* Note: this code is harmless on little-endian machines.
*/
static void byteReverse (unsigned char *buf, unsigned longs){
uint32 t;
uint32_t t;
do {
t = (uint32)((unsigned)buf[3]<<8 | buf[2]) << 16 |
t = (uint32_t)((unsigned)buf[3]<<8 | buf[2]) << 16 |
((unsigned)buf[1]<<8 | buf[0]);
*(uint32 *)buf = t;
*(uint32_t *)buf = t;
buf += 4;
} while (--longs);
}
@ -59,8 +59,8 @@ static void byteReverse (unsigned char *buf, unsigned longs){
* reflect the addition of 16 longwords of new data. MD5Update blocks
* the data and converts bytes into longwords for this routine.
*/
static void MD5Transform(uint32 buf[4], const uint32 in[16]){
register uint32 a, b, c, d;
static void MD5Transform(uint32_t buf[4], const uint32_t in[16]){
register uint32_t a, b, c, d;
a = buf[0];
b = buf[1];
@ -162,14 +162,14 @@ void MD5Init(MD5Context *pCtx){
void MD5Update(MD5Context *pCtx, const void *inbuf, size_t len){
struct Context *ctx = (struct Context *)pCtx;
const unsigned char* buf = (const unsigned char*)inbuf;
uint32 t;
uint32_t t;
/* Update bitcount */
t = ctx->bits[0];
if ((ctx->bits[0] = t + ((uint32)len << 3)) < t)
if ((ctx->bits[0] = t + ((uint32_t)len << 3)) < t)
ctx->bits[1]++; /* Carry from low to high */
ctx->bits[1] += static_cast<uint32>(len >> 29);
ctx->bits[1] += static_cast<uint32_t>(len >> 29);
t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
@ -185,7 +185,7 @@ void MD5Update(MD5Context *pCtx, const void *inbuf, size_t len){
}
memcpy(p, buf, t);
byteReverse(ctx->in, 16);
MD5Transform(ctx->buf, (uint32 *)ctx->in);
MD5Transform(ctx->buf, (uint32_t *)ctx->in);
buf += t;
len -= t;
}
@ -195,7 +195,7 @@ void MD5Update(MD5Context *pCtx, const void *inbuf, size_t len){
while (len >= 64) {
memcpy(ctx->in, buf, 64);
byteReverse(ctx->in, 16);
MD5Transform(ctx->buf, (uint32 *)ctx->in);
MD5Transform(ctx->buf, (uint32_t *)ctx->in);
buf += 64;
len -= 64;
}
@ -230,7 +230,7 @@ void MD5Final(MD5Digest* digest, MD5Context *pCtx){
/* Two lots of padding: Pad the first block to 64 bytes */
memset(p, 0, count);
byteReverse(ctx->in, 16);
MD5Transform(ctx->buf, (uint32 *)ctx->in);
MD5Transform(ctx->buf, (uint32_t *)ctx->in);
/* Now fill the next block with 56 bytes */
memset(ctx->in, 0, 56);
@ -241,10 +241,10 @@ void MD5Final(MD5Digest* digest, MD5Context *pCtx){
byteReverse(ctx->in, 14);
/* Append length in bits and transform */
((uint32 *)ctx->in)[ 14 ] = ctx->bits[0];
((uint32 *)ctx->in)[ 15 ] = ctx->bits[1];
((uint32_t *)ctx->in)[ 14 ] = ctx->bits[0];
((uint32_t *)ctx->in)[ 15 ] = ctx->bits[1];
MD5Transform(ctx->buf, (uint32 *)ctx->in);
MD5Transform(ctx->buf, (uint32_t *)ctx->in);
byteReverse((unsigned char *)ctx->buf, 4);
memcpy(digest->a, ctx->buf, 16);
memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */

View File

@ -76,7 +76,7 @@ MessagePumpQt::scheduleDelayedIfNeeded(const Time& delayed_work_time)
}
TimeDelta later = delayed_work_time - Time::Now();
// later.InMilliseconds() returns an int64, QTimer only accepts int's for start(),
// later.InMilliseconds() returns an int64_t, QTimer only accepts int's for start(),
// std::min only works on exact same types.
int laterMsecs = later.InMilliseconds() > std::numeric_limits<int>::max() ?
std::numeric_limits<int>::max() : later.InMilliseconds();

View File

@ -15,11 +15,11 @@
const int Pickle::kPayloadUnit = 64;
// We mark a read only pickle with a special capacity_.
static const uint32 kCapacityReadOnly = (uint32) -1;
static const uint32_t kCapacityReadOnly = (uint32_t) -1;
static const char kBytePaddingMarker = char(0xbf);
// Payload is uint32 aligned.
// Payload is uint32_t aligned.
Pickle::Pickle()
: header_(NULL),
@ -32,10 +32,10 @@ Pickle::Pickle()
Pickle::Pickle(int header_size)
: header_(NULL),
header_size_(AlignInt(header_size, sizeof(uint32))),
header_size_(AlignInt(header_size, sizeof(uint32_t))),
capacity_(0),
variable_buffer_offset_(0) {
DCHECK(static_cast<uint32>(header_size) >= sizeof(Header));
DCHECK(static_cast<uint32_t>(header_size) >= sizeof(Header));
DCHECK(header_size <= kPayloadUnit);
Resize(kPayloadUnit);
header_->payload_size = 0;
@ -47,7 +47,7 @@ Pickle::Pickle(const char* data, int data_len)
capacity_(kCapacityReadOnly),
variable_buffer_offset_(0) {
DCHECK(header_size_ >= sizeof(Header));
DCHECK(header_size_ == AlignInt(header_size_, sizeof(uint32)));
DCHECK(header_size_ == AlignInt(header_size_, sizeof(uint32_t)));
}
Pickle::Pickle(const Pickle& other)
@ -55,7 +55,7 @@ Pickle::Pickle(const Pickle& other)
header_size_(other.header_size_),
capacity_(0),
variable_buffer_offset_(other.variable_buffer_offset_) {
uint32 payload_size = header_size_ + other.header_->payload_size;
uint32_t payload_size = header_size_ + other.header_->payload_size;
bool resized = Resize(payload_size);
CHECK(resized); // Realloc failed.
memcpy(header_, other.header_, payload_size);
@ -90,7 +90,7 @@ bool Pickle::ReadBool(void** iter, bool* result) const {
return true;
}
bool Pickle::ReadInt16(void** iter, int16* result) const {
bool Pickle::ReadInt16(void** iter, int16_t* result) const {
DCHECK(iter);
if (!*iter)
*iter = const_cast<char*>(payload());
@ -104,7 +104,7 @@ bool Pickle::ReadInt16(void** iter, int16* result) const {
return true;
}
bool Pickle::ReadUInt16(void** iter, uint16* result) const {
bool Pickle::ReadUInt16(void** iter, uint16_t* result) const {
DCHECK(iter);
if (!*iter)
*iter = const_cast<char*>(payload());
@ -142,7 +142,7 @@ bool Pickle::ReadLong(void** iter, long* result) const {
if (!*iter)
*iter = const_cast<char*>(payload());
int64 bigResult = 0;
int64_t bigResult = 0;
if (!IteratorHasRoomFor(*iter, sizeof(bigResult)))
return false;
@ -163,7 +163,7 @@ bool Pickle::ReadULong(void** iter, unsigned long* result) const {
if (!*iter)
*iter = const_cast<char*>(payload());
uint64 bigResult = 0;
uint64_t bigResult = 0;
if (!IteratorHasRoomFor(*iter, sizeof(bigResult)))
return false;
@ -190,7 +190,7 @@ bool Pickle::ReadSize(void** iter, size_t* result) const {
if (!*iter)
*iter = const_cast<char*>(payload());
uint64 bigResult = 0;
uint64_t bigResult = 0;
if (!IteratorHasRoomFor(*iter, sizeof(bigResult)))
return false;
@ -204,7 +204,7 @@ bool Pickle::ReadSize(void** iter, size_t* result) const {
return true;
}
bool Pickle::ReadInt32(void** iter, int32* result) const {
bool Pickle::ReadInt32(void** iter, int32_t* result) const {
DCHECK(iter);
if (!*iter)
*iter = const_cast<char*>(payload());
@ -218,7 +218,7 @@ bool Pickle::ReadInt32(void** iter, int32* result) const {
return true;
}
bool Pickle::ReadUInt32(void** iter, uint32* result) const {
bool Pickle::ReadUInt32(void** iter, uint32_t* result) const {
DCHECK(iter);
if (!*iter)
*iter = const_cast<char*>(payload());
@ -232,7 +232,7 @@ bool Pickle::ReadUInt32(void** iter, uint32* result) const {
return true;
}
bool Pickle::ReadInt64(void** iter, int64* result) const {
bool Pickle::ReadInt64(void** iter, int64_t* result) const {
DCHECK(iter);
if (!*iter)
*iter = const_cast<char*>(payload());
@ -246,7 +246,7 @@ bool Pickle::ReadInt64(void** iter, int64* result) const {
return true;
}
bool Pickle::ReadUInt64(void** iter, uint64* result) const {
bool Pickle::ReadUInt64(void** iter, uint64_t* result) const {
DCHECK(iter);
if (!*iter)
*iter = const_cast<char*>(payload());
@ -281,7 +281,7 @@ bool Pickle::ReadIntPtr(void** iter, intptr_t* result) const {
if (!*iter)
*iter = const_cast<char*>(payload());
int64 bigResult = 0;
int64_t bigResult = 0;
if (!IteratorHasRoomFor(*iter, sizeof(bigResult)))
return false;
@ -362,7 +362,7 @@ bool Pickle::ReadString16(void** iter, string16* result) const {
}
bool Pickle::ReadBytes(void** iter, const char** data, int length,
uint32 alignment) const {
uint32_t alignment) const {
DCHECK(iter);
DCHECK(data);
DCHECK(alignment == 4 || alignment == 8);
@ -371,12 +371,12 @@ bool Pickle::ReadBytes(void** iter, const char** data, int length,
if (!*iter)
*iter = const_cast<char*>(payload());
uint32 paddingLen = intptr_t(*iter) % alignment;
uint32_t paddingLen = intptr_t(*iter) % alignment;
if (paddingLen) {
#ifdef DEBUG
{
const char* padding = static_cast<const char*>(*iter);
for (uint32 i = 0; i < paddingLen; i++) {
for (uint32_t i = 0; i < paddingLen; i++) {
DCHECK(*(padding + i) == kBytePaddingMarker);
}
}
@ -407,14 +407,14 @@ bool Pickle::ReadData(void** iter, const char** data, int* length) const {
return ReadBytes(iter, data, *length);
}
char* Pickle::BeginWrite(uint32 length, uint32 alignment) {
char* Pickle::BeginWrite(uint32_t length, uint32_t alignment) {
DCHECK(alignment % 4 == 0) << "Must be at least 32-bit aligned!";
// write at an alignment-aligned offset from the beginning of the header
uint32 offset = AlignInt(header_->payload_size, sizeof(uint32));
uint32 padding = (header_size_ + offset) % alignment;
uint32 new_size = offset + padding + AlignInt(length, sizeof(uint32));
uint32 needed_size = header_size_ + new_size;
uint32_t offset = AlignInt(header_->payload_size, sizeof(uint32_t));
uint32_t padding = (header_size_ + offset) % alignment;
uint32_t new_size = offset + padding + AlignInt(length, sizeof(uint32_t));
uint32_t needed_size = header_size_ + new_size;
if (needed_size > capacity_ && !Resize(std::max(capacity_ * 2, needed_size)))
return NULL;
@ -422,7 +422,7 @@ char* Pickle::BeginWrite(uint32 length, uint32 alignment) {
DCHECK(intptr_t(header_) % alignment == 0);
#ifdef ARCH_CPU_64_BITS
DCHECK_LE(length, std::numeric_limits<uint32>::max());
DCHECK_LE(length, std::numeric_limits<uint32_t>::max());
#endif
char* buffer = payload() + offset;
@ -441,11 +441,11 @@ char* Pickle::BeginWrite(uint32 length, uint32 alignment) {
void Pickle::EndWrite(char* dest, int length) {
// Zero-pad to keep tools like purify from complaining about uninitialized
// memory.
if (length % sizeof(uint32))
memset(dest + length, 0, sizeof(uint32) - (length % sizeof(uint32)));
if (length % sizeof(uint32_t))
memset(dest + length, 0, sizeof(uint32_t) - (length % sizeof(uint32_t)));
}
bool Pickle::WriteBytes(const void* data, int data_len, uint32 alignment) {
bool Pickle::WriteBytes(const void* data, int data_len, uint32_t alignment) {
DCHECK(capacity_ != kCapacityReadOnly) << "oops: pickle is readonly";
DCHECK(alignment == 4 || alignment == 8);
DCHECK(intptr_t(header_) % alignment == 0);
@ -494,7 +494,7 @@ char* Pickle::BeginWriteData(int length) {
if (!WriteInt(length))
return false;
char *data_ptr = BeginWrite(length, sizeof(uint32));
char *data_ptr = BeginWrite(length, sizeof(uint32_t));
if (!data_ptr)
return NULL;
@ -524,7 +524,7 @@ void Pickle::TrimWriteData(int new_length) {
*cur_length = new_length;
}
bool Pickle::Resize(uint32 new_capacity) {
bool Pickle::Resize(uint32_t new_capacity) {
new_capacity = AlignInt(new_capacity, kPayloadUnit);
void* p = realloc(header_, new_capacity);
@ -537,11 +537,11 @@ bool Pickle::Resize(uint32 new_capacity) {
}
// static
const char* Pickle::FindNext(uint32 header_size,
const char* Pickle::FindNext(uint32_t header_size,
const char* start,
const char* end) {
DCHECK(header_size == AlignInt(header_size, sizeof(uint32)));
DCHECK(header_size <= static_cast<uint32>(kPayloadUnit));
DCHECK(header_size == AlignInt(header_size, sizeof(uint32_t)));
DCHECK(header_size <= static_cast<uint32_t>(kPayloadUnit));
const Header* hdr = reinterpret_cast<const Header*>(start);
const char* payload_base = start + header_size;

View File

@ -65,17 +65,17 @@ class Pickle {
// true. Otherwise, false is returned to indicate that the result could not
// be extracted.
bool ReadBool(void** iter, bool* result) const;
bool ReadInt16(void** iter, int16* result) const;
bool ReadUInt16(void** iter, uint16* result) const;
bool ReadInt16(void** iter, int16_t* result) const;
bool ReadUInt16(void** iter, uint16_t* result) const;
bool ReadShort(void** iter, short* result) const;
bool ReadInt(void** iter, int* result) const;
bool ReadLong(void** iter, long* result) const;
bool ReadULong(void** iter, unsigned long* result) const;
bool ReadSize(void** iter, size_t* result) const;
bool ReadInt32(void** iter, int32* result) const;
bool ReadUInt32(void** iter, uint32* result) const;
bool ReadInt64(void** iter, int64* result) const;
bool ReadUInt64(void** iter, uint64* result) const;
bool ReadInt32(void** iter, int32_t* result) const;
bool ReadUInt32(void** iter, uint32_t* result) const;
bool ReadInt64(void** iter, int64_t* result) const;
bool ReadUInt64(void** iter, uint64_t* result) const;
bool ReadDouble(void** iter, double* result) const;
bool ReadIntPtr(void** iter, intptr_t* result) const;
bool ReadUnsignedChar(void** iter, unsigned char* result) const;
@ -84,7 +84,7 @@ class Pickle {
bool ReadString16(void** iter, string16* result) const;
bool ReadData(void** iter, const char** data, int* length) const;
bool ReadBytes(void** iter, const char** data, int length,
uint32 alignment = sizeof(uint32)) const;
uint32_t alignment = sizeof(uint32_t)) const;
// Safer version of ReadInt() checks for the result not being negative.
// Use it for reading the object sizes.
@ -97,10 +97,10 @@ class Pickle {
bool WriteBool(bool value) {
return WriteInt(value ? 1 : 0);
}
bool WriteInt16(int16 value) {
bool WriteInt16(int16_t value) {
return WriteBytes(&value, sizeof(value));
}
bool WriteUInt16(uint16 value) {
bool WriteUInt16(uint16_t value) {
return WriteBytes(&value, sizeof(value));
}
bool WriteInt(int value) {
@ -109,28 +109,28 @@ class Pickle {
bool WriteLong(long value) {
// Always written as a 64-bit value since the size for this type can
// differ between architectures.
return WriteInt64(int64(value));
return WriteInt64(int64_t(value));
}
bool WriteULong(unsigned long value) {
// Always written as a 64-bit value since the size for this type can
// differ between architectures.
return WriteUInt64(uint64(value));
return WriteUInt64(uint64_t(value));
}
bool WriteSize(size_t value) {
// Always written as a 64-bit value since the size for this type can
// differ between architectures.
return WriteUInt64(uint64(value));
return WriteUInt64(uint64_t(value));
}
bool WriteInt32(int32 value) {
bool WriteInt32(int32_t value) {
return WriteBytes(&value, sizeof(value));
}
bool WriteUInt32(uint32 value) {
bool WriteUInt32(uint32_t value) {
return WriteBytes(&value, sizeof(value));
}
bool WriteInt64(int64 value) {
bool WriteInt64(int64_t value) {
return WriteBytes(&value, sizeof(value));
}
bool WriteUInt64(uint64 value) {
bool WriteUInt64(uint64_t value) {
return WriteBytes(&value, sizeof(value));
}
bool WriteDouble(double value) {
@ -139,7 +139,7 @@ class Pickle {
bool WriteIntPtr(intptr_t value) {
// Always written as a 64-bit value since the size for this type can
// differ between architectures.
return WriteInt64(int64(value));
return WriteInt64(int64_t(value));
}
bool WriteUnsignedChar(unsigned char value) {
return WriteBytes(&value, sizeof(value));
@ -149,7 +149,7 @@ class Pickle {
bool WriteString16(const string16& value);
bool WriteData(const char* data, int length);
bool WriteBytes(const void* data, int data_len,
uint32 alignment = sizeof(uint32));
uint32_t alignment = sizeof(uint32_t));
// Same as WriteData, but allows the caller to write directly into the
// Pickle. This saves a copy in cases where the data is not already
@ -178,7 +178,7 @@ class Pickle {
// Payload follows after allocation of Header (header size is customizable).
struct Header {
uint32 payload_size; // Specifies the size of the payload.
uint32_t payload_size; // Specifies the size of the payload.
};
// Returns the header, cast to a user-specified type T. The type T must be a
@ -207,7 +207,7 @@ class Pickle {
}
protected:
uint32 payload_size() const { return header_->payload_size; }
uint32_t payload_size() const { return header_->payload_size; }
char* payload() {
return reinterpret_cast<char*>(header_) + header_size_;
@ -225,7 +225,7 @@ class Pickle {
return payload() + payload_size();
}
uint32 capacity() const {
uint32_t capacity() const {
return capacity_;
}
@ -233,7 +233,7 @@ class Pickle {
// location that the data should be written at is returned, or NULL if there
// was an error. Call EndWrite with the returned offset and the given length
// to pad out for the next write.
char* BeginWrite(uint32 length, uint32 alignment);
char* BeginWrite(uint32_t length, uint32_t alignment);
// Completes the write operation by padding the data with NULL bytes until it
// is padded. Should be paired with BeginWrite, but it does not necessarily
@ -244,23 +244,23 @@ class Pickle {
// the header: new_capacity = sizeof(Header) + desired_payload_capacity.
// A realloc() failure will cause a Resize failure... and caller should check
// the return result for true (i.e., successful resizing).
bool Resize(uint32 new_capacity);
bool Resize(uint32_t new_capacity);
// Aligns 'i' by rounding it up to the next multiple of 'alignment'
static uint32 AlignInt(uint32 i, int alignment) {
static uint32_t AlignInt(uint32_t i, int alignment) {
return i + (alignment - (i % alignment)) % alignment;
}
// Moves the iterator by the given number of bytes, making sure it is aligned.
// Pointer (iterator) is NOT aligned, but the change in the pointer
// is guaranteed to be a multiple of sizeof(uint32).
// is guaranteed to be a multiple of sizeof(uint32_t).
static void UpdateIter(void** iter, int bytes) {
*iter = static_cast<char*>(*iter) + AlignInt(bytes, sizeof(uint32));
*iter = static_cast<char*>(*iter) + AlignInt(bytes, sizeof(uint32_t));
}
// Find the end of the pickled data that starts at range_start. Returns NULL
// if the entire Pickle is not found in the given data range.
static const char* FindNext(uint32 header_size,
static const char* FindNext(uint32_t header_size,
const char* range_start,
const char* range_end);
@ -269,9 +269,9 @@ class Pickle {
private:
Header* header_;
uint32 header_size_;
uint32 capacity_;
uint32 variable_buffer_offset_;
uint32_t header_size_;
uint32_t capacity_;
uint32_t variable_buffer_offset_;
FRIEND_TEST(PickleTest, Resize);
FRIEND_TEST(PickleTest, FindNext);
FRIEND_TEST(PickleTest, IteratorHasRoom);

View File

@ -161,10 +161,10 @@ TEST(PickleTest, Resize) {
// construct a message that will be exactly the size of one payload unit,
// note that any data will have a 4-byte header indicating the size
const size_t payload_size_after_header = unit - sizeof(uint32);
const size_t payload_size_after_header = unit - sizeof(uint32_t);
Pickle pickle;
pickle.WriteData(data_ptr,
static_cast<int>(payload_size_after_header - sizeof(uint32)));
static_cast<int>(payload_size_after_header - sizeof(uint32_t)));
size_t cur_payload = payload_size_after_header;
// note: we assume 'unit' is a power of 2
@ -172,7 +172,7 @@ TEST(PickleTest, Resize) {
EXPECT_EQ(pickle.payload_size(), payload_size_after_header);
// fill out a full page (noting data header)
pickle.WriteData(data_ptr, static_cast<int>(unit - sizeof(uint32)));
pickle.WriteData(data_ptr, static_cast<int>(unit - sizeof(uint32_t)));
cur_payload += unit;
EXPECT_EQ(unit * 2, pickle.capacity());
EXPECT_EQ(cur_payload, pickle.payload_size());
@ -193,7 +193,7 @@ struct CustomHeader : Pickle::Header {
} // namespace
TEST(PickleTest, HeaderPadding) {
const uint32 kMagic = 0x12345678;
const uint32_t kMagic = 0x12345678;
Pickle pickle(sizeof(CustomHeader));
pickle.WriteInt(kMagic);
@ -205,7 +205,7 @@ TEST(PickleTest, HeaderPadding) {
int result;
ASSERT_TRUE(pickle.ReadInt(&iter, &result));
EXPECT_EQ(static_cast<uint32>(result), kMagic);
EXPECT_EQ(static_cast<uint32_t>(result), kMagic);
}
TEST(PickleTest, EqualsOperator) {

View File

@ -422,8 +422,8 @@ class ProcessMetrics {
int processor_count_;
// Used to store the previous times so we can compute the CPU usage.
int64 last_time_;
int64 last_system_time_;
int64_t last_time_;
int64_t last_system_time_;
DISALLOW_EVIL_CONSTRUCTORS(ProcessMetrics);
};

View File

@ -333,7 +333,7 @@ int WaitpidWithTimeout(ProcessHandle handle, int wait_milliseconds,
// the application itself it would probably be best to examine other routes.
int status = -1;
pid_t ret_pid = HANDLE_EINTR(waitpid(handle, &status, WNOHANG));
static const int64 kQuarterSecondInMicroseconds = kMicrosecondsPerSecond/4;
static const int64_t kQuarterSecondInMicroseconds = kMicrosecondsPerSecond/4;
// If the process hasn't exited yet, then sleep and try again.
Time wakeup_time = Time::Now() + TimeDelta::FromMilliseconds(
@ -343,7 +343,7 @@ int WaitpidWithTimeout(ProcessHandle handle, int wait_milliseconds,
if (now > wakeup_time)
break;
// Guaranteed to be non-negative!
int64 sleep_time_usecs = (wakeup_time - now).InMicroseconds();
int64_t sleep_time_usecs = (wakeup_time - now).InMicroseconds();
// Don't sleep for more than 0.25 secs at a time.
if (sleep_time_usecs > kQuarterSecondInMicroseconds) {
sleep_time_usecs = kQuarterSecondInMicroseconds;
@ -393,7 +393,7 @@ bool CrashAwareSleep(ProcessHandle handle, int wait_milliseconds) {
namespace {
int64 TimeValToMicroseconds(const struct timeval& tv) {
int64_t TimeValToMicroseconds(const struct timeval& tv) {
return tv.tv_sec * kMicrosecondsPerSecond + tv.tv_usec;
}
@ -410,10 +410,10 @@ int ProcessMetrics::GetCPUUsage() {
if (retval)
return 0;
int64 system_time = (TimeValToMicroseconds(usage.ru_stime) +
int64_t system_time = (TimeValToMicroseconds(usage.ru_stime) +
TimeValToMicroseconds(usage.ru_utime)) /
processor_count_;
int64 time = TimeValToMicroseconds(now);
int64_t time = TimeValToMicroseconds(now);
if ((last_system_time_ == 0) || (last_time_ == 0)) {
// First call, just set the last values.
@ -422,8 +422,8 @@ int ProcessMetrics::GetCPUUsage() {
return 0;
}
int64 system_time_delta = system_time - last_system_time_;
int64 time_delta = time - last_time_;
int64_t system_time_delta = system_time - last_system_time_;
int64_t time_delta = time - last_time_;
DCHECK(time_delta != 0);
if (time_delta == 0)
return 0;

View File

@ -173,9 +173,9 @@ int GetMaxFilesOpenInProcess() {
return 0;
}
// rlim_t is a uint64 - clip to maxint. We do this since FD #s are ints
// rlim_t is a uint64_t - clip to maxint. We do this since FD #s are ints
// which are all 32 bits on the supported platforms.
rlim_t max_int = static_cast<rlim_t>(std::numeric_limits<int32>::max());
rlim_t max_int = static_cast<rlim_t>(std::numeric_limits<int32_t>::max());
if (rlim.rlim_cur > max_int) {
return max_int;
}

View File

@ -617,7 +617,7 @@ bool ProcessMetrics::GetWorkingSetKBytes(WorkingSetKBytes* ws_usage) const {
return true;
}
static uint64 FileTimeToUTC(const FILETIME& ftime) {
static uint64_t FileTimeToUTC(const FILETIME& ftime) {
LARGE_INTEGER li;
li.LowPart = ftime.dwLowDateTime;
li.HighPart = ftime.dwHighDateTime;
@ -640,9 +640,9 @@ int ProcessMetrics::GetCPUUsage() {
// not yet received the notification.
return 0;
}
int64 system_time = (FileTimeToUTC(kernel_time) + FileTimeToUTC(user_time)) /
int64_t system_time = (FileTimeToUTC(kernel_time) + FileTimeToUTC(user_time)) /
processor_count_;
int64 time = FileTimeToUTC(now);
int64_t time = FileTimeToUTC(now);
if ((last_system_time_ == 0) || (last_time_ == 0)) {
// First call, just set the last values.
@ -651,8 +651,8 @@ int ProcessMetrics::GetCPUUsage() {
return 0;
}
int64 system_time_delta = system_time - last_system_time_;
int64 time_delta = time - last_time_;
int64_t system_time_delta = system_time - last_system_time_;
int64_t time_delta = time - last_time_;
DCHECK(time_delta != 0);
if (time_delta == 0)
return 0;

View File

@ -16,8 +16,8 @@ namespace base {
int RandInt(int min, int max) {
DCHECK(min <= max);
uint64 range = static_cast<int64>(max) - min + 1;
uint64 number = base::RandUint64();
uint64_t range = static_cast<int64_t>(max) - min + 1;
uint64_t number = base::RandUint64();
int result = min + static_cast<int>(number % range);
DCHECK(result >= min && result <= max);
return result;
@ -31,7 +31,7 @@ double RandDouble() {
COMPILE_ASSERT(std::numeric_limits<double>::radix == 2, otherwise_use_scalbn);
static const int kBits = std::numeric_limits<double>::digits;
uint64 random_bits = base::RandUint64() & ((GG_UINT64_C(1) << kBits) - 1);
uint64_t random_bits = base::RandUint64() & ((GG_UINT64_C(1) << kBits) - 1);
double result = ldexp(static_cast<double>(random_bits), -1 * kBits);
DCHECK(result >= 0.0 && result < 1.0);
return result;

View File

@ -10,7 +10,7 @@
namespace base {
// Returns a random number in range [0, kuint64max]. Thread-safe.
uint64 RandUint64();
uint64_t RandUint64();
// Returns a random number between min and max (inclusive). Thread-safe.
int RandInt(int min, int max);

View File

@ -12,8 +12,8 @@
namespace base {
uint64 RandUint64() {
uint64 number;
uint64_t RandUint64() {
uint64_t number;
int urandom_fd = open("/dev/urandom", O_RDONLY);
CHECK(urandom_fd >= 0);

View File

@ -11,8 +11,8 @@
namespace {
uint32 RandUint32() {
uint32 number;
uint32_t RandUint32() {
uint32_t number;
CHECK(rand_s(&number) == 0);
return number;
}
@ -21,10 +21,10 @@ uint32 RandUint32() {
namespace base {
uint64 RandUint64() {
uint32 first_half = RandUint32();
uint32 second_half = RandUint32();
return (static_cast<uint64>(first_half) << 32) + second_half;
uint64_t RandUint64() {
uint32_t first_half = RandUint32();
uint32_t second_half = RandUint32();
return (static_cast<uint64_t>(first_half) << 32) + second_half;
}
} // namespace base

View File

@ -51,16 +51,16 @@ BSTR ScopedBstr::AllocateBytes(int bytes) {
return bstr_;
}
void ScopedBstr::SetByteLen(uint32 bytes) {
void ScopedBstr::SetByteLen(uint32_t bytes) {
DCHECK(bstr_ != NULL) << "attempting to modify a NULL bstr";
uint32* data = reinterpret_cast<uint32*>(bstr_);
uint32_t* data = reinterpret_cast<uint32_t*>(bstr_);
data[-1] = bytes;
}
uint32 ScopedBstr::Length() const {
uint32_t ScopedBstr::Length() const {
return SysStringLen(bstr_);
}
uint32 ScopedBstr::ByteLength() const {
uint32_t ScopedBstr::ByteLength() const {
return SysStringByteLen(bstr_);
}

View File

@ -52,7 +52,7 @@ class ScopedBstr {
//
// NOTE: The actual allocated size of the BSTR MUST be >= bytes.
// That responsibility is with the caller.
void SetByteLen(uint32 bytes);
void SetByteLen(uint32_t bytes);
// Swap values of two ScopedBstr's.
void Swap(ScopedBstr& bstr2);
@ -64,10 +64,10 @@ class ScopedBstr {
BSTR* Receive();
// Returns number of chars in the BSTR.
uint32 Length() const;
uint32_t Length() const;
// Returns the number of bytes allocated for the BSTR.
uint32 ByteLength() const;
uint32_t ByteLength() const;
operator BSTR() const {
return bstr_;
@ -87,7 +87,7 @@ class ScopedBstr {
// Template class to generate a BSTR from a static wide string
// without touching the heap. Use this class via the StackBstrVar and
// StackBstr macros.
template <uint32 string_bytes>
template <uint32_t string_bytes>
class StackBstrT {
public:
// Try to stay as const as we can in an attempt to avoid someone
@ -95,9 +95,9 @@ class StackBstrT {
// of a verbatim string. We also have an assert in the constructor
// as an extra runtime check since the const-ness only catches one case.
explicit StackBstrT(const wchar_t* const str) {
// The BSTR API uses UINT, but we prefer uint32.
// The BSTR API uses UINT, but we prefer uint32_t.
// Make sure we'll know about it if these types don't match.
COMPILE_ASSERT(sizeof(uint32) == sizeof(UINT), UintToUint32);
COMPILE_ASSERT(sizeof(uint32_t) == sizeof(UINT), UintToUint32);
COMPILE_ASSERT(sizeof(wchar_t) == sizeof(OLECHAR), WcharToOlechar);
// You shouldn't pass string pointers to this constructor since
@ -115,7 +115,7 @@ class StackBstrT {
protected:
struct BstrInternal {
uint32 len_;
uint32_t len_;
wchar_t str_[string_bytes / sizeof(wchar_t)];
} bstr_;
};

View File

@ -9,8 +9,8 @@ namespace {
static const wchar_t kTestString1[] = L"123";
static const wchar_t kTestString2[] = L"456789";
uint32 test1_len = arraysize(kTestString1) - 1;
uint32 test2_len = arraysize(kTestString2) - 1;
uint32_t test1_len = arraysize(kTestString1) - 1;
uint32_t test2_len = arraysize(kTestString2) - 1;
void DumbBstrTests() {
ScopedBstr b;
@ -80,9 +80,9 @@ TEST(StackBstrTest, StackBstr) {
VARCMP_EQ);
StackBstrVar(kSourceStrEmpty, empty);
uint32 l1 = SysStringLen(stack_bstr);
uint32 l2 = SysStringLen(StackBstr(kSourceStr));
uint32 l3 = SysStringLen(system_bstr);
uint32_t l1 = SysStringLen(stack_bstr);
uint32_t l2 = SysStringLen(StackBstr(kSourceStr));
uint32_t l3 = SysStringLen(system_bstr);
EXPECT_TRUE(l1 == l2);
EXPECT_TRUE(l2 == l3);
EXPECT_TRUE(SysStringLen(empty) == 0);

View File

@ -103,49 +103,49 @@ void ScopedVariant::Set(const wchar_t* str) {
var_.bstrVal = ::SysAllocString(str);
}
void ScopedVariant::Set(int8 i8) {
void ScopedVariant::Set(int8_t i8) {
DCHECK(!IsLeakableVarType(var_.vt)) << "leaking variant: " << var_.vt;
var_.vt = VT_I1;
var_.cVal = i8;
}
void ScopedVariant::Set(uint8 ui8) {
void ScopedVariant::Set(uint8_t ui8) {
DCHECK(!IsLeakableVarType(var_.vt)) << "leaking variant: " << var_.vt;
var_.vt = VT_UI1;
var_.bVal = ui8;
}
void ScopedVariant::Set(int16 i16) {
void ScopedVariant::Set(int16_t i16) {
DCHECK(!IsLeakableVarType(var_.vt)) << "leaking variant: " << var_.vt;
var_.vt = VT_I2;
var_.iVal = i16;
}
void ScopedVariant::Set(uint16 ui16) {
void ScopedVariant::Set(uint16_t ui16) {
DCHECK(!IsLeakableVarType(var_.vt)) << "leaking variant: " << var_.vt;
var_.vt = VT_UI2;
var_.uiVal = ui16;
}
void ScopedVariant::Set(int32 i32) {
void ScopedVariant::Set(int32_t i32) {
DCHECK(!IsLeakableVarType(var_.vt)) << "leaking variant: " << var_.vt;
var_.vt = VT_I4;
var_.lVal = i32;
}
void ScopedVariant::Set(uint32 ui32) {
void ScopedVariant::Set(uint32_t ui32) {
DCHECK(!IsLeakableVarType(var_.vt)) << "leaking variant: " << var_.vt;
var_.vt = VT_UI4;
var_.ulVal = ui32;
}
void ScopedVariant::Set(int64 i64) {
void ScopedVariant::Set(int64_t i64) {
DCHECK(!IsLeakableVarType(var_.vt)) << "leaking variant: " << var_.vt;
var_.vt = VT_I8;
var_.llVal = i64;
}
void ScopedVariant::Set(uint64 ui64) {
void ScopedVariant::Set(uint64_t ui64) {
DCHECK(!IsLeakableVarType(var_.vt)) << "leaking variant: " << var_.vt;
var_.vt = VT_UI8;
var_.ullVal = ui64;

View File

@ -80,14 +80,14 @@ class ScopedVariant {
void Set(const wchar_t* str);
// Setters for simple types.
void Set(int8 i8);
void Set(uint8 ui8);
void Set(int16 i16);
void Set(uint16 ui16);
void Set(int32 i32);
void Set(uint32 ui32);
void Set(int64 i64);
void Set(uint64 ui64);
void Set(int8_t i8);
void Set(uint8_t ui8);
void Set(int16_t i16);
void Set(uint16_t ui16);
void Set(int32_t i32);
void Set(uint32_t ui32);
void Set(int64_t i64);
void Set(uint64_t ui64);
void Set(float r32);
void Set(double r64);
void Set(bool b);

View File

@ -123,7 +123,7 @@ TEST(ScopedVariantTest, ScopedVariant) {
// need to be freed explicitly).
// We need static cast here since char defaults to int (!?).
var.Set(static_cast<int8>('v'));
var.Set(static_cast<int8_t>('v'));
EXPECT_EQ(VT_I1, var.type());
EXPECT_EQ('v', V_I1(&var));
@ -131,15 +131,15 @@ TEST(ScopedVariantTest, ScopedVariant) {
EXPECT_EQ(VT_I2, var.type());
EXPECT_EQ(123, V_I2(&var));
var.Set(static_cast<int32>(123));
var.Set(static_cast<int32_t>(123));
EXPECT_EQ(VT_I4, var.type());
EXPECT_EQ(123, V_I4(&var));
var.Set(static_cast<int64>(123));
var.Set(static_cast<int64_t>(123));
EXPECT_EQ(VT_I8, var.type());
EXPECT_EQ(123, V_I8(&var));
var.Set(static_cast<uint8>(123));
var.Set(static_cast<uint8_t>(123));
EXPECT_EQ(VT_UI1, var.type());
EXPECT_EQ(123, V_UI1(&var));
@ -147,11 +147,11 @@ TEST(ScopedVariantTest, ScopedVariant) {
EXPECT_EQ(VT_UI2, var.type());
EXPECT_EQ(123, V_UI2(&var));
var.Set(static_cast<uint32>(123));
var.Set(static_cast<uint32_t>(123));
EXPECT_EQ(VT_UI4, var.type());
EXPECT_EQ(123, V_UI4(&var));
var.Set(static_cast<uint64>(123));
var.Set(static_cast<uint64_t>(123));
EXPECT_EQ(VT_UI8, var.type());
EXPECT_EQ(123, V_UI8(&var));

View File

@ -22,7 +22,7 @@ namespace {
// Verify that each thread's value in the shared memory is always correct.
class MultipleThreadMain : public PlatformThread::Delegate {
public:
explicit MultipleThreadMain(int16 id) : id_(id) {}
explicit MultipleThreadMain(int16_t id) : id_(id) {}
~MultipleThreadMain() {}
static void CleanUp() {
@ -52,7 +52,7 @@ class MultipleThreadMain : public PlatformThread::Delegate {
}
private:
int16 id_;
int16_t id_;
static const wchar_t* const s_test_name_;
@ -183,7 +183,7 @@ TEST(SharedMemoryTest, MultipleThreads) {
thread_delegates.reset(new MultipleThreadMain*[numthreads]);
// Spawn the threads.
for (int16 index = 0; index < numthreads; index++) {
for (int16_t index = 0; index < numthreads; index++) {
PlatformThreadHandle pth;
thread_delegates[index] = new MultipleThreadMain(index);
EXPECT_TRUE(PlatformThread::Create(0, thread_delegates[index], &pth));

View File

@ -157,7 +157,7 @@ class StatsCounter {
// The counter id in the table. We initialize to -1 (an invalid value)
// and then cache it once it has been looked up. The counter_id is
// valid across all threads and processes.
int32 counter_id_;
int32_t counter_id_;
};

View File

@ -206,7 +206,7 @@ TEST_F(StatsTableTest, MultipleProcesses) {
ProcessHandle procs[kMaxProcs];
// Spawn the processes.
for (int16 index = 0; index < kMaxProcs; index++) {
for (int16_t index = 0; index < kMaxProcs; index++) {
procs[index] = this->SpawnChild(L"StatsTableMultipleProcessMain");
EXPECT_NE(static_cast<ProcessHandle>(NULL), procs[index]);
}

View File

@ -38,7 +38,7 @@ typedef std::wstring string16;
#elif defined(WCHAR_T_IS_UTF32)
typedef uint16 char16;
typedef uint16_t char16;
namespace base {

View File

@ -57,7 +57,7 @@ struct ToUnsigned<wchar_t> {
#if defined(WCHAR_T_IS_UTF16)
typedef unsigned short Unsigned;
#elif defined(WCHAR_T_IS_UTF32)
typedef uint32 Unsigned;
typedef uint32_t Unsigned;
#endif
};
template<>
@ -164,7 +164,7 @@ class String16ToLongTraits {
class StringToInt64Traits {
public:
typedef std::string string_type;
typedef int64 value_type;
typedef int64_t value_type;
static const int kBase = 10;
static inline value_type convert_func(const string_type::value_type* str,
string_type::value_type** endptr) {
@ -182,7 +182,7 @@ class StringToInt64Traits {
class String16ToInt64Traits {
public:
typedef string16 string_type;
typedef int64 value_type;
typedef int64_t value_type;
static const int kBase = 10;
static inline value_type convert_func(const string_type::value_type* str,
string_type::value_type** endptr) {
@ -721,11 +721,11 @@ bool StartsWith(const std::wstring& str,
}
}
DataUnits GetByteDisplayUnits(int64 bytes) {
DataUnits GetByteDisplayUnits(int64_t bytes) {
// The byte thresholds at which we display amounts. A byte count is displayed
// in unit U when kUnitThresholds[U] <= bytes < kUnitThresholds[U+1].
// This must match the DataUnits enum.
static const int64 kUnitThresholds[] = {
static const int64_t kUnitThresholds[] = {
0, // DATA_UNITS_BYTE,
3*1024, // DATA_UNITS_KILOBYTE,
2*1024*1024, // DATA_UNITS_MEGABYTE,
@ -763,7 +763,7 @@ static const wchar_t* const kSpeedStrings[] = {
L"GB/s"
};
std::wstring FormatBytesInternal(int64 bytes,
std::wstring FormatBytesInternal(int64_t bytes,
DataUnits units,
bool show_units,
const wchar_t* const* suffix) {
@ -786,7 +786,7 @@ std::wstring FormatBytesInternal(int64 bytes,
modf(fractional_part * 10, &int_part);
if (int_part == 0) {
base::swprintf(tmp, arraysize(tmp),
L"%lld", static_cast<int64>(unit_amount));
L"%lld", static_cast<int64_t>(unit_amount));
} else {
base::swprintf(tmp, arraysize(tmp), L"%.1lf", unit_amount);
}
@ -800,11 +800,11 @@ std::wstring FormatBytesInternal(int64 bytes,
return ret;
}
std::wstring FormatBytes(int64 bytes, DataUnits units, bool show_units) {
std::wstring FormatBytes(int64_t bytes, DataUnits units, bool show_units) {
return FormatBytesInternal(bytes, units, show_units, kByteStrings);
}
std::wstring FormatSpeed(int64 bytes, DataUnits units, bool show_units) {
std::wstring FormatSpeed(int64_t bytes, DataUnits units, bool show_units) {
return FormatBytesInternal(bytes, units, show_units, kSpeedStrings);
}
@ -1034,20 +1034,20 @@ std::wstring UintToWString(unsigned int value) {
return IntToStringT<std::wstring, unsigned int, unsigned int, false>::
IntToString(value);
}
std::string Int64ToString(int64 value) {
return IntToStringT<std::string, int64, uint64, true>::
std::string Int64ToString(int64_t value) {
return IntToStringT<std::string, int64_t, uint64_t, true>::
IntToString(value);
}
std::wstring Int64ToWString(int64 value) {
return IntToStringT<std::wstring, int64, uint64, true>::
std::wstring Int64ToWString(int64_t value) {
return IntToStringT<std::wstring, int64_t, uint64_t, true>::
IntToString(value);
}
std::string Uint64ToString(uint64 value) {
return IntToStringT<std::string, uint64, uint64, false>::
std::string Uint64ToString(uint64_t value) {
return IntToStringT<std::string, uint64_t, uint64_t, false>::
IntToString(value);
}
std::wstring Uint64ToWString(uint64 value) {
return IntToStringT<std::wstring, uint64, uint64, false>::
std::wstring Uint64ToWString(uint64_t value) {
return IntToStringT<std::wstring, uint64_t, uint64_t, false>::
IntToString(value);
}
@ -1457,11 +1457,11 @@ bool StringToInt(const string16& input, int* output) {
}
#endif // !defined(ARCH_CPU_64_BITS)
bool StringToInt64(const std::string& input, int64* output) {
bool StringToInt64(const std::string& input, int64_t* output) {
return StringToNumber<StringToInt64Traits>(input, output);
}
bool StringToInt64(const string16& input, int64* output) {
bool StringToInt64(const string16& input, int64_t* output) {
return StringToNumber<String16ToInt64Traits>(input, output);
}
@ -1504,7 +1504,7 @@ bool HexStringToInt(const string16& input, int* output) {
namespace {
template<class CHAR>
bool HexDigitToIntT(const CHAR digit, uint8* val) {
bool HexDigitToIntT(const CHAR digit, uint8_t* val) {
if (digit >= '0' && digit <= '9')
*val = digit - '0';
else if (digit >= 'a' && digit <= 'f')
@ -1517,14 +1517,14 @@ bool HexDigitToIntT(const CHAR digit, uint8* val) {
}
template<typename STR>
bool HexStringToBytesT(const STR& input, std::vector<uint8>* output) {
bool HexStringToBytesT(const STR& input, std::vector<uint8_t>* output) {
DCHECK(output->size() == 0);
int count = input.size();
if (count == 0 || (count % 2) != 0)
return false;
for (int i = 0; i < count / 2; ++i) {
uint8 msb = 0; // most significant 4 bits
uint8 lsb = 0; // least significant 4 bits
uint8_t msb = 0; // most significant 4 bits
uint8_t lsb = 0; // least significant 4 bits
if (!HexDigitToIntT(input[i * 2], &msb) ||
!HexDigitToIntT(input[i * 2 + 1], &lsb))
return false;
@ -1535,11 +1535,11 @@ bool HexStringToBytesT(const STR& input, std::vector<uint8>* output) {
} // namespace
bool HexStringToBytes(const std::string& input, std::vector<uint8>* output) {
bool HexStringToBytes(const std::string& input, std::vector<uint8_t>* output) {
return HexStringToBytesT(input, output);
}
bool HexStringToBytes(const string16& input, std::vector<uint8>* output) {
bool HexStringToBytes(const string16& input, std::vector<uint8_t>* output) {
return HexStringToBytesT(input, output);
}
@ -1555,14 +1555,14 @@ int StringToInt(const string16& value) {
return result;
}
int64 StringToInt64(const std::string& value) {
int64 result;
int64_t StringToInt64(const std::string& value) {
int64_t result;
StringToInt64(value, &result);
return result;
}
int64 StringToInt64(const string16& value) {
int64 result;
int64_t StringToInt64(const string16& value) {
int64_t result;
StringToInt64(value, &result);
return result;
}

View File

@ -358,22 +358,22 @@ enum DataUnits {
// Return the unit type that is appropriate for displaying the amount of bytes
// passed in.
DataUnits GetByteDisplayUnits(int64 bytes);
DataUnits GetByteDisplayUnits(int64_t bytes);
// Return a byte string in human-readable format, displayed in units appropriate
// specified by 'units', with an optional unit suffix.
// Ex: FormatBytes(512, DATA_UNITS_KILOBYTE, true) => "0.5 KB"
// Ex: FormatBytes(10*1024, DATA_UNITS_MEGABYTE, false) => "0.1"
std::wstring FormatBytes(int64 bytes, DataUnits units, bool show_units);
std::wstring FormatBytes(int64_t bytes, DataUnits units, bool show_units);
// As above, but with "/s" units.
// Ex: FormatSpeed(512, DATA_UNITS_KILOBYTE, true) => "0.5 KB/s"
// Ex: FormatSpeed(10*1024, DATA_UNITS_MEGABYTE, false) => "0.1"
std::wstring FormatSpeed(int64 bytes, DataUnits units, bool show_units);
std::wstring FormatSpeed(int64_t bytes, DataUnits units, bool show_units);
// Return a number formated with separators in the user's locale way.
// Ex: FormatNumber(1234567) => 1,234,567
std::wstring FormatNumber(int64 number);
std::wstring FormatNumber(int64_t number);
// Starting at |start_offset| (usually 0), replace the first instance of
// |find_this| with |replace_with|.
@ -406,10 +406,10 @@ std::string IntToString(int value);
std::wstring IntToWString(int value);
std::string UintToString(unsigned int value);
std::wstring UintToWString(unsigned int value);
std::string Int64ToString(int64 value);
std::wstring Int64ToWString(int64 value);
std::string Uint64ToString(uint64 value);
std::wstring Uint64ToWString(uint64 value);
std::string Int64ToString(int64_t value);
std::wstring Int64ToWString(int64_t value);
std::string Uint64ToString(uint64_t value);
std::wstring Uint64ToWString(uint64_t value);
// The DoubleToString methods convert the double to a string format that
// ignores the locale. If you want to use locale specific formatting, use ICU.
std::string DoubleToString(double value);
@ -427,8 +427,8 @@ std::wstring DoubleToWString(double value);
// - Empty string. |*output| will be set to 0.
bool StringToInt(const std::string& input, int* output);
bool StringToInt(const string16& input, int* output);
bool StringToInt64(const std::string& input, int64* output);
bool StringToInt64(const string16& input, int64* output);
bool StringToInt64(const std::string& input, int64_t* output);
bool StringToInt64(const string16& input, int64_t* output);
bool HexStringToInt(const std::string& input, int* output);
bool HexStringToInt(const string16& input, int* output);
@ -436,8 +436,8 @@ bool HexStringToInt(const string16& input, int* output);
// |*output| will contain as many bytes as were successfully parsed prior to the
// error. There is no overflow, but input.size() must be evenly divisible by 2.
// Leading 0x or +/- are not allowed.
bool HexStringToBytes(const std::string& input, std::vector<uint8>* output);
bool HexStringToBytes(const string16& input, std::vector<uint8>* output);
bool HexStringToBytes(const std::string& input, std::vector<uint8_t>* output);
bool HexStringToBytes(const string16& input, std::vector<uint8_t>* output);
// For floating-point conversions, only conversions of input strings in decimal
// form are defined to work. Behavior with strings representing floating-point
@ -453,8 +453,8 @@ bool StringToDouble(const string16& input, double* output);
// above conversions: a best-effort conversion when possible, otherwise, 0.
int StringToInt(const std::string& value);
int StringToInt(const string16& value);
int64 StringToInt64(const std::string& value);
int64 StringToInt64(const string16& value);
int64_t StringToInt64(const std::string& value);
int64_t StringToInt64(const string16& value);
int HexStringToInt(const std::string& value);
int HexStringToInt(const string16& value);
double StringToDouble(const std::string& value);

View File

@ -25,14 +25,14 @@ namespace {
// (as in a for loop) will take the reader to the next character.
//
// Returns true on success. On false, |*code_point| will be invalid.
bool ReadUnicodeCharacter(const char* src, int32 src_len,
int32* char_index, uint32* code_point_out) {
bool ReadUnicodeCharacter(const char* src, int32_t src_len,
int32_t* char_index, uint32_t* code_point_out) {
// U8_NEXT expects to be able to use -1 to signal an error, so we must
// use a signed type for code_point. But this function returns false
// on error anyway, so code_point_out is unsigned.
int32 code_point;
int32_t code_point;
U8_NEXT(src, *char_index, src_len, code_point);
*code_point_out = static_cast<uint32>(code_point);
*code_point_out = static_cast<uint32_t>(code_point);
// The ICU macro above moves to the next char, we want to point to the last
// char consumed.
@ -43,8 +43,8 @@ bool ReadUnicodeCharacter(const char* src, int32 src_len,
}
// Reads a UTF-16 character. The usage is the same as the 8-bit version above.
bool ReadUnicodeCharacter(const char16* src, int32 src_len,
int32* char_index, uint32* code_point) {
bool ReadUnicodeCharacter(const char16* src, int32_t src_len,
int32_t* char_index, uint32_t* code_point) {
if (U16_IS_SURROGATE(src[*char_index])) {
if (!U16_IS_SURROGATE_LEAD(src[*char_index]) ||
*char_index + 1 >= src_len ||
@ -67,8 +67,8 @@ bool ReadUnicodeCharacter(const char16* src, int32 src_len,
#if defined(WCHAR_T_IS_UTF32)
// Reads UTF-32 character. The usage is the same as the 8-bit version above.
bool ReadUnicodeCharacter(const wchar_t* src, int32 src_len,
int32* char_index, uint32* code_point) {
bool ReadUnicodeCharacter(const wchar_t* src, int32_t src_len,
int32_t* char_index, uint32_t* code_point) {
// Conversion is easy since the source is 32-bit.
*code_point = src[*char_index];
@ -80,7 +80,7 @@ bool ReadUnicodeCharacter(const wchar_t* src, int32 src_len,
// WriteUnicodeCharacter -------------------------------------------------------
// Appends a UTF-8 character to the given 8-bit string.
void WriteUnicodeCharacter(uint32 code_point, std::string* output) {
void WriteUnicodeCharacter(uint32_t code_point, std::string* output) {
if (code_point <= 0x7f) {
// Fast path the common case of one byte.
output->push_back(code_point);
@ -88,7 +88,7 @@ void WriteUnicodeCharacter(uint32 code_point, std::string* output) {
}
// U8_APPEND_UNSAFE can append up to 4 bytes.
int32 char_offset = static_cast<int32>(output->length());
int32_t char_offset = static_cast<int32_t>(output->length());
output->resize(char_offset + U8_MAX_LENGTH);
U8_APPEND_UNSAFE(&(*output)[0], char_offset, code_point);
@ -99,13 +99,13 @@ void WriteUnicodeCharacter(uint32 code_point, std::string* output) {
}
// Appends the given code point as a UTF-16 character to the STL string.
void WriteUnicodeCharacter(uint32 code_point, string16* output) {
void WriteUnicodeCharacter(uint32_t code_point, string16* output) {
if (U16_LENGTH(code_point) == 1) {
// Thie code point is in the Basic Multilingual Plane (BMP).
output->push_back(static_cast<char16>(code_point));
} else {
// Non-BMP characters use a double-character encoding.
int32 char_offset = static_cast<int32>(output->length());
int32_t char_offset = static_cast<int32_t>(output->length());
output->resize(char_offset + U16_MAX_LENGTH);
U16_APPEND_UNSAFE(&(*output)[0], char_offset, code_point);
}
@ -113,7 +113,7 @@ void WriteUnicodeCharacter(uint32 code_point, string16* output) {
#if defined(WCHAR_T_IS_UTF32)
// Appends the given UTF-32 character to the given 32-bit string.
inline void WriteUnicodeCharacter(uint32 code_point, std::wstring* output) {
inline void WriteUnicodeCharacter(uint32_t code_point, std::wstring* output) {
// This is the easy case, just append the character.
output->push_back(code_point);
}
@ -131,9 +131,9 @@ bool ConvertUnicode(const SRC_CHAR* src, size_t src_len, DEST_STRING* output) {
// ICU requires 32-bit numbers.
bool success = true;
int32 src_len32 = static_cast<int32>(src_len);
for (int32 i = 0; i < src_len32; i++) {
uint32 code_point;
int32_t src_len32 = static_cast<int32_t>(src_len);
for (int32_t i = 0; i < src_len32; i++) {
uint32_t code_point;
if (ReadUnicodeCharacter(src, src_len32, &i, &code_point))
WriteUnicodeCharacter(code_point, output);
else
@ -501,7 +501,7 @@ struct NumberFormatSingletonTraits
} // namespace
std::wstring FormatNumber(int64 number) {
std::wstring FormatNumber(int64_t number) {
NumberFormat* number_format =
Singleton<NumberFormat, NumberFormatSingletonTraits>::get();
@ -516,7 +516,7 @@ std::wstring FormatNumber(int64 number) {
return std::wstring(ustr.getBuffer(),
static_cast<std::wstring::size_type>(ustr.length()));
#elif defined(WCHAR_T_IS_UTF32)
wchar_t buffer[64]; // A int64 is less than 20 chars long, so 64 chars
wchar_t buffer[64]; // A int64_t is less than 20 chars long, so 64 chars
// leaves plenty of room for formating stuff.
int length = 0;
UErrorCode error = U_ZERO_ERROR;

View File

@ -666,7 +666,7 @@ TEST(StringUtilTest, LowerCaseEqualsASCII) {
TEST(StringUtilTest, GetByteDisplayUnits) {
static const struct {
int64 bytes;
int64_t bytes;
DataUnits expected;
} cases[] = {
{0, DATA_UNITS_BYTE},
@ -686,7 +686,7 @@ TEST(StringUtilTest, GetByteDisplayUnits) {
TEST(StringUtilTest, FormatBytes) {
static const struct {
int64 bytes;
int64_t bytes;
DataUnits units;
const wchar_t* expected;
const wchar_t* expected_with_units;
@ -798,13 +798,13 @@ TEST(StringUtilTest, IntToString) {
{ std::numeric_limits<int>::max(), "2147483647", "2147483647" },
{ std::numeric_limits<int>::min(), "-2147483648", "2147483648" },
};
static const IntToStringTest<int64> int64_tests[] = {
static const IntToStringTest<int64_t> int64_tests[] = {
{ 0, "0", "0" },
{ -1, "-1", "18446744073709551615" },
{ std::numeric_limits<int64>::max(),
{ std::numeric_limits<int64_t>::max(),
"9223372036854775807",
"9223372036854775807", },
{ std::numeric_limits<int64>::min(),
{ std::numeric_limits<int64_t>::min(),
"-9223372036854775808",
"9223372036854775808" },
};
@ -817,7 +817,7 @@ TEST(StringUtilTest, IntToString) {
EXPECT_EQ(UintToWString(test->num), UTF8ToWide(test->uexpected));
}
for (size_t i = 0; i < arraysize(int64_tests); ++i) {
const IntToStringTest<int64>* test = &int64_tests[i];
const IntToStringTest<int64_t>* test = &int64_tests[i];
EXPECT_EQ(Int64ToString(test->num), test->sexpected);
EXPECT_EQ(Int64ToWString(test->num), UTF8ToWide(test->sexpected));
EXPECT_EQ(Uint64ToString(test->num), test->uexpected);
@ -827,7 +827,7 @@ TEST(StringUtilTest, IntToString) {
TEST(StringUtilTest, Uint64ToString) {
static const struct {
uint64 input;
uint64_t input;
std::string output;
} cases[] = {
{0, "0"},
@ -900,7 +900,7 @@ TEST(StringUtilTest, StringToInt) {
TEST(StringUtilTest, StringToInt64) {
static const struct {
std::string input;
int64 output;
int64_t output;
bool success;
} cases[] = {
{"0", 0, true},
@ -937,7 +937,7 @@ TEST(StringUtilTest, StringToInt64) {
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) {
EXPECT_EQ(cases[i].output, StringToInt64(cases[i].input));
int64 output;
int64_t output;
EXPECT_EQ(cases[i].success, StringToInt64(cases[i].input, &output));
EXPECT_EQ(cases[i].output, output);
@ -953,7 +953,7 @@ TEST(StringUtilTest, StringToInt64) {
// interpreted as junk after the number.
const char input[] = "6\06";
std::string input_string(input, arraysize(input) - 1);
int64 output;
int64_t output;
EXPECT_FALSE(StringToInt64(input_string, &output));
EXPECT_EQ(6, output);
@ -1051,12 +1051,12 @@ TEST(StringUtilTest, HexStringToBytes) {
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) {
std::vector<uint8> output;
std::vector<uint8> compare;
std::vector<uint8_t> output;
std::vector<uint8_t> compare;
EXPECT_EQ(cases[i].success, HexStringToBytes(cases[i].input, &output)) <<
i << ": " << cases[i].input;
for (size_t j = 0; j < cases[i].output_len; ++j)
compare.push_back(static_cast<uint8>(cases[i].output[j]));
compare.push_back(static_cast<uint8_t>(cases[i].output[j]));
ASSERT_EQ(output.size(), compare.size()) << i << ": " << cases[i].input;
EXPECT_TRUE(std::equal(output.begin(), output.end(), compare.begin())) <<
i << ": " << cases[i].input;
@ -1069,7 +1069,7 @@ TEST(StringUtilTest, HexStringToBytes) {
HexStringToBytes(WideToUTF16Hack(wide_input), &output)) <<
i << ": " << cases[i].input;
for (size_t j = 0; j < cases[i].output_len; ++j)
compare.push_back(static_cast<uint8>(cases[i].output[j]));
compare.push_back(static_cast<uint8_t>(cases[i].output[j]));
ASSERT_EQ(output.size(), compare.size()) << i << ": " << cases[i].input;
EXPECT_TRUE(std::equal(output.begin(), output.end(), compare.begin())) <<
i << ": " << cases[i].input;

View File

@ -19,7 +19,7 @@ class SysInfo {
static int NumberOfProcessors();
// Return the number of bytes of physical memory on the current machine.
static int64 AmountOfPhysicalMemory();
static int64_t AmountOfPhysicalMemory();
// Return the number of megabytes of physical memory on the current machine.
static int AmountOfPhysicalMemoryMB() {
@ -28,7 +28,7 @@ class SysInfo {
// Return the available disk space in bytes on the volume containing |path|,
// or -1 on failure.
static int64 AmountOfFreeDiskSpace(const std::wstring& path);
static int64_t AmountOfFreeDiskSpace(const std::wstring& path);
// Return true if the given environment variable is defined.
// TODO: find a better place for HasEnvVar.
@ -50,9 +50,9 @@ class SysInfo {
// until it's been initialized by being called once without a race.
// TODO(port): Implement a Linux version of this method and enable the
// corresponding unit test.
static void OperatingSystemVersionNumbers(int32 *major_version,
int32 *minor_version,
int32 *bugfix_version);
static void OperatingSystemVersionNumbers(int32_t *major_version,
int32_t *minor_version,
int32_t *bugfix_version);
// Returns the CPU architecture of the system. Exact return value may differ
// across platforms.

View File

@ -9,13 +9,13 @@
namespace base {
// static
void SysInfo::OperatingSystemVersionNumbers(int32 *major_version,
int32 *minor_version,
int32 *bugfix_version) {
void SysInfo::OperatingSystemVersionNumbers(int32_t *major_version,
int32_t *minor_version,
int32_t *bugfix_version) {
static bool is_initialized = false;
static int32 major_version_cached = 0;
static int32 minor_version_cached = 0;
static int32 bugfix_version_cached = 0;
static int32_t major_version_cached = 0;
static int32_t minor_version_cached = 0;
static int32_t bugfix_version_cached = 0;
if (!is_initialized) {
// Gestalt can't be called in the sandbox, so we cache its return value.
@ -39,7 +39,7 @@ void SysInfo::CacheSysInfo() {
// from functions we know to be called in the renderer & fail when the sandbox
// is enabled.
NumberOfProcessors();
int32 dummy;
int32_t dummy;
OperatingSystemVersionNumbers(&dummy, &dummy, &dummy);
}

View File

@ -45,7 +45,7 @@ int SysInfo::NumberOfProcessors() {
}
// static
int64 SysInfo::AmountOfPhysicalMemory() {
int64_t SysInfo::AmountOfPhysicalMemory() {
// _SC_PHYS_PAGES is not part of POSIX and not available on OS X
#if defined(OS_MACOSX)
struct host_basic_info hostinfo;
@ -60,7 +60,7 @@ int64 SysInfo::AmountOfPhysicalMemory() {
return 0;
}
return static_cast<int64>(hostinfo.max_mem);
return static_cast<int64_t>(hostinfo.max_mem);
#elif defined(OS_NETBSD)
int mib[2];
int rc;
@ -83,18 +83,18 @@ int64 SysInfo::AmountOfPhysicalMemory() {
return 0;
}
return static_cast<int64>(pages) * page_size;
return static_cast<int64_t>(pages) * page_size;
#endif
}
// static
int64 SysInfo::AmountOfFreeDiskSpace(const std::wstring& path) {
int64_t SysInfo::AmountOfFreeDiskSpace(const std::wstring& path) {
#ifndef ANDROID
struct statvfs stats;
if (statvfs(WideToUTF8(path).c_str(), &stats) != 0) {
return -1;
}
return static_cast<int64>(stats.f_bavail) * stats.f_frsize;
return static_cast<int64_t>(stats.f_bavail) * stats.f_frsize;
#else
return -1;
#endif

View File

@ -41,9 +41,9 @@ TEST_F(SysInfoTest, HasEnvVar) {
// unit test.
#if defined(OS_WIN) || defined(OS_MACOSX)
TEST_F(SysInfoTest, OperatingSystemVersionNumbers) {
int32 os_major_version = -1;
int32 os_minor_version = -1;
int32 os_bugfix_version = -1;
int32_t os_major_version = -1;
int32_t os_minor_version = -1;
int32_t os_bugfix_version = -1;
base::SysInfo::OperatingSystemVersionNumbers(&os_major_version,
&os_minor_version,
&os_bugfix_version);

View File

@ -20,7 +20,7 @@ int SysInfo::NumberOfProcessors() {
}
// static
int64 SysInfo::AmountOfPhysicalMemory() {
int64_t SysInfo::AmountOfPhysicalMemory() {
MEMORYSTATUSEX memory_info;
memory_info.dwLength = sizeof(memory_info);
if (!GlobalMemoryStatusEx(&memory_info)) {
@ -28,19 +28,19 @@ int64 SysInfo::AmountOfPhysicalMemory() {
return 0;
}
int64 rv = static_cast<int64>(memory_info.ullTotalPhys);
int64_t rv = static_cast<int64_t>(memory_info.ullTotalPhys);
if (rv < 0)
rv = kint64max;
return rv;
}
// static
int64 SysInfo::AmountOfFreeDiskSpace(const std::wstring& path) {
int64_t SysInfo::AmountOfFreeDiskSpace(const std::wstring& path) {
ULARGE_INTEGER available, total, free;
if (!GetDiskFreeSpaceExW(path.c_str(), &available, &total, &free)) {
return -1;
}
int64 rv = static_cast<int64>(available.QuadPart);
int64_t rv = static_cast<int64_t>(available.QuadPart);
if (rv < 0)
rv = kint64max;
return rv;
@ -109,9 +109,9 @@ size_t SysInfo::VMAllocationGranularity() {
}
// static
void SysInfo::OperatingSystemVersionNumbers(int32 *major_version,
int32 *minor_version,
int32 *bugfix_version) {
void SysInfo::OperatingSystemVersionNumbers(int32_t *major_version,
int32_t *minor_version,
int32_t *bugfix_version) {
OSVERSIONINFO info = {0};
info.dwOSVersionInfoSize = sizeof(info);
GetVersionEx(&info);

View File

@ -44,8 +44,8 @@ std::wstring SysNativeMBToWide(const StringPiece& native_mb);
// Converts between 8-bit and wide strings, using the given code page. The
// code page identifier is one accepted by the Windows function
// MultiByteToWideChar().
std::wstring SysMultiByteToWide(const StringPiece& mb, uint32 code_page);
std::string SysWideToMultiByte(const std::wstring& wide, uint32 code_page);
std::wstring SysMultiByteToWide(const StringPiece& mb, uint32_t code_page);
std::string SysWideToMultiByte(const std::wstring& wide, uint32_t code_page);
#endif // defined(OS_WIN)

View File

@ -29,7 +29,7 @@ std::wstring SysNativeMBToWide(const StringPiece& native_mb) {
}
// Do not assert in this function since it is used by the asssertion code!
std::wstring SysMultiByteToWide(const StringPiece& mb, uint32 code_page) {
std::wstring SysMultiByteToWide(const StringPiece& mb, uint32_t code_page) {
if (mb.empty())
return std::wstring();
@ -48,7 +48,7 @@ std::wstring SysMultiByteToWide(const StringPiece& mb, uint32 code_page) {
}
// Do not assert in this function since it is used by the asssertion code!
std::string SysWideToMultiByte(const std::wstring& wide, uint32 code_page) {
std::string SysWideToMultiByte(const std::wstring& wide, uint32_t code_page) {
int wide_length = static_cast<int>(wide.length());
if (wide_length == 0)
return std::string();

View File

@ -23,7 +23,7 @@ bool EvictFileFromSystemCache(const FilePath& file) {
return false;
}
if (msync(const_cast<uint8*>(mapped_file.data()), mapped_file.length(),
if (msync(const_cast<uint8_t*>(mapped_file.data()), mapped_file.length(),
MS_INVALIDATE) != 0) {
DLOG(WARNING) << "failed to invalidate memory map of " << file.value()
<< ", errno: " << errno;

View File

@ -29,7 +29,7 @@ double TimeDelta::InSecondsF() const {
return static_cast<double>(delta_) / Time::kMicrosecondsPerSecond;
}
int64 TimeDelta::InSeconds() const {
int64_t TimeDelta::InSeconds() const {
return delta_ / Time::kMicrosecondsPerSecond;
}
@ -37,11 +37,11 @@ double TimeDelta::InMillisecondsF() const {
return static_cast<double>(delta_) / Time::kMicrosecondsPerMillisecond;
}
int64 TimeDelta::InMilliseconds() const {
int64_t TimeDelta::InMilliseconds() const {
return delta_ / Time::kMicrosecondsPerMillisecond;
}
int64 TimeDelta::InMicroseconds() const {
int64_t TimeDelta::InMicroseconds() const {
return delta_;
}

View File

@ -48,17 +48,17 @@ class TimeDelta {
}
// Converts units of time to TimeDeltas.
static TimeDelta FromDays(int64 days);
static TimeDelta FromHours(int64 hours);
static TimeDelta FromMinutes(int64 minutes);
static TimeDelta FromSeconds(int64 secs);
static TimeDelta FromMilliseconds(int64 ms);
static TimeDelta FromMicroseconds(int64 us);
static TimeDelta FromDays(int64_t days);
static TimeDelta FromHours(int64_t hours);
static TimeDelta FromMinutes(int64_t minutes);
static TimeDelta FromSeconds(int64_t secs);
static TimeDelta FromMilliseconds(int64_t ms);
static TimeDelta FromMicroseconds(int64_t us);
// Returns the internal numeric value of the TimeDelta object. Please don't
// use this and do arithmetic on it, as it is more error prone than using the
// provided operators.
int64 ToInternalValue() const {
int64_t ToInternalValue() const {
return delta_;
}
@ -68,10 +68,10 @@ class TimeDelta {
int InHours() const;
int InMinutes() const;
double InSecondsF() const;
int64 InSeconds() const;
int64_t InSeconds() const;
double InMillisecondsF() const;
int64 InMilliseconds() const;
int64 InMicroseconds() const;
int64_t InMilliseconds() const;
int64_t InMicroseconds() const;
TimeDelta& operator=(TimeDelta other) {
delta_ = other.delta_;
@ -100,21 +100,21 @@ class TimeDelta {
// Computations with ints, note that we only allow multiplicative operations
// with ints, and additive operations with other deltas.
TimeDelta operator*(int64 a) const {
TimeDelta operator*(int64_t a) const {
return TimeDelta(delta_ * a);
}
TimeDelta operator/(int64 a) const {
TimeDelta operator/(int64_t a) const {
return TimeDelta(delta_ / a);
}
TimeDelta& operator*=(int64 a) {
TimeDelta& operator*=(int64_t a) {
delta_ *= a;
return *this;
}
TimeDelta& operator/=(int64 a) {
TimeDelta& operator/=(int64_t a) {
delta_ /= a;
return *this;
}
int64 operator/(TimeDelta a) const {
int64_t operator/(TimeDelta a) const {
return delta_ / a.delta_;
}
@ -145,19 +145,19 @@ class TimeDelta {
private:
friend class Time;
friend class TimeTicks;
friend TimeDelta operator*(int64 a, TimeDelta td);
friend TimeDelta operator*(int64_t a, TimeDelta td);
// Constructs a delta given the duration in microseconds. This is private
// to avoid confusion by callers with an integer constructor. Use
// FromSeconds, FromMilliseconds, etc. instead.
explicit TimeDelta(int64 delta_us) : delta_(delta_us) {
explicit TimeDelta(int64_t delta_us) : delta_(delta_us) {
}
// Delta in microseconds.
int64 delta_;
int64_t delta_;
};
inline TimeDelta operator*(int64 a, TimeDelta td) {
inline TimeDelta operator*(int64_t a, TimeDelta td) {
return TimeDelta(a * td.delta_);
}
@ -166,16 +166,16 @@ inline TimeDelta operator*(int64 a, TimeDelta td) {
// Represents a wall clock time.
class Time {
public:
static const int64 kMillisecondsPerSecond = 1000;
static const int64 kMicrosecondsPerMillisecond = 1000;
static const int64 kMicrosecondsPerSecond = kMicrosecondsPerMillisecond *
static const int64_t kMillisecondsPerSecond = 1000;
static const int64_t kMicrosecondsPerMillisecond = 1000;
static const int64_t kMicrosecondsPerSecond = kMicrosecondsPerMillisecond *
kMillisecondsPerSecond;
static const int64 kMicrosecondsPerMinute = kMicrosecondsPerSecond * 60;
static const int64 kMicrosecondsPerHour = kMicrosecondsPerMinute * 60;
static const int64 kMicrosecondsPerDay = kMicrosecondsPerHour * 24;
static const int64 kMicrosecondsPerWeek = kMicrosecondsPerDay * 7;
static const int64 kNanosecondsPerMicrosecond = 1000;
static const int64 kNanosecondsPerSecond = kNanosecondsPerMicrosecond *
static const int64_t kMicrosecondsPerMinute = kMicrosecondsPerSecond * 60;
static const int64_t kMicrosecondsPerHour = kMicrosecondsPerMinute * 60;
static const int64_t kMicrosecondsPerDay = kMicrosecondsPerHour * 24;
static const int64_t kMicrosecondsPerWeek = kMicrosecondsPerDay * 7;
static const int64_t kNanosecondsPerMicrosecond = 1000;
static const int64_t kNanosecondsPerSecond = kNanosecondsPerMicrosecond *
kMicrosecondsPerSecond;
// Represents an exploded time that can be formatted nicely. This is kind of
@ -243,7 +243,7 @@ class Time {
// when deserializing a |Time| structure, using a value known to be
// compatible. It is not provided as a constructor because the integer type
// may be unclear from the perspective of a caller.
static Time FromInternalValue(int64 us) {
static Time FromInternalValue(int64_t us) {
return Time(us);
}
@ -258,7 +258,7 @@ class Time {
// For serializing, use FromInternalValue to reconstitute. Please don't use
// this and do arithmetic on it, as it is more error prone than using the
// provided operators.
int64 ToInternalValue() const {
int64_t ToInternalValue() const {
return us_;
}
@ -334,15 +334,15 @@ class Time {
// |is_local = true| or UTC |is_local = false|.
static Time FromExploded(bool is_local, const Exploded& exploded);
Time(int64 us) : us_(us) {
Time(int64_t us) : us_(us) {
}
// The representation of Jan 1, 1970 UTC in microseconds since the
// platform-dependent epoch.
static const int64 kTimeTToMicrosecondsOffset;
static const int64_t kTimeTToMicrosecondsOffset;
// Time in microseconds in UTC.
int64 us_;
int64_t us_;
};
inline Time TimeDelta::operator+(Time t) const {
@ -352,32 +352,32 @@ inline Time TimeDelta::operator+(Time t) const {
// Inline the TimeDelta factory methods, for fast TimeDelta construction.
// static
inline TimeDelta TimeDelta::FromDays(int64 days) {
inline TimeDelta TimeDelta::FromDays(int64_t days) {
return TimeDelta(days * Time::kMicrosecondsPerDay);
}
// static
inline TimeDelta TimeDelta::FromHours(int64 hours) {
inline TimeDelta TimeDelta::FromHours(int64_t hours) {
return TimeDelta(hours * Time::kMicrosecondsPerHour);
}
// static
inline TimeDelta TimeDelta::FromMinutes(int64 minutes) {
inline TimeDelta TimeDelta::FromMinutes(int64_t minutes) {
return TimeDelta(minutes * Time::kMicrosecondsPerMinute);
}
// static
inline TimeDelta TimeDelta::FromSeconds(int64 secs) {
inline TimeDelta TimeDelta::FromSeconds(int64_t secs) {
return TimeDelta(secs * Time::kMicrosecondsPerSecond);
}
// static
inline TimeDelta TimeDelta::FromMilliseconds(int64 ms) {
inline TimeDelta TimeDelta::FromMilliseconds(int64_t ms) {
return TimeDelta(ms * Time::kMicrosecondsPerMillisecond);
}
// static
inline TimeDelta TimeDelta::FromMicroseconds(int64 us) {
inline TimeDelta TimeDelta::FromMicroseconds(int64_t us) {
return TimeDelta(us);
}
@ -405,7 +405,7 @@ class TimeTicks {
}
// Returns the internal numeric value of the TimeTicks object.
int64 ToInternalValue() const {
int64_t ToInternalValue() const {
return ticks_;
}
@ -463,11 +463,11 @@ class TimeTicks {
// Please use Now() to create a new object. This is for internal use
// and testing. Ticks is in microseconds.
explicit TimeTicks(int64 ticks) : ticks_(ticks) {
explicit TimeTicks(int64_t ticks) : ticks_(ticks) {
}
// Tick count in microseconds.
int64 ticks_;
int64_t ticks_;
#if defined(OS_WIN)
typedef DWORD (*TickFunctionType)(void);

View File

@ -31,13 +31,13 @@ namespace base {
// Some functions in time.cc use time_t directly, so we provide a zero offset
// for them. The epoch is 1970-01-01 00:00:00 UTC.
// static
const int64 Time::kTimeTToMicrosecondsOffset = GG_INT64_C(0);
const int64_t Time::kTimeTToMicrosecondsOffset = GG_INT64_C(0);
// static
Time Time::Now() {
CFAbsoluteTime now =
CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970;
return Time(static_cast<int64>(now * kMicrosecondsPerSecond));
return Time(static_cast<int64_t>(now * kMicrosecondsPerSecond));
}
// static
@ -61,7 +61,7 @@ Time Time::FromExploded(bool is_local, const Exploded& exploded) {
time_zone(is_local ? CFTimeZoneCopySystem() : NULL);
CFAbsoluteTime seconds = CFGregorianDateGetAbsoluteTime(date, time_zone) +
kCFAbsoluteTimeIntervalSince1970;
return Time(static_cast<int64>(seconds * kMicrosecondsPerSecond));
return Time(static_cast<int64_t>(seconds * kMicrosecondsPerSecond));
}
void Time::Explode(bool is_local, Exploded* exploded) const {

View File

@ -33,7 +33,7 @@ namespace base {
// Some functions in time.cc use time_t directly, so we provide a zero offset
// for them. The epoch is 1970-01-01 00:00:00 UTC.
// static
const int64 Time::kTimeTToMicrosecondsOffset = GG_INT64_C(0);
const int64_t Time::kTimeTToMicrosecondsOffset = GG_INT64_C(0);
// static
Time Time::Now() {
@ -78,7 +78,7 @@ Time Time::FromExploded(bool is_local, const Exploded& exploded) {
seconds = timegm(&timestruct);
#endif
int64 milliseconds;
int64_t milliseconds;
// Handle overflow. Clamping the range to what mktime and timegm might
// return is the best that can be done here. It's not ideal, but it's better
// than failing here or ignoring the overflow case and treating each time
@ -117,7 +117,7 @@ Time Time::FromExploded(bool is_local, const Exploded& exploded) {
void Time::Explode(bool is_local, Exploded* exploded) const {
// Time stores times with microsecond resolution, but Exploded only carries
// millisecond resolution, so begin by being lossy.
int64 milliseconds = us_ / kMicrosecondsPerMillisecond;
int64_t milliseconds = us_ / kMicrosecondsPerMillisecond;
time_t seconds = milliseconds / kMillisecondsPerSecond;
struct tm timestruct;
@ -177,8 +177,8 @@ TimeTicks TimeTicks::Now() {
}
absolute_micro =
(static_cast<int64>(ts.tv_sec) * Time::kMicrosecondsPerSecond) +
(static_cast<int64>(ts.tv_nsec) / Time::kNanosecondsPerMicrosecond);
(static_cast<int64_t>(ts.tv_sec) * Time::kMicrosecondsPerSecond) +
(static_cast<int64_t>(ts.tv_nsec) / Time::kNanosecondsPerMicrosecond);
#else // _POSIX_MONOTONIC_CLOCK
#error No usable tick clock function on this platform.

View File

@ -55,23 +55,23 @@ namespace {
// From MSDN, FILETIME "Contains a 64-bit value representing the number of
// 100-nanosecond intervals since January 1, 1601 (UTC)."
int64 FileTimeToMicroseconds(const FILETIME& ft) {
int64_t FileTimeToMicroseconds(const FILETIME& ft) {
// Need to bit_cast to fix alignment, then divide by 10 to convert
// 100-nanoseconds to milliseconds. This only works on little-endian
// machines.
return bit_cast<int64, FILETIME>(ft) / 10;
return bit_cast<int64_t, FILETIME>(ft) / 10;
}
void MicrosecondsToFileTime(int64 us, FILETIME* ft) {
void MicrosecondsToFileTime(int64_t us, FILETIME* ft) {
DCHECK(us >= 0) << "Time is less than 0, negative values are not "
"representable in FILETIME";
// Multiply by 10 to convert milliseconds to 100-nanoseconds. Bit_cast will
// handle alignment problems. This only works on little-endian machines.
*ft = bit_cast<FILETIME, int64>(us * 10);
*ft = bit_cast<FILETIME, int64_t>(us * 10);
}
int64 CurrentWallclockMicroseconds() {
int64_t CurrentWallclockMicroseconds() {
FILETIME ft;
::GetSystemTimeAsFileTime(&ft);
return FileTimeToMicroseconds(ft);
@ -80,7 +80,7 @@ int64 CurrentWallclockMicroseconds() {
// Time between resampling the un-granular clock for this API. 60 seconds.
const int kMaxMillisecondsToAvoidDrift = 60 * Time::kMillisecondsPerSecond;
int64 initial_time = 0;
int64_t initial_time = 0;
TimeTicks initial_ticks;
void InitializeClock() {
@ -97,7 +97,7 @@ void InitializeClock() {
// number of leap year days between 1601 and 1970: (1970-1601)/4 excluding
// 1700, 1800, and 1900.
// static
const int64 Time::kTimeTToMicrosecondsOffset = GG_INT64_C(11644473600000000);
const int64_t Time::kTimeTToMicrosecondsOffset = GG_INT64_C(11644473600000000);
// static
Time Time::Now() {
@ -308,7 +308,7 @@ class HighResNowSingleton {
const int kMaxTimeDrift = 50 * Time::kMicrosecondsPerMillisecond;
if (IsUsingHighResClock()) {
int64 now = UnreliableNow();
int64_t now = UnreliableNow();
// Verify that QPC does not seem to drift.
DCHECK(now - ReliableNow() - skew_ < kMaxTimeDrift);
@ -333,21 +333,21 @@ class HighResNowSingleton {
}
// Get the number of microseconds since boot in a reliable fashion
int64 UnreliableNow() {
int64_t UnreliableNow() {
LARGE_INTEGER now;
QueryPerformanceCounter(&now);
return static_cast<int64>(now.QuadPart / ticks_per_microsecond_);
return static_cast<int64_t>(now.QuadPart / ticks_per_microsecond_);
}
// Get the number of microseconds since boot in a reliable fashion
int64 ReliableNow() {
int64_t ReliableNow() {
return Singleton<NowSingleton>::get()->Now().InMicroseconds();
}
// Cached clock frequency -> microseconds. This assumes that the clock
// frequency is faster than one microsecond (which is 1MHz, should be OK).
float ticks_per_microsecond_; // 0 indicates QPF failed and we're broken.
int64 skew_; // Skew between lo-res and hi-res clocks (for debugging).
int64_t skew_; // Skew between lo-res and hi-res clocks (for debugging).
DISALLOW_COPY_AND_ASSIGN(HighResNowSingleton);
};

View File

@ -41,14 +41,14 @@ MockTimeTicks::TickFunctionType MockTimeTicks::old_tick_function_;
HANDLE g_rollover_test_start;
unsigned __stdcall RolloverTestThreadMain(void* param) {
int64 counter = reinterpret_cast<int64>(param);
int64_t counter = reinterpret_cast<int64_t>(param);
DWORD rv = WaitForSingleObject(g_rollover_test_start, INFINITE);
EXPECT_EQ(rv, WAIT_OBJECT_0);
TimeTicks last = TimeTicks::Now();
for (int index = 0; index < counter; index++) {
TimeTicks now = TimeTicks::Now();
int64 milliseconds = (now - last).InMilliseconds();
int64_t milliseconds = (now - last).InMilliseconds();
// This is a tight loop; we could have looped faster than our
// measurements, so the time might be 0 millis.
EXPECT_GE(milliseconds, 0);
@ -71,8 +71,8 @@ TEST(TimeTicks, WinRollover) {
// 5) Each thread verifies integrity of result.
const int kThreads = 8;
// Use int64 so we can cast into a void* without a compiler warning.
const int64 kChecks = 10;
// Use int64_t so we can cast into a void* without a compiler warning.
const int64_t kChecks = 10;
// It takes a lot of iterations to reproduce the bug!
// (See bug 1081395)
@ -112,7 +112,7 @@ TEST(TimeTicks, SubMillisecondTimers) {
// see at least one case where we get a new sample in
// less than one millisecond.
bool saw_submillisecond_timer = false;
int64 min_timer = 1000;
int64_t min_timer = 1000;
TimeTicks last_time = TimeTicks::HighResNow();
for (int index = 0; index < 1000; index++) {
TimeTicks now = TimeTicks::HighResNow();

View File

@ -128,7 +128,7 @@ void TraceLog::Trace(const std::string& name,
TimeTicks tick = TimeTicks::Now();
#endif
TimeDelta delta = tick - trace_start_time_;
int64 usec = delta.InMicroseconds();
int64_t usec = delta.InMicroseconds();
std::string msg =
StringPrintf("{'pid':'0x%lx', 'tid':'0x%lx', 'type':'%s', "
"'name':'%s', 'id':'0x%lx', 'extra':'%s', 'file':'%s', "

View File

@ -22,7 +22,7 @@ TLSSlot ThreadData::tls_index_(base::LINKER_INITIALIZED);
void DeathData::RecordDeath(const TimeDelta& duration) {
++count_;
life_duration_ += duration;
int64 milliseconds = duration.InMilliseconds();
int64_t milliseconds = duration.InMilliseconds();
square_duration_ += milliseconds * milliseconds;
}

View File

@ -85,7 +85,7 @@ class DeathData {
// Metrics accessors.
int count() const { return count_; }
base::TimeDelta life_duration() const { return life_duration_; }
int64 square_duration() const { return square_duration_; }
int64_t square_duration() const { return square_duration_; }
int AverageMsDuration() const;
double StandardDeviation() const;
@ -100,7 +100,7 @@ class DeathData {
private:
int count_; // Number of destructions.
base::TimeDelta life_duration_; // Sum of all lifetime durations.
int64 square_duration_; // Sum of squares in milliseconds.
int64_t square_duration_; // Sum of squares in milliseconds.
};
//------------------------------------------------------------------------------
@ -129,7 +129,7 @@ class Snapshot {
int count() const { return death_data_.count(); }
base::TimeDelta life_duration() const { return death_data_.life_duration(); }
int64 square_duration() const { return death_data_.square_duration(); }
int64_t square_duration() const { return death_data_.square_duration(); }
int AverageMsDuration() const { return death_data_.AverageMsDuration(); }
void Write(std::string* output) const;

View File

@ -28,7 +28,7 @@ bool Version::Equals(const Version& that) const {
}
int Version::CompareTo(const Version& other) const {
std::vector<uint16> other_components = other.components();
std::vector<uint16_t> other_components = other.components();
size_t count = std::min(components_.size(), other_components.size());
for (size_t i = 0; i < count; ++i) {
if (components_[i] > other_components[i])
@ -69,13 +69,13 @@ bool Version::InitFromString(const std::string& version_str) {
return false;
if (num < 0)
return false;
const uint16 max = 0xFFFF;
const uint16_t max = 0xFFFF;
if (num > max)
return false;
// This throws out things like +3, or 032.
if (IntToString(num) != *i)
return false;
uint16 component = static_cast<uint16>(num);
uint16_t component = static_cast<uint16_t>(num);
components_.push_back(component);
}
return true;

View File

@ -12,7 +12,7 @@
class Version {
public:
// The version string must be made up of 1 or more uint16's separated
// The version string must be made up of 1 or more uint16_t's separated
// by '.'. Returns NULL if string is not in this format.
// Caller is responsible for freeing the Version object once done.
static Version* GetVersionFromString(const std::wstring& version_str);
@ -28,13 +28,13 @@ public:
// Return the string representation of this version.
const std::string GetString() const;
const std::vector<uint16>& components() const { return components_; }
const std::vector<uint16_t>& components() const { return components_; }
private:
Version() {}
bool InitFromString(const std::string& version_str);
std::vector<uint16> components_;
std::vector<uint16_t> components_;
};
#endif // BASE_VERSION_H_

View File

@ -53,7 +53,7 @@ void AppCacheContextImpl::UnInitializeContext() {
void AppCacheContextImpl::SelectAppCacheWithoutManifest(
const GURL &document_url,
int64 cache_document_was_loaded_from) {
int64_t cache_document_was_loaded_from) {
DCHECK(context_id_ != kNoAppCacheContextId);
app_cache_id_ = kUnknownAppCacheId; // unknown until we get a response
sender_->Send(new AppCacheMsg_SelectAppCache(
@ -64,7 +64,7 @@ void AppCacheContextImpl::SelectAppCacheWithoutManifest(
void AppCacheContextImpl::SelectAppCacheWithManifest(
const GURL &document_url,
int64 cache_document_was_loaded_from,
int64_t cache_document_was_loaded_from,
const GURL &manifest_url) {
DCHECK(context_id_ != kNoAppCacheContextId);
app_cache_id_ = kUnknownAppCacheId; // unknown until we get a response
@ -75,7 +75,7 @@ void AppCacheContextImpl::SelectAppCacheWithManifest(
}
void AppCacheContextImpl::OnAppCacheSelected(int select_request_id,
int64 app_cache_id) {
int64_t app_cache_id) {
if (select_request_id == pending_select_request_id_) {
DCHECK(app_cache_id_ == kUnknownAppCacheId);
DCHECK(app_cache_id != kUnknownAppCacheId);

View File

@ -20,25 +20,25 @@ class AppCacheContextImpl : public WebAppCacheContext {
// WebAppCacheContext implementation
virtual int GetContextID() { return context_id_; }
virtual int64 GetAppCacheID() { return app_cache_id_; }
virtual int64_t GetAppCacheID() { return app_cache_id_; }
virtual void Initialize(WebAppCacheContext::ContextType context_type,
WebAppCacheContext* opt_parent);
virtual void SelectAppCacheWithoutManifest(
const GURL& document_url,
int64 cache_document_was_loaded_from);
int64_t cache_document_was_loaded_from);
virtual void SelectAppCacheWithManifest(
const GURL& document_url,
int64 cache_document_was_loaded_from,
int64_t cache_document_was_loaded_from,
const GURL& manifest_url);
// Called by AppCacheDispatcher when the browser has selected an appcache.
void OnAppCacheSelected(int select_request_id, int64 app_cache_id);
void OnAppCacheSelected(int select_request_id, int64_t app_cache_id);
private:
void UnInitializeContext();
int context_id_;
int64 app_cache_id_;
int64_t app_cache_id_;
int pending_select_request_id_;
IPC::Message::Sender* sender_;

View File

@ -18,7 +18,7 @@ bool AppCacheDispatcher::OnMessageReceived(const IPC::Message& msg) {
void AppCacheDispatcher::OnAppCacheSelected(int context_id,
int select_request_id,
int64 app_cache_id) {
int64_t app_cache_id) {
AppCacheContextImpl *context = AppCacheContextImpl::FromContextId(context_id);
if (context) {
context->OnAppCacheSelected(select_request_id, app_cache_id);

View File

@ -20,7 +20,7 @@ class AppCacheDispatcher {
// AppCacheContextImpl related messages
void OnAppCacheSelected(int context_id,
int select_request_id,
int64 app_cache_id);
int64_t app_cache_id);
};
#endif // CHROME_COMMON_APP_CACHE_APP_CACHE_DISPATCHER_H_

View File

@ -51,7 +51,7 @@ void AppCacheDispatcherHost::OnSelectAppCache(
int context_id,
int select_request_id,
const GURL& document_url,
int64 cache_document_was_loaded_from,
int64_t cache_document_was_loaded_from,
const GURL& opt_manifest_url) {
// TODO(michaeln): implement me, plumb to request_context->app_cache_service
DCHECK(context_id != WebAppCacheContext::kNoAppCacheContextId);

View File

@ -30,7 +30,7 @@ class AppCacheDispatcherHost {
void OnSelectAppCache(int context_id,
int select_request_id,
const GURL& document_url,
int64 cache_document_was_loaded_from,
int64_t cache_document_was_loaded_from,
const GURL& opt_manifest_url);
bool Send(IPC::Message* msg) {

View File

@ -167,7 +167,7 @@ void ChildProcessHost::ListenerHook::OnMessageReceived(
#endif
}
void ChildProcessHost::ListenerHook::OnChannelConnected(int32 peer_pid) {
void ChildProcessHost::ListenerHook::OnChannelConnected(int32_t peer_pid) {
host_->opening_channel_ = false;
host_->OnChannelConnected(peer_pid);

View File

@ -70,7 +70,7 @@ class ChildProcessHost :
// IPC::Channel::Listener implementation:
virtual void OnMessageReceived(const IPC::Message& msg) { }
virtual void OnChannelConnected(int32 peer_pid) { }
virtual void OnChannelConnected(int32_t peer_pid) { }
virtual void OnChannelError() { }
bool opening_channel() { return opening_channel_; }
@ -97,7 +97,7 @@ class ChildProcessHost :
public:
ListenerHook(ChildProcessHost* host);
virtual void OnMessageReceived(const IPC::Message& msg);
virtual void OnChannelConnected(int32 peer_pid);
virtual void OnChannelConnected(int32_t peer_pid);
virtual void OnChannelError();
virtual void GetQueuedMessages(std::queue<IPC::Message>& queue);
private:

View File

@ -43,13 +43,13 @@ bool ChildThread::Send(IPC::Message* msg) {
return channel_->Send(msg);
}
void ChildThread::AddRoute(int32 routing_id, IPC::Channel::Listener* listener) {
void ChildThread::AddRoute(int32_t routing_id, IPC::Channel::Listener* listener) {
DCHECK(MessageLoop::current() == message_loop());
router_.AddRoute(routing_id, listener);
}
void ChildThread::RemoveRoute(int32 routing_id) {
void ChildThread::RemoveRoute(int32_t routing_id) {
DCHECK(MessageLoop::current() == message_loop());
router_.RemoveRoute(routing_id);

View File

@ -24,8 +24,8 @@ class ChildThread : public IPC::Channel::Listener,
virtual bool Send(IPC::Message* msg);
// See documentation on MessageRouter for AddRoute and RemoveRoute
void AddRoute(int32 routing_id, IPC::Channel::Listener* listener);
void RemoveRoute(int32 routing_id);
void AddRoute(int32_t routing_id, IPC::Channel::Listener* listener);
void RemoveRoute(int32_t routing_id);
MessageLoop* owner_loop() { return owner_loop_; }

View File

@ -87,7 +87,7 @@ typedef struct _CPID_t* CPID;
// profile is active. Note that this ID is global to all processes, so it can
// be passed from one process to another. The value 0 is reserved for an
// undefined context.
typedef uint32 CPBrowsingContext;
typedef uint32_t CPBrowsingContext;
// Types of context info to query using CPB_GetBrowsingContextInfo.
typedef enum {
@ -180,7 +180,7 @@ typedef CPError (STDCALL *CPB_HandleCommandFunc)(
// requests it makes that match a given scheme. The browser may choose not to
// allow the plugin to intercept certain protocols.
typedef void (STDCALL *CPB_EnableRequestInterceptFunc)(
CPID id, const char** schemes, uint32 num_schemes);
CPID id, const char** schemes, uint32_t num_schemes);
// Asks the browser to create a request object for the given method/url.
// Returns CPERR_SUCCESS and puts the new object into the 'request' field on
@ -199,7 +199,7 @@ typedef CPError (STDCALL *CPB_GetCookiesFunc)(
// Allocates memory for the given size using the browser's allocator. Call
// CPB_Free when done.
typedef void* (STDCALL *CPB_AllocFunc)(uint32 size);
typedef void* (STDCALL *CPB_AllocFunc)(uint32_t size);
// Frees a pointer allocated by CPB_Alloc.
typedef void (STDCALL *CPB_FreeFunc)(void* memory);
@ -244,7 +244,7 @@ typedef CPBrowsingContext (STDCALL *CPB_GetBrowsingContextFromNPPFunc)(
// Otherwise, the return value is a CPError or CPERR_SUCCESS.
typedef int (STDCALL *CPB_GetBrowsingContextInfoFunc)(
CPID id, CPBrowsingContext context, CPBrowsingContextInfoType type,
void* buf, uint32 buf_size);
void* buf, uint32_t buf_size);
// Given an URL string, returns the string of command-line arguments that should
// be passed to start the browser at the given URL. 'arguments' should be freed
@ -288,7 +288,7 @@ typedef void (STDCALL *CPR_SetExtraRequestHeadersFunc)(CPRequest* request,
// Sets the load flags for this request. 'flags' is a bitwise-OR of
// CPRequestLoadFlags. Must be called before CPRR_StartCompletedFunc.
typedef void (STDCALL *CPR_SetRequestLoadFlagsFunc)(CPRequest* request,
uint32 flags);
uint32_t flags);
// Appends binary data to the request body of a POST or PUT request. The caller
// should set the "Content-Type" header to the appropriate mime type using
@ -308,7 +308,7 @@ typedef void (STDCALL *CPR_AppendDataToUploadFunc)(
// See CPR_AppendDataToUploadFunc for additional usage information.
// (added in v0.4)
typedef CPError (STDCALL *CPR_AppendFileToUploadFunc)(
CPRequest* request, const char* filepath, uint64 offset, uint64 length);
CPRequest* request, const char* filepath, uint64_t offset, uint64_t length);
// Queries for some response meta data. See CPResponseInfoType for possible
// queries. If buf_size is too small to contain the entire data, the return
@ -316,7 +316,7 @@ typedef CPError (STDCALL *CPR_AppendFileToUploadFunc)(
// CPError or CPERR_SUCCESS.
typedef int (STDCALL *CPR_GetResponseInfoFunc)(
CPRequest* request, CPResponseInfoType type,
void* buf, uint32 buf_size);
void* buf, uint32_t buf_size);
// Attempts to read a request's response data. The number of bytes read is
// returned; 0 indicates an EOF. CPERR_IO_PENDING is returned if an
@ -324,7 +324,7 @@ typedef int (STDCALL *CPR_GetResponseInfoFunc)(
// when it completes; 'buf' must be available until the operation completes.
// Returns an error code on failure.
typedef int (STDCALL *CPR_ReadFunc)(
CPRequest* request, void* buf, uint32 buf_size);
CPRequest* request, void* buf, uint32_t buf_size);
//
// Functions related to serving network requests.
@ -354,8 +354,8 @@ typedef void (STDCALL *CPRR_ReadCompletedFunc)(CPRequest* request,
// Called as upload progress is being made for async POST requests.
// (added in v0.5)
typedef void (STDCALL *CPRR_UploadProgressFunc)(CPRequest* request,
uint64 position,
uint64 size);
uint64_t position,
uint64_t size);
//
// Functions to support the sending and receipt of messages between processes.
@ -372,7 +372,7 @@ typedef CPProcessType (STDCALL *CPB_GetProcessTypeFunc)(CPID id);
// the message.
typedef CPError (STDCALL *CPB_SendMessageFunc)(CPID id,
const void *data,
uint32 data_len);
uint32_t data_len);
// Asks the browser to send raw data to the other process hosting an instance of
// this plugin. This function only works from the plugin or renderer process.
@ -380,9 +380,9 @@ typedef CPError (STDCALL *CPB_SendMessageFunc)(CPID id,
// freed using CPB_Free when done.
typedef CPError (STDCALL *CPB_SendSyncMessageFunc)(CPID id,
const void *data,
uint32 data_len,
uint32_t data_len,
void **retval,
uint32 *retval_len);
uint32_t *retval_len);
// This function asynchronously calls the provided function on the plugin
// thread. user_data is passed as the argument to the function.
@ -401,25 +401,25 @@ typedef CPError (STDCALL *CPB_OpenFileDialogFunc)(CPID id,
void *user_data);
// Informs the plugin of raw data having been sent from another process.
typedef void (STDCALL *CPP_OnMessageFunc)(void *data, uint32 data_len);
typedef void (STDCALL *CPP_OnMessageFunc)(void *data, uint32_t data_len);
// Informs the plugin of raw data having been sent from another process.
typedef void (STDCALL *CPP_OnSyncMessageFunc)(void *data, uint32 data_len,
typedef void (STDCALL *CPP_OnSyncMessageFunc)(void *data, uint32_t data_len,
void **retval,
uint32 *retval_len);
uint32_t *retval_len);
// Informs the plugin that the file dialog has completed, and contains the
// results.
typedef void (STDCALL *CPP_OnFileDialogResultFunc)(void *data,
const char **files,
uint32 files_len);
uint32_t files_len);
// Function table for issuing requests using via the other side's network stack.
// For the plugin, this functions deal with issuing requests through the
// browser. For the browser, these functions deal with allowing the plugin to
// intercept requests.
typedef struct _CPRequestFuncs {
uint16 size;
uint16_t size;
CPR_SetExtraRequestHeadersFunc set_extra_request_headers;
CPR_SetRequestLoadFlagsFunc set_request_load_flags;
CPR_AppendDataToUploadFunc append_data_to_upload;
@ -435,7 +435,7 @@ typedef struct _CPRequestFuncs {
// the browser, these deal with serving requests that the plugin has issued
// through us.
typedef struct _CPResponseFuncs {
uint16 size;
uint16_t size;
CPRR_ReceivedRedirectFunc received_redirect;
CPRR_StartCompletedFunc start_completed;
CPRR_ReadCompletedFunc read_completed;
@ -447,8 +447,8 @@ typedef struct _CPResponseFuncs {
// the 'size' field, which is set by the browser. The version fields should be
// set to those that the plugin was compiled using.
typedef struct _CPPluginFuncs {
uint16 size;
uint16 version;
uint16_t size;
uint16_t version;
CPRequestFuncs* request_funcs;
CPResponseFuncs* response_funcs;
CPP_ShutdownFunc shutdown;
@ -465,8 +465,8 @@ typedef struct _CPPluginFuncs {
// plugin will likely want to save a copy of this structure to make calls
// back to the browser.
typedef struct _CPBrowserFuncs {
uint16 size;
uint16 version;
uint16_t size;
uint16_t version;
CPRequestFuncs* request_funcs;
CPResponseFuncs* response_funcs;
CPB_EnableRequestInterceptFunc enable_request_intercept;
@ -506,7 +506,7 @@ typedef struct _CPBrowserFuncs {
// exported by the chrome plugin module, CP_Initiailize will be called with
// a version of the host's choosing.
typedef CPError (STDCALL *CP_VersionNegotiateFunc)(
uint16 min_version, uint16 max_version, uint16 *selected_version);
uint16_t min_version, uint16_t max_version, uint16_t *selected_version);
// 'bfuncs' are the browser functions provided to the plugin. 'id' is the
// plugin identifier that the plugin should use when calling browser functions.

View File

@ -214,7 +214,7 @@ bool ChromePluginLib::CP_Initialize(const CPBrowserFuncs* bfuncs) {
return false;
if (CP_VersionNegotiate_) {
uint16 selected_version = 0;
uint16_t selected_version = 0;
CPError rv = CP_VersionNegotiate_(CP_VERSION, CP_VERSION,
&selected_version);
if ( (rv != CPERR_SUCCESS) || (selected_version != CP_VERSION))

View File

@ -79,8 +79,8 @@ void PluginHelper::Observe(NotificationType type,
// PluginResponseUtils
//
uint32 PluginResponseUtils::CPLoadFlagsToNetFlags(uint32 flags) {
uint32 net_flags = 0;
uint32_t PluginResponseUtils::CPLoadFlagsToNetFlags(uint32_t flags) {
uint32_t net_flags = 0;
#define HANDLE_FLAG(name) \
if (flags & CPREQUEST##name) \
net_flags |= net::name
@ -156,7 +156,7 @@ CPError CPB_GetCommandLineArgumentsCommon(const char* url,
// Host functions shared by browser and plugin processes
//
void* STDCALL CPB_Alloc(uint32 size) {
void* STDCALL CPB_Alloc(uint32_t size) {
return malloc(size);
}

View File

@ -61,7 +61,7 @@ class PluginResponseUtils {
public:
// Helper to convert request load flags from the plugin API to the net API
// versions.
static uint32 CPLoadFlagsToNetFlags(uint32 flags);
static uint32_t CPLoadFlagsToNetFlags(uint32_t flags);
// Common implementation of a CPR_GetResponseInfo call.
static int GetResponseInfo(
@ -71,7 +71,7 @@ public:
// Helper to allocate a string using the given CPB_Alloc function.
inline char* CPB_StringDup(CPB_AllocFunc alloc, const std::string& str) {
char* cstr = static_cast<char*>(alloc(static_cast<uint32>(str.length() + 1)));
char* cstr = static_cast<char*>(alloc(static_cast<uint32_t>(str.length() + 1)));
memcpy(cstr, str.c_str(), str.length() + 1); // Include null terminator.
return cstr;
}
@ -79,7 +79,7 @@ inline char* CPB_StringDup(CPB_AllocFunc alloc, const std::string& str) {
CPError CPB_GetCommandLineArgumentsCommon(const char* url,
std::string* arguments);
void* STDCALL CPB_Alloc(uint32 size);
void* STDCALL CPB_Alloc(uint32_t size);
void STDCALL CPB_Free(void* memory);
#endif // CHROME_COMMON_CHROME_PLUGIN_UTIL_H_

View File

@ -28,11 +28,11 @@ class FilterPolicy {
FILTER_ALL
};
static bool ValidType(int32 type) {
static bool ValidType(int32_t type) {
return type >= DONT_FILTER && type <= FILTER_ALL;
}
static Type FromInt(int32 type) {
static Type FromInt(int32_t type) {
return static_cast<Type>(type);
}

View File

@ -80,7 +80,7 @@ typedef struct _GearsShortcutList {
// Memory for these shortcuts, including the strings they hold, should be
// freed by the browser using CPB_Free.
GearsShortcutData* shortcuts; // array of installed shortcuts
uint32 num_shortcuts; // size of the array
uint32_t num_shortcuts; // size of the array
} GearsShortcutList;
// Command data for GEARSBROWSERCOMMAND_CREATE_SHORTCUT_DONE

View File

@ -32,7 +32,7 @@ static const double kCIEConversionGamma = 2.2;
static const double kE = 0.008856;
static const double kK = 903.3;
static double CIEConvertNonLinear(uint8 color_component) {
static double CIEConvertNonLinear(uint8_t color_component) {
double color_component_d = static_cast<double>(color_component) / 255.0;
if (color_component_d > 0.04045) {
double base = (color_component_d + kCIEConversionAlpha) /
@ -45,9 +45,9 @@ static double CIEConvertNonLinear(uint8 color_component) {
// Note: this works only for sRGB.
void SkColorToCIEXYZ(SkColor c, CIE_XYZ* xyz) {
uint8 r = SkColorGetR(c);
uint8 g = SkColorGetG(c);
uint8 b = SkColorGetB(c);
uint8_t r = SkColorGetR(c);
uint8_t g = SkColorGetG(c);
uint8_t b = SkColorGetB(c);
xyz->X =
0.4124 * CIEConvertNonLinear(r) +
@ -82,7 +82,7 @@ void CIEXYZToLabColor(const CIE_XYZ& xyz, LabColor* lab) {
lab->b = static_cast<int>(200 * (fy - fz));
}
static uint8 sRGBColorComponentFromLinearComponent(double component) {
static uint8_t sRGBColorComponentFromLinearComponent(double component) {
double result;
if (component <= 0.0031308) {
result = 12.92 * component;
@ -91,16 +91,16 @@ static uint8 sRGBColorComponentFromLinearComponent(double component) {
pow(component, (static_cast<double>(1) / 2.4)) -
kCIEConversionAlpha;
}
return std::min(static_cast<uint8>(255), static_cast<uint8>(result * 255));
return std::min(static_cast<uint8_t>(255), static_cast<uint8_t>(result * 255));
}
SkColor CIEXYZToSkColor(SkAlpha alpha, const CIE_XYZ& xyz) {
double r_linear = 3.2410 * xyz.X - 1.5374 * xyz.Y - 0.4986 * xyz.Z;
double g_linear = -0.9692 * xyz.X + 1.8760 * xyz.Y + 0.0416 * xyz.Z;
double b_linear = 0.0556 * xyz.X - 0.2040 * xyz.Y + 1.0570 * xyz.Z;
uint8 r = sRGBColorComponentFromLinearComponent(r_linear);
uint8 g = sRGBColorComponentFromLinearComponent(g_linear);
uint8 b = sRGBColorComponentFromLinearComponent(b_linear);
uint8_t r = sRGBColorComponentFromLinearComponent(r_linear);
uint8_t g = sRGBColorComponentFromLinearComponent(g_linear);
uint8_t b = sRGBColorComponentFromLinearComponent(b_linear);
return SkColorSetARGB(alpha, r, g, b);
}

Some files were not shown because too many files have changed in this diff Show More