summaryrefslogtreecommitdiffstats
path: root/media/webm
diff options
context:
space:
mode:
authorfischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-10 04:47:31 +0000
committerfischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-10 04:47:31 +0000
commitf1ca6dfe8f214f66dd7ab58d8bc30fe1e8553352 (patch)
tree5107ccd0d038153d126a1d3e842dd042944f31f3 /media/webm
parentc2e45bf3a3207e2072c78804b012309de511275a (diff)
downloadchromium_src-f1ca6dfe8f214f66dd7ab58d8bc30fe1e8553352.zip
chromium_src-f1ca6dfe8f214f66dd7ab58d8bc30fe1e8553352.tar.gz
chromium_src-f1ca6dfe8f214f66dd7ab58d8bc30fe1e8553352.tar.bz2
Take advantage of the new Pass() machinery on scoped_ptr{,_malloc}.
Pass() was announced in https://groups.google.com/a/chromium.org/d/topic/chromium-dev/RTd7rNxHjqk/discussion This CL replaces comments about ownership transfer (in all files whose paths contain media/) with the explicit passing of the appropriate scoper. The exceptions that are not touched by this CL: - scoped_refptr<> doesn't support Pass() and so is untouched. - media/audio code defines its own callback machinery, mimicking the old-style callbacks (pass by pointer, explicit deletes). I think that whole pile needs to be replaced with new-style (Bind) callbacks, so left it alone for now. BUG=none TEST=trybots Review URL: http://codereview.chromium.org/9015015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117009 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/webm')
-rw-r--r--media/webm/cluster_builder.cc11
-rw-r--r--media/webm/cluster_builder.h9
-rw-r--r--media/webm/webm_cluster_parser.cc4
-rw-r--r--media/webm/webm_parser_unittest.cc8
4 files changed, 16 insertions, 16 deletions
diff --git a/media/webm/cluster_builder.cc b/media/webm/cluster_builder.cc
index 44c87c8..4c951ad 100644
--- a/media/webm/cluster_builder.cc
+++ b/media/webm/cluster_builder.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -31,7 +31,8 @@ const int kSimpleBlockSizeOffset = 1;
const int kInitialBufferSize = 32768;
-Cluster::Cluster(const uint8* data, int size) : data_(data), size_(size) {}
+Cluster::Cluster(scoped_array<uint8> data, int size)
+ : data_(data.Pass()), size_(size) {}
Cluster::~Cluster() {}
ClusterBuilder::ClusterBuilder() { Reset(); }
@@ -84,14 +85,14 @@ void ClusterBuilder::AddSimpleBlock(int track_num, int64 timecode, int flags,
bytes_used_ += bytes_needed;
}
-Cluster* ClusterBuilder::Finish() {
+scoped_ptr<Cluster> ClusterBuilder::Finish() {
DCHECK_NE(cluster_timecode_, -1);
UpdateUInt64(kClusterSizeOffset, bytes_used_ - (kClusterSizeOffset + 8));
- scoped_ptr<Cluster> ret(new Cluster(buffer_.release(), bytes_used_));
+ scoped_ptr<Cluster> ret(new Cluster(buffer_.Pass(), bytes_used_));
Reset();
- return ret.release();
+ return ret.Pass();
}
void ClusterBuilder::Reset() {
diff --git a/media/webm/cluster_builder.h b/media/webm/cluster_builder.h
index 132da8a..39cd0d0 100644
--- a/media/webm/cluster_builder.h
+++ b/media/webm/cluster_builder.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -13,15 +13,14 @@ namespace media {
class Cluster {
public:
- // Takes ownership of |data|
- Cluster(const uint8* data, int size);
+ Cluster(scoped_array<uint8> data, int size);
~Cluster();
const uint8* data() const { return data_.get(); }
int size() const { return size_; }
private:
- scoped_array<const uint8> data_;
+ scoped_array<uint8> data_;
int size_;
DISALLOW_IMPLICIT_CONSTRUCTORS(Cluster);
@@ -36,7 +35,7 @@ class ClusterBuilder {
void AddSimpleBlock(int track_num, int64 timecode, int flags,
const uint8* data, int size);
- Cluster* Finish();
+ scoped_ptr<Cluster> Finish();
private:
void Reset();
diff --git a/media/webm/webm_cluster_parser.cc b/media/webm/webm_cluster_parser.cc
index 2d84405..8151ec6 100644
--- a/media/webm/webm_cluster_parser.cc
+++ b/media/webm/webm_cluster_parser.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -13,7 +13,7 @@ namespace media {
static Buffer* CreateBuffer(const uint8* data, size_t size) {
scoped_array<uint8> buf(new uint8[size]);
memcpy(buf.get(), data, size);
- return new DataBuffer(buf.release(), size);
+ return new DataBuffer(buf.Pass(), size);
}
WebMClusterParser::WebMClusterParser(int64 timecode_scale,
diff --git a/media/webm/webm_parser_unittest.cc b/media/webm/webm_parser_unittest.cc
index bfb5624..751af9e 100644
--- a/media/webm/webm_parser_unittest.cc
+++ b/media/webm/webm_parser_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -46,9 +46,9 @@ static void AddSimpleBlock(ClusterBuilder* cb, int track_num,
cb->AddSimpleBlock(track_num, timecode, 0, data, sizeof(data));
}
-static Cluster* CreateCluster(int timecode,
- const SimpleBlockInfo* block_info,
- int block_count) {
+static scoped_ptr<Cluster> CreateCluster(int timecode,
+ const SimpleBlockInfo* block_info,
+ int block_count) {
ClusterBuilder cb;
cb.SetClusterTimecode(0);