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

Unified Diff: remoting/base/encoder_row_based.cc

Issue 9720019: Use scoped_ptr<> to pass ownership in more places. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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 | « remoting/base/encoder.h ('k') | remoting/base/encoder_vp8.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/base/encoder_row_based.cc
diff --git a/remoting/base/encoder_row_based.cc b/remoting/base/encoder_row_based.cc
index 332cde377091f513863dfe07f98e39449cabc86e..25d9ad6c5070cf032a363c765c0668c45c85ed52 100644
--- a/remoting/base/encoder_row_based.cc
+++ b/remoting/base/encoder_row_based.cc
@@ -86,21 +86,21 @@ void EncoderRowBased::EncodeRect(const SkIRect& rect, bool last) {
compressor_->Reset();
- VideoPacket* packet = new VideoPacket();
- PrepareUpdateStart(rect, packet);
+ scoped_ptr<VideoPacket> packet(new VideoPacket());
+ PrepareUpdateStart(rect, packet.get());
const uint8* in = capture_data_->data_planes().data[0] +
rect.fTop * strides + rect.fLeft * bytes_per_pixel;
// TODO(hclam): Fill in the sequence number.
- uint8* out = GetOutputBuffer(packet, packet_size_);
+ uint8* out = GetOutputBuffer(packet.get(), packet_size_);
int filled = 0;
int row_pos = 0; // Position in the current row in bytes.
int row_y = 0; // Current row.
bool compress_again = true;
while (compress_again) {
// Prepare a message for sending out.
- if (!packet) {
- packet = new VideoPacket();
- out = GetOutputBuffer(packet, packet_size_);
+ if (!packet.get()) {
+ packet.reset(new VideoPacket());
+ out = GetOutputBuffer(packet.get(), packet_size_);
filled = 0;
}
@@ -132,8 +132,7 @@ void EncoderRowBased::EncodeRect(const SkIRect& rect, bool last) {
// If we have filled the message or we have reached the end of stream.
if (filled == packet_size_ || !compress_again) {
packet->mutable_data()->resize(filled);
- callback_.Run(packet);
- packet = NULL;
+ callback_.Run(packet.Pass());
}
// Reached the end of input row and we're not at the last row.
@@ -169,5 +168,4 @@ uint8* EncoderRowBased::GetOutputBuffer(VideoPacket* packet, size_t size) {
packet->mutable_data()->data()));
}
-
} // namespace remoting
« no previous file with comments | « remoting/base/encoder.h ('k') | remoting/base/encoder_vp8.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698