diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-21 20:37:31 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-21 20:37:31 +0000 |
commit | 09b3cb28711902453149f16d847be24923f7213e (patch) | |
tree | 79ee78be075c978b45674e8d622e8e80a83374ca /mojo | |
parent | 0209e3937bc2703b36c95cf95edfa121755a4866 (diff) | |
download | chromium_src-09b3cb28711902453149f16d847be24923f7213e.zip chromium_src-09b3cb28711902453149f16d847be24923f7213e.tar.gz chromium_src-09b3cb28711902453149f16d847be24923f7213e.tar.bz2 |
Mojo bindings tweaks based on feedback from dmichael.
This addresses only a subset of issues raised on:
https://codereview.chromium.org/27034003/
Review URL: https://codereview.chromium.org/31303002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@229903 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo')
-rw-r--r-- | mojo/public/bindings/lib/buffer.cc | 7 | ||||
-rw-r--r-- | mojo/public/bindings/lib/buffer.h | 2 | ||||
-rw-r--r-- | mojo/public/bindings/lib/message.cc | 1 | ||||
-rw-r--r-- | mojo/public/bindings/lib/message.h | 6 | ||||
-rw-r--r-- | mojo/public/bindings/lib/message_builder.h | 2 | ||||
-rw-r--r-- | mojo/public/bindings/sample/generated/sample_service_proxy.cc | 2 | ||||
-rw-r--r-- | mojo/public/system/macros.h | 4 |
7 files changed, 13 insertions, 11 deletions
diff --git a/mojo/public/bindings/lib/buffer.cc b/mojo/public/bindings/lib/buffer.cc index 1aa98a9..b5b9e7d 100644 --- a/mojo/public/bindings/lib/buffer.cc +++ b/mojo/public/bindings/lib/buffer.cc @@ -58,10 +58,15 @@ void* ScratchBuffer::AllocateInSegment(Segment* segment, size_t delta) { void ScratchBuffer::AddOverflowSegment(size_t delta) { if (delta < kMinSegmentSize) delta = kMinSegmentSize; - Segment* segment = static_cast<Segment*>(malloc(sizeof(Segment) + delta)); + + // Ensure segment buffer is aligned. + size_t segment_size = internal::Align(sizeof(Segment)) + delta; + + Segment* segment = static_cast<Segment*>(malloc(segment_size)); segment->next = overflow_; segment->cursor = reinterpret_cast<char*>(segment + 1); segment->end = segment->cursor + delta; + overflow_ = segment; } diff --git a/mojo/public/bindings/lib/buffer.h b/mojo/public/bindings/lib/buffer.h index 7fc4588..c3479b6 100644 --- a/mojo/public/bindings/lib/buffer.h +++ b/mojo/public/bindings/lib/buffer.h @@ -76,7 +76,7 @@ class FixedBuffer : public Buffer { virtual ~FixedBuffer(); // Grows the buffer by |num_bytes| and returns a pointer to the start of the - // addition. The resulting address is 8-byte aligned, and the contents of the + // addition. The resulting address is 8-byte aligned, and the content of the // memory is zero-filled. virtual void* Allocate(size_t num_bytes) MOJO_OVERRIDE; diff --git a/mojo/public/bindings/lib/message.cc b/mojo/public/bindings/lib/message.cc index ab565ba..b01366f 100644 --- a/mojo/public/bindings/lib/message.cc +++ b/mojo/public/bindings/lib/message.cc @@ -13,6 +13,7 @@ Message::Message() } Message::~Message() { + free(data); } } // namespace mojo diff --git a/mojo/public/bindings/lib/message.h b/mojo/public/bindings/lib/message.h index d29ce79..19f4d10 100644 --- a/mojo/public/bindings/lib/message.h +++ b/mojo/public/bindings/lib/message.h @@ -31,10 +31,8 @@ struct Message { class MessageReceiver { public: - // The receiver may mutate the given message or take ownership of the its - // contents. Upon return, if message->data is non-null, then the caller - // regains ownership of the Message and should be responsible for freeing its - // data member. + // The receiver may mutate the given message or take ownership of its + // |message->data| member by setting it to NULL. virtual bool Accept(Message* message) = 0; }; diff --git a/mojo/public/bindings/lib/message_builder.h b/mojo/public/bindings/lib/message_builder.h index 49ece95..8a5b50d 100644 --- a/mojo/public/bindings/lib/message_builder.h +++ b/mojo/public/bindings/lib/message_builder.h @@ -27,6 +27,8 @@ class MessageBuilder { private: FixedBuffer buf_; + + MOJO_DISALLOW_COPY_AND_ASSIGN(MessageBuilder); }; } // namespace mojo diff --git a/mojo/public/bindings/sample/generated/sample_service_proxy.cc b/mojo/public/bindings/sample/generated/sample_service_proxy.cc index 847a6be..4f27203 100644 --- a/mojo/public/bindings/sample/generated/sample_service_proxy.cc +++ b/mojo/public/bindings/sample/generated/sample_service_proxy.cc @@ -50,8 +50,6 @@ void ServiceProxy::Frobinate(const Foo* foo, bool baz, mojo::Handle port) { message.data = builder.Finish(); receiver_->Accept(&message); - - free(message.data); } } // namespace sample diff --git a/mojo/public/system/macros.h b/mojo/public/system/macros.h index c411303..4a1c3ce 100644 --- a/mojo/public/system/macros.h +++ b/mojo/public/system/macros.h @@ -13,9 +13,7 @@ namespace mojo { // method in the parent class. // Use like: // virtual void foo() OVERRIDE; -#if defined(_MSC_VER) -#define MOJO_OVERRIDE override -#elif defined(__clang__) +#if defined(_MSC_VER) || defined(__clang__) #define MOJO_OVERRIDE override #else #define MOJO_OVERRIDE |