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

Unified Diff: mojo/public/cpp/bindings/lib/fixed_buffer.cc

Issue 2207763003: Make mojo::internal::Buffer a non-virtual class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@85_3_inline_validation_context
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/cpp/bindings/lib/fixed_buffer.h ('k') | mojo/public/cpp/bindings/lib/message_buffer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/lib/fixed_buffer.cc
diff --git a/mojo/public/cpp/bindings/lib/fixed_buffer.cc b/mojo/public/cpp/bindings/lib/fixed_buffer.cc
index 50b8a21c56b331aa7626981e4df3ae83fca1e7cf..725a193cd740940948c6d7939cdf10d22cfb6034 100644
--- a/mojo/public/cpp/bindings/lib/fixed_buffer.cc
+++ b/mojo/public/cpp/bindings/lib/fixed_buffer.cc
@@ -4,56 +4,25 @@
#include "mojo/public/cpp/bindings/lib/fixed_buffer.h"
-#include <stddef.h>
#include <stdlib.h>
-#include <algorithm>
-
-#include "base/logging.h"
-#include "mojo/public/cpp/bindings/lib/serialization_util.h"
-
namespace mojo {
namespace internal {
-FixedBuffer::FixedBuffer() : ptr_(nullptr), cursor_(0), size_(0) {}
-
-void FixedBuffer::Initialize(void* memory, size_t size) {
- DCHECK(size == internal::Align(size));
-
- ptr_ = static_cast<char*>(memory);
- cursor_ = 0;
- size_ = size;
-}
-
-void* FixedBuffer::Allocate(size_t delta) {
- delta = internal::Align(delta);
-
- if (delta == 0 || delta > size_ - cursor_) {
- NOTREACHED();
- return nullptr;
- }
-
- char* result = ptr_ + cursor_;
- cursor_ += delta;
-
- return result;
-}
-
FixedBufferForTesting::FixedBufferForTesting(size_t size) {
- size_ = internal::Align(size);
+ size = internal::Align(size);
// Use calloc here to ensure all message memory is zero'd out.
- ptr_ = static_cast<char*>(calloc(size_, 1));
+ void* ptr = calloc(size, 1);
+ Initialize(ptr, size);
}
FixedBufferForTesting::~FixedBufferForTesting() {
- free(ptr_);
+ free(data());
}
void* FixedBufferForTesting::Leak() {
- char* ptr = ptr_;
- ptr_ = nullptr;
- cursor_ = 0;
- size_ = 0;
+ void* ptr = data();
+ Initialize(nullptr, 0);
return ptr;
}
« no previous file with comments | « mojo/public/cpp/bindings/lib/fixed_buffer.h ('k') | mojo/public/cpp/bindings/lib/message_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698