summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authormbelshe@chromium.org <mbelshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-07 22:12:13 +0000
committermbelshe@chromium.org <mbelshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-07 22:12:13 +0000
commita23a90aeb11a1be89c52712c8866bbc195b422d5 (patch)
treec20bc592167d3e670dcd8ba4ce872759f71b4638 /net
parentb89b00b655ac2359585ae39f1ebdd65e93da0aa4 (diff)
downloadchromium_src-a23a90aeb11a1be89c52712c8866bbc195b422d5.zip
chromium_src-a23a90aeb11a1be89c52712c8866bbc195b422d5.tar.gz
chromium_src-a23a90aeb11a1be89c52712c8866bbc195b422d5.tar.bz2
Change many of the int and uint32 uses to size_t.
I think we should avoid using uint32 except where we're defining protocol elements which specifically are intended to be 32 bits. Using size_t for lengths is a good way to avoid any accidental signed/unsigned comparisons. This cleanup is a result of the linux port, which gets lots of unsigned/signed warnings (which we treat as errors). BUG=none TEST=none Review URL: http://codereview.chromium.org/263004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28318 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/flip/flip_framer.cc26
-rw-r--r--net/flip/flip_framer.h22
2 files changed, 24 insertions, 24 deletions
diff --git a/net/flip/flip_framer.cc b/net/flip/flip_framer.cc
index a8a4dc8..393331e 100644
--- a/net/flip/flip_framer.cc
+++ b/net/flip/flip_framer.cc
@@ -15,10 +15,10 @@ namespace flip {
// The initial size of the control frame buffer; this is used internally
// as we we parse though control frames.
-static const int kControlFrameBufferInitialSize = 32 * 1024;
+static const size_t kControlFrameBufferInitialSize = 32 * 1024;
// The maximum size of the control frame buffer that we support.
// TODO(mbelshe): We should make this stream-based so there are no limits.
-static const int kControlFrameBufferMaxSize = 64 * 1024;
+static const size_t kControlFrameBufferMaxSize = 64 * 1024;
// This implementation of Flip is version 1.
static const int kFlipProtocolVersion = 1;
@@ -100,7 +100,7 @@ const char* FlipFramer::StateToString(int state) {
return "UNKNOWN_STATE";
}
-uint32 FlipFramer::BytesSafeToRead() const {
+size_t FlipFramer::BytesSafeToRead() const {
switch (state_) {
case FLIP_ERROR:
case FLIP_DONE:
@@ -148,11 +148,11 @@ const char* FlipFramer::ErrorCodeToString(int error_code) {
return "UNKNOWN_STATE";
}
-uint32 FlipFramer::ProcessInput(const char* data, uint32 len) {
+size_t FlipFramer::ProcessInput(const char* data, size_t len) {
DCHECK(visitor_);
DCHECK(data);
- uint32 original_len = len;
+ size_t original_len = len;
while (len != 0) {
FlipControlFrame* current_control_frame =
reinterpret_cast<FlipControlFrame*>(current_frame_buffer_);
@@ -240,7 +240,7 @@ uint32 FlipFramer::ProcessInput(const char* data, uint32 len) {
// intentional fallthrough
case FLIP_FORWARD_STREAM_FRAME:
if (remaining_payload_) {
- uint32 amount_to_forward = std::min(remaining_payload_, len);
+ size_t amount_to_forward = std::min(remaining_payload_, len);
if (amount_to_forward && state_ != FLIP_IGNORE_REMAINING_PAYLOAD) {
const FlipDataFrame* data_frame =
reinterpret_cast<const FlipDataFrame*>(current_data_frame);
@@ -290,7 +290,7 @@ uint32 FlipFramer::ProcessInput(const char* data, uint32 len) {
return original_len - len;
}
-uint32 FlipFramer::ProcessCommonHeader(const char* data, uint32 len) {
+size_t FlipFramer::ProcessCommonHeader(const char* data, size_t len) {
// This should only be called when we're in the FLIP_READING_COMMON_HEADER
// state.
DCHECK(state_ == FLIP_READING_COMMON_HEADER);
@@ -301,8 +301,8 @@ uint32 FlipFramer::ProcessCommonHeader(const char* data, uint32 len) {
do {
if (current_frame_len_ < sizeof(FlipFrame)) {
- uint32 bytes_desired = sizeof(FlipFrame) - current_frame_len_;
- uint32 bytes_to_append = std::min(bytes_desired, len);
+ size_t bytes_desired = sizeof(FlipFrame) - current_frame_len_;
+ size_t bytes_to_append = std::min(bytes_desired, len);
char* header_buffer = current_frame_buffer_;
memcpy(&header_buffer[current_frame_len_], data, bytes_to_append);
current_frame_len_ += bytes_to_append;
@@ -328,11 +328,11 @@ uint32 FlipFramer::ProcessCommonHeader(const char* data, uint32 len) {
return original_len - len;
}
-uint32 FlipFramer::ProcessControlFramePayload(const char* data, uint32 len) {
- int original_len = len;
+size_t FlipFramer::ProcessControlFramePayload(const char* data, size_t len) {
+ size_t original_len = len;
do {
if (remaining_control_payload_) {
- uint32 amount_to_consume = std::min(remaining_control_payload_, len);
+ size_t amount_to_consume = std::min(remaining_control_payload_, len);
memcpy(&current_frame_buffer_[current_frame_len_], data,
amount_to_consume);
current_frame_len_ += amount_to_consume;
@@ -351,7 +351,7 @@ uint32 FlipFramer::ProcessControlFramePayload(const char* data, uint32 len) {
return original_len - len;
}
-void FlipFramer::ExpandControlFrameBuffer(int size) {
+void FlipFramer::ExpandControlFrameBuffer(size_t size) {
DCHECK(size < kControlFrameBufferMaxSize);
if (size < current_frame_capacity_)
return;
diff --git a/net/flip/flip_framer.h b/net/flip/flip_framer.h
index e50cc83..b7a2cc0 100644
--- a/net/flip/flip_framer.h
+++ b/net/flip/flip_framer.h
@@ -48,9 +48,9 @@ class FlipFramerVisitorInterface {
virtual void OnControl(const FlipControlFrame* frame) = 0;
// Called when data is received.
- virtual void OnStreamFrameData(uint32 sream_id,
+ virtual void OnStreamFrameData(flip::FlipStreamId stream_id,
const char* data,
- uint32 len) = 0;
+ size_t len) = 0;
// TODO(fenix): Implement me!
virtual void OnLameDuck() = 0;
@@ -99,7 +99,7 @@ class FlipFramer {
// Pass data into the framer for parsing.
// Returns the number of bytes consumed. It is safe to pass more bytes in
// than may be consumed.
- uint32 ProcessInput(const char* data, uint32 len);
+ size_t ProcessInput(const char* data, size_t len);
// Resets the framer state after a frame has been successfully decoded.
// TODO(mbelshe): can we make this private?
@@ -183,21 +183,21 @@ class FlipFramer {
private:
// Internal breakout from ProcessInput. Returns the number of bytes
// consumed from the data.
- uint32 ProcessCommonHeader(const char* data, uint32 len);
- uint32 ProcessControlFramePayload(const char* data, uint32 len);
+ size_t ProcessCommonHeader(const char* data, size_t len);
+ size_t ProcessControlFramePayload(const char* data, size_t len);
// Initialize the ZLib state.
bool InitializeCompressor();
bool InitializeDecompressor();
// Not used (yet)
- uint32 BytesSafeToRead() const;
+ size_t BytesSafeToRead() const;
// Set the error code.
void set_error(FlipError error);
// Expands the control frame buffer to accomodate a particular payload size.
- void ExpandControlFrameBuffer(int size);
+ void ExpandControlFrameBuffer(size_t size);
// Given a frame, breakdown the variable payload length, the static header
// header length, and variable payload pointer.
@@ -207,12 +207,12 @@ class FlipFramer {
FlipState state_;
FlipError error_code_;
- uint32 remaining_payload_;
- uint32 remaining_control_payload_;
+ size_t remaining_payload_;
+ size_t remaining_control_payload_;
char* current_frame_buffer_;
- int current_frame_len_; // Number of bytes read into the current_frame_.
- int current_frame_capacity_;
+ size_t current_frame_len_; // Number of bytes read into the current_frame_.
+ size_t current_frame_capacity_;
bool enable_compression_;
scoped_ptr<z_stream> compressor_;