Commit 9bf17495 authored by avi's avatar avi Committed by Commit Bot

Remove ScopedVector from ppapi/.

BUG=554289

Review-Url: https://codereview.chromium.org/2972053003
Cr-Commit-Position: refs/heads/master@{#485173}
parent 1c176482
......@@ -9,7 +9,6 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_vector.h"
#include "ppapi/proxy/connection.h"
#include "ppapi/proxy/plugin_resource.h"
#include "ppapi/shared_impl/media_stream_buffer_manager.h"
......
......@@ -238,14 +238,10 @@ int32_t VideoDecoderResource::Decode(uint32_t decode_id,
return PP_ERROR_NOMEMORY;
available_shm_buffers_.push_back(shm_buffer.get());
if (shm_buffers_.size() < kMaximumPendingDecodes) {
shm_buffers_.push_back(shm_buffer.release());
} else {
// Delete manually since ScopedVector won't delete the existing element if
// we just assign it.
delete shm_buffers_[shm_id];
shm_buffers_[shm_id] = shm_buffer.release();
}
if (shm_buffers_.size() < kMaximumPendingDecodes)
shm_buffers_.push_back(std::move(shm_buffer));
else
shm_buffers_[shm_id] = std::move(shm_buffer);
}
// At this point we should have shared memory to hold the plugin's buffer.
......@@ -486,7 +482,7 @@ void VideoDecoderResource::OnPluginMsgDecodeComplete(
return;
}
// Make the shm buffer available.
available_shm_buffers_.push_back(shm_buffers_[shm_id]);
available_shm_buffers_.push_back(shm_buffers_[shm_id].get());
// If the plugin is waiting, let it call Decode again.
if (decode_callback_.get()) {
scoped_refptr<TrackedCallback> callback;
......
......@@ -9,11 +9,11 @@
#include <memory>
#include <queue>
#include <vector>
#include "base/containers/hash_tables.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_vector.h"
#include "ppapi/proxy/connection.h"
#include "ppapi/proxy/plugin_resource.h"
#include "ppapi/proxy/ppapi_proxy_export.h"
......@@ -143,8 +143,8 @@ class PPAPI_PROXY_EXPORT VideoDecoderResource
void DeleteGLTexture(uint32_t texture_id);
void WriteNextPicture();
// ScopedVector to own the shared memory buffers.
ScopedVector<ShmBuffer> shm_buffers_;
// The shared memory buffers.
std::vector<std::unique_ptr<ShmBuffer>> shm_buffers_;
// List of available shared memory buffers.
typedef std::vector<ShmBuffer*> ShmBufferList;
......
......@@ -401,10 +401,10 @@ void VideoEncoderResource::OnPluginMsgBitstreamBuffers(
new base::SharedMemory(shm_handles[i], true));
CHECK(shm->Map(buffer_length));
ShmBuffer* buffer = new ShmBuffer(i, std::move(shm));
shm_buffers_.push_back(buffer);
auto buffer = base::MakeUnique<ShmBuffer>(i, std::move(shm));
bitstream_buffer_map_.insert(
std::make_pair(buffer->shm->memory(), buffer->id));
shm_buffers_.push_back(std::move(buffer));
}
}
......
......@@ -9,10 +9,10 @@
#include <deque>
#include <memory>
#include <vector>
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_vector.h"
#include "ppapi/proxy/connection.h"
#include "ppapi/proxy/plugin_resource.h"
#include "ppapi/shared_impl/media_stream_buffer_manager.h"
......@@ -46,7 +46,7 @@ class PPAPI_PROXY_EXPORT VideoEncoderResource
ShmBuffer(uint32_t id, std::unique_ptr<base::SharedMemory> shm);
~ShmBuffer();
// Index of the buffer in the ScopedVector. Buffers have the same id in
// Index of the buffer in the vector. Buffers have the same id in
// the plugin and the host.
uint32_t id;
std::unique_ptr<base::SharedMemory> shm;
......@@ -56,7 +56,7 @@ class PPAPI_PROXY_EXPORT VideoEncoderResource
BitstreamBuffer(uint32_t id, uint32_t size, bool key_frame);
~BitstreamBuffer();
// Index of the buffer in the ScopedVector. Same as ShmBuffer::id.
// Index of the buffer in the vector. Same as ShmBuffer::id.
uint32_t id;
uint32_t size;
bool key_frame;
......@@ -141,7 +141,7 @@ class PPAPI_PROXY_EXPORT VideoEncoderResource
VideoFrameMap;
VideoFrameMap video_frames_;
ScopedVector<ShmBuffer> shm_buffers_;
std::vector<std::unique_ptr<ShmBuffer>> shm_buffers_;
std::deque<BitstreamBuffer> available_bitstream_buffers_;
typedef std::map<void*, uint32_t> BitstreamBufferMap;
......
......@@ -6,7 +6,9 @@
#include <stdint.h>
#include <memory>
#include <utility>
#include <vector>
#include "base/memory/shared_memory.h"
#include "base/process/process.h"
......@@ -290,7 +292,7 @@ class VideoEncoderResourceTest : public PluginProxyTest,
void SendBitstreamBuffers(const ResourceMessageCallParams& params,
uint32_t buffer_length) {
std::vector<SerializedHandle> handles;
for (base::SharedMemory* mem : shared_memory_bitstreams_) {
for (const auto& mem : shared_memory_bitstreams_) {
ASSERT_EQ(mem->requested_size(), buffer_length);
base::SharedMemoryHandle handle = mem->handle().Duplicate();
ASSERT_TRUE(handle.IsValid());
......@@ -423,7 +425,7 @@ class VideoEncoderResourceTest : public PluginProxyTest,
const PPB_VideoEncoder_0_2* encoder_iface_;
const PPB_VideoEncoder_0_1* encoder_iface_0_1_;
ScopedVector<base::SharedMemory> shared_memory_bitstreams_;
std::vector<std::unique_ptr<base::SharedMemory>> shared_memory_bitstreams_;
MediaStreamBufferManager video_frames_manager_;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment